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