Revision 97

View differences:

org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/build.number
1
#Build Number for ANT. Do not edit!
2
#Tue Apr 28 16:00:47 CEST 2009
3
build.number=2005
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/gvPostProcessTaskFactory.java
1
package org.gvsig.sextante.app.extension.gui;
2

  
3
import es.unex.sextante.core.GeoAlgorithm;
4
import es.unex.sextante.gui.core.IPostProcessTaskFactory;
5

  
6
public class gvPostProcessTaskFactory implements IPostProcessTaskFactory{
7

  
8
	public Runnable getPostProcessTask(GeoAlgorithm alg) {
9

  
10
		return new gvPostProcessTask(alg);
11

  
12
	}
13

  
14
}
0 15

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/gvInputFactory.java
1
package org.gvsig.sextante.app.extension.gui;
2

  
3
import java.awt.geom.Rectangle2D;
4
import java.util.ArrayList;
5
import java.util.List;
6

  
7
import org.gvsig.andami.PluginServices;
8
import org.gvsig.app.extension.ProjectExtension;
9
import org.gvsig.app.project.Project;
10
import org.gvsig.app.project.ProjectManager;
11
import org.gvsig.app.project.documents.Document;
12
import org.gvsig.app.project.documents.table.TableDocument;
13
import org.gvsig.app.project.documents.table.TableManager;
14
import org.gvsig.app.project.documents.view.DefaultViewDocument;
15
import org.gvsig.app.project.documents.view.ViewManager;
16
import org.gvsig.fmap.mapcontext.layers.FLayer;
17
import org.gvsig.fmap.mapcontext.layers.FLayers;
18
import org.gvsig.fmap.mapcontext.layers.LayersIterator;
19
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
20
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
21
import org.gvsig.sextante.app.extension.core.FileTools;
22
import org.gvsig.sextante.app.extension.core.gvRasterLayer;
23
import org.gvsig.sextante.app.extension.core.gvTable;
24
import org.gvsig.sextante.app.extension.core.gvVectorLayer;
25

  
26
import es.unex.sextante.core.AbstractInputFactory;
27
import es.unex.sextante.core.NamedExtent;
28
import es.unex.sextante.dataObjects.IDataObject;
29

  
30
public class gvInputFactory extends AbstractInputFactory {
31

  
32
	public void createDataObjects() {
33

  
34
		ArrayList list = new ArrayList();
35

  
36
//		Project project = ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
37
		final Project project = ProjectManager.getInstance().getCurrentProject();
38
		List<Document> views = project.getDocuments(ViewManager.TYPENAME);
39
		for (int i = 0; i < views.size(); i++) {
40
			DefaultViewDocument view = (DefaultViewDocument) views.get(i);
41
			FLayers layers = view.getMapContext().getLayers();
42
			LayersIterator iter = new LayersIterator(layers);
43
			while (iter.hasNext()){
44
				FLayer layer = iter.nextLayer();
45
				if (layer instanceof FLyrRasterSE){
46
					gvRasterLayer rasterLayer = new gvRasterLayer();
47
					rasterLayer.create((FLyrRasterSE)layer);
48
					list.add(rasterLayer);
49
				}
50
				else if (layer instanceof FLyrVect){
51
					gvVectorLayer vectorLayer =new gvVectorLayer();
52
					vectorLayer.create((FLyrVect)layer);
53
					list.add(vectorLayer);
54
				}
55
			}
56
		}
57

  
58
		List<Document> tables = project.getDocuments(TableManager.TYPENAME);
59
		for (int i = 0; i < tables.size(); i++) {
60
			gvTable table = new gvTable();
61
			table.create((TableDocument) tables.get(i));
62
			list.add(table);
63
		}
64

  
65
		m_Objects =  new IDataObject[list.size()];
66
		for (int i = 0; i < list.size(); i++) {
67
			m_Objects[i] = (IDataObject)list.get(i);
68
		}
69

  
70
	}
71

  
72
	public NamedExtent[] getPredefinedExtents() {
73
		final Project project = ProjectManager.getInstance().getCurrentProject();
74
		List<Document> views = project.getDocuments(ViewManager.TYPENAME);
75
				NamedExtent ne[] = new NamedExtent[views.size()];
76
		for (int i = 0; i < views.size(); i++) {
77
			DefaultViewDocument view = (DefaultViewDocument) views.get(i);
78
			Rectangle2D extent = view.getMapContext().getViewPort().getExtent();
79
			String sName = view.getName();
80
			ne[i] = new NamedExtent(sName, extent);
81
		}
82

  
83
		return ne;
84
	}
85

  
86

  
87
	public String[] getRasterLayerInputExtensions() {
88
		return FileTools.RASTER_EXT_IN;
89
	}
90

  
91
	public String[] getVectorLayerInputExtensions() {
92
		return FileTools.VECTOR_EXT_IN;
93
	}
94

  
95
	public String[] getTableInputExtensions() {
96
		return FileTools.TABLE_EXT;
97
	}
98

  
99
	public IDataObject openDataObjectFromFile(String sFilename) {
100
		Object object = FileTools.open(sFilename);
101

  
102
		if (object == null) {
103
			return null;
104
		} else 
105
			if (object instanceof FLyrRasterSE) {
106
				gvRasterLayer layer = new gvRasterLayer();
107
				layer.create(object);
108
				return layer;
109
		} else 
110
			if (object instanceof FLyrVect) {
111
				gvVectorLayer layer = new gvVectorLayer();
112
				layer.create(object);
113
				return layer;
114
		} else 
115
			return null;
116
	}
117
	
118
	public void close(String sName) {
119
		IDataObject dataObject = this.getInputFromName(sName);
120

  
121
		Object obj = dataObject.getBaseDataObject();
122
		if (obj instanceof FLayer){
123
			removeLayer((FLayer)obj);
124
		} else {
125
			Project project = ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
126
			project.remove((Document) obj);
127
		}
128
	}
129
	
130
	private static void removeLayer(FLayer baseLayer) {
131
		Project project = ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
132
		List<Document> views = project.getDocuments(ViewManager.TYPENAME);
133
		for (int i = 0; i < views.size(); i++) {
134
			DefaultViewDocument view = (DefaultViewDocument) views.get(i);
135
			FLayers layers = view.getMapContext().getLayers();
136
			LayersIterator iter = new LayersIterator(layers);
137
			while (iter.hasNext()){
138
				FLayer layer = iter.nextLayer();
139
				if (layer.equals(baseLayer)){
140
					layers.removeLayer(baseLayer);
141
					return;
142
				}
143
			}
144
		}
145
	}
146

  
147
}
0 148

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/gvPostProcessTask.java
1
package org.gvsig.sextante.app.extension.gui;
2

  
3
import java.awt.Component;
4
import java.lang.reflect.InvocationTargetException;
5
import java.util.ArrayList;
6
import java.util.List;
7

  
8
import javax.swing.BorderFactory;
9
import javax.swing.JScrollPane;
10
import javax.swing.JTextPane;
11
import javax.swing.SwingUtilities;
12
import javax.swing.border.BevelBorder;
13

  
14
import org.gvsig.andami.PluginServices;
15
import org.gvsig.andami.ui.mdiManager.IWindow;
16
import org.gvsig.app.extension.ProjectExtension;
17
import org.gvsig.app.project.Project;
18
import org.gvsig.app.project.ProjectManager;
19
import org.gvsig.app.project.documents.Document;
20
import org.gvsig.app.project.documents.table.TableDocument;
21
import org.gvsig.app.project.documents.view.DefaultViewDocument;
22
import org.gvsig.app.project.documents.view.ViewManager;
23
import org.gvsig.fmap.mapcontext.MapContext;
24
import org.gvsig.fmap.mapcontext.layers.FLayer;
25
import org.gvsig.fmap.mapcontext.layers.FLayers;
26
import org.gvsig.fmap.mapcontext.layers.LayersIterator;
27
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
28

  
29
import es.unex.sextante.core.GeoAlgorithm;
30
import es.unex.sextante.core.ObjectAndDescription;
31
import es.unex.sextante.core.OutputObjectsSet;
32
import es.unex.sextante.core.ParametersSet;
33
import es.unex.sextante.dataObjects.IDataObject;
34
import es.unex.sextante.dataObjects.ILayer;
35
import es.unex.sextante.dataObjects.IRasterLayer;
36
import es.unex.sextante.dataObjects.ITable;
37
import es.unex.sextante.dataObjects.IVectorLayer;
38
import es.unex.sextante.gui.additionalResults.AdditionalResults;
39
import es.unex.sextante.gui.core.SextanteGUI;
40
import es.unex.sextante.outputs.Output;
41
import es.unex.sextante.parameters.Parameter;
42
import es.unex.sextante.parameters.RasterLayerAndBand;
43

  
44
public class gvPostProcessTask implements Runnable{
45

  
46
    private MapContext m_MapContext;
47
    GeoAlgorithm m_Algorithm;
48
	private OutputObjectsSet m_Output;
49
	//private IProjection m_Projection;
50

  
51
    public gvPostProcessTask(GeoAlgorithm algorithm){
52

  
53
        m_Output = algorithm.getOutputObjects();
54
        m_Algorithm = algorithm;
55

  
56
    }
57

  
58
    public void run(){
59

  
60
    	setOutputView();
61

  
62
    	addResults();
63

  
64
    }
65

  
66
    private void setOutputView() {
67

  
68
        DefaultViewDocument view = null;
69
        ParametersSet parameters = m_Algorithm.getParameters();
70
        for (int i = 0; i < parameters.getNumberOfParameters(); i++) {
71
        	Parameter param = parameters.getParameter(i);
72
        	Object object = param.getParameterValueAsObject();
73
        	if (object instanceof ILayer){
74
        		view = getViewFromLayer((ILayer) object);
75
        		m_MapContext = view.getMapContext();
76
        		return;
77
        	}
78
        	else if (object instanceof ArrayList){
79
        		ArrayList list = (ArrayList) object;
80
        		for (int j = 0; j < list.size(); j++) {
81
					Object obj = list.get(j);
82
					if (obj instanceof ILayer){
83
			      		view = getViewFromLayer((ILayer) obj);
84
		        		m_MapContext = view.getMapContext();
85
		        		return;
86
					}
87
					else if(obj instanceof RasterLayerAndBand){
88
						RasterLayerAndBand rlab = (RasterLayerAndBand) obj;
89
			      		view = getViewFromLayer(rlab.getRasterLayer());
90
		        		m_MapContext = view.getMapContext();
91
		        		return;
92
					}
93
				}
94
        	}
95
        }
96

  
97
        final DefaultViewDocument newView = (DefaultViewDocument) ProjectManager.getInstance().createDocument(ViewManager.TYPENAME,"NUEVA");
98
		final Project project = ProjectManager.getInstance().getCurrentProject();
99
		project.add(newView);
100
        final IWindow window = newView.getFactory().getMainWindow(newView);
101

  
102
        Runnable doWorkRunnable = new Runnable() {
103
            public void run() {
104
                PluginServices.getMDIManager().addWindow(window);
105
        		m_MapContext = newView.getMapContext();
106
            }
107
        };
108
        try {
109
			SwingUtilities.invokeAndWait(doWorkRunnable);
110
		} catch (InterruptedException e) {
111
			e.printStackTrace();
112
		} catch (InvocationTargetException e) {
113

  
114
			e.printStackTrace();
115
		}
116

  
117
    }
118

  
119
    private DefaultViewDocument getViewFromLayer(ILayer layer) {
120

  
121
    	FLayer gvSIGBaseLayer = (FLayer) layer.getBaseDataObject();
122
		//Project project = ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
123
		final Project project = ProjectManager.getInstance().getCurrentProject();
124
		List<Document> views = project.getDocuments(ViewManager.TYPENAME);
125

  
126
		for (int i = 0; i < views.size(); i++) {
127
			DefaultViewDocument view = (DefaultViewDocument) views.get(i);
128
			FLayers layers = view.getMapContext().getLayers();
129
			LayersIterator iter = new LayersIterator(layers);
130
			while (iter.hasNext()){
131
				FLayer gvSIGLayer = iter.nextLayer();
132
				if (gvSIGLayer.equals(gvSIGBaseLayer)){
133
					return view;
134
				}
135
			}
136

  
137
		}
138

  
139
		return null;
140

  
141
	}
142

  
143
	private void addResults(){
144

  
145
        FLayer layer = null;
146
        String sDescription;
147
        boolean bInvalidate = false;
148
        boolean bShowAdditionalPanel = false;
149

  
150
        if (m_MapContext != null){
151
            m_MapContext.beginAtomicEvent();
152
        }
153

  
154
        for (int i = 0; i < m_Output.getOutputObjectsCount(); i++) {
155

  
156
            Output out =  m_Output.getOutput(i);
157
            sDescription = out.getDescription();
158
            Object object = out.getOutputObject();
159
            if (object instanceof IVectorLayer){
160
            		layer = (FLayer) ((IVectorLayer)object).getBaseDataObject();
161
                    if (layer != null){
162
                        layer.setName(sDescription);
163
                        m_MapContext.getLayers().addLayer(layer);
164
                        bInvalidate = true;
165
                        SextanteGUI.getInputFactory().addDataObject((IDataObject) object);
166
                    }
167
            }
168
            else if (object instanceof ITable){
169
                try {
170
                	TableDocument table = (TableDocument) ((ITable)object).getBaseDataObject();
171
                    if (table != null){
172
                    	((ProjectExtension) PluginServices.getExtension(ProjectExtension.class))
173
    							.getProject().add(table);
174

  
175
                        SextanteGUI.getInputFactory().addDataObject((IDataObject) object);
176
                    }
177
                } catch (Exception e) {
178
                    e.printStackTrace();
179
                }
180
            }
181
            else if (object instanceof IRasterLayer){
182
                IRasterLayer rasterLayer = (IRasterLayer) object;
183
                layer = (FLayer) rasterLayer.getBaseDataObject();
184
                if (layer != null){
185
                    ((FLyrRasterSE)layer).setNoDataValue(rasterLayer.getNoDataValue());
186
                    layer.setName(sDescription);
187
                    m_MapContext.getLayers().addLayer(layer);
188
                    bInvalidate = true;
189
                    SextanteGUI.getInputFactory().addDataObject((IDataObject) object);
190
                }
191
            }
192
            else if (object instanceof String){
193
                JTextPane jTextPane;
194
                JScrollPane jScrollPane;
195
                jTextPane = new JTextPane();
196
                jTextPane.setEditable(false);
197
                jTextPane.setContentType("text/html");
198
                jTextPane.setText((String) object);
199
                jScrollPane = new JScrollPane();
200
                jScrollPane.setViewportView(jTextPane);
201
                jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
202
                jTextPane.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
203
                AdditionalResults.addComponent(new ObjectAndDescription(sDescription, jScrollPane));
204
                bShowAdditionalPanel = true;
205
            }
206
            else if (object instanceof Component){
207
                AdditionalResults.addComponent(new ObjectAndDescription(sDescription, object));
208
                bShowAdditionalPanel = true;
209
            }
210

  
211
        }
212

  
213
        if (m_MapContext != null){
214
            m_MapContext.endAtomicEvent();
215
        }
216

  
217
        if (bInvalidate){
218
            m_MapContext.invalidate();
219
        }
220

  
221
        if (bShowAdditionalPanel){
222
            AdditionalResults.showPanel();
223
        }
224

  
225
    }
226

  
227
}
0 228

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/gvDefaultParametersPanel.java
1
/*
2
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2010 Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 */
21
package org.gvsig.sextante.app.extension.gui;
22

  
23
import javax.swing.JPanel;
24

  
25
import jsh.shell.Utils;
26

  
27
import org.gvsig.sextante.app.extension.core.CompositeSourceOutputChannel;
28
import org.gvsig.sextante.app.extension.core.OutputParameters;
29

  
30
import es.unex.sextante.core.OutputObjectsSet;
31
import es.unex.sextante.exceptions.WrongOutputIDException;
32
import es.unex.sextante.gui.algorithm.DefaultParametersPanel;
33
import es.unex.sextante.gui.algorithm.OutputParameterContainer;
34
import es.unex.sextante.gui.algorithm.ParameterContainer;
35
import es.unex.sextante.outputs.FileOutputChannel;
36
import es.unex.sextante.outputs.Output;
37

  
38
/**
39
 * Default panel for gvSIG algorithms
40
 * 
41
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
42
 */
