gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.app / org.gvsig.geoprocess.app.mainplugin / src / main / java / org / gvsig / geoprocess / extension / GeoprocessExtension.java @ 474
History | View | Annotate | Download (4.86 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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.geoprocess.extension; |
25 |
|
26 |
import java.awt.Frame; |
27 |
import java.io.File; |
28 |
import java.util.HashMap; |
29 |
|
30 |
import es.unex.sextante.gui.additionalResults.AdditionalResults; |
31 |
import es.unex.sextante.gui.core.IGUIFactory; |
32 |
import es.unex.sextante.gui.core.SextanteGUI; |
33 |
import es.unex.sextante.gui.history.History; |
34 |
|
35 |
import org.gvsig.andami.PluginServices; |
36 |
import org.gvsig.andami.plugins.Extension; |
37 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
38 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
39 |
import org.gvsig.geoprocess.lib.api.GeoProcessLocator; |
40 |
import org.gvsig.geoprocess.lib.sextante.SextanteGeoProcessManager; |
41 |
import org.gvsig.geoprocess.lib.sextante.core.DefaultInputFactory; |
42 |
import org.gvsig.geoprocess.lib.sextante.core.DefaultOutputFactory; |
43 |
import org.gvsig.geoprocess.lib.sextante.core.DefaultPostProcessTaskFactory; |
44 |
import org.gvsig.geoprocess.sextante.gui.core.GUIFactory; |
45 |
|
46 |
/**
|
47 |
* Extension to show Geoprocess GUI utilities.
|
48 |
*
|
49 |
* @author gvSIG Team
|
50 |
* @version $Id$
|
51 |
*/
|
52 |
public class GeoprocessExtension extends Extension { |
53 |
|
54 |
private static final String GEOPROCESS_SELECTOR = "GEOPROCESS_SELECTOR"; |
55 |
|
56 |
private static final String GEOPROCESS_MODELER = "GEOPROCESS_MODELER"; |
57 |
|
58 |
private static final String GEOPROCESS_HISTORY = "GEOPROCESS_HISTORY"; |
59 |
|
60 |
private static final String GEOPROCESS_COMMAND_LINE = |
61 |
"GEOPROCESS_COMMAND_LINE";
|
62 |
|
63 |
private static final String GEOPROCESS_RESULTS = "GEOPROCESS_RESULTS"; |
64 |
|
65 |
private static final String GEOPROCESS_DATAEXPLORER = |
66 |
"GEOPROCESS_DATAEXPLORER";
|
67 |
|
68 |
private static final String GEOPROCESS_HELP = "GEOPROCESS_HELP"; |
69 |
|
70 |
public void initialize() { |
71 |
SextanteGUI.setSextantePath(System.getProperty("user.dir") |
72 |
+ File.separator + "gvSIG" + File.separator + "extensiones" |
73 |
+ File.separator + "org.gvsig.geoprocess.app.mainplugin"); |
74 |
|
75 |
SextanteGUI.addAlgorithmProvider( |
76 |
(SextanteGeoProcessManager) GeoProcessLocator.getGeoProcessManager()); |
77 |
SextanteGUI.initialize(); |
78 |
|
79 |
// Sextante API uses collection implementations :(
|
80 |
HashMap<String, String> map = new HashMap<String, String>(); |
81 |
map.put("isFirstTimeUsingSextante", Boolean.FALSE.toString()); |
82 |
|
83 |
SextanteGUI.setCustomDefaultSettings(map); |
84 |
SextanteGUI.setMainFrame(((Frame) PluginServices.getMainFrame()));
|
85 |
SextanteGUI.setOutputFactory(new DefaultOutputFactory());
|
86 |
SextanteGUI.setInputFactory(new DefaultInputFactory());
|
87 |
SextanteGUI.setPostProcessTaskFactory(new DefaultPostProcessTaskFactory());
|
88 |
SextanteGUI.setGUIFactory(new GUIFactory());
|
89 |
History.startSession(); |
90 |
} |
91 |
|
92 |
public void execute(String actionCommand) { |
93 |
|
94 |
IGUIFactory guiFactory = SextanteGUI.getGUIFactory(); |
95 |
|
96 |
if (GEOPROCESS_SELECTOR.equals(actionCommand)) {
|
97 |
guiFactory.showToolBoxDialog(); |
98 |
return;
|
99 |
} |
100 |
|
101 |
if (GEOPROCESS_MODELER.equals(actionCommand)) {
|
102 |
guiFactory.showModelerDialog(); |
103 |
return;
|
104 |
} |
105 |
|
106 |
if (GEOPROCESS_HISTORY.equals(actionCommand)) {
|
107 |
guiFactory.showHistoryDialog(); |
108 |
return;
|
109 |
} |
110 |
|
111 |
if (GEOPROCESS_COMMAND_LINE.equals(actionCommand)) {
|
112 |
guiFactory.showCommandLineDialog(); |
113 |
return;
|
114 |
} |
115 |
|
116 |
if (GEOPROCESS_RESULTS.equals(actionCommand)) {
|
117 |
guiFactory.showAdditionalResultsDialog(AdditionalResults |
118 |
.getComponents()); |
119 |
return;
|
120 |
} |
121 |
|
122 |
if (GEOPROCESS_DATAEXPLORER.equals(actionCommand)) {
|
123 |
guiFactory.showDataExplorer(); |
124 |
return;
|
125 |
} |
126 |
|
127 |
if (GEOPROCESS_HELP.equals(actionCommand)) {
|
128 |
guiFactory.showHelpWindow(); |
129 |
return;
|
130 |
} |
131 |
} |
132 |
|
133 |
public boolean isEnabled() { |
134 |
return true; |
135 |
} |
136 |
|
137 |
public boolean isVisible() { |
138 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
139 |
if(w instanceof AbstractViewPanel) |
140 |
return true; |
141 |
return false; |
142 |
} |
143 |
|
144 |
} |