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 / GUIFactory.java @ 228
History | View | Annotate | Download (4.25 KB)
1 |
package org.gvsig.geoprocess.gui; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.HashMap; |
5 |
import java.util.List; |
6 |
|
7 |
import es.unex.sextante.dataObjects.IDataObject; |
8 |
import es.unex.sextante.gui.cmd.BSHDialog; |
9 |
import es.unex.sextante.gui.core.DefaultGUIFactory; |
10 |
import es.unex.sextante.gui.core.NameAndIcon; |
11 |
import es.unex.sextante.gui.core.SextanteGUI; |
12 |
import es.unex.sextante.gui.core.ToolboxAction; |
13 |
import es.unex.sextante.gui.dataExplorer.DataExplorerDialog; |
14 |
import es.unex.sextante.gui.exceptions.WrongViewNameException; |
15 |
import es.unex.sextante.gui.history.HistoryDialog; |
16 |
|
17 |
import org.gvsig.andami.PluginServices; |
18 |
import org.gvsig.app.extension.ProjectExtension; |
19 |
import org.gvsig.app.project.Project; |
20 |
import org.gvsig.app.project.documents.Document; |
21 |
import org.gvsig.app.project.documents.view.ViewDocument; |
22 |
import org.gvsig.app.project.documents.view.ViewManager; |
23 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
24 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
25 |
|
26 |
public class GUIFactory extends DefaultGUIFactory { |
27 |
|
28 |
@Override
|
29 |
public void showToolBoxDialog() { |
30 |
|
31 |
final ToolboxDialog toolbox = new ToolboxDialog(); |
32 |
m_Toolbox = toolbox.getToolboxPanel(); |
33 |
PluginServices.getMDIManager().addWindow(toolbox); |
34 |
|
35 |
} |
36 |
|
37 |
@Override
|
38 |
public void showModelerDialog() { |
39 |
|
40 |
SextanteGUI.getInputFactory().createDataObjects(); |
41 |
|
42 |
final ModelerDialog dialog = new ModelerDialog(m_Toolbox); |
43 |
PluginServices.getMDIManager().addWindow(dialog); |
44 |
|
45 |
} |
46 |
|
47 |
@Override
|
48 |
public void showHistoryDialog() { |
49 |
|
50 |
SextanteGUI.getInputFactory().createDataObjects(); |
51 |
|
52 |
final HistoryDialog dialog =
|
53 |
new HistoryDialog(SextanteGUI.getMainFrame());
|
54 |
SextanteGUI.setLastCommandOrigin(SextanteGUI.HISTORY); |
55 |
SextanteGUI.setLastCommandOriginParentDialog(dialog); |
56 |
m_History = dialog.getHistoryPanel(); |
57 |
dialog.pack(); |
58 |
dialog.setVisible(true);
|
59 |
|
60 |
if (m_Toolbox == null) { |
61 |
SextanteGUI.getInputFactory().clearDataObjects(); |
62 |
} |
63 |
|
64 |
m_History = null;
|
65 |
|
66 |
} |
67 |
|
68 |
@Override
|
69 |
public void showCommandLineDialog() { |
70 |
|
71 |
SextanteGUI.getInputFactory().createDataObjects(); |
72 |
|
73 |
final BSHDialog dialog = new BSHDialog(SextanteGUI.getMainFrame()); |
74 |
SextanteGUI.setLastCommandOrigin(SextanteGUI.COMMANDLINE); |
75 |
SextanteGUI.setLastCommandOriginParentDialog(dialog); |
76 |
dialog.pack(); |
77 |
dialog.setVisible(true);
|
78 |
|
79 |
if (m_Toolbox == null) { |
80 |
SextanteGUI.getInputFactory().clearDataObjects(); |
81 |
} |
82 |
|
83 |
} |
84 |
|
85 |
@Override
|
86 |
public void showDataExplorer() { |
87 |
|
88 |
SextanteGUI.getInputFactory().createDataObjects(); |
89 |
|
90 |
final DataExplorerDialog dialog =
|
91 |
new DataExplorerDialog(SextanteGUI.getMainFrame());
|
92 |
dialog.pack(); |
93 |
dialog.setVisible(true);
|
94 |
|
95 |
if (m_Toolbox == null) { |
96 |
SextanteGUI.getInputFactory().clearDataObjects(); |
97 |
} |
98 |
|
99 |
} |
100 |
|
101 |
@Override
|
102 |
public void updateToolbox() { |
103 |
|
104 |
super.updateToolbox();
|
105 |
|
106 |
} |
107 |
|
108 |
public void setToolboxHidden() { |
109 |
|
110 |
m_Toolbox = null;
|
111 |
|
112 |
} |
113 |
|
114 |
@Override
|
115 |
public void addToView(final IDataObject obj, final String viewName) |
116 |
throws WrongViewNameException {
|
117 |
|
118 |
final Project project =
|
119 |
((ProjectExtension) PluginServices |
120 |
.getExtension(ProjectExtension.class)).getProject(); |
121 |
final List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
122 |
for (int i = 0; i < views.size(); i++) { |
123 |
final ViewDocument view = (ViewDocument) views.get(i);
|
124 |
if (view.getName().equals(viewName)) {
|
125 |
final FLayers layers = view.getMapContext().getLayers();
|
126 |
final Object layer = obj.getBaseDataObject(); |
127 |
if (layer instanceof FLayer) { |
128 |
layers.addLayer((FLayer) layer); |
129 |
} |
130 |
return;
|
131 |
} |
132 |
} |
133 |
|
134 |
throw new WrongViewNameException(); |
135 |
} |
136 |
|
137 |
@Override
|
138 |
public HashMap<NameAndIcon, ArrayList<ToolboxAction>> getToolboxActions() { |
139 |
|
140 |
final HashMap<NameAndIcon, ArrayList<ToolboxAction>> map = |
141 |
new HashMap<NameAndIcon, ArrayList<ToolboxAction>>(); |
142 |
|
143 |
return map;
|
144 |
|
145 |
} |
146 |
//
|
147 |
// public Class getDefaultParametersPanel() {
|
148 |
//
|
149 |
// return ParametersPanel.class;
|
150 |
//
|
151 |
// }
|
152 |
} |