Revision 5893 trunk/extensions/extCAD/src/com/iver/cit/gvsig/StartEditing.java
StartEditing.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig; |
2 | 2 |
|
3 | 3 |
import java.awt.event.ActionEvent; |
4 |
import java.awt.event.KeyEvent; |
|
5 | 4 |
|
6 | 5 |
import javax.swing.AbstractAction; |
7 |
import javax.swing.Action; |
|
8 |
import javax.swing.ActionMap; |
|
9 |
import javax.swing.InputMap; |
|
10 |
import javax.swing.JComponent; |
|
11 |
import javax.swing.KeyStroke; |
|
12 | 6 |
|
13 | 7 |
import com.iver.andami.PluginServices; |
14 | 8 |
import com.iver.andami.messages.NotificationManager; |
15 | 9 |
import com.iver.andami.plugins.Extension; |
16 | 10 |
import com.iver.cit.gvsig.fmap.FMap; |
17 | 11 |
import com.iver.cit.gvsig.fmap.MapControl; |
12 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
13 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
18 | 14 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
19 | 15 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
16 |
import com.iver.cit.gvsig.fmap.edition.rules.IRule; |
|
17 |
import com.iver.cit.gvsig.fmap.edition.rules.RulePolygon; |
|
20 | 18 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
21 | 19 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
22 | 20 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
... | ... | |
72 | 70 |
FMap mapa = model.getMapContext(); |
73 | 71 |
FLayers layers = mapa.getLayers(); |
74 | 72 |
|
75 |
// registerKeyStrokes() |
|
76 | 73 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
77 | 74 |
if (layers.getLayer(i) instanceof FLyrVect |
78 | 75 |
&& layers.getLayer(i).isActive()) { |
... | ... | |
86 | 83 |
lv.addLayerListener(CADExtension.getEditionManager()); |
87 | 84 |
try { |
88 | 85 |
lv.setEditing(true); |
86 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) lv |
|
87 |
.getSource(); |
|
88 |
vea.getRules().clear(); |
|
89 |
if (vea.getShapeType() == FShape.POLYGON) |
|
90 |
{ |
|
91 |
IRule rulePol = new RulePolygon(); |
|
92 |
vea.getRules().add(rulePol); |
|
93 |
} |
|
94 |
vea.getCommandRecord().addCommandListener(mapControl); |
|
95 |
// Si existe una tabla asociada a esta capa se cambia su |
|
96 |
// modelo por el VectorialEditableAdapter. |
|
97 |
ProjectExtension pe = (ProjectExtension) PluginServices |
|
98 |
.getExtension(ProjectExtension.class); |
|
99 |
ProjectTable pt = pe.getProject().getTable(lv); |
|
100 |
if (pt != null){ |
|
101 |
pt.setModel(vea); |
|
102 |
changeModelTable(pt); |
|
103 |
} |
|
104 |
startCommandsApplicable(vista,lv); |
|
89 | 105 |
} catch (EditionException e) { |
90 | 106 |
e.printStackTrace(); |
91 | 107 |
NotificationManager.addError(e); |
108 |
} catch (DriverIOException e) { |
|
109 |
e.printStackTrace(); |
|
110 |
NotificationManager.addError(e); |
|
92 | 111 |
} |
93 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) lv |
|
94 |
.getSource(); |
|
95 |
vea.getCommandRecord().addCommandListener(mapControl); |
|
96 |
// Si existe una tabla asociada a esta capa se cambia su |
|
97 |
// modelo por el VectorialEditableAdapter. |
|
98 |
ProjectExtension pe = (ProjectExtension) PluginServices |
|
99 |
.getExtension(ProjectExtension.class); |
|
100 |
ProjectTable pt = pe.getProject().getTable(lv); |
|
101 |
if (pt != null){ |
|
102 |
pt.setModel(vea); |
|
103 |
changeModelTable(pt); |
|
104 |
} |
|
105 |
startCommandsApplicable(vista,lv); |
|
112 |
|
|
106 | 113 |
// return; |
107 | 114 |
} |
108 | 115 |
} |
Also available in: Unified diff