43
public class gvDefaultParametersPanel extends DefaultParametersPanel {
44
	private static final long serialVersionUID = 1L;
45

  
46
	@SuppressWarnings("unchecked")
47
	protected void addOutputObjects(JPanel pane) {
48
		String sDescription;
49
		OutputObjectsSet ooset = m_Algorithm.getOutputObjects();
50

  
51
		m_iCurrentRow = 0;
52

  
53
		for (int i = 0; i < ooset.getOutputObjectsCount(); i++) {
54
			Output out = ooset.getOutput(i);
55

  
56
			sDescription = out.getDescription() + "[" + out.getTypeDescription() + "]";
57
			addTitleLabel(pane, sDescription, m_iCurrentRow, false);
58

  
59
			AlgorithmOutputPanel algorithmOutputPanel = new AlgorithmOutputPanel();
60

  
61
			pane.add(algorithmOutputPanel, getStringTableCoords(2, m_iCurrentRow));
62
			m_iCurrentRow++;
63
			m_OutputParameterContainer.add(new OutputParameterContainer(out.getName(), algorithmOutputPanel));
64
		}
65
	}
66
	
67
	   public boolean assignParameters() {
68

  
69
		      boolean bAssigningOK = true;
70
		      int i;
71
		      ParameterContainer parameterContainer;
72
		      String sType;
73

  
74
		      for (i = 0; i < m_ParameterContainer.size(); i++) {
75
		         parameterContainer = (ParameterContainer) m_ParameterContainer.get(i);
76
		         sType = parameterContainer.getType();
77
		         if (sType.equals("Table")) {
78
		            bAssigningOK = assignInputTable(parameterContainer);
79
		         }
80
		         else if (sType.equals("Vector Layer") || sType.equals("Raster Layer")) {
81
		            bAssigningOK = assignInputLayer(parameterContainer);
82
		         }
83
		         else if (sType.equals("Numerical Value")) {
84
		            bAssigningOK = assignInputNumericalValue(parameterContainer);
85
		         }
86
		         else if (sType.equals("String")) {
87
		            bAssigningOK = assignInputString(parameterContainer);
88
		         }
89
		         else if (sType.equals("Boolean")) {
90
		            bAssigningOK = assignInputBoolean(parameterContainer);
91
		         }
92
		         else if (sType.equals("Fixed Table")) {
93
		            bAssigningOK = assignInputFixedTable(parameterContainer);
94
		         }
95
		         else if (sType.equals("Multiple Input")) {
96
		            bAssigningOK = assignInputMultipleInput(parameterContainer);
97
		         }
98
		         else if (sType.equals("Point")) {
99
		            bAssigningOK = assignInputPoint(parameterContainer);
100
		         }
101
		         else if (parameterContainer.getType().equals("Filepath")) {
102
		            bAssigningOK = assignInputFilepath(parameterContainer);
103
		         }
104
		         else if (sType.equals("Table Field") || sType.equals("Selection") || sType.equals("Band")) {
105
		            bAssigningOK = assignInputSelection(parameterContainer);
106
		         }
107

  
108
		         if (!bAssigningOK) {
109
		            return false;
110
		         }
111

  
112
		      }
113

  
114
		      OutputObjectsSet ooset = m_Algorithm.getOutputObjects();
115
		      for (i = 0; i < m_OutputParameterContainer.size(); i++) {
116
		         OutputParameterContainer opc = (OutputParameterContainer) m_OutputParameterContainer.get(i);
117
		         Output out;
118
		         try {
119
		            out = ooset.getOutput(opc.getName());
120
		            AlgorithmOutputPanel op = (AlgorithmOutputPanel) opc.getContainer();
121
		            Object obj = op.getOutputParameters();
122
		            if(obj instanceof OutputParameters) 
123
		            	out.setOutputChannel(new CompositeSourceOutputChannel(obj));
124
		         }
125
		         catch (WrongOutputIDException e) {}
126
		      }
127

  
128
		      return true;
129

  
130
		   }
131
}
0 132

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/ToolboxDialog.java
1
package org.gvsig.sextante.app.extension.gui;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.Dimension;
5
import java.beans.PropertyChangeEvent;
6
import java.beans.PropertyChangeListener;
7
import java.util.ArrayList;
8

  
9
import javax.swing.JDialog;
10
import javax.swing.JPanel;
11

  
12
import org.gvsig.andami.PluginServices;
13
import org.gvsig.andami.ui.mdiManager.IWindow;
14
import org.gvsig.andami.ui.mdiManager.IWindowListener;
15
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
16
import org.gvsig.andami.ui.mdiManager.WindowInfo;
17
import org.gvsig.app.project.Project;
18
import org.gvsig.app.project.ProjectManager;
19
import org.gvsig.app.project.documents.ProjectDocumentListener;
20
import org.gvsig.app.project.documents.view.DefaultViewDocument;
21
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
22
import org.gvsig.fmap.mapcontext.layers.CancelationException;
23
import org.gvsig.fmap.mapcontext.layers.FLayers;
24
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent;
25
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener;
26
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent;
27

  
28
import es.unex.sextante.core.Sextante;
29
import es.unex.sextante.gui.core.SextanteGUI;
30
import es.unex.sextante.gui.toolbox.IToolboxDialog;
31
import es.unex.sextante.gui.toolbox.ToolboxPanel;
32

  
33
public class ToolboxDialog extends JPanel implements SingletonWindow, IWindowListener, LayerCollectionListener,
34
														PropertyChangeListener, ProjectDocumentListener, IToolboxDialog  {
35
	private static final long serialVersionUID = 1L;
36
	private ArrayList<FLayers> listLayers = new ArrayList<FLayers>();
37
	private WindowInfo viewInfo;
38
	private ToolboxPanel m_Panel;
39
	private int m_iCount;
40

  
41
	public ToolboxDialog(){
42

  
43
		super();
44

  
45
		if (SextanteGUI.getInputFactory().getDataObjects() == null){
46
			SextanteGUI.getInputFactory().createDataObjects();
47
		}
48

  
49
		initGUI();
50
		addListeners();
51

  
52
	}
53

  
54
	private void addListeners() {
55

  
56
		//Register a propertyChangeListener to capture event when a new document is added in gvSIG
57
//		Project p = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject();
58
		final Project p = ProjectManager.getInstance().getCurrentProject();
59
		p.addPropertyChangeListener(this);
60

  
61
		//Register addLayerCollectionListener in existing views
62
		IWindow[] window = PluginServices.getMDIManager().getAllWindows();
63
		for (int i = 0; i < window.length; i++) {
64
			if(window[i] instanceof AbstractViewPanel) {
65
				FLayers layers = ((AbstractViewPanel)window[i]).getMapControl().getMapContext().getLayers();
66
				if(listLayers.indexOf(layers) == -1) {
67
					layers.addLayerCollectionListener(this);
68
					listLayers.add(layers);
69
				}
70
			}
71
		}
72

  
73

  
74
	}
75

  
76
	private void removeListeners() {
77

  
78
		//TODO:RELLENAR ESTO
79

  
80
	}
81

  
82
	private void initGUI() {
83

  
84
		m_Panel = new ToolboxPanel(this, null);
85
		m_iCount = m_Panel.getAlgorithmsCount();
86
		BorderLayout thisLayout = new BorderLayout();
87
		this.setLayout(thisLayout);
88
		this.setSize(new Dimension(m_Panel.getWidth(), m_Panel.getHeight()));
89
		this.add(m_Panel);
90

  
91
	}
92

  
93
	public WindowInfo getWindowInfo() {
94

  
95
        if (viewInfo == null) {
96
            viewInfo=new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
97
        }
98
        return viewInfo;
99

  
100
	}
101

  
102
	public Object getWindowProfile() {
103
		return WindowInfo.TOOL_PROFILE;
104
	}
105

  
106
	public Object getWindowModel() {
107

  
108
		return "SEXTANTE";
109

  
110
	}
111

  
112
	public ToolboxPanel getToolboxPanel(){
113

  
114
		return m_Panel;
115
	}
116

  
117
	public void cancel(){
118

  
119
		removeListeners();
120

  
121
		if (PluginServices.getMainFrame() == null){
122
			((JDialog) (getParent().getParent().getParent().getParent())).dispose();
123
		}
124
		else{
125
			PluginServices.getMDIManager().closeWindow(ToolboxDialog.this);
126
		}
127

  
128
	}
129

  
130
	public void windowActivated() {}
131

  
132
	public void windowClosed() {
133

  
134
		removeListeners();
135
		SextanteGUI.getInputFactory().clearDataObjects();
136

  
137
	}
138

  
139
	/**
140
	 * Event throwed when a new document is added
141
	 */
142
	public void propertyChange(PropertyChangeEvent evt) {
143
		if(evt.getPropertyName().equals("addDocument")) {
144
			if(evt.getNewValue() instanceof DefaultViewDocument) {
145
				DefaultViewDocument pd = (DefaultViewDocument)evt.getNewValue();
146
				pd.addListener(this);
147
			}
148
		}
149
	}
150

  
151
	/**
152
	 * Event throwed when a window (View) is created. This method register a listener
153
	 * in FLayers. When a new layer is going to be added or removed the methods layerAdded and
154
	 * layerRemoved will catch this event.
155
	 */
156
	public void windowCreated(IWindow window) {
157
		if(window instanceof AbstractViewPanel) {
158
			FLayers layers = ((AbstractViewPanel)window).getMapControl().getMapContext().getLayers();
159
			if(listLayers.indexOf(layers) == -1) {
160
				layers.addLayerCollectionListener(this);
161
				listLayers.add(layers);
162
			}
163
		}
164
	}
165

  
166
	public void layerAdded(LayerCollectionEvent e) {
167

  
168
		// this could be done more elegantly, just adding the new layers...
169
		// but it works fine this way ;-)
170
		SextanteGUI.getInputFactory().clearDataObjects();
171
		SextanteGUI.getInputFactory().createDataObjects();
172

  
173
	}
174

  
175
	public void layerRemoved(LayerCollectionEvent e) {
176

  
177
		SextanteGUI.getInputFactory().clearDataObjects();
178
		SextanteGUI.getInputFactory().createDataObjects();
179

  
180
	}
181

  
182
	public void layerMoved(LayerPositionEvent e) {}
183
	public void layerAdding(LayerCollectionEvent e) throws CancelationException {}
184
	public void layerMoving(LayerPositionEvent e) throws CancelationException {}
185
	public void layerRemoving(LayerCollectionEvent e) throws CancelationException {}
186
	public void visibilityChanged(LayerCollectionEvent e) throws CancelationException {}
187
	
188
	public JDialog getDialog() {
189
		return null;
190
	}
191

  
192
	/*
193
	 * (non-Javadoc)
194
	 * @see es.unex.sextante.gui.toolbox.IToolboxDialog#setAlgorithmsCount(int)
195
	 */
196
	public void setAlgorithmsCount(int iCount) {
197
		getWindowInfo().setTitle("SEXTANTE - " + Integer.toString(iCount)
198
				+ " " + PluginServices.getText(this, "Algorithms"));
199
	}
200
}
0 201

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/AlgorithmOutputPanel.java
1
/*
2
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2010 Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 */
21
package org.gvsig.sextante.app.extension.gui;
22

  
23
import java.awt.Dimension;
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.Insets;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.util.ArrayList;
30
import java.util.Iterator;
31
import java.util.List;
32

  
33
import javax.swing.JButton;
34
import javax.swing.JComboBox;
35
import javax.swing.JPanel;
36

  
37
import org.gvsig.fmap.dal.DALLocator;
38
import org.gvsig.fmap.dal.DataManager;
39
import org.gvsig.fmap.dal.DataServerExplorer;
40
import org.gvsig.fmap.dal.DataServerExplorerParameters;
41
import org.gvsig.fmap.dal.DataStoreParameters;
42
import org.gvsig.fmap.dal.NewDataStoreParameters;
43
import org.gvsig.fmap.dal.exception.DataException;
44
import org.gvsig.fmap.dal.exception.InitializeException;
45
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
46
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
47
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
48
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor;
49
import org.gvsig.sextante.app.extension.core.OutputParameters;
50
import org.gvsig.tools.dynobject.DynObject;
51

  
52
import es.unex.sextante.core.GeoAlgorithm;
53
import es.unex.sextante.core.Sextante;
54

  
55
/**
56
 * 
57
 * @author Nacho Brodin (nachobrodin@gmail.com)
58
 */
