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