svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / StartEditing.java @ 3736
History | View | Annotate | Download (4.67 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import com.iver.andami.PluginServices; |
4 |
import com.iver.andami.plugins.Extension; |
5 |
import com.iver.cit.gvsig.fmap.FMap; |
6 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
7 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
8 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
9 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
10 |
import com.iver.cit.gvsig.gui.View; |
11 |
import com.iver.cit.gvsig.project.ProjectView; |
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
/**
|
18 |
* DOCUMENT ME!
|
19 |
*
|
20 |
* @author Vicente Caballero Navarro
|
21 |
*/
|
22 |
public class StartEditing implements Extension { |
23 |
/**
|
24 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
25 |
*/
|
26 |
public void inicializar() { |
27 |
} |
28 |
|
29 |
/**
|
30 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
31 |
*/
|
32 |
public void execute(String actionCommand) { |
33 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
34 |
.getActiveView(); |
35 |
|
36 |
if (f instanceof View) { |
37 |
View vista = (View) f; |
38 |
vista.showConsole(); |
39 |
ProjectView model = vista.getModel(); |
40 |
FMap mapa = model.getMapContext(); |
41 |
FLayers layers = mapa.getLayers(); |
42 |
|
43 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
44 |
if (layers.getLayer(i) instanceof FLyrVect && |
45 |
layers.getLayer(i).isActive()) { |
46 |
for (int j = 0; j < i; j++) { |
47 |
layers.getLayer(j).setVisible(false);
|
48 |
} |
49 |
|
50 |
FLyrVect lv = (FLyrVect) layers.getLayer(i); |
51 |
lv.setVisible(true);
|
52 |
|
53 |
VectorialEditableAdapter vea = new VectorialEditableAdapter(lv.getSource());
|
54 |
try{
|
55 |
vea.startEdition(); |
56 |
}catch (EditionException e) {
|
57 |
// TODO: handle exception
|
58 |
} |
59 |
lv.setSource(vea); |
60 |
CADExtension.getCADToolAdapter().setVectorialAdapter(vea,null);
|
61 |
lv.setEditing(true);
|
62 |
layers.removeLayer(lv); |
63 |
layers.addLayer(lv); |
64 |
return;
|
65 |
} |
66 |
} |
67 |
|
68 |
/*
|
69 |
PluginServices.getMDIManager().setWaitCursor();
|
70 |
try {
|
71 |
if (((FLyrVect) capa).getSource().getDriver().getClass() == DXFCadDriver.class) {
|
72 |
if (JOptionPane.showConfirmDialog(
|
73 |
(Component) PluginServices.getMainFrame(),
|
74 |
"Todas las geometr?as del formato DXF no se pueden editar, de momento podemos editar: Line, Point, Polyline, Arc, Circle y Ellipse. \n El resto de geometr?as se perder?n con la edici?n. \n ?Desea continuar?") == JOptionPane.YES_OPTION) {
|
75 |
capa.startEdition();
|
76 |
vista.getMapControl().setCadTool("selection");
|
77 |
} else {
|
78 |
}
|
79 |
} else {
|
80 |
capa.startEdition();
|
81 |
vista.getMapControl().setCadTool("selection");
|
82 |
}
|
83 |
} catch (EditionException e) {
|
84 |
// TODO Auto-generated catch block
|
85 |
e.printStackTrace();
|
86 |
}
|
87 |
PluginServices.getMDIManager().restoreCursor();
|
88 |
*/
|
89 |
vista.getMapControl().drawMap(false);
|
90 |
} |
91 |
} |
92 |
|
93 |
/**
|
94 |
* @see com.iver.andami.plugins.Extension#isEnabled()
|
95 |
*/
|
96 |
public boolean isEnabled() { |
97 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
98 |
.getActiveView(); |
99 |
|
100 |
if (f == null) { |
101 |
return false; |
102 |
} |
103 |
|
104 |
if (f.getClass() == View.class) { |
105 |
View vista = (View) f; |
106 |
ProjectView model = vista.getModel(); |
107 |
FMap mapa = model.getMapContext(); |
108 |
|
109 |
FLayers capas = mapa.getLayers(); |
110 |
|
111 |
for (int i = 0; i < capas.getLayersCount(); i++) { |
112 |
if (capas.getLayer(i) instanceof FLyrVect && |
113 |
capas.getLayer(i).isEditing()) { |
114 |
return false; |
115 |
} |
116 |
} |
117 |
|
118 |
return true; |
119 |
} |
120 |
|
121 |
return false; |
122 |
} |
123 |
|
124 |
/**
|
125 |
* @see com.iver.andami.plugins.Extension#isVisible()
|
126 |
*/
|
127 |
public boolean isVisible() { |
128 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
129 |
.getActiveView(); |
130 |
|
131 |
if (f == null) { |
132 |
return false; |
133 |
} |
134 |
|
135 |
if (f.getClass() == View.class) { |
136 |
return true; |
137 |
} else {
|
138 |
return false; |
139 |
} |
140 |
} |
141 |
} |