svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutEditVertexExtension.java @ 46
History | View | Annotate | Download (3.52 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.extension; |
23 |
|
24 |
import org.slf4j.Logger; |
25 |
import org.slf4j.LoggerFactory; |
26 |
|
27 |
import org.gvsig.andami.IconThemeHelper; |
28 |
import org.gvsig.andami.PluginServices; |
29 |
import org.gvsig.andami.plugins.Extension; |
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
32 |
|
33 |
/**
|
34 |
* Extensi?n que contiene todas las herramientas de edici?n.
|
35 |
*
|
36 |
* @author Vicente Caballero Navarro
|
37 |
*/
|
38 |
public class LayoutEditVertexExtension extends Extension { |
39 |
|
40 |
private static final Logger logger = LoggerFactory |
41 |
.getLogger(LayoutEditVertexExtension.class);; |
42 |
private LayoutPanel layout = null; |
43 |
|
44 |
/**
|
45 |
* DOCUMENT ME!
|
46 |
*/
|
47 |
public void initialize() { |
48 |
// TODO Auto-generated method stub
|
49 |
registerIcons(); |
50 |
} |
51 |
|
52 |
private void registerIcons() { |
53 |
|
54 |
IconThemeHelper.registerIcon( |
55 |
"action", "layout-graphic-edit-vertex", this); |
56 |
} |
57 |
|
58 |
/**
|
59 |
* DOCUMENT ME!
|
60 |
*
|
61 |
* @param s
|
62 |
* DOCUMENT ME!
|
63 |
*/
|
64 |
public void execute(String s) { |
65 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
66 |
|
67 |
logger.debug("Comand : " + s);
|
68 |
if (s.compareTo("layout-graphic-edit-vertex") == 0) { |
69 |
layout.getLayoutControl().setTool("layoutedit");
|
70 |
layout.getDocument().setModified(true);
|
71 |
} |
72 |
} |
73 |
|
74 |
/**
|
75 |
* DOCUMENT ME!
|
76 |
*
|
77 |
* @return DOCUMENT ME!
|
78 |
*/
|
79 |
public boolean isEnabled() { |
80 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
81 |
|
82 |
if (f == null) { |
83 |
return false; |
84 |
} |
85 |
|
86 |
if (f instanceof LayoutPanel) { |
87 |
LayoutPanel layout = (LayoutPanel) f; |
88 |
if (layout.getLayoutContext().isEditable()) {
|
89 |
return true; |
90 |
// IFFrame[] fframes = layout.getFFrames();
|
91 |
// for (int i = 0; i < fframes.length; i++) {
|
92 |
// if (fframes[i].getSelected() != IFFrame.NOSELECT
|
93 |
// && fframes[i] instanceof IFFrameEditableVertex) {
|
94 |
// return true;
|
95 |
// }
|
96 |
// }
|
97 |
} |
98 |
} |
99 |
return false; |
100 |
} |
101 |
|
102 |
/**
|
103 |
* DOCUMENT ME!
|
104 |
*
|
105 |
* @return DOCUMENT ME!
|
106 |
*/
|
107 |
public boolean isVisible() { |
108 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
109 |
|
110 |
if (f == null) { |
111 |
return false; |
112 |
} |
113 |
|
114 |
if (f instanceof LayoutPanel) { |
115 |
// Layout layout = (Layout) f;
|
116 |
return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() |
117 |
// > 0;
|
118 |
} else {
|
119 |
return false; |
120 |
} |
121 |
} |
122 |
} |