59
public class AlgorithmOutputPanel extends JPanel implements ActionListener {
60
	private static final long                serialVersionUID = 1L;
61
	//private GeoAlgorithm                     m_Algorithm      = null;
62
	private JComboBox                        cProvider        = null;
63
	private JComboBox                        cExplorer        = null;
64
	private JButton                          button           = null;
65
	private ArrayList<DataServerExplorer>    listExplorer     = new ArrayList<DataServerExplorer>();
66
	private DynObjectEditor                  editor           = null; 
67
	private static AlgorithmOutputPanel      algOutputPanel   = null;
68
	
69
	/**
70
	 * Gets an unique static reference to AlgorithmOutputPanel object
71
	 * @return
72
	 */
73
	public static AlgorithmOutputPanel getReference() {
74
		if(algOutputPanel == null)
75
			algOutputPanel = new AlgorithmOutputPanel();
76
		return algOutputPanel;
77
	}
78
	
79
	public AlgorithmOutputPanel() {
80
		super();
81
		initGUI();
82
		loadProviderList(getCProvider());
83
		loadExplorerList(getCExplorer());
84
	}
85

  
86
    public void init(GeoAlgorithm algorithm) {
87
    	//m_Algorithm = algorithm;
88
    	initGUI();
89
    }
90

  
91
	private void initGUI() {
92
		GridBagLayout gbl = new GridBagLayout();
93
		this.setLayout(gbl);
94
		
95
		GridBagConstraints gbc = new GridBagConstraints();
96
		gbc.fill = GridBagConstraints.HORIZONTAL;
97
		gbc.weightx = 1.0;
98
		gbc.gridx = 0;
99
		gbc.gridy = 0;
100
		gbc.insets = new Insets(0, 2, 0, 0);
101
		this.add(getCExplorer(), gbc);
102
		
103
		gbc.gridx = 1;
104
		this.add(getCProvider(), gbc);
105
		
106
		gbc.fill = GridBagConstraints.NONE;
107
		gbc.weightx = 0;
108
		gbc.gridx = 2;
109
		gbc.insets = new Insets(0, 5, 0, 2);
110
		this.add(getButton(), gbc);
111
	}
112

  
113
	/**
114
	 * Gets a ComboBox
115
	 * @return
116
	 */
117
	public JComboBox getCProvider() {
118
		if(cProvider == null) {
119
			cProvider = new JComboBox();
120
			cProvider.addActionListener(this);
121
			cProvider.setPreferredSize(new Dimension(0, 18));
122
		}
123
		return cProvider;
124
	}
125
	
126
	/**
127
	 * Gets a ComboBox
128
	 * @return
129
	 */
130
	public JComboBox getCExplorer() {
131
		if(cExplorer == null) {
132
			cExplorer = new JComboBox();
133
			cExplorer.addActionListener(this);
134
			cExplorer.setPreferredSize(new Dimension(0, 18));
135
		}
136
		return cExplorer;
137
	}
138
	
139
	/**
140
	 * Gets a JButton
141
	 * @return
142
	 */
143
	public JButton getButton() {
144
		if(button == null) {
145
			button = new JButton("...");
146
			button.setPreferredSize(new Dimension(60, 18));
147
			button.addActionListener(this);
148
		}
149
		return button;
150
	}
151
	
152
	/**
153
	 * Loads the list of providers
154
	 * @param cProvider
155
	 * @param listDSParam
156
	 */
157
	@SuppressWarnings("unchecked")
158
	private void loadProviderList(JComboBox cProvider) {
159
		DataManager manager = DALLocator.getDataManager();
160
		
161
		List lProvider = manager.getStoreProviders();
162
		Iterator it = lProvider.iterator();
163
		cProvider.removeAllItems();
164
		while(it.hasNext()) {
165
			String provider = it.next().toString();
166
			cProvider.addItem(provider);
167
		}
168
	}
169
	
170
	@SuppressWarnings("unchecked")
171
	private void loadExplorerList(JComboBox cExplorer) {
172
		DataManager manager = DALLocator.getDataManager();
173
		List lExplorer = manager.getExplorerProviders();
174
		
175
		Iterator it = lExplorer.iterator();
176
		listExplorer.clear();
177
		cExplorer.removeAllItems();
178
		
179
		while(it.hasNext()) {
180
			String explorer = (String)it.next();
181
			try {
182
				DataServerExplorerParameters params = manager.createServerExplorerParameters(explorer);
183
				listExplorer.add(manager.createServerExplorer(params));
184
				cExplorer.addItem(explorer);
185
			} catch (ValidateDataParametersException e) {
186
				Sextante.addErrorToLog(e);
187
			} catch (InitializeException e) {
188
				Sextante.addErrorToLog(e);
189
			} catch (ProviderNotRegisteredException e) {
190
				Sextante.addErrorToLog(e);
191
			} catch (Exception e) { //Este es pq al intentar crear un WFSServerExplorer peta desconsideradamente
192
			}
193
		}
194
	}
195
	
196
	public void actionPerformed(ActionEvent e) {
197
		if(e.getSource() == getButton()) {
198
			int indexExplorer = getCExplorer().getSelectedIndex();
199
			
200
			DataServerExplorer explorer = listExplorer.get(indexExplorer);
201
			NewDataStoreParameters params;
202
			try {
203
				params = explorer.getAddParameters((String)getCProvider().getSelectedItem());
204
				editor = new DynObjectEditor(params,
205
						DynObjectEditor.SHOW_ALL, null, true, false);
206
				editor.editObject(true);
207
			} catch (DataException e1) {
208
				Sextante.addErrorToLog(e1);
209
			}
210
		}
211
		
212
		if(e.getSource() == getCProvider()) {
213
		}
214
		
215
		if(e.getSource() == getCExplorer()) {
216
		}
217
	}
218

  
219
	public Object getOutputParameters() {
220
		if(editor != null && editor.getParameters() instanceof NewFeatureStoreParameters) {
221
			int index = getCExplorer().getSelectedIndex();
222
			if(((NewFeatureStoreParameters)editor.getParameters()).isValid())
223
				return new OutputParameters((NewFeatureStoreParameters)editor.getParameters(), listExplorer.get(index));
224
			else
225
				return null;
226
		}
227
		return null;
228
	}
229

  
230
	public void setOutputParameters(Object param) {
231
		if(param instanceof DataStoreParameters)
232
			editor.setParameters((DynObject)param);
233
	}
234
}
0 235

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/ModelerDialog.java
1
package org.gvsig.sextante.app.extension.gui;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.Dimension;
5

  
6
import javax.swing.JPanel;
7

  
8
import org.gvsig.andami.PluginServices;
9
import org.gvsig.andami.ui.mdiManager.IWindow;
10
import org.gvsig.andami.ui.mdiManager.IWindowListener;
11
import org.gvsig.andami.ui.mdiManager.WindowInfo;
12

  
13
import es.unex.sextante.gui.core.SextanteGUI;
14
import es.unex.sextante.gui.modeler.ModelerPanel;
15
import es.unex.sextante.gui.toolbox.ToolboxPanel;
16

  
17
public class ModelerDialog extends JPanel implements IWindow, IWindowListener {
18

  
19
	private static final long  serialVersionUID = 1L;
20
	private WindowInfo         viewInfo;
21
	private ModelerPanel       m_Panel;
22
	private final ToolboxPanel m_Toolbox;
23

  
24

  
25
	public ModelerDialog(final ToolboxPanel toolbox) {
26

  
27
		super();
28

  
29
		m_Toolbox = toolbox;
30

  
31
		if (SextanteGUI.getInputFactory().getDataObjects() == null) {
32
			SextanteGUI.getInputFactory().createDataObjects();
33
		}
34

  
35
		initGUI();
36

  
37
	}
38

  
39

  
40
	private void initGUI() {
41

  
42
		m_Panel = new ModelerPanel(null);
43
		final BorderLayout thisLayout = new BorderLayout();
44
		this.setLayout(thisLayout);
45
		this.setSize(new Dimension(m_Panel.getWidth(), m_Panel.getHeight()));
46
		this.add(m_Panel);
47

  
48
	}
49

  
50

  
51
	public WindowInfo getWindowInfo() {
52

  
53
		if (viewInfo == null) {
54
			viewInfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
55
			viewInfo.setTitle(PluginServices.getText(this, "Modeler"));
56
		}
57
		return viewInfo;
58

  
59
	}
60

  
61

  
62
	public Object getWindowProfile() {
63
		return WindowInfo.DIALOG_PROFILE;
64
	}
65

  
66

  
67
	public void windowActivated() {}
68

  
69

  
70
	public void windowClosed() {
71

  
72
		if (m_Toolbox == null) {
73
			SextanteGUI.getInputFactory().clearDataObjects();
74
		}
75

  
76
	}
77
}
0 78

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/gui/gvGUIFactory.java
1
package org.gvsig.sextante.app.extension.gui;
2

  
3
import org.gvsig.andami.PluginServices;
4

  
5
import es.unex.sextante.gui.cmd.BSHDialog;
6
import es.unex.sextante.gui.core.DefaultGUIFactory;
7
import es.unex.sextante.gui.core.SextanteGUI;
8
import es.unex.sextante.gui.dataExplorer.DataExplorerDialog;
9
import es.unex.sextante.gui.history.HistoryDialog;
10

  
11
public class gvGUIFactory extends DefaultGUIFactory {
12

  
13
	   @Override
14
	   public void showToolBoxDialog() {
15

  
16
	      final ToolboxDialog toolbox = new ToolboxDialog();
17
	      m_Toolbox = toolbox.getToolboxPanel();
18
	      PluginServices.getMDIManager().addWindow(toolbox);
19

  
20
	   }
21

  
22
	   @Override
23
	   public void showModelerDialog() {
24

  
25
	      SextanteGUI.getInputFactory().createDataObjects();
26

  
27
	      final ModelerDialog dialog = new ModelerDialog(m_Toolbox);
28
	      PluginServices.getMDIManager().addWindow(dialog);
29

  
30

  
31
	   }
32

  
33
	   @Override
34
	   public void showHistoryDialog() {
35

  
36
	      SextanteGUI.getInputFactory().createDataObjects();
37

  
38
	      final HistoryDialog dialog = new HistoryDialog(SextanteGUI.getMainFrame());
39
	      SextanteGUI.setLastCommandOrigin(SextanteGUI.HISTORY);
40
	      SextanteGUI.setLastCommandOriginParentDialog(dialog);
41
	      m_History = dialog.getHistoryPanel();
42
	      dialog.pack();
43
	      dialog.setVisible(true);
44

  
45
	      if (m_Toolbox == null) {
46
	         SextanteGUI.getInputFactory().clearDataObjects();
47
	      }
48

  
49
	      m_History = null;
50

  
51
	   }
52

  
53
	   @Override
54
	   public void showCommandLineDialog() {
55

  
56
	      SextanteGUI.getInputFactory().createDataObjects();
57

  
58
	      final BSHDialog dialog = new BSHDialog(SextanteGUI.getMainFrame());
59
	      SextanteGUI.setLastCommandOrigin(SextanteGUI.COMMANDLINE);
60
	      SextanteGUI.setLastCommandOriginParentDialog(dialog);
61
	      dialog.pack();
62
	      dialog.setVisible(true);
63

  
64
	      if (m_Toolbox == null) {
65
	         SextanteGUI.getInputFactory().clearDataObjects();
66
	      }
67

  
68
	   }
69

  
70
	   @Override
71
	   public void showDataExplorer() {
72

  
73
	      SextanteGUI.getInputFactory().createDataObjects();
74

  
75
	      final DataExplorerDialog dialog = new DataExplorerDialog(SextanteGUI.getMainFrame());
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 updateToolbox() {
87

  
88
	      super.updateToolbox();
89

  
90
	   }
91

  
92
	   public void setToolboxHidden() {
93

  
94
	      m_Toolbox = null;
95

  
96
	   }
97

  
98
	   @SuppressWarnings("unchecked")
99
	   public Class getDefaultParametersPanel() {
100

  
101
		   return gvDefaultParametersPanel.class;
102

  
103
	   }
104

  
105
}
0 106

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/ButtonDefinitionDialog.java
1
package org.gvsig.sextante.app.extension;
2
import info.clearthought.layout.TableLayout;
3

  
4
import java.awt.event.ActionEvent;
5
import java.awt.event.ActionListener;
6

  
7
import javax.swing.JButton;
8
import javax.swing.JDialog;
9
import javax.swing.JLabel;
10
import javax.swing.JOptionPane;
11
import javax.swing.JTextField;
12

  
13
import org.gvsig.andami.PluginServices;
14

  
15
import es.unex.sextante.core.GeoAlgorithm;
16
import es.unex.sextante.gui.algorithm.FileSelectionPanel;
17
import es.unex.sextante.modeler.ModelAlgorithm;
18

  
19
public class ButtonDefinitionDialog extends JDialog{
20
	private static final long serialVersionUID = 1L;
21
	private JLabel jLabelName;
22
	private JTextField jTextFieldName;
23
	private JTextField jTextFieldCmd;
24
	private JLabel jLabelCmd;
25
	private AlgorithmsTreePanel jPanelAlgorithms;
26
	private JButton jButtonCancel;
27
	private JButton jButtonOK;
28
	private FileSelectionPanel jTextFieldIcon;
29
	private JLabel jLabelIcon;
30
	private Button m_Button;
31

  
32
	public ButtonDefinitionDialog(ToolbarConfigDialog toolbarConfigDialog){
33

  
34
		super(toolbarConfigDialog, "SextanteToolbar", true);
35

  
36
		initGUI();
37

  
38
	}
39

  
40
	private void initGUI() {
41
		{
42
			TableLayout thisLayout = new TableLayout(new double[][] {{7.0, TableLayout.FILL, TableLayout.FILL, 100.0, 100.0, 7.0}, {TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, 7.0, 30.0, 7.0}});
43
			thisLayout.setHGap(5);
44
			thisLayout.setVGap(5);
45
			getContentPane().setLayout(thisLayout);
46
			this.setBounds(0, 0, 365, 496);
47
			{
48
				jLabelName = new JLabel();
49
				getContentPane().add(jLabelName, "1, 2");
50
				jLabelName.setText(PluginServices.getText(this, "Name"));
51
			}
52
			{
53
				jLabelIcon = new JLabel();
54
				getContentPane().add(jLabelIcon, "1, 3");
55
				jLabelIcon.setText(PluginServices.getText(this, "Icon"));
56
			}
57
			{
58
				jTextFieldName = new JTextField();
59
				getContentPane().add(jTextFieldName, "2, 2, 4, 2");
60
			}
61
			{
62
				jTextFieldIcon = new FileSelectionPanel(false, true, new String[]{"jpg", "gif", "png", "bmp"},
63
										"*.jpg, *.bmp, *.gif, *.png");
64
				getContentPane().add(jTextFieldIcon, "2, 3, 4, 3");
65
			}
66
			{
67
				jButtonOK = new JButton();
68
				getContentPane().add(jButtonOK, "3, 5");
69
				jButtonOK.setText(PluginServices.getText(this, "OK"));
70
				jButtonOK.addActionListener(new ActionListener() {
71
					public void actionPerformed(ActionEvent evt) {
72
						jButtonOKActionPerformed(evt);
73
					}
74
				});
75
			}
76
			{
77
				jButtonCancel = new JButton();
78
				getContentPane().add(jButtonCancel, "4, 5");
79
				jButtonCancel.setText(PluginServices.getText(this, "Cancel"));
80
				jButtonCancel.addActionListener(new ActionListener() {
81
					public void actionPerformed(ActionEvent evt) {
82
						jButtonCancelActionPerformed(evt);
83
					}
84
				});
85
			}
86
			{
87
				jPanelAlgorithms = new AlgorithmsTreePanel(this);
88
				getContentPane().add(jPanelAlgorithms, "1, 0, 4, 0");
89
				{
90
					jLabelCmd = new JLabel();
91
					getContentPane().add(jLabelCmd, "1, 1");
92
					jLabelCmd.setText(PluginServices.getText(this, "Command"));
93
				}
94
				{
95
					jTextFieldCmd = new JTextField();
96
					getContentPane().add(jTextFieldCmd, "2, 1, 4, 1");
97
					jTextFieldCmd.setEditable(false);
98
					jTextFieldCmd.setEnabled(false);
99
				}
100
			}
101
		}
102

  
103
	}
104

  
105
	public void setCommand(GeoAlgorithm alg) {
106

  
107
		String sCmd = alg.getClass().toString();
108
		if (alg instanceof ModelAlgorithm){
109
			sCmd = sCmd + "," + ((ModelAlgorithm) alg).getFilename();
110
		}
111
		else{
112
			sCmd = sCmd + "," + " ";
113
		}
114

  
115
		jTextFieldCmd.setText(sCmd);
116

  
117
	}
118

  
119
	public Button getButton() {
120

  
121
		return m_Button;
122

  
123
	}
124

  
125
	private void jButtonOKActionPerformed(ActionEvent evt) {
126

  
127
		if (createButton()){
128
			dispose();
129
			setVisible(false);
130
		}
131
		else{
132
			JOptionPane.showMessageDialog(null,
133
					PluginServices.getText(this, "Wrong_or_missing_parameters_definition"),
134
					PluginServices.getText(this, "Warning"),
135
					JOptionPane.WARNING_MESSAGE);
136
		}
137

  
138
	}
139

  
140
	private boolean createButton() {
141

  
142
		m_Button = new Button();
143
		m_Button.sIconFilename = jTextFieldIcon.getFilepath() + " ";
144
		m_Button.sCommand = jTextFieldCmd.getText();
145
		m_Button.sName = jTextFieldName.getText() + " ";
146

  
147
		return !(m_Button.sCommand.trim().equals(""));
148

  
149
	}
150

  
151
	private void jButtonCancelActionPerformed(ActionEvent evt) {
152

  
153
		m_Button = null;
154
		dispose();
155
		setVisible(false);
156

  
157
	}
158

  
159
}
0 160

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/ButtonTableModel.java
1
package org.gvsig.sextante.app.extension;
2

  
3
import java.util.ArrayList;
4

  
5
import javax.swing.table.AbstractTableModel;
6

  
7
import org.gvsig.andami.PluginServices;
8

  
9
public class ButtonTableModel extends AbstractTableModel {
10
	private static final long serialVersionUID = 1L;
11
	private final String[] NAMES;
12
	private ArrayList<Button> m_Buttons;
13

  
14
	public ButtonTableModel(ArrayList<Button> buttons) {
15

  
16
		m_Buttons = buttons;
17
		NAMES = new String[3];
18
		NAMES[0] = PluginServices.getText(this, "Icon");
19
		NAMES[1] = PluginServices.getText(this, "Name"); 
20
		NAMES[2] = PluginServices.getText(this, "Command");
21

  
22
	}
23

  
24
	public Class<?> getColumnClass(int columnIndex) {
25

  
26
		return String.class;
27

  
28
	}
29

  
30
	public int getColumnCount() {
31

  
32
		return 3;
33
	}
34

  
35
	public String getColumnName(int columnIndex) {
36

  
37
		return NAMES[columnIndex];
38

  
39
	}
40

  
41
	public int getRowCount() {
42

  
43
		return m_Buttons.size();
44

  
45
	}
46

  
47
	public void removeRow (int iRow){
48

  
49
		m_Buttons.remove(iRow);
50

  
51
    	this.fireTableRowsDeleted(iRow, iRow);
52

  
53
	}
54

  
55
	public Object getValueAt(int rowIndex, int columnIndex) {
56

  
57
		if (columnIndex == 0){
58
			return m_Buttons.get(rowIndex).sIconFilename;
59
		}
60
		else if (columnIndex == 1){
61
			return m_Buttons.get(rowIndex).sName;
62
		}
63
		else if (columnIndex == 2){
64
			return m_Buttons.get(rowIndex).sCommand;
65
		}
66

  
67
		return null;
68

  
69
	}
70

  
71
	public boolean isCellEditable(int rowIndex, int columnIndex) {
72

  
73
		return false;
74

  
75
	}
76

  
77
}
0 78

  
org.gvsig.sextante/tags/gvsig-v2_0_0_Build_2011/org.gvsig.sextante.app.extension/src/main/java/org/gvsig/sextante/app/extension/core/FileTools.java
1
package org.gvsig.sextante.app.extension.core;
2

  
3
import java.io.File;
4

  
5
import org.cresques.cts.IProjection;
6
import org.gvsig.andami.messages.NotificationManager;
7
import org.gvsig.app.ApplicationLocator;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff