Revision 6019 trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/manager/GeoprocessTree.java
GeoprocessTree.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.1 2006-06-22 17:46:30 azabala |
|
48 |
* Revision 1.2 2006-06-23 19:04:23 azabala |
|
49 |
* bug for tree creation by namespacies resolved |
|
50 |
* |
|
51 |
* Revision 1.1 2006/06/22 17:46:30 azabala |
|
49 | 52 |
* first version in cvs |
50 | 53 |
* |
51 | 54 |
* |
52 | 55 |
*/ |
53 | 56 |
package com.iver.cit.gvsig.geoprocess.manager; |
54 | 57 |
|
55 |
import java.util.ArrayList; |
|
56 |
import java.util.Enumeration; |
|
57 | 58 |
import java.util.Iterator; |
58 |
import java.util.Stack; |
|
59 |
import java.util.StringTokenizer; |
|
60 | 59 |
|
61 | 60 |
import javax.swing.JFrame; |
62 | 61 |
import javax.swing.JScrollPane; |
63 | 62 |
import javax.swing.JTree; |
64 |
import javax.swing.event.TreeSelectionEvent; |
|
65 | 63 |
import javax.swing.event.TreeSelectionListener; |
66 | 64 |
import javax.swing.tree.DefaultMutableTreeNode; |
67 |
import javax.swing.tree.TreeNode; |
|
68 |
import javax.swing.tree.TreePath; |
|
69 | 65 |
import javax.swing.tree.TreeSelectionModel; |
70 | 66 |
|
71 |
import com.iver.cit.gvsig.geoprocess.core.IGeoprocessMetadata;
|
|
72 |
import com.iver.cit.gvsig.geoprocess.impl.buffer.BufferGeoprocessMetadata;
|
|
73 |
import com.iver.cit.gvsig.geoprocess.impl.clip.ClipGeoprocessMetadata;
|
|
67 |
import com.iver.cit.gvsig.geoprocess.core.IGeoprocessPlugin;
|
|
68 |
import com.iver.cit.gvsig.geoprocess.impl.buffer.BufferGeoprocessPlugin;
|
|
69 |
import com.iver.cit.gvsig.geoprocess.impl.clip.ClipGeoprocessPlugin;
|
|
74 | 70 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
75 | 71 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
76 | 72 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
... | ... | |
82 | 78 |
* Its tree hasnt root node, and different subnodes represents an organization |
83 | 79 |
* of geoprocesses. |
84 | 80 |
* |
85 |
* Leaf nodes are IGeoprocessMetadata instances.
|
|
81 |
* Leaf nodes are IGeoprocessPlugin instances.
|
|
86 | 82 |
* |
87 | 83 |
* @author azabala |
88 | 84 |
* |
... | ... | |
104 | 100 |
tree.setShowsRootHandles(true); |
105 | 101 |
setViewportView(tree); |
106 | 102 |
// tree.setCellRenderer( new JTreeEntidadesRenderer(listeners) ); |
107 |
|
|
108 | 103 |
} |
109 | 104 |
|
110 | 105 |
public static void main(String[] args){ |
111 | 106 |
JFrame f = new JFrame(); |
107 |
//ESTO SE HARA EN EL METODO INITIALIZE DE CADA EXTENSION |
|
112 | 108 |
ExtensionPoints extensionPoints = |
113 | 109 |
ExtensionPointsSingleton.getInstance(); |
114 |
extensionPoints.add("GeoprocessManager","BUFFER", BufferGeoprocessMetadata.class); |
|
115 |
extensionPoints.add("GeoprocessManager","CLIP", ClipGeoprocessMetadata.class); |
|
116 |
GeoprocessTree tree = new GeoprocessTree(); |
|
110 |
extensionPoints.add("GeoprocessManager","BUFFER", BufferGeoprocessPlugin.class); |
|
111 |
extensionPoints.add("GeoprocessManager","CLIP", ClipGeoprocessPlugin.class); |
|
112 |
//REVISAR ESTO ULTIMO, PUES EST? PETANDO |
|
113 |
// GeoprocessTree tree = new GeoprocessTree(); |
|
114 |
GeoprocessManager tree = new GeoprocessManager(); |
|
117 | 115 |
f.getContentPane().add(tree); |
118 | 116 |
f.setSize(800,600); |
119 | 117 |
f.setVisible(true); |
... | ... | |
132 | 130 |
Class metadataClass = |
133 | 131 |
(Class) geoprocessManager.get(nombre); |
134 | 132 |
try { |
135 |
register((IGeoprocessMetadata)metadataClass.newInstance());
|
|
133 |
register((IGeoprocessPlugin)metadataClass.newInstance());
|
|
136 | 134 |
} catch (InstantiationException e) { |
137 | 135 |
// TODO Auto-generated catch block |
138 | 136 |
e.printStackTrace(); |
... | ... | |
143 | 141 |
} |
144 | 142 |
} |
145 | 143 |
|
146 |
public void register(IGeoprocessMetadata metadata) {
|
|
144 |
public void register(IGeoprocessPlugin metadata) {
|
|
147 | 145 |
String namespace = metadata.getNamespace(); |
148 | 146 |
String[] directories = getObjectsInPath(namespace); |
149 |
/* |
|
150 |
* Si el namespace del geoproceso es |
|
151 |
* 'Manejo de Datos/Resumen/Dissolve/Dissolve 1 campo' |
|
152 |
* antes de a?adir al arbol 4 TreeNodes |
|
153 |
* (3 con un Directorio, y 1 con el propio gpmetadata) verifico |
|
154 |
* que no existen ya. |
|
155 |
* |
|
156 |
* */ |
|
157 | 147 |
DefaultMutableTreeNode bestMatch = root; |
158 | 148 |
DefaultMutableTreeNode scanned = null; |
159 | 149 |
int levelNum = 0; |
... | ... | |
167 | 157 |
scanned = |
168 | 158 |
(DefaultMutableTreeNode) bestMatch.getChildAt(i); |
169 | 159 |
if(scanned.isLeaf() || |
170 |
(scanned.getUserObject() instanceof IGeoprocessMetadata))//this is a geoprocess, not a directory
|
|
160 |
(scanned.getUserObject() instanceof IGeoprocessPlugin))//this is a geoprocess, not a directory
|
|
171 | 161 |
{ |
172 | 162 |
doit = false; |
173 | 163 |
if(scanned.getUserObject().getClass() == metadata.getClass()){ |
... | ... | |
187 | 177 |
break; |
188 | 178 |
} |
189 | 179 |
}//for num paths |
190 |
if(match) |
|
180 |
if(match){
|
|
191 | 181 |
bestMatch = scanned; |
182 |
break; |
|
183 |
} |
|
192 | 184 |
}//for numChilds |
193 | 185 |
|
194 | 186 |
if(! match)//si en el escaneo de nivel no se encontro nada, paramos |
... | ... | |
237 | 229 |
|
238 | 230 |
|
239 | 231 |
|
240 |
public IGeoprocessMetadata getGeoprocess() {
|
|
232 |
public IGeoprocessPlugin getGeoprocess() {
|
|
241 | 233 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree |
242 | 234 |
.getLastSelectedPathComponent(); |
243 | 235 |
Object nodeInfo = node.getUserObject(); |
244 |
if ((node == null) || !(nodeInfo instanceof IGeoprocessMetadata))
|
|
236 |
if ((node == null) || !(nodeInfo instanceof IGeoprocessPlugin))
|
|
245 | 237 |
return null; |
246 | 238 |
else { |
247 |
return (IGeoprocessMetadata)nodeInfo;
|
|
239 |
return (IGeoprocessPlugin)nodeInfo;
|
|
248 | 240 |
} |
249 | 241 |
} |
250 | 242 |
|
... | ... | |
290 | 282 |
private String[] getObjectsInPath(String path) { |
291 | 283 |
return path.split(PATH_SEPARATOR); |
292 | 284 |
} |
293 |
|
|
294 | 285 |
|
286 |
public void addTreeSelectionListener(TreeSelectionListener l) { |
|
287 |
tree.addTreeSelectionListener(l); |
|
288 |
} |
|
295 | 289 |
} |
Also available in: Unified diff