Revision 69
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.main/src/main/java/org/gvsig/vectorediting/main/Main.java | ||
---|---|---|
45 | 45 |
import org.gvsig.fmap.dal.DALLocator; |
46 | 46 |
import org.gvsig.fmap.dal.DataManager; |
47 | 47 |
import org.gvsig.fmap.dal.DataStoreParameters; |
48 |
import org.gvsig.fmap.dal.exception.DataException; |
|
49 | 48 |
import org.gvsig.fmap.dal.exception.InitializeException; |
50 | 49 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
51 | 50 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
... | ... | |
257 | 256 |
paletteTools.add(insertPointButton); |
258 | 257 |
paletteTools.add(circleCrButton); |
259 | 258 |
paletteTools.add(polylineButton); |
259 |
|
|
260 |
paletteTools.add(new JLabel("Modify tools")); |
|
260 | 261 |
paletteTools.add(symmetryButton); |
261 | 262 |
} |
262 | 263 |
|
... | ... | |
383 | 384 |
editingExtensionAction = new AbstractAction("EditingExtension") { |
384 | 385 |
|
385 | 386 |
public void actionPerformed(ActionEvent e) { |
386 |
try { |
|
387 |
swingManager.beginEdition(currentLayer, mapControl); |
|
388 |
} |
|
389 |
catch (DataException e1) { |
|
390 |
e1.printStackTrace(); |
|
391 |
} |
|
387 |
swingManager.beginEdition(currentLayer, mapControl); |
|
392 | 388 |
} |
393 | 389 |
}; |
394 | 390 |
|
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.api/src/main/java/org/gvsig/vectorediting/lib/api/exceptions/EndEditingException.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2014 DiSiD Technologies S.L.L. All rights reserved. |
|
3 |
* |
|
4 |
* Project : DiSiD org.gvsig.vectorediting.lib.api |
|
5 |
* SVN Id : $Id$ |
|
6 |
*/ |
|
7 |
package org.gvsig.vectorediting.lib.api.exceptions; |
|
8 |
|
|
9 |
|
|
10 |
public class EndEditingException extends VectorEditingException { |
|
11 |
|
|
12 |
private static final long serialVersionUID = 2150082352618473147L; |
|
13 |
|
|
14 |
private static final String MESSAGE = |
|
15 |
"An error has been produced ending edition."; |
|
16 |
|
|
17 |
private static final String KEY = "_EndEditionException"; |
|
18 |
|
|
19 |
|
|
20 |
public EndEditingException(Throwable ex) { |
|
21 |
super(MESSAGE, ex, KEY, serialVersionUID); |
|
22 |
} |
|
23 |
|
|
24 |
public EndEditingException(String message, Throwable ex){ |
|
25 |
super(message, ex, KEY, serialVersionUID); |
|
26 |
} |
|
27 |
|
|
28 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.api/src/main/java/org/gvsig/vectorediting/lib/api/exceptions/StartEditingException.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2014 DiSiD Technologies S.L.L. All rights reserved. |
|
3 |
* |
|
4 |
* Project : DiSiD org.gvsig.vectorediting.lib.api |
|
5 |
* SVN Id : $Id$ |
|
6 |
*/ |
|
7 |
package org.gvsig.vectorediting.lib.api.exceptions; |
|
8 |
|
|
9 |
|
|
10 |
public class StartEditingException extends VectorEditingException { |
|
11 |
|
|
12 |
private static final long serialVersionUID = 3223155291885793084L; |
|
13 |
|
|
14 |
private static final String MESSAGE = |
|
15 |
"An error has been produced starting edition."; |
|
16 |
|
|
17 |
private static final String KEY = "_StartEditionException"; |
|
18 |
|
|
19 |
|
|
20 |
public StartEditingException(Throwable ex) { |
|
21 |
super(MESSAGE, ex, KEY, serialVersionUID); |
|
22 |
} |
|
23 |
|
|
24 |
public StartEditingException(String message, Throwable ex){ |
|
25 |
super(message, ex, KEY, serialVersionUID); |
|
26 |
} |
|
27 |
|
|
28 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.api/src/main/java/org/gvsig/vectorediting/lib/api/exceptions/EditingServiceException.java | ||
---|---|---|
14 | 14 |
private static final String MESSAGE = |
15 | 15 |
"An error has been produced in the VectorEditing library"; |
16 | 16 |
|
17 |
private static final String KEY = "_WasteException";
|
|
17 |
private static final String KEY = "_EditingServiceException";
|
|
18 | 18 |
|
19 | 19 |
/** |
20 | 20 |
* Constructor to be used in rare cases, usually you must create a new child |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/DefaultEditingSwingManager.java | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
package org.gvsig.vectorediting.swing.impl; |
8 | 8 |
|
9 |
import java.awt.BorderLayout; |
|
10 |
import java.awt.Component; |
|
11 |
import java.awt.Font; |
|
12 |
import java.awt.GridBagConstraints; |
|
13 |
import java.awt.GridBagLayout; |
|
14 |
import java.awt.Insets; |
|
15 |
|
|
16 |
import javax.swing.JLabel; |
|
17 |
import javax.swing.JOptionPane; |
|
18 |
import javax.swing.JPanel; |
|
19 |
|
|
20 |
import org.gvsig.andami.PluginServices; |
|
9 | 21 |
import org.gvsig.editing.EditingNotification; |
10 | 22 |
import org.gvsig.editing.EditingNotificationManager; |
11 |
import org.gvsig.fmap.dal.exception.DataException;
|
|
23 |
import org.gvsig.fmap.dal.feature.FeatureStore;
|
|
12 | 24 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
13 | 25 |
import org.gvsig.fmap.mapcontrol.MapControl; |
14 | 26 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
15 | 27 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
28 |
import org.gvsig.tools.ToolsLocator; |
|
16 | 29 |
import org.gvsig.tools.dynobject.DynObject; |
30 |
import org.gvsig.tools.i18n.I18nManager; |
|
17 | 31 |
import org.gvsig.tools.service.AbstractManager; |
18 | 32 |
import org.gvsig.tools.service.Service; |
19 | 33 |
import org.gvsig.tools.service.ServiceException; |
20 | 34 |
import org.gvsig.vectorediting.lib.api.EditingManager; |
35 |
import org.gvsig.vectorediting.lib.api.exceptions.EndEditingException; |
|
36 |
import org.gvsig.vectorediting.lib.api.exceptions.StartEditingException; |
|
37 |
import org.gvsig.vectorediting.lib.api.exceptions.VectorEditingException; |
|
21 | 38 |
import org.gvsig.vectorediting.lib.impl.DefaultEditingProviderManager; |
22 | 39 |
import org.gvsig.vectorediting.swing.api.EditingBehavior; |
23 | 40 |
import org.gvsig.vectorediting.swing.api.EditingSwingManager; |
... | ... | |
29 | 46 |
|
30 | 47 |
private static final Logger logger = LoggerFactory |
31 | 48 |
.getLogger(EditingManager.class); |
49 |
|
|
50 |
private I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
32 | 51 |
|
52 |
private final int CANCEL = 0; |
|
53 |
|
|
54 |
private final int SAVE_CHANGES = 1; |
|
55 |
|
|
56 |
private final int DISCARD_CHANGES = 2; |
|
57 |
|
|
58 |
private final int EXPORT_LAYER = 3; |
|
59 |
|
|
33 | 60 |
public DefaultEditingSwingManager() { |
34 | 61 |
super(new DefaultEditingProviderManager()); |
35 | 62 |
// TODO Auto-generated constructor stub |
36 | 63 |
} |
37 | 64 |
|
38 |
public Service getService(DynObject parameters) throws ServiceException { |
|
39 |
// TODO Auto-generated method stub |
|
40 |
return null; |
|
41 |
} |
|
42 |
|
|
43 | 65 |
public void activateTool(String name, MapControl mapControl) { |
44 | 66 |
// TODO Auto-generated method stub |
45 | 67 |
if (mapControl != null && mapControl.hasTool("VectorEditing")) { |
46 | 68 |
EditingBehavior behavior = (EditingBehavior) mapControl |
47 | 69 |
.getMapTool("VectorEditing"); |
70 |
mapControl.setTool("VectorEditing"); |
|
48 | 71 |
behavior.activateTool(name); |
49 | 72 |
} |
50 | 73 |
} |
51 | 74 |
|
52 |
public void beginEdition(FLyrVect layer, MapControl mapControl) |
|
53 |
throws DataException { |
|
75 |
public void beginEdition(FLyrVect layer, MapControl mapControl) { |
|
54 | 76 |
|
55 | 77 |
EditingNotificationManager editingNotificationManager = MapControlLocator |
56 | 78 |
.getEditingNotificationManager(); |
... | ... | |
61 | 83 |
|
62 | 84 |
if (notification.isCanceled()) { |
63 | 85 |
logger.info("Edit layer '" + layer.getName() |
64 |
+ "' canceled by somme observer.");
|
|
65 |
throw new RuntimeException("Edit layer '" + layer.getName()
|
|
66 |
+ "' canceled."); |
|
86 |
+ "' canceled by somme observer.", new StartEditingException(
|
|
87 |
"Edit layer '" + layer.getName() + "' canceled.", null));
|
|
88 |
|
|
67 | 89 |
} |
68 | 90 |
|
69 | 91 |
initFocus(mapControl); |
70 |
|
|
71 |
layer.getFeatureStore().edit(); |
|
72 |
// layer.getFeatureStore().addObserver(view); |
|
92 |
|
|
93 |
try { |
|
94 |
layer.getFeatureStore().edit(); |
|
95 |
} |
|
96 |
catch (Exception e) { |
|
97 |
logger.error("Can't set featureStore in edit mode", |
|
98 |
new VectorEditingException(e)); |
|
99 |
} |
|
100 |
|
|
101 |
// layer.getFeatureStore().addObserver(view); |
|
73 | 102 |
layer.getFeatureStore().addObserver(mapControl); |
74 | 103 |
|
75 | 104 |
editingNotificationManager.notifyObservers(this, |
76 |
EditingNotification.AFTER_ENTER_EDITING_STORE, null, |
|
77 |
layer); |
|
105 |
EditingNotification.AFTER_ENTER_EDITING_STORE, null, layer); |
|
78 | 106 |
} |
79 | 107 |
|
108 |
/** |
|
109 |
* @param layer |
|
110 |
* @param mapControl |
|
111 |
* @throws EndEditingException |
|
112 |
*/ |
|
113 |
private void discardChanges(FLyrVect layer, MapControl mapControl) |
|
114 |
throws EndEditingException { |
|
115 |
FeatureStore featureStore = layer.getFeatureStore(); |
|
116 |
try { |
|
117 |
featureStore.cancelEditing(); |
|
118 |
EditingBehavior editingBehavior = (EditingBehavior) mapControl |
|
119 |
.getMapTool("VectorEditing"); |
|
120 |
editingBehavior.cleanBehavior(); |
|
121 |
editingBehavior.hideConsole(); |
|
122 |
} |
|
123 |
catch (Exception e) { |
|
124 |
throw new EndEditingException(e); |
|
125 |
} |
|
126 |
|
|
127 |
featureStore.deleteObserver(mapControl); |
|
128 |
|
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* |
|
133 |
* @param layer |
|
134 |
* @param mapControl |
|
135 |
* @param option |
|
136 |
*/ |
|
137 |
private void doAction(FLyrVect layer, MapControl mapControl, int option) { |
|
138 |
switch (option) { |
|
139 |
case SAVE_CHANGES: |
|
140 |
try { |
|
141 |
saveChanges(layer, mapControl); |
|
142 |
} |
|
143 |
catch (VectorEditingException e) { |
|
144 |
logger.error("Changes can not be saved in " + layer.getName(), e); |
|
145 |
} |
|
146 |
break; |
|
147 |
case DISCARD_CHANGES: |
|
148 |
try { |
|
149 |
discardChanges(layer, mapControl); |
|
150 |
} |
|
151 |
catch (VectorEditingException e) { |
|
152 |
logger.error("Changes can not be discared in " + layer.getName(), e); |
|
153 |
} |
|
154 |
break; |
|
155 |
case EXPORT_LAYER: |
|
156 |
try { |
|
157 |
exportLayer(layer, mapControl); |
|
158 |
} |
|
159 |
catch (VectorEditingException e) { |
|
160 |
logger.error("Changes can not be imported", e); |
|
161 |
} |
|
162 |
break; |
|
163 |
case CANCEL: |
|
164 |
break; |
|
165 |
} |
|
166 |
|
|
167 |
} |
|
168 |
|
|
169 |
public void endEdition(FLyrVect layer, MapControl mapControl) { |
|
170 |
EditingNotificationManager editingNotificationManager = MapControlLocator |
|
171 |
.getEditingNotificationManager(); |
|
172 |
|
|
173 |
EditingNotification notification = editingNotificationManager |
|
174 |
.notifyObservers(this, EditingNotification.BEFORE_EXIT_EDITING_STORE, |
|
175 |
null, layer); |
|
176 |
|
|
177 |
if (notification.isCanceled()) { |
|
178 |
logger.info("Stop edit layer '" + layer.getName() |
|
179 |
+ "' canceled by somme observer.", new EndEditingException( |
|
180 |
"Stop edit layer '" + layer.getName() + "' canceled.", null)); |
|
181 |
|
|
182 |
} |
|
183 |
|
|
184 |
int option; |
|
185 |
if (layer.isWritable()) { |
|
186 |
option = showPanelSaveOrDiscard(layer.getName()); |
|
187 |
} |
|
188 |
else { |
|
189 |
option = showPanelExportOrDiscard(layer.getName()); |
|
190 |
} |
|
191 |
|
|
192 |
doAction(layer, mapControl, option); |
|
193 |
|
|
194 |
editingNotificationManager.notifyObservers(this, |
|
195 |
EditingNotification.AFTER_EXIT_EDITING_STORE, null, layer); |
|
196 |
|
|
197 |
} |
|
198 |
|
|
199 |
private void exportLayer(FLyrVect layer, MapControl mapCotrol) |
|
200 |
throws EndEditingException { |
|
201 |
// TODO Export layer |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* @param translatedQuestion |
|
206 |
* @param translatedFirstTag |
|
207 |
* @param translatedFirstDescription |
|
208 |
* @return |
|
209 |
*/ |
|
210 |
private JPanel getExplanationPanel(String translatedQuestion, |
|
211 |
String translatedFirstTag, |
|
212 |
String translatedFirstDescription) { |
|
213 |
|
|
214 |
JPanel resp = new JPanel(new BorderLayout(10, 10)); |
|
215 |
|
|
216 |
JLabel topLabel = new JLabel(translatedQuestion); |
|
217 |
|
|
218 |
JPanel mainPanel = new JPanel(new GridBagLayout()); |
|
219 |
GridBagConstraints cc = new GridBagConstraints(); |
|
220 |
|
|
221 |
cc.gridx = 0; |
|
222 |
cc.gridy = 0; |
|
223 |
cc.anchor = GridBagConstraints.WEST; |
|
224 |
|
|
225 |
cc.insets = new Insets(3, 6, 3, 6); |
|
226 |
|
|
227 |
Font boldf = mainPanel.getFont().deriveFont(Font.BOLD); |
|
228 |
|
|
229 |
JLabel lbl = new JLabel(translatedFirstTag); |
|
230 |
lbl.setFont(boldf); |
|
231 |
mainPanel.add(lbl, cc); |
|
232 |
cc.gridx = 1; |
|
233 |
mainPanel.add(new JLabel(translatedFirstDescription), cc); |
|
234 |
|
|
235 |
cc.gridx = 0; |
|
236 |
cc.gridy = 1; |
|
237 |
lbl = new JLabel(i18nManager.getTranslation("discard")); |
|
238 |
lbl.setFont(boldf); |
|
239 |
mainPanel.add(lbl, cc); |
|
240 |
cc.gridx = 1; |
|
241 |
mainPanel |
|
242 |
.add(new JLabel(i18nManager.getTranslation("discard_and_loose_changes")), cc); |
|
243 |
|
|
244 |
cc.gridx = 0; |
|
245 |
cc.gridy = 2; |
|
246 |
lbl = new JLabel(i18nManager.getTranslation("continue")); |
|
247 |
lbl.setFont(boldf); |
|
248 |
mainPanel.add(lbl, cc); |
|
249 |
cc.gridx = 1; |
|
250 |
mainPanel.add( |
|
251 |
new JLabel(i18nManager.getTranslation("do_not_save_yet_stay_in_editing_mode")), |
|
252 |
cc); |
|
253 |
|
|
254 |
resp.add(mainPanel, BorderLayout.CENTER); |
|
255 |
resp.add(topLabel, BorderLayout.NORTH); |
|
256 |
return resp; |
|
257 |
} |
|
258 |
|
|
259 |
public Service getService(DynObject parameters) throws ServiceException { |
|
260 |
// TODO Auto-generated method stub |
|
261 |
return null; |
|
262 |
} |
|
263 |
|
|
264 |
/** |
|
265 |
* @param mapControl |
|
266 |
*/ |
|
80 | 267 |
private void initFocus(MapControl mapControl) { |
81 |
|
|
268 |
|
|
82 | 269 |
EditingBehavior editingBehavior; |
83 | 270 |
if (!mapControl.hasTool("VectorEditing")) { |
84 | 271 |
editingBehavior = new DefaultEditingBehavior(mapControl); |
85 | 272 |
mapControl.addBehavior("VectorEditing", (Behavior) editingBehavior); |
86 |
|
|
273 |
|
|
87 | 274 |
} |
88 | 275 |
else { |
89 | 276 |
editingBehavior = (EditingBehavior) mapControl |
90 | 277 |
.getMapTool("VectorEditing"); |
91 | 278 |
editingBehavior.cleanBehavior(); |
92 | 279 |
} |
93 |
|
|
280 |
|
|
94 | 281 |
mapControl.setTool("VectorEditing"); |
95 | 282 |
editingBehavior.showConsole(); |
96 | 283 |
} |
97 | 284 |
|
285 |
/** |
|
286 |
* @param layer |
|
287 |
* @param mapControl |
|
288 |
* @throws EndEditingException |
|
289 |
*/ |
|
290 |
private void saveChanges(FLyrVect layer, MapControl mapControl) |
|
291 |
throws EndEditingException { |
|
292 |
FeatureStore featureStore = layer.getFeatureStore(); |
|
293 |
try { |
|
294 |
featureStore.finishEditing(); |
|
295 |
EditingBehavior editingBehavior = (EditingBehavior) mapControl |
|
296 |
.getMapTool("VectorEditing"); |
|
297 |
editingBehavior.cleanBehavior(); |
|
298 |
editingBehavior.hideConsole(); |
|
299 |
} |
|
300 |
catch (Exception e) { |
|
301 |
throw new EndEditingException(e); |
|
302 |
} |
|
303 |
|
|
304 |
featureStore.deleteObserver(mapControl); |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* |
|
309 |
* @param name |
|
310 |
* @return |
|
311 |
*/ |
|
312 |
private int showPanelExportOrDiscard(String name) { |
|
313 |
Object[] options = { PluginServices.getText(this, "export"), |
|
314 |
" " + i18nManager.getTranslation("discard") + " ", |
|
315 |
i18nManager.getTranslation("continue") }; |
|
316 |
|
|
317 |
String question = i18nManager.getTranslation("no_existe_writer_para_este_formato_de_capa_o_no_tiene_permisos_de_escritura_los_datos_que_desea_hacer"); |
|
318 |
String firstLabel = i18nManager.getTranslation("export"); |
|
319 |
String firstDesc = i18nManager.getTranslation("export_to_another_format"); |
|
320 |
|
|
321 |
JPanel explanation_panel = getExplanationPanel(question, firstLabel, |
|
322 |
firstDesc); |
|
323 |
|
|
324 |
int resp = JOptionPane.showOptionDialog( |
|
325 |
(Component) PluginServices.getMainFrame(), explanation_panel, |
|
326 |
i18nManager.getTranslation("stop_edition"), |
|
327 |
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, |
|
328 |
options, options[2]); |
|
329 |
|
|
330 |
if (resp == JOptionPane.NO_OPTION) { |
|
331 |
return DISCARD_CHANGES; |
|
332 |
} |
|
333 |
else if (resp == JOptionPane.YES_OPTION) { |
|
334 |
return EXPORT_LAYER; |
|
335 |
} |
|
336 |
return CANCEL; |
|
337 |
} |
|
338 |
|
|
339 |
/** |
|
340 |
* |
|
341 |
* @param layerName |
|
342 |
* @return |
|
343 |
*/ |
|
344 |
private int showPanelSaveOrDiscard(String layerName) { |
|
345 |
Object[] options = { PluginServices.getText(this, "_Guardar"), |
|
346 |
" " + PluginServices.getText(this, "_Descartar") + " ", |
|
347 |
PluginServices.getText(this, "_Continuar") }; |
|
348 |
|
|
349 |
String question = i18nManager.getTranslation("realmente_desea_guardar_la_capa"); |
|
350 |
question = question + " '" + layerName + "'?"; |
|
351 |
String firstLabel = i18nManager.getTranslation("guardar"); |
|
352 |
String firstDesc = i18nManager.getTranslation("save_changes_performed"); |
|
353 |
JPanel explanation_panel = getExplanationPanel(question, firstLabel, |
|
354 |
firstDesc); |
|
355 |
|
|
356 |
int resp = JOptionPane.showOptionDialog( |
|
357 |
(Component) PluginServices.getMainFrame(), explanation_panel, |
|
358 |
PluginServices.getText(this, "stop_edition"), |
|
359 |
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, |
|
360 |
options, options[2]); |
|
361 |
|
|
362 |
if (resp == JOptionPane.YES_OPTION) { |
|
363 |
return SAVE_CHANGES; |
|
364 |
} |
|
365 |
else if (resp == JOptionPane.NO_OPTION) { |
|
366 |
return DISCARD_CHANGES; |
|
367 |
} |
|
368 |
return CANCEL; |
|
369 |
} |
|
98 | 370 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/EditingSwingManager.java | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
package org.gvsig.vectorediting.swing.api; |
8 | 8 |
|
9 |
import org.gvsig.fmap.dal.exception.DataException; |
|
10 | 9 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
11 | 10 |
import org.gvsig.fmap.mapcontrol.MapControl; |
12 | 11 |
import org.gvsig.tools.service.Manager; |
... | ... | |
21 | 20 |
public void activateTool(String name, MapControl mapControl); |
22 | 21 |
|
23 | 22 |
/** |
23 |
* |
|
24 |
* @param layer |
|
24 | 25 |
* @param mapControl |
25 | 26 |
*/ |
26 |
void beginEdition(FLyrVect layer, MapControl mapControl) throws DataException; |
|
27 |
void beginEdition(FLyrVect layer, MapControl mapControl); |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @param layer |
|
32 |
* @param mapControl |
|
33 |
*/ |
|
34 |
void endEdition(FLyrVect layer, MapControl mapControl); |
|
27 | 35 |
|
28 | 36 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
6 | 6 |
short_no=N |
7 | 7 |
invalid_option=Opci\u00f3n no v\u00e1lida |
8 | 8 |
center=Centro |
9 |
radius=Radio |
|
9 |
radius=Radio |
|
10 |
save_changes_performed=Guardar cambios realizados |
|
11 |
discard= Descartar |
|
12 |
discard_and_loose_changes= Descartar cambios y perder los cambios |
|
13 |
continue= Continuar |
|
14 |
do_not_save_yet_stay_in_editing_mode= No guardar los cambios y seguir en modo edici\u00f3n |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
6 | 6 |
short_no=N |
7 | 7 |
invalid_option=Invalid option |
8 | 8 |
center=Center |
9 |
radius=Radius |
|
9 |
radius=Radius |
|
10 |
save_changes_performed=Save changed performed |
|
11 |
discard= Discard |
|
12 |
discard_and_loose_changes= Discard changes and loose changes |
|
13 |
continue= Continue |
|
14 |
do_not_save_yet_stay_in_editing_mode= Don't save changes and continue editing |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
40 | 40 |
</tool-bar> |
41 | 41 |
|
42 | 42 |
</extension> |
43 |
|
|
43 | 44 |
<extension |
45 |
class-name="org.gvsig.vectorediting.app.mainplugin.extensions.EndEditingExtension" |
|
46 |
description="" active="true" priority="1"> |
|
47 |
|
|
48 |
<action |
|
49 |
name="end-edit" |
|
50 |
label="_End_edit" |
|
51 |
tooltip="_End_edit" |
|
52 |
position="600800000" |
|
53 |
action-command="end_edit" |
|
54 |
icon="vector-editing" |
|
55 |
accelerator="" |
|
56 |
/> |
|
57 |
|
|
58 |
<menu |
|
59 |
name="end-edit" |
|
60 |
text="Layer/end_edit" |
|
61 |
/> |
|
62 |
|
|
63 |
<tool-bar name="vector_editing" position="600800100"> |
|
64 |
<action-tool name="end-edit" /> |
|
65 |
</tool-bar> |
|
66 |
|
|
67 |
</extension> |
|
68 |
<extension |
|
44 | 69 |
class-name="org.gvsig.vectorediting.app.mainplugin.extensions.InsertPointExtension" |
45 | 70 |
description="" active="true" priority="1"> |
46 | 71 |
|
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/extensions/EditingExtension.java | ||
---|---|---|
28 | 28 |
FLyrVect layer = getActiveLayer(vista); |
29 | 29 |
|
30 | 30 |
if (canBeEdited(layer)) { |
31 |
try { |
|
32 | 31 |
swingManager.beginEdition(layer, vista.getMapControl()); |
33 | 32 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
34 |
} |
|
35 |
catch (DataException e) { |
|
36 |
// TODO Auto-generated catch block |
|
37 |
e.printStackTrace(); |
|
38 |
} |
|
39 | 33 |
} |
40 |
|
|
41 | 34 |
} |
42 | 35 |
} |
43 | 36 |
|
... | ... | |
54 | 47 |
DefaultViewPanel vista = getActiveView(); |
55 | 48 |
FLyrVect activeLayer = getActiveLayer(vista); |
56 | 49 |
|
57 |
return (canBeEdited(activeLayer) ? true : false);
|
|
50 |
return (canBeEdited(activeLayer)); |
|
58 | 51 |
|
59 | 52 |
} |
60 | 53 |
|
61 | 54 |
public boolean isVisible() { |
62 | 55 |
DefaultViewPanel vista = getActiveView(); |
63 |
return (vista != null) ? true : false; |
|
56 |
FLyrVect activeLayer = getActiveLayer(vista); |
|
57 |
|
|
58 |
return (vista != null && activeLayer !=null && !activeLayer.isEditing()); |
|
64 | 59 |
} |
65 | 60 |
|
66 | 61 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/extensions/SymmetryExtension.java | ||
---|---|---|
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
private void registerIcons() { |
35 |
IconThemeHelper.registerIcon("action", "symmetry", this); |
|
35 |
IconThemeHelper.registerIcon("action", "layer-modify-symmetry", this);
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
public boolean isEnabled() { |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/extensions/EndEditingExtension.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2014 DiSiD Technologies S.L.L. All rights reserved. |
|
3 |
* |
|
4 |
* Project : DiSiD org.gvsig.vectorediting.app.mainplugin |
|
5 |
* SVN Id : $Id$ |
|
6 |
*/ |
|
7 |
package org.gvsig.vectorediting.app.mainplugin.extensions; |
|
8 |
|
|
9 |
import org.gvsig.app.ApplicationLocator; |
|
10 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
11 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
12 |
import org.gvsig.vectorediting.app.mainplugin.BaseEditingServiceExtension; |
|
13 |
|
|
14 |
public class EndEditingExtension extends BaseEditingServiceExtension { |
|
15 |
|
|
16 |
public void initialize() { |
|
17 |
|
|
18 |
} |
|
19 |
|
|
20 |
public void execute(String actionCommand) { |
|
21 |
DefaultViewPanel vista = getActiveView(); |
|
22 |
|
|
23 |
if (vista != null) { |
|
24 |
FLyrVect layer = getActiveLayer(vista); |
|
25 |
|
|
26 |
if (layer != null && layer.isEditing()) { |
|
27 |
swingManager.endEdition(layer, vista.getMapControl()); |
|
28 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
|
29 |
} |
|
30 |
} |
|
31 |
|
|
32 |
} |
|
33 |
|
|
34 |
public boolean isEnabled() { |
|
35 |
DefaultViewPanel vista = getActiveView(); |
|
36 |
FLyrVect activeLayer = getActiveLayer(vista); |
|
37 |
if(activeLayer != null && activeLayer.isEditing()){ |
|
38 |
return activeLayer.isEditing(); |
|
39 |
} |
|
40 |
return false; |
|
41 |
|
|
42 |
} |
|
43 |
|
|
44 |
public boolean isVisible() { |
|
45 |
DefaultViewPanel vista = getActiveView(); |
|
46 |
FLyrVect activeLayer = getActiveLayer(vista); |
|
47 |
if(activeLayer != null && activeLayer.isEditing()){ |
|
48 |
return activeLayer.isEditing(); |
|
49 |
} |
|
50 |
return false; |
|
51 |
} |
|
52 |
|
|
53 |
} |
Also available in: Unified diff