Revision 5014 trunk/extensions/extCAD/src/com/iver/cit/gvsig/EditionManager.java
EditionManager.java | ||
---|---|---|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.logging.Logger; |
5 | 5 |
|
6 |
import com.iver.andami.PluginServices; |
|
6 | 7 |
import com.iver.cit.gvsig.fmap.AtomicEvent; |
7 | 8 |
import com.iver.cit.gvsig.fmap.AtomicEventListener; |
8 | 9 |
import com.iver.cit.gvsig.fmap.MapControl; |
... | ... | |
29 | 30 |
* Lo principal es una colecci?n de LayerEdited, y cada |
30 | 31 |
* LayerEdited es un wrapper alrededor de un tema que guarda |
31 | 32 |
* las propiedades de la edici?n. |
32 |
*
|
|
33 |
* |
|
33 | 34 |
* Nuevo: Llevar aqu? el control de las tablas en edici?n tambi?n |
34 | 35 |
* y centralizar los listeners interesados en los eventos de edici?n. |
35 | 36 |
* |
... | ... | |
40 | 41 |
public class EditionManager implements LayerListener { |
41 | 42 |
private ArrayList editedLayers = new ArrayList(); |
42 | 43 |
private ArrayList editedTables = new ArrayList(); |
43 |
private ILayerEdited activeLayerEdited = null;
|
|
44 |
//private ArrayList activeLayerEdited = new ArrayList();
|
|
44 | 45 |
private MapControl mapCtrl = null; |
46 |
private ILayerEdited ile=null; |
|
47 |
//private int idActiveLayer=0; |
|
45 | 48 |
|
46 | 49 |
|
47 | 50 |
/** |
... | ... | |
64 | 67 |
} |
65 | 68 |
|
66 | 69 |
public void activationChanged(LayerEvent e) { |
67 |
// Aqu? controlamos que solo exista un tema activo y en edici?n |
|
68 |
// a la vez. Recorremos los temas en edici?n, y dejamos el primero que encontremos |
|
69 |
// activado, mientras el resto los desactivamos. |
|
70 |
// ILayerEdited aux = null; |
|
71 |
// boolean bFirst = true; |
|
72 |
// mapCtrl.getMapContext().beginAtomicEvent(); |
|
73 |
// for (int i=0; i < editedLayers.size(); i++) |
|
74 |
// { |
|
75 |
// aux = (ILayerEdited) editedLayers.get(i); |
|
76 |
// if (aux.getLayer().isActive()) |
|
77 |
// { |
|
78 |
// if (!bFirst) |
|
79 |
// aux.getLayer().setActive(false); |
|
80 |
// else |
|
81 |
// activeLayerEdited = aux; |
|
82 |
// bFirst = false; |
|
83 |
// } |
|
84 |
// } |
|
85 |
// mapCtrl.getMapContext().endAtomicEvent(); |
|
86 |
if (e.getSource() instanceof FLyrVect){ |
|
87 |
activeLayerEdited=new VectorialLayerEdited(e.getSource()); |
|
70 |
|
|
71 |
if (ile!=null) { |
|
72 |
VectorialLayerEdited lastVLE = (VectorialLayerEdited)ile; |
|
73 |
lastVLE.activationLost(e); |
|
88 | 74 |
} |
75 |
if (e.getSource() instanceof FLyrVect) { |
|
76 |
VectorialLayerEdited vle = null; |
|
77 |
vle=(VectorialLayerEdited)getLayerEdited(e.getSource()); |
|
78 |
// for (int i = 0; i < editedLayers.size(); i++) { |
|
79 |
// vle = (VectorialLayerEdited) editedLayers.get(i); |
|
80 |
// if (vle.getLayer().equals(e.getSource())) { |
|
81 |
// idActiveLayer = i; |
|
82 |
ile=vle; |
|
83 |
if (getMapControl()!=null && vle!=null){ |
|
84 |
getMapControl().setTool("cadtooladapter"); |
|
85 |
vle.activationGained(e); |
|
86 |
return; |
|
87 |
} |
|
88 |
} |
|
89 |
// } |
|
90 |
// idActiveLayer=-1; |
|
91 |
//ile=null; |
|
92 |
if (getMapControl()!=null){ |
|
93 |
getMapControl().setTool("zoomIn"); |
|
94 |
PluginServices.getMainFrame().setSelectedTool("ZOOM_IN"); |
|
95 |
} |
|
89 | 96 |
} |
90 | 97 |
|
91 | 98 |
public void nameChanged(LayerEvent e) { |
... | ... | |
101 | 108 |
{ |
102 | 109 |
lyrEdit = FactoryLayerEdited.createLayerEdited(e.getSource()); |
103 | 110 |
editedLayers.add(lyrEdit); |
111 |
if (getMapControl()!=null){ |
|
112 |
getMapControl().setTool("cadtooladapter"); |
|
113 |
CADExtension.setCADTool("_selection",true); |
|
114 |
} |
|
115 |
PluginServices.getMainFrame().setSelectedTool("_selection"); |
|
116 |
//idActiveLayer = editedLayers.size() - 1; |
|
117 |
ile=getLayerEdited(e.getSource()); |
|
104 | 118 |
System.out.println("NUEVA CAPA EN EDICION: " + lyrEdit.getLayer().getName()); |
105 |
activationChanged(e); |
|
106 |
|
|
119 |
//activationChanged(e);
|
|
120 |
|
|
107 | 121 |
// Ponemos el resto de temas desactivados |
108 | 122 |
if (mapCtrl != null) |
109 | 123 |
mapCtrl.getMapContext().getLayers().setActive(false); |
110 | 124 |
// y activamos el nuevo. |
111 | 125 |
e.getSource().setActive(true); |
112 |
|
|
126 |
|
|
127 |
}else{ |
|
128 |
for (int i = 0; i < editedLayers.size(); i++) { |
|
129 |
VectorialLayerEdited vle = (VectorialLayerEdited) editedLayers.get(i); |
|
130 |
if (vle.equals(lyrEdit)) { |
|
131 |
editedLayers.remove(i); |
|
132 |
ile=null; |
|
133 |
//idActiveLayer=-1; |
|
134 |
return; |
|
135 |
} |
|
136 |
} |
|
113 | 137 |
} |
114 |
|
|
138 |
|
|
115 | 139 |
} |
116 | 140 |
|
117 | 141 |
/** |
118 | 142 |
* @return Returns the activeLayerEdited. Null if there isn't any active AND edited |
119 | 143 |
*/ |
120 | 144 |
public ILayerEdited getActiveLayerEdited() { |
121 |
return activeLayerEdited;
|
|
145 |
return ile;
|
|
122 | 146 |
} |
123 | 147 |
|
124 | 148 |
/** |
Also available in: Unified diff