Revision 40954 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/DefaultLayersDynObjectSetComponent.java
DefaultLayersDynObjectSetComponent.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.awt.BorderLayout; |
27 | 27 |
import java.awt.Dimension; |
28 |
import java.awt.event.ActionEvent; |
|
28 | 29 |
import java.util.Iterator; |
29 | 30 |
import java.util.Map; |
30 | 31 |
|
32 |
import javax.swing.AbstractAction; |
|
33 |
import javax.swing.Action; |
|
31 | 34 |
import javax.swing.JComponent; |
32 | 35 |
import javax.swing.JPanel; |
33 | 36 |
import javax.swing.JScrollPane; |
... | ... | |
42 | 45 |
import javax.swing.tree.TreePath; |
43 | 46 |
import javax.swing.tree.TreeSelectionModel; |
44 | 47 |
|
48 |
import org.gvsig.fmap.geom.DataTypes; |
|
49 |
import org.gvsig.fmap.geom.Geometry; |
|
50 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
45 | 51 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent; |
52 |
import org.gvsig.tools.ToolsLocator; |
|
53 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
|
46 | 54 |
import org.gvsig.tools.dynform.AbortActionException; |
47 | 55 |
import org.gvsig.tools.dynform.DynFormLocator; |
56 |
import org.gvsig.tools.dynform.JDynFormField; |
|
48 | 57 |
import org.gvsig.tools.dynform.JDynFormSet; |
49 | 58 |
import org.gvsig.tools.dynform.JDynFormSet.JDynFormSetListener; |
50 | 59 |
import org.gvsig.tools.dynobject.DynObject; |
... | ... | |
77 | 86 |
|
78 | 87 |
private DefaultMutableTreeNode topNode; |
79 | 88 |
private MutableTreeNode previousSelection = null; |
89 |
|
|
90 |
private MapContext mapContext = null; |
|
80 | 91 |
|
81 | 92 |
/** |
82 | 93 |
* Creates a new {@link DefaultLayersDynObjectSetComponent} with the given |
... | ... | |
194 | 205 |
newComponent.setAllowNew(false); |
195 | 206 |
newComponent.setAllowSearch(false); |
196 | 207 |
newComponent.setAllowUpdate(false); |
208 |
// FIXME: (jjdc) eliminar los comentartios cuando JDynObjectSet tenga el metodo addActionToPopupMenu |
|
209 |
// if( this.mapContext!=null ) { |
|
210 |
// DataTypesManager dataManager = ToolsLocator.getDataTypesManager(); |
|
211 |
// newComponent.addActionToPopupMenu( dataManager.get(DataTypes.GEOMETRY), "Center in current view", new CenterGeometryInMapContext(this.mapContext)); |
|
212 |
// } |
|
197 | 213 |
removeCurrentDynObjectSetComponent(); |
198 | 214 |
component = newComponent; |
199 | 215 |
component.addListener(this); |
... | ... | |
302 | 318 |
layersTree.setSelectionPath(path); |
303 | 319 |
} |
304 | 320 |
|
321 |
public void setMapContext(MapContext mapContext) { |
|
322 |
this.mapContext = mapContext; |
|
323 |
} |
|
324 |
|
|
325 |
public class CenterGeometryInMapContext extends AbstractAction implements Action { |
|
326 |
|
|
327 |
private MapContext mapContext; |
|
328 |
|
|
329 |
public CenterGeometryInMapContext(MapContext mapContext) { |
|
330 |
super("Center in the current view"); |
|
331 |
this.mapContext = mapContext; |
|
332 |
this.putValue(Action.SHORT_DESCRIPTION, "Center geometry in the current view"); |
|
333 |
this.putValue(Action.LONG_DESCRIPTION, "Center geometry in the current view"); |
|
334 |
} |
|
335 |
|
|
336 |
public void actionPerformed(ActionEvent arg0) { |
|
337 |
if( mapContext == null ) { |
|
338 |
return ; |
|
339 |
} |
|
340 |
JDynFormField field = (JDynFormField) arg0.getSource(); |
|
341 |
Geometry geom = (Geometry) field.getValue(); |
|
342 |
mapContext.getViewPort().setEnvelope(geom.getEnvelope()); |
|
343 |
mapContext.invalidate(); |
|
344 |
} |
|
345 |
|
|
346 |
} |
|
347 |
|
|
305 | 348 |
} |
Also available in: Unified diff