Revision 170
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.app.document.layout"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
|
0 | 9 |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<dependencySets> |
|
26 |
|
|
27 |
<!-- |
|
28 |
<dependencySet> |
|
29 |
<useProjectArtifact>false</useProjectArtifact> |
|
30 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
31 |
<outputDirectory>lib</outputDirectory> |
|
32 |
<includes> |
|
33 |
</includes> |
|
34 |
</dependencySet> |
|
35 |
|
|
36 |
--> |
|
37 |
|
|
38 |
</dependencySets> |
|
39 |
|
|
40 |
</assembly> |
|
0 | 41 |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutEditVertexExtension.java | ||
---|---|---|
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 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutMainExtension.java | ||
---|---|---|
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 java.awt.Component; |
|
25 |
import java.io.File; |
|
26 |
import java.io.FileInputStream; |
|
27 |
import java.io.FileNotFoundException; |
|
28 |
import java.io.IOException; |
|
29 |
import java.text.MessageFormat; |
|
30 |
import java.util.prefs.Preferences; |
|
31 |
|
|
32 |
import javax.swing.JOptionPane; |
|
33 |
|
|
34 |
import org.gvsig.andami.IconThemeHelper; |
|
35 |
import org.gvsig.andami.PluginServices; |
|
36 |
import org.gvsig.andami.messages.NotificationManager; |
|
37 |
import org.gvsig.andami.plugins.Extension; |
|
38 |
import org.gvsig.app.ApplicationLocator; |
|
39 |
import org.gvsig.app.project.Project; |
|
40 |
import org.gvsig.app.project.ProjectManager; |
|
41 |
import org.gvsig.app.project.documents.layout.DefaultLayoutManager; |
|
42 |
import org.gvsig.app.project.documents.layout.LayoutDocument; |
|
43 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
|
44 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.BeforeLayoutMenuEntry; |
|
45 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.BehindLayoutMenuEntry; |
|
46 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.CancelLayoutMenuEntry; |
|
47 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.CopyLayoutMenuEntry; |
|
48 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.CutLayoutMenuEntry; |
|
49 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.PasteLayoutMenuEntry; |
|
50 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.PositionLayoutMenuEntry; |
|
51 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.PropertyLayoutMenuEntry; |
|
52 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.RefreshLayoutMenuEntry; |
|
53 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.SelectAllLayoutMenuEntry; |
|
54 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.SimplifyLayoutMenuEntry; |
|
55 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.TerminateLayoutMenuEntry; |
|
56 |
import org.gvsig.app.project.documents.layout.fframes.FFrame; |
|
57 |
import org.gvsig.app.project.documents.layout.fframes.FFrameBasicFactory; |
|
58 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphics; |
|
59 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphicsFactory; |
|
60 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGrid; |
|
61 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGridFactory; |
|
62 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGroup; |
|
63 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGroupFactory; |
|
64 |
import org.gvsig.app.project.documents.layout.fframes.FFrameLegend; |
|
65 |
import org.gvsig.app.project.documents.layout.fframes.FFrameLegendFactory; |
|
66 |
import org.gvsig.app.project.documents.layout.fframes.FFrameNorth; |
|
67 |
import org.gvsig.app.project.documents.layout.fframes.FFrameNorthFactory; |
|
68 |
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView; |
|
69 |
import org.gvsig.app.project.documents.layout.fframes.FFrameOverViewFactory; |
|
70 |
import org.gvsig.app.project.documents.layout.fframes.FFramePicture; |
|
71 |
import org.gvsig.app.project.documents.layout.fframes.FFramePictureFactory; |
|
72 |
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBar; |
|
73 |
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBarFactory; |
|
74 |
import org.gvsig.app.project.documents.layout.fframes.FFrameSymbol; |
|
75 |
import org.gvsig.app.project.documents.layout.fframes.FFrameSymbolFactory; |
|
76 |
import org.gvsig.app.project.documents.layout.fframes.FFrameTable; |
|
77 |
import org.gvsig.app.project.documents.layout.fframes.FFrameTableFactory; |
|
78 |
import org.gvsig.app.project.documents.layout.fframes.FFrameText; |
|
79 |
import org.gvsig.app.project.documents.layout.fframes.FFrameTextFactory; |
|
80 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
|
81 |
import org.gvsig.app.project.documents.layout.fframes.FFrameViewFactory; |
|
82 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameBoxDialog; |
|
83 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog; |
|
84 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGridDialog; |
|
85 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGroupDialog; |
|
86 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameLegendDialog; |
|
87 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameNorthDialog; |
|
88 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameOverViewDialog; |
|
89 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFramePictureDialog; |
|
90 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameScaleBarDialog; |
|
91 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameTextDialog; |
|
92 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameViewDialog; |
|
93 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
94 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
95 |
import org.gvsig.i18n.Messages; |
|
96 |
import org.gvsig.tools.ToolsLocator; |
|
97 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
98 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
99 |
import org.gvsig.tools.persistence.PersistentState; |
|
100 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
101 |
import org.gvsig.utils.GenericFileFilter; |
|
102 |
|
|
103 |
/** |
|
104 |
* Extension que proporciona controles para crear proyectos nuevos, abrirlos y |
|
105 |
* guardarlos. Adem?s los tipos de tabla que soporta el proyecto son a?adidos |
|
106 |
* en esta clase. |
|
107 |
* |
|
108 |
* @author Fernando Gonz?lez Cort?s |
|
109 |
*/ |
|
110 |
public class LayoutMainExtension extends Extension { |
|
111 |
|
|
112 |
private String templatesPath; |
|
113 |
public static final String LAYOUT_TEMPLATE_FILECHOOSER_ID = |
|
114 |
"LAYOUT_TEMPLATE_FILECHOOSER_ID"; |
|
115 |
|
|
116 |
private void registerIcons() { |
|
117 |
|
|
118 |
IconThemeHelper.registerIcon("action", |
|
119 |
"application-layout-template-open", this); |
|
120 |
} |
|
121 |
|
|
122 |
public void initialize() { |
|
123 |
registerIcons(); |
|
124 |
} |
|
125 |
|
|
126 |
public void postInitialize() { |
|
127 |
super.postInitialize(); |
|
128 |
initializeDocumentActionsExtensionPoint(); |
|
129 |
registerDocuments(); |
|
130 |
registerFFrames(); |
|
131 |
registerContextMenuOptions(); |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String) |
|
136 |
*/ |
|
137 |
public void execute(String actionCommand) { |
|
138 |
if ("application-layout-template-open".equals(actionCommand)) { |
|
139 |
openLayout(); |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
private void openLayout() { |
|
144 |
// Project project = ((ProjectExtension) |
|
145 |
// PluginServices.getExtension(ProjectExtension.class)).getProject(); |
|
146 |
LayoutPanel layout = null; |
|
147 |
|
|
148 |
if (templatesPath == null) { |
|
149 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
|
150 |
templatesPath = prefs.get("TemplatesFolder", null); |
|
151 |
} |
|
152 |
|
|
153 |
JFileChooser jfc = |
|
154 |
new JFileChooser(LAYOUT_TEMPLATE_FILECHOOSER_ID, templatesPath); |
|
155 |
jfc.addChoosableFileFilter(new GenericFileFilter( |
|
156 |
LayoutManager.TEMPLATE_FILE_POINTEXT, |
|
157 |
Messages.getText("_Layout_template") + " (*" |
|
158 |
+ LayoutManager.TEMPLATE_FILE_POINTEXT + ")" |
|
159 |
)); |
|
160 |
|
|
161 |
if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
162 |
File file = jfc.getSelectedFile(); |
|
163 |
try { |
|
164 |
if (!file.exists()) { |
|
165 |
/* |
|
166 |
* The user has written a file name instead of clicking on one |
|
167 |
* and it does not exist |
|
168 |
*/ |
|
169 |
File auxfile = new File(file.getPath() + LayoutManager.TEMPLATE_FILE_POINTEXT); |
|
170 |
if (!auxfile.exists()) { |
|
171 |
/* |
|
172 |
* Not even this one exists: error |
|
173 |
*/ |
|
174 |
throw new IOException("File does not exist: " + file.getName()); |
|
175 |
} else { |
|
176 |
file = auxfile; |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
File xmlFile = new File(file.getAbsolutePath()); |
|
181 |
FileInputStream is = new FileInputStream(xmlFile); |
|
182 |
|
|
183 |
PersistenceManager persistenceManager = |
|
184 |
ToolsLocator.getPersistenceManager(); |
|
185 |
PersistentState persistentState = |
|
186 |
persistenceManager.loadState(is); |
|
187 |
layout = |
|
188 |
(LayoutPanel) persistenceManager.create(persistentState); |
|
189 |
|
|
190 |
} catch (Exception e) { |
|
191 |
|
|
192 |
String tit = Messages.getText("_Layout_template"); |
|
193 |
String msg = null; |
|
194 |
|
|
195 |
if (e instanceof PersistenceException) { |
|
196 |
msg = Messages.getText("_Bad_format_in_layout_template"); |
|
197 |
} else { |
|
198 |
msg = Messages.getText("_Cant_load_layout_template"); |
|
199 |
} |
|
200 |
|
|
201 |
msg = msg + ": " + file.getPath(); |
|
202 |
msg = msg + "\n" + e.getMessage(); |
|
203 |
JOptionPane.showMessageDialog( |
|
204 |
ApplicationLocator.getManager().getRootComponent(), |
|
205 |
msg, tit, JOptionPane.ERROR_MESSAGE); |
|
206 |
} |
|
207 |
|
|
208 |
if (layout == null) { |
|
209 |
return; |
|
210 |
} |
|
211 |
|
|
212 |
LayoutDocument layoutDocument = (LayoutDocument) layout.getDocument(); |
|
213 |
/* |
|
214 |
(LayoutDocument) ProjectManager.getInstance().createDocument( |
|
215 |
DefaultLayoutManager.TYPENAME, file.getName()); |
|
216 |
*/ |
|
217 |
|
|
218 |
Project p = ApplicationLocator.getManager().getProjectManager() |
|
219 |
.getCurrentProject(); |
|
220 |
p.add(layoutDocument); |
|
221 |
|
|
222 |
layout.getLayoutControl().setTool("layoutselect"); |
|
223 |
|
|
224 |
LayoutManager lm = (LayoutManager) layoutDocument.getFactory(); |
|
225 |
layout.setLayoutManager(lm); |
|
226 |
|
|
227 |
PluginServices.getMDIManager().addWindow(layout); |
|
228 |
|
|
229 |
} |
|
230 |
} |
|
231 |
|
|
232 |
private void registerDocuments() { |
|
233 |
DefaultLayoutManager.register(); |
|
234 |
} |
|
235 |
|
|
236 |
private void registerFFrames() { |
|
237 |
DefaultLayoutManager layoutManager = |
|
238 |
(DefaultLayoutManager) ProjectManager.getInstance() |
|
239 |
.getDocumentManager(DefaultLayoutManager.TYPENAME); |
|
240 |
|
|
241 |
// Register Frames |
|
242 |
layoutManager.registerFrameFactory(new FFrameBasicFactory()); |
|
243 |
layoutManager.registerFrameFactory(new FFrameGraphicsFactory()); |
|
244 |
layoutManager.registerFrameFactory(new FFrameGroupFactory()); |
|
245 |
layoutManager.registerFrameFactory(new FFrameLegendFactory()); |
|
246 |
layoutManager.registerFrameFactory(new FFrameNorthFactory()); |
|
247 |
layoutManager.registerFrameFactory(new FFrameOverViewFactory()); |
|
248 |
layoutManager.registerFrameFactory(new FFramePictureFactory()); |
|
249 |
layoutManager.registerFrameFactory(new FFrameScaleBarFactory()); |
|
250 |
layoutManager.registerFrameFactory(new FFrameSymbolFactory()); |
|
251 |
layoutManager.registerFrameFactory(new FFrameTableFactory()); |
|
252 |
layoutManager.registerFrameFactory(new FFrameTextFactory()); |
|
253 |
layoutManager.registerFrameFactory(new FFrameViewFactory()); |
|
254 |
layoutManager.registerFrameFactory(new FFrameGridFactory()); |
|
255 |
|
|
256 |
// Register FFrameDialogs forms |
|
257 |
layoutManager.registerFFrameDialog( |
|
258 |
FFrameGraphics.PERSISTENCE_DEFINITION_NAME, FFrameGraphicsDialog.class); |
|
259 |
layoutManager.registerFFrameDialog( |
|
260 |
FFrameSymbol.PERSISTENCE_DEFINITION_NAME, FFrameGraphicsDialog.class); |
|
261 |
layoutManager.registerFFrameDialog( |
|
262 |
FFrameGroup.PERSISTENCE_DEFINITION_NAME, FFrameGroupDialog.class); |
|
263 |
layoutManager.registerFFrameDialog( |
|
264 |
FFrameTable.PERSISTENCE_DEFINITION_NAME, FFrameBoxDialog.class); |
|
265 |
layoutManager.registerFFrameDialog( |
|
266 |
FFrameLegend.PERSISTENCE_DEFINITION_NAME, FFrameLegendDialog.class); |
|
267 |
layoutManager.registerFFrameDialog( |
|
268 |
FFramePicture.PERSISTENCE_DEFINITION_NAME, FFramePictureDialog.class); |
|
269 |
layoutManager.registerFFrameDialog( |
|
270 |
FFrameNorth.PERSISTENCE_DEFINITION_NAME, FFrameNorthDialog.class); |
|
271 |
layoutManager.registerFFrameDialog( |
|
272 |
FFrameScaleBar.PERSISTENCE_DEFINITION_NAME, FFrameScaleBarDialog.class); |
|
273 |
layoutManager.registerFFrameDialog( |
|
274 |
FFrameText.PERSISTENCE_DEFINITION_NAME, FFrameTextDialog.class); |
|
275 |
layoutManager.registerFFrameDialog( |
|
276 |
FFrameView.PERSISTENCE_DEFINITION_NAME, FFrameViewDialog.class); |
|
277 |
layoutManager.registerFFrameDialog( |
|
278 |
FFrameOverView.PERSISTENCE_DEFINITION_NAME, FFrameOverViewDialog.class); |
|
279 |
layoutManager.registerFFrameDialog( |
|
280 |
FFrameGrid.PERSISTENCE_DEFINITION_NAME, FFrameGridDialog.class); |
|
281 |
|
|
282 |
FFrame.initializeIcons(); |
|
283 |
FFrameTable.initializeIcons(); |
|
284 |
} |
|
285 |
|
|
286 |
private void registerContextMenuOptions() { |
|
287 |
LayoutManager layoutManager = |
|
288 |
(LayoutManager) ProjectManager.getInstance() |
|
289 |
.getDocumentManager("project.document.layout"); |
|
290 |
|
|
291 |
layoutManager.registerLayoutMenuAction("Terminate", TerminateLayoutMenuEntry.class); |
|
292 |
layoutManager.registerLayoutMenuAction("Cancel", CancelLayoutMenuEntry.class); |
|
293 |
layoutManager.registerLayoutMenuAction("Copy", CopyLayoutMenuEntry.class); |
|
294 |
layoutManager.registerLayoutMenuAction("Cut", CutLayoutMenuEntry.class); |
|
295 |
layoutManager.registerLayoutMenuAction("Paste", PasteLayoutMenuEntry.class); |
|
296 |
layoutManager.registerLayoutMenuAction("Simplify", SimplifyLayoutMenuEntry.class); |
|
297 |
layoutManager.registerLayoutMenuAction("Property",PropertyLayoutMenuEntry.class); |
|
298 |
layoutManager.registerLayoutMenuAction("SelectAll", SelectAllLayoutMenuEntry.class); |
|
299 |
layoutManager.registerLayoutMenuAction("Behind", BehindLayoutMenuEntry.class); |
|
300 |
layoutManager.registerLayoutMenuAction("Before", BeforeLayoutMenuEntry.class); |
|
301 |
layoutManager.registerLayoutMenuAction("Position", PositionLayoutMenuEntry.class); |
|
302 |
layoutManager.registerLayoutMenuAction("Refresh", RefreshLayoutMenuEntry.class); |
|
303 |
|
|
304 |
} |
|
305 |
|
|
306 |
private void initializeDocumentActionsExtensionPoint() { |
|
307 |
ExtensionPointManager epMan = ToolsLocator.getExtensionPointManager(); |
|
308 |
epMan.add("DocumentActions_Map", |
|
309 |
"Context menu options of the map document list" |
|
310 |
+ " in the project window " + "(register instances of " |
|
311 |
+ "org.gvsig.app.project.AbstractDocumentContextMenuAction)"); |
|
312 |
} |
|
313 |
|
|
314 |
public boolean isEnabled() { |
|
315 |
return true; |
|
316 |
} |
|
317 |
|
|
318 |
public boolean isVisible() { |
|
319 |
return true; |
|
320 |
} |
|
321 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutInsertToolsExtension.java | ||
---|---|---|
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 para editar los v?rtices de las geometr?as a?adidas en un |
|
35 |
* FFrameGraphics. |
|
36 |
* |
|
37 |
* @author Vicente Caballero Navarro |
|
38 |
*/ |
|
39 |
public class LayoutInsertToolsExtension extends Extension { |
|
40 |
|
|
41 |
private static final Logger logger = LoggerFactory |
|
42 |
.getLogger(LayoutInsertToolsExtension.class); |
|
43 |
|
|
44 |
private LayoutPanel layout = null; |
|
45 |
|
|
46 |
public void initialize() { |
|
47 |
// TODO Auto-generated method stub |
|
48 |
registerIcons(); |
|
49 |
} |
|
50 |
|
|
51 |
private void registerIcons() { |
|
52 |
|
|
53 |
IconThemeHelper.registerIcon("action", "layout-insert-text", this); |
|
54 |
IconThemeHelper.registerIcon("action", "layout-insert-point", this); |
|
55 |
IconThemeHelper.registerIcon("action", "layout-insert-rectangle", this); |
|
56 |
IconThemeHelper.registerIcon("action", "layout-insert-circle", this); |
|
57 |
|
|
58 |
IconThemeHelper.registerIcon("action", "layout-insert-line", this); |
|
59 |
IconThemeHelper.registerIcon("action", "layout-insert-polyline", this); |
|
60 |
IconThemeHelper.registerIcon("action", "layout-insert-polygon", this); |
|
61 |
IconThemeHelper.registerIcon("action", "layout-insert-image", this); |
|
62 |
|
|
63 |
IconThemeHelper.registerIcon("action", "layout-insert-view", this); |
|
64 |
IconThemeHelper.registerIcon("action", "layout-insert-locator", this); |
|
65 |
IconThemeHelper.registerIcon("action", "layout-insert-legend", this); |
|
66 |
IconThemeHelper.registerIcon("action", "layout-insert-scalebar", this); |
|
67 |
|
|
68 |
IconThemeHelper.registerIcon("action", "layout-insert-north", this); |
|
69 |
IconThemeHelper.registerIcon("action", "layout-insert-box", this); |
|
70 |
|
|
71 |
// ============================================================ |
|
72 |
|
|
73 |
IconThemeHelper.registerIcon("action", "edit-delete", this); |
|
74 |
IconThemeHelper.registerIcon("action", "selection-by-rectangle", this); |
|
75 |
} |
|
76 |
|
|
77 |
public void execute(String s) { |
|
78 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
79 |
|
|
80 |
logger.debug("Comand : " + s); |
|
81 |
boolean insertGroupPosibility = false; |
|
82 |
|
|
83 |
if (s.equals("selection-select-by-rectangle-layout")) { |
|
84 |
layout.getLayoutControl().setTool("layoutselect"); |
|
85 |
} else |
|
86 |
if (s.equals("layout-insert-view")) { |
|
87 |
layout.getLayoutControl().setTool("layoutaddview"); |
|
88 |
insertGroupPosibility = true; |
|
89 |
} else |
|
90 |
if (s.equals("layout-insert-locator")) { |
|
91 |
layout.getLayoutControl().setTool("layoutaddoverview"); |
|
92 |
insertGroupPosibility = true; |
|
93 |
} else |
|
94 |
if (s.equals("layout-insert-image")) { |
|
95 |
layout.getLayoutControl().setTool("layoutaddpicture"); |
|
96 |
insertGroupPosibility = true; |
|
97 |
} else |
|
98 |
if (s.equals("layout-insert-scalebar")) { |
|
99 |
layout.getLayoutControl().setTool("layoutaddscale"); |
|
100 |
insertGroupPosibility = true; |
|
101 |
} else |
|
102 |
if (s.equals("layout-insert-legend")) { |
|
103 |
layout.getLayoutControl().setTool( |
|
104 |
"layoutaddlegend"); |
|
105 |
insertGroupPosibility = true; |
|
106 |
} else |
|
107 |
if (s.equals("layout-insert-text")) { |
|
108 |
layout.getLayoutControl().setTool( |
|
109 |
"layoutaddtext"); |
|
110 |
insertGroupPosibility = true; |
|
111 |
} else |
|
112 |
if (s.equals("layout-insert-north")) { |
|
113 |
layout.getLayoutControl().setTool( |
|
114 |
"layoutaddnorth"); |
|
115 |
insertGroupPosibility = true; |
|
116 |
} else |
|
117 |
if (s.equals("layout-insert-box")) { |
|
118 |
layout.getLayoutControl().setTool( |
|
119 |
"layoutaddbox"); |
|
120 |
insertGroupPosibility = true; |
|
121 |
} else |
|
122 |
if (s.equals("layout-insert-point")) { |
|
123 |
layout.getLayoutControl() |
|
124 |
.setTool("layoutaddpoint"); |
|
125 |
} else |
|
126 |
if (s.equals("layout-insert-line")) { |
|
127 |
layout.getLayoutControl() |
|
128 |
.setTool( |
|
129 |
"layoutaddline"); |
|
130 |
} else |
|
131 |
if (s.equals("layout-insert-polyline")) { |
|
132 |
layout |
|
133 |
.getLayoutControl() |
|
134 |
.setTool( |
|
135 |
"layoutaddpolyline"); |
|
136 |
} else |
|
137 |
if (s.equals("layout-insert-circle")) { |
|
138 |
layout |
|
139 |
.getLayoutControl() |
|
140 |
.setTool( |
|
141 |
"layoutaddcircle"); |
|
142 |
} else |
|
143 |
if (s |
|
144 |
.equals("layout-insert-rectangle")) { |
|
145 |
layout |
|
146 |
.getLayoutControl() |
|
147 |
.setTool( |
|
148 |
"layoutaddrectangle"); |
|
149 |
} else |
|
150 |
if (s |
|
151 |
.equals("layout-insert-polygon")) { |
|
152 |
layout |
|
153 |
.getLayoutControl() |
|
154 |
.setTool( |
|
155 |
"layoutaddpolygon"); |
|
156 |
} else |
|
157 |
if (s |
|
158 |
.equals("edit-delete-layout")) { |
|
159 |
layout |
|
160 |
.getLayoutContext() |
|
161 |
.delFFrameSelected(); |
|
162 |
layout |
|
163 |
.getLayoutControl() |
|
164 |
.refresh(); |
|
165 |
} |
|
166 |
layout.getDocument().setModified(true); |
|
167 |
} |
|
168 |
|
|
169 |
public boolean isEnabled() { |
|
170 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
171 |
|
|
172 |
if (f == null) { |
|
173 |
return false; |
|
174 |
} |
|
175 |
|
|
176 |
if (f instanceof LayoutPanel) { |
|
177 |
return ((LayoutPanel) f).getLayoutContext().isEditable(); |
|
178 |
} |
|
179 |
|
|
180 |
return false; |
|
181 |
} |
|
182 |
|
|
183 |
public boolean isVisible() { |
|
184 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
185 |
|
|
186 |
if (f == null) { |
|
187 |
return false; |
|
188 |
} |
|
189 |
|
|
190 |
if (f instanceof LayoutPanel) { |
|
191 |
return true; |
|
192 |
} else { |
|
193 |
return false; |
|
194 |
} |
|
195 |
} |
|
196 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutRedoExtension.java | ||
---|---|---|
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.gvsig.andami.IconThemeHelper; |
|
25 |
import org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.andami.messages.NotificationManager; |
|
27 |
import org.gvsig.andami.plugins.Extension; |
|
28 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
29 |
import org.gvsig.tools.undo.RedoException; |
|
30 |
|
|
31 |
public class LayoutRedoExtension extends Extension { |
|
32 |
|
|
33 |
public void initialize() { |
|
34 |
registerIcons(); |
|
35 |
} |
|
36 |
|
|
37 |
private void registerIcons() { |
|
38 |
|
|
39 |
IconThemeHelper.registerIcon("action", "edit-redo", this); |
|
40 |
} |
|
41 |
|
|
42 |
public void execute(String actionCommand) { |
|
43 |
LayoutPanel layout = |
|
44 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
45 |
if (actionCommand.equals("edit-redo-layout")) { |
|
46 |
try { |
|
47 |
layout.getLayoutContext().getFrameCommandsRecord().redo(); |
|
48 |
} catch (RedoException e) { |
|
49 |
NotificationManager.showMessageError("Redo layout", e); |
|
50 |
} |
|
51 |
layout.getLayoutContext().updateFFrames(); |
|
52 |
layout.getLayoutControl().refresh(); |
|
53 |
layout.getDocument().setModified(true); |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
public boolean isEnabled() { |
|
58 |
if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) { |
|
59 |
LayoutPanel layout = |
|
60 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
61 |
if (layout.getLayoutContext().getFrameCommandsRecord().canRedo() |
|
62 |
&& layout.getLayoutContext().isEditable()) |
|
63 |
return true; |
|
64 |
} |
|
65 |
return false; |
|
66 |
} |
|
67 |
|
|
68 |
public boolean isVisible() { |
|
69 |
if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) { |
|
70 |
return true; |
|
71 |
} |
|
72 |
return false; |
|
73 |
} |
|
74 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutInsertOverViewExtension.java | ||
---|---|---|
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.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
27 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
28 |
|
|
29 |
/** |
|
30 |
* Extensi?n para insertar un localizador sobre el Layout. |
|
31 |
* |
|
32 |
* @author Vicente Caballero Navarro |
|
33 |
*/ |
|
34 |
public class LayoutInsertOverViewExtension extends Extension { |
|
35 |
|
|
36 |
private LayoutPanel layout = null; |
|
37 |
|
|
38 |
public void initialize() { |
|
39 |
// TODO Auto-generated method stub |
|
40 |
} |
|
41 |
|
|
42 |
public void execute(String s) { |
|
43 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
44 |
|
|
45 |
if (s.equals("layout-insert-locator")) { |
|
46 |
layout.getLayoutControl().setTool("layoutaddoverview"); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
public boolean isEnabled() { |
|
51 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
52 |
|
|
53 |
if (f == null) { |
|
54 |
return false; |
|
55 |
} |
|
56 |
|
|
57 |
if (f instanceof LayoutPanel) { |
|
58 |
return ((LayoutPanel) f).getLayoutContext().isEditable(); |
|
59 |
} |
|
60 |
|
|
61 |
return false; |
|
62 |
} |
|
63 |
|
|
64 |
public boolean isVisible() { |
|
65 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
66 |
|
|
67 |
if (f == null) { |
|
68 |
return false; |
|
69 |
} |
|
70 |
|
|
71 |
if (f instanceof LayoutPanel) { |
|
72 |
return true; |
|
73 |
} else { |
|
74 |
return false; |
|
75 |
} |
|
76 |
} |
|
77 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewExtension.java | ||
---|---|---|
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 javax.swing.JOptionPane; |
|
25 |
|
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.andami.PluginsLocator; |
|
28 |
import org.gvsig.andami.PluginsManager; |
|
29 |
import org.gvsig.andami.messages.NotificationManager; |
|
30 |
import org.gvsig.andami.plugins.Extension; |
|
31 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
32 |
import org.gvsig.app.ApplicationLocator; |
|
33 |
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView; |
|
34 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
|
35 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
36 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap; |
|
37 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
38 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
39 |
import org.gvsig.tools.ToolsLocator; |
|
40 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
41 |
import org.slf4j.Logger; |
|
42 |
import org.slf4j.LoggerFactory; |
|
43 |
|
|
44 |
/** |
|
45 |
* Extensi?n preparada para controlar las opciones que se pueden realizar sobre |
|
46 |
* una vista a?adida en el Layout. |
|
47 |
* |
|
48 |
* @author Vicente Caballero Navarro |
|
49 |
*/ |
|
50 |
public class FFrameViewExtension extends Extension { |
|
51 |
|
|
52 |
private LayoutPanel layout = null; |
|
53 |
private static Logger logger = LoggerFactory.getLogger(FFrameViewExtension.class); |
|
54 |
//.info("Can't change scale of view.", ex); |
|
55 |
|
|
56 |
/** |
|
57 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
58 |
*/ |
|
59 |
public void initialize() { |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String, Object[]) |
|
65 |
*/ |
|
66 |
public void execute(String command, Object[] args) { |
|
67 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
68 |
if (command.endsWith("view-change-scale")) { |
|
69 |
try { |
|
70 |
if (args.length>0) { |
|
71 |
Long scale = (Long) ToolsLocator.getDataTypesManager().coerce(DataTypes.LONG, args[0]); |
|
72 |
if (layout!=null && |
|
73 |
layout.getLayoutControl()!=null && |
|
74 |
layout.getLayoutControl().getLayoutFunctions()!=null) { |
|
75 |
layout.getLayoutControl().getLayoutFunctions().setScale(scale); |
|
76 |
} |
|
77 |
} |
|
78 |
} catch (Throwable ex) { |
|
79 |
logger.info("Can't change scale of view.", ex); |
|
80 |
ApplicationLocator.getManager().message("Can't change scale of view.", JOptionPane.ERROR_MESSAGE); |
|
81 |
} |
|
82 |
} |
|
83 |
else { |
|
84 |
execute(command); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
90 |
*/ |
|
91 |
public void execute(String s) { |
|
92 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
93 |
|
|
94 |
if (s.compareTo("layout-view-navigation-zoom-in-topoint") == 0) { |
|
95 |
layout.getLayoutControl().setTool("layoutviewzoomin"); |
|
96 |
} else if (s.compareTo("layout-view-navigation-zoom-out-topoint") == 0) { |
|
97 |
layout.getLayoutControl().setTool("layoutviewzoomout"); |
|
98 |
} else if (s.compareTo("layout-view-navigation-zoom-all") == 0) { |
|
99 |
try { |
|
100 |
layout.getLayoutControl().viewFull(); |
|
101 |
} catch (ReadException e) { |
|
102 |
NotificationManager.addError("Error de Driver", e); |
|
103 |
} |
|
104 |
} else if (s.compareTo("layout-view-navigation-pan") == 0) { |
|
105 |
layout.getLayoutControl().setTool("layoutviewpan"); |
|
106 |
} else if (s.compareTo("layout-view-add-layer") == 0) { |
|
107 |
PluginsManager manager = PluginsLocator.getManager(); |
|
108 |
AddLayer plugin = (AddLayer) manager.getExtension(AddLayer.class); |
|
109 |
IFFrameUseFMap[] fframes = this.layout.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class); |
|
110 |
if (fframes.length>0) { |
|
111 |
plugin.addLayers(fframes[0].getMapContext()); |
|
112 |
fframes[0].refresh(); |
|
113 |
} |
|
114 |
} |
|
115 |
layout.getDocument().setModified(true); |
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
/** |
|
120 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
121 |
*/ |
|
122 |
public boolean isEnabled() { |
|
123 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
124 |
if (window instanceof LayoutPanel) { |
|
125 |
LayoutPanel l = |
|
126 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
127 |
if (!l.getLayoutContext().isEditable()) { |
|
128 |
return false; |
|
129 |
} |
|
130 |
IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class); |
|
131 |
if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) { |
|
132 |
return true; |
|
133 |
} |
|
134 |
} |
|
135 |
return false; |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
140 |
*/ |
|
141 |
public boolean isVisible() { |
|
142 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
143 |
|
|
144 |
if (f == null) { |
|
145 |
return false; |
|
146 |
} |
|
147 |
|
|
148 |
if (f instanceof LayoutPanel) { |
|
149 |
// Layout layout = (Layout) f; |
|
150 |
|
|
151 |
return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() |
|
152 |
// > 0; |
|
153 |
} else { |
|
154 |
return false; |
|
155 |
} |
|
156 |
} |
|
157 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutEditableControls.java | ||
---|---|---|
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 java.awt.event.KeyEvent; |
|
25 |
|
|
26 |
import javax.swing.KeyStroke; |
|
27 |
|
|
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.LayoutKeyEvent; |
|
32 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
33 |
|
|
34 |
/** |
|
35 |
* Extensi?n para controlar las operaciones basicas de edici?n sobre el Layout. |
|
36 |
* |
|
37 |
* @author Vicente Caballero Navarro |
|
38 |
*/ |
|
39 |
public class LayoutEditableControls extends Extension { |
|
40 |
|
|
41 |
private static LayoutKeyEvent lke = new LayoutKeyEvent(); |
|
42 |
private static KeyStroke copyLayout = KeyStroke.getKeyStroke(KeyEvent.VK_C, |
|
43 |
KeyEvent.CTRL_MASK); |
|
44 |
private static KeyStroke cutLayout = KeyStroke.getKeyStroke(KeyEvent.VK_X, |
|
45 |
KeyEvent.CTRL_MASK); |
|
46 |
private static KeyStroke pasteLayout = KeyStroke.getKeyStroke( |
|
47 |
KeyEvent.VK_V, KeyEvent.CTRL_MASK); |
|
48 |
private static KeyStroke leftLayout = KeyStroke.getKeyStroke( |
|
49 |
KeyEvent.VK_LEFT, 0); |
|
50 |
private static KeyStroke rightLayout = KeyStroke.getKeyStroke( |
|
51 |
KeyEvent.VK_RIGHT, 0); |
|
52 |
private static KeyStroke upLayout = KeyStroke.getKeyStroke(KeyEvent.VK_UP, |
|
53 |
0); |
|
54 |
private static KeyStroke downLayout = KeyStroke.getKeyStroke( |
|
55 |
KeyEvent.VK_DOWN, 0); |
|
56 |
private static KeyStroke undoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Z, |
|
57 |
KeyEvent.CTRL_MASK); |
|
58 |
private static KeyStroke redoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Y, |
|
59 |
KeyEvent.CTRL_MASK); |
|
60 |
private static KeyStroke del1Layout = KeyStroke.getKeyStroke( |
|
61 |
KeyEvent.VK_DELETE, 0); |
|
62 |
private static KeyStroke del2Layout = KeyStroke.getKeyStroke( |
|
63 |
KeyEvent.VK_BACK_SPACE, 0); |
|
64 |
|
|
65 |
/** |
|
66 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
67 |
*/ |
|
68 |
public void execute(String s) { |
|
69 |
LayoutPanel layout = |
|
70 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
71 |
if (s.equals("layout-properties")) { |
|
72 |
if (layout.showFProperties()) { |
|
73 |
layout.getDocument().setModified(true); |
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible() |
|
80 |
*/ |
|
81 |
public boolean isVisible() { |
|
82 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
83 |
|
|
84 |
if (f == null) { |
|
85 |
return false; |
|
86 |
} |
|
87 |
|
|
88 |
if (f instanceof LayoutPanel) { |
|
89 |
return true; |
|
90 |
} |
|
91 |
return false; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
96 |
*/ |
|
97 |
public void initialize() { |
|
98 |
registerKeys(); |
|
99 |
} |
|
100 |
|
|
101 |
private static void registerKeys() { |
|
102 |
PluginServices.registerKeyStroke(copyLayout, lke); |
|
103 |
PluginServices.registerKeyStroke(cutLayout, lke); |
|
104 |
PluginServices.registerKeyStroke(pasteLayout, lke); |
|
105 |
PluginServices.registerKeyStroke(leftLayout, lke); |
|
106 |
PluginServices.registerKeyStroke(rightLayout, lke); |
|
107 |
PluginServices.registerKeyStroke(upLayout, lke); |
|
108 |
PluginServices.registerKeyStroke(downLayout, lke); |
|
109 |
PluginServices.registerKeyStroke(undoLayout, lke); |
|
110 |
PluginServices.registerKeyStroke(redoLayout, lke); |
|
111 |
PluginServices.registerKeyStroke(del1Layout, lke); |
|
112 |
PluginServices.registerKeyStroke(del2Layout, lke); |
|
113 |
} |
|
114 |
|
|
115 |
// private static void unregisterKeys() { |
|
116 |
// PluginServices.unRegisterKeyStroke(copyLayout); |
|
117 |
// PluginServices.unRegisterKeyStroke(cutLayout); |
|
118 |
// PluginServices.unRegisterKeyStroke(pasteLayout); |
|
119 |
// PluginServices.unRegisterKeyStroke(leftLayout); |
|
120 |
// PluginServices.unRegisterKeyStroke(rightLayout); |
|
121 |
// PluginServices.unRegisterKeyStroke(upLayout); |
|
122 |
// PluginServices.unRegisterKeyStroke(downLayout); |
|
123 |
// PluginServices.unRegisterKeyStroke(undoLayout); |
|
124 |
// PluginServices.unRegisterKeyStroke(redoLayout); |
|
125 |
// PluginServices.unRegisterKeyStroke(del1Layout); |
|
126 |
// PluginServices.unRegisterKeyStroke(del2Layout); |
|
127 |
// } |
|
128 |
|
|
129 |
/** |
|
130 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
131 |
*/ |
|
132 |
public boolean isEnabled() { |
|
133 |
return true; |
|
134 |
} |
|
135 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.24/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/Print.java | ||
---|---|---|
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 java.awt.Graphics; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.geom.AffineTransform; |
|
27 |
import java.awt.geom.Rectangle2D; |
|
28 |
import java.awt.print.PageFormat; |
|
29 |
import java.awt.print.Printable; |
|
30 |
import java.awt.print.PrinterException; |
|
31 |
import java.awt.print.PrinterJob; |
|
32 |
|
|
33 |
import javax.print.Doc; |
|
34 |
import javax.print.DocFlavor; |
|
35 |
import javax.print.DocPrintJob; |
|
36 |
import javax.print.PrintException; |
|
37 |
import javax.print.PrintService; |
|
38 |
import javax.print.PrintServiceLookup; |
|
39 |
import javax.print.ServiceUI; |
|
40 |
import javax.print.SimpleDoc; |
|
41 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
42 |
import javax.print.event.PrintJobAdapter; |
|
43 |
import javax.print.event.PrintJobEvent; |
|
44 |
import javax.print.event.PrintJobListener; |
|
45 |
import javax.swing.JOptionPane; |
|
46 |
|
|
47 |
import org.slf4j.Logger; |
|
48 |
import org.slf4j.LoggerFactory; |
|
49 |
|
|
50 |
import org.gvsig.andami.IconThemeHelper; |
|
51 |
import org.gvsig.andami.PluginServices; |
|
52 |
import org.gvsig.andami.plugins.Extension; |
|
53 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
54 |
import org.gvsig.app.ApplicationLocator; |
|
55 |
import org.gvsig.app.project.documents.layout.Attributes; |
|
56 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
|
57 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
58 |
import org.gvsig.i18n.Messages; |
|
59 |
|
|
60 |
/** |
|
61 |
* Extensi?n desde la que se imprime. |
|
62 |
* |
|
63 |
* @author Vicente Caballero Navarro |
|
64 |
*/ |
|
65 |
public class Print extends Extension implements Printable { |
|
66 |
|
|
67 |
private static Logger logger = LoggerFactory.getLogger(Print.class); |
|
68 |
|
|
69 |
public static PrinterJob printerJob = PrinterJob.getPrinterJob(); |
|
70 |
|
|
71 |
// private Paper paper; |
|
72 |
Rectangle2D.Double aux = null; |
|
73 |
private PrintService[] m_cachePrintServices = null; |
|
74 |
private PrintService m_cachePrintService = null; |
|
75 |
|
|
76 |
private static LayoutPanel theLayoutPanel = null; |
|
77 |
|
|
78 |
public void execute(String s) { |
|
79 |
if (s.compareTo("application-print-layout") == 0) { |
|
80 |
doPrint((LayoutPanel) PluginServices.getMDIManager().getActiveWindow()); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
public void doPrint(final LayoutPanel layoutPanel) { |
|
85 |
|
|
86 |
theLayoutPanel = layoutPanel; |
|
87 |
|
|
88 |
try { |
|
89 |
PluginServices.backgroundExecution(new Runnable() { |
|
90 |
|
|
91 |
public void run() { |
|
92 |
if (layoutPanel.getLayoutContext().getAttributes().getType() == Attributes.CUSTOM) { |
|
93 |
layoutPanel.showPrintDialog(printerJob); |
|
94 |
} else { |
|
95 |
layoutPanel.showPrintDialog(null); |
|
96 |
} |
|
97 |
} |
|
98 |
}); |
|
99 |
|
|
100 |
} catch (Exception e) { |
|
101 |
|
|
102 |
logger.info("Error while showing print dialog.", e); |
|
103 |
ApplicationLocator.getManager().messageDialog( |
|
104 |
Messages.getText("_Error_while_showing_print_dialog"), |
|
105 |
Messages.getText("Imprimir"), |
|
106 |
JOptionPane.ERROR_MESSAGE); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
public void setLayout(LayoutPanel layoutp){ |
|
111 |
theLayoutPanel = layoutp; |
|
112 |
} |
|
113 |
|
|
114 |
|
|
115 |
public boolean isVisible() { |
|
116 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
117 |
|
|
118 |
if (f == null) { |
|
119 |
return false; |
|
120 |
} |
|
121 |
|
|
122 |
return (f instanceof LayoutPanel); |
|
123 |
} |
|
124 |
|
|
125 |
public boolean isEnabled() { |
|
126 |
LayoutPanel f = |
|
127 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
128 |
|
|
129 |
if (f == null) { |
|
130 |
return false; |
|
131 |
} |
|
132 |
|
|
133 |
return true; |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
public void initialize() { |
|
138 |
registerIcons(); |
|
139 |
} |
|
140 |
|
|
141 |
private void registerIcons() { |
|
142 |
IconThemeHelper.registerIcon("action", "application-print", this); |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Abre un di?logo para imprimir. |
|
147 |
* |
|
148 |
* @param layout |
|
149 |
* Layout a imprimir. |
|
150 |
*/ |
|
151 |
public void openDialogToPrint(LayoutPanel layoutPanel) { |
|
152 |
|
|
153 |
theLayoutPanel = layoutPanel; |
|
154 |
|
|
155 |
try { |
|
156 |
if (layoutPanel.getLayoutContext().getAttributes().getType() == Attributes.CUSTOM) { |
|
157 |
layoutPanel.showPrintDialog(printerJob); |
|
158 |
} else { |
|
159 |
layoutPanel.showPrintDialog(null); |
|
160 |
} |
|
161 |
} catch (Exception e) { |
|
162 |
System.out.println("Excepci?n al abrir el di?logo de impresi?n: " |
|
163 |
+ e); |
|
164 |
e.printStackTrace(); |
|
165 |
} |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* Imprime el Layout que se pasa como par?metro. |
|
170 |
* |
|
171 |
* @param layout |
|
172 |
* Layout a imprimir. |
|
173 |
*/ |
|
174 |
public void printLayout(LayoutPanel layoutPanel) { |
|
175 |
|
|
176 |
theLayoutPanel = layoutPanel; |
|
177 |
|
Also available in: Unified diff