gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.app / org.gvsig.geoprocess.app.mainplugin / src / main / java / org / gvsig / geoprocess / gui / gvGUIFactory.java @ 189
History | View | Annotate | Download (6.27 KB)
1 |
package org.gvsig.geoprocess.gui; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.io.File; |
5 |
import java.net.MalformedURLException; |
6 |
import java.net.URL; |
7 |
import java.util.ArrayList; |
8 |
import java.util.HashMap; |
9 |
import java.util.List; |
10 |
|
11 |
import javax.swing.BorderFactory; |
12 |
import javax.swing.JEditorPane; |
13 |
import javax.swing.JScrollPane; |
14 |
import javax.swing.border.BevelBorder; |
15 |
|
16 |
import es.unex.sextante.dataObjects.IDataObject; |
17 |
import es.unex.sextante.gui.cmd.BSHDialog; |
18 |
import es.unex.sextante.gui.core.DefaultGUIFactory; |
19 |
import es.unex.sextante.gui.core.NameAndIcon; |
20 |
import es.unex.sextante.gui.core.SextanteGUI; |
21 |
import es.unex.sextante.gui.core.ToolboxAction; |
22 |
import es.unex.sextante.gui.dataExplorer.DataExplorerDialog; |
23 |
import es.unex.sextante.gui.exceptions.WrongViewNameException; |
24 |
import es.unex.sextante.gui.history.HistoryDialog; |
25 |
|
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.app.extension.ProjectExtension; |
28 |
import org.gvsig.app.project.Project; |
29 |
import org.gvsig.app.project.documents.Document; |
30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
31 |
import org.gvsig.app.project.documents.view.ViewManager; |
32 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
33 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
34 |
|
35 |
public class gvGUIFactory extends DefaultGUIFactory { |
36 |
|
37 |
public static final String IS_NOT_FIRST_TIME_USING_SEXTANTE = |
38 |
"isFirstTimeUsingSextante";
|
39 |
|
40 |
@Override
|
41 |
public void showToolBoxDialog() { |
42 |
|
43 |
showFirstTimeWarning(); |
44 |
|
45 |
final ToolboxDialog toolbox = new ToolboxDialog(); |
46 |
m_Toolbox = toolbox.getToolboxPanel(); |
47 |
PluginServices.getMDIManager().addWindow(toolbox); |
48 |
|
49 |
} |
50 |
|
51 |
private void showFirstTimeWarning() { |
52 |
|
53 |
final boolean b = |
54 |
new Boolean( |
55 |
SextanteGUI |
56 |
.getSettingParameterValue(IS_NOT_FIRST_TIME_USING_SEXTANTE)) |
57 |
.booleanValue(); |
58 |
|
59 |
if (!b) {
|
60 |
final JEditorPane jEditorPane = new JEditorPane(); |
61 |
jEditorPane.setEditable(false);
|
62 |
final JScrollPane scrollPane = new JScrollPane(); |
63 |
scrollPane.setPreferredSize(new Dimension(800, 600)); |
64 |
scrollPane.setSize(new Dimension(800, 600)); |
65 |
scrollPane.setMaximumSize(new Dimension(800, 600)); |
66 |
scrollPane.setViewportView(jEditorPane); |
67 |
jEditorPane.setBorder(BorderFactory
|
68 |
.createEtchedBorder(BevelBorder.LOWERED));
|
69 |
jEditorPane.setContentType("text/html");
|
70 |
try {
|
71 |
jEditorPane.setPage(getFirstTimeWebpageURL()); |
72 |
} catch (final Exception e) { |
73 |
return;
|
74 |
} |
75 |
jEditorPane.setPreferredSize(new Dimension(600, 500)); |
76 |
jEditorPane.setCaretPosition(0);
|
77 |
|
78 |
showGenericInfoDialog(jEditorPane, "SEXTANTE");
|
79 |
SextanteGUI.setSettingParameterValue( |
80 |
IS_NOT_FIRST_TIME_USING_SEXTANTE, Boolean.TRUE.toString());
|
81 |
SextanteGUI.saveSettings(); |
82 |
|
83 |
} |
84 |
|
85 |
} |
86 |
|
87 |
private URL getFirstTimeWebpageURL() throws MalformedURLException { |
88 |
|
89 |
return new File(SextanteGUI.getSextantePath() + File.separator |
90 |
+ "first_time.html").toURI().toURL();
|
91 |
} |
92 |
|
93 |
@Override
|
94 |
public void showModelerDialog() { |
95 |
|
96 |
showFirstTimeWarning(); |
97 |
|
98 |
SextanteGUI.getInputFactory().createDataObjects(); |
99 |
|
100 |
final ModelerDialog dialog = new ModelerDialog(m_Toolbox); |
101 |
PluginServices.getMDIManager().addWindow(dialog); |
102 |
|
103 |
} |
104 |
|
105 |
@Override
|
106 |
public void showHistoryDialog() { |
107 |
|
108 |
showFirstTimeWarning(); |
109 |
|
110 |
SextanteGUI.getInputFactory().createDataObjects(); |
111 |
|
112 |
final HistoryDialog dialog =
|
113 |
new HistoryDialog(SextanteGUI.getMainFrame());
|
114 |
SextanteGUI.setLastCommandOrigin(SextanteGUI.HISTORY); |
115 |
SextanteGUI.setLastCommandOriginParentDialog(dialog); |
116 |
m_History = dialog.getHistoryPanel(); |
117 |
dialog.pack(); |
118 |
dialog.setVisible(true);
|
119 |
|
120 |
if (m_Toolbox == null) { |
121 |
SextanteGUI.getInputFactory().clearDataObjects(); |
122 |
} |
123 |
|
124 |
m_History = null;
|
125 |
|
126 |
} |
127 |
|
128 |
@Override
|
129 |
public void showCommandLineDialog() { |
130 |
|
131 |
showFirstTimeWarning(); |
132 |
|
133 |
SextanteGUI.getInputFactory().createDataObjects(); |
134 |
|
135 |
final BSHDialog dialog = new BSHDialog(SextanteGUI.getMainFrame()); |
136 |
SextanteGUI.setLastCommandOrigin(SextanteGUI.COMMANDLINE); |
137 |
SextanteGUI.setLastCommandOriginParentDialog(dialog); |
138 |
dialog.pack(); |
139 |
dialog.setVisible(true);
|
140 |
|
141 |
if (m_Toolbox == null) { |
142 |
SextanteGUI.getInputFactory().clearDataObjects(); |
143 |
} |
144 |
|
145 |
} |
146 |
|
147 |
@Override
|
148 |
public void showDataExplorer() { |
149 |
|
150 |
showFirstTimeWarning(); |
151 |
|
152 |
SextanteGUI.getInputFactory().createDataObjects(); |
153 |
|
154 |
final DataExplorerDialog dialog =
|
155 |
new DataExplorerDialog(SextanteGUI.getMainFrame());
|
156 |
dialog.pack(); |
157 |
dialog.setVisible(true);
|
158 |
|
159 |
if (m_Toolbox == null) { |
160 |
SextanteGUI.getInputFactory().clearDataObjects(); |
161 |
} |
162 |
|
163 |
} |
164 |
|
165 |
@Override
|
166 |
public void updateToolbox() { |
167 |
|
168 |
super.updateToolbox();
|
169 |
|
170 |
} |
171 |
|
172 |
public void setToolboxHidden() { |
173 |
|
174 |
m_Toolbox = null;
|
175 |
|
176 |
} |
177 |
|
178 |
@Override
|
179 |
public void addToView(final IDataObject obj, final String viewName) |
180 |
throws WrongViewNameException {
|
181 |
|
182 |
final Project project =
|
183 |
((ProjectExtension) PluginServices |
184 |
.getExtension(ProjectExtension.class)).getProject(); |
185 |
final List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
186 |
for (int i = 0; i < views.size(); i++) { |
187 |
final ViewDocument view = (ViewDocument) views.get(i);
|
188 |
if (view.getName().equals(viewName)) {
|
189 |
final FLayers layers = view.getMapContext().getLayers();
|
190 |
final Object layer = obj.getBaseDataObject(); |
191 |
if (layer instanceof FLayer) { |
192 |
layers.addLayer((FLayer) layer); |
193 |
} |
194 |
return;
|
195 |
} |
196 |
} |
197 |
|
198 |
throw new WrongViewNameException(); |
199 |
} |
200 |
|
201 |
@Override
|
202 |
public HashMap<NameAndIcon, ArrayList<ToolboxAction>> getToolboxActions() { |
203 |
|
204 |
final HashMap<NameAndIcon, ArrayList<ToolboxAction>> map = |
205 |
new HashMap<NameAndIcon, ArrayList<ToolboxAction>>(); |
206 |
|
207 |
return map;
|
208 |
|
209 |
} |
210 |
//
|
211 |
// public Class getDefaultParametersPanel() {
|
212 |
//
|
213 |
// return gvDefaultParametersPanel.class;
|
214 |
//
|
215 |
// }
|
216 |
} |