Revision 46039
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableCommandStackExtension.java | ||
---|---|---|
60 | 60 |
CommandStackDialog csd = new CommandStackDialog(); |
61 | 61 |
|
62 | 62 |
csd.setModel(featureStore); |
63 |
|
|
64 |
PluginServices.getMDIManager().addWindow(csd);
|
|
63 |
csd.setLabelModel(featureStore.getName()); |
|
64 |
PluginServices.getMDIManager().addWindow(csd);
|
|
65 | 65 |
} |
66 | 66 |
} |
67 | 67 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1311 | 1311 |
</extension> |
1312 | 1312 |
|
1313 | 1313 |
|
1314 |
<extension class-name="org.gvsig.app.extension.UndoViewExtension"
|
|
1315 |
description="Extensi?n encargada de deshacer la edici?n sobre la capa activa."
|
|
1316 |
active="true" > |
|
1314 |
<extension class-name="org.gvsig.app.extension.UndoRedoViewExtension"
|
|
1315 |
description="Extensi?n encargada de hacer/deshacer la edici?n sobre la capa activa y mostrar el hist?rico."
|
|
1316 |
active="true" >
|
|
1317 | 1317 |
|
1318 | 1318 |
<action |
1319 | 1319 |
name="edit-undo-layer" |
... | ... | |
1325 | 1325 |
accelerator="" |
1326 | 1326 |
/> |
1327 | 1327 |
|
1328 |
<menu |
|
1329 |
name="edit-undo-layer" |
|
1330 |
text="Edit/_Undo" |
|
1331 |
/> |
|
1332 |
|
|
1333 |
<tool-bar name="edit"> |
|
1334 |
<action-tool name="edit-undo-layer"/> |
|
1335 |
</tool-bar> |
|
1336 |
|
|
1337 |
</extension> |
|
1338 |
|
|
1339 |
<extension class-name="org.gvsig.app.extension.RedoViewExtension" |
|
1340 |
description="Extensi?n encargada de rehacer la edici?n sobre la capa activa." |
|
1341 |
active="true"> |
|
1342 |
|
|
1343 | 1328 |
<action |
1344 | 1329 |
name="edit-redo-layer" |
1345 | 1330 |
label="_Redo" |
... | ... | |
1350 | 1335 |
accelerator="" |
1351 | 1336 |
/> |
1352 | 1337 |
|
1353 |
<menu |
|
1354 |
name="edit-redo-layer" |
|
1355 |
text="Edit/_Redo" |
|
1356 |
/> |
|
1357 |
|
|
1358 |
<tool-bar name="edit"> |
|
1359 |
<action-tool name="edit-redo-layer"/> |
|
1360 |
</tool-bar> |
|
1361 |
|
|
1362 |
</extension> |
|
1363 |
|
|
1364 |
<extension class-name="org.gvsig.app.extension.ViewCommandStackExtension" |
|
1365 |
description="Extensi?n encargada de administrar la pila de comados de edici?n sobre una vista." |
|
1366 |
active="true"> |
|
1367 |
|
|
1368 |
<action |
|
1338 |
<action |
|
1369 | 1339 |
name="edit-undo-redo-actions-layer" |
1370 | 1340 |
label="_Undo_redo_history" |
1371 | 1341 |
tooltip="_Undo_redo_history" |
... | ... | |
1376 | 1346 |
/> |
1377 | 1347 |
|
1378 | 1348 |
<menu |
1349 |
name="edit-undo-layer" |
|
1350 |
text="Edit/_Undo" |
|
1351 |
/> |
|
1352 |
|
|
1353 |
<menu |
|
1354 |
name="edit-redo-layer" |
|
1355 |
text="Edit/_Redo" |
|
1356 |
/> |
|
1357 |
|
|
1358 |
<menu |
|
1379 | 1359 |
name="edit-undo-redo-actions-layer" |
1380 | 1360 |
text="Edit/_Undo_redo_history" |
1381 | 1361 |
/> |
1382 |
|
|
1362 |
|
|
1383 | 1363 |
<tool-bar name="edit"> |
1364 |
<action-tool name="edit-undo-layer"/> |
|
1365 |
<action-tool name="edit-redo-layer"/> |
|
1384 | 1366 |
<action-tool name="edit-undo-redo-actions-layer"/> |
1385 | 1367 |
</tool-bar> |
1386 |
|
|
1387 | 1368 |
</extension> |
1388 | 1369 |
|
1389 | 1370 |
|
... | ... | |
1420 | 1401 |
</tool-bar> |
1421 | 1402 |
</extension> |
1422 | 1403 |
|
1423 |
<!-- <extension class-name="org.gvsig.app.extension.clipboard.PasteFeaturesFromClipboardExtension" |
|
1424 |
description="Paste features from system clipboard into editing layer" |
|
1425 |
active="true"> |
|
1426 |
|
|
1427 |
<action |
|
1428 |
name="layer-modify-clipboard-paste" |
|
1429 |
label="_Paste_features_from_clipboard" |
|
1430 |
tooltip="_Paste_features_from_clipboard" |
|
1431 |
position="601105100" |
|
1432 |
action-command="layer-modify-clipboard-paste" |
|
1433 |
icon="layer-modify-clipboard-paste" |
|
1434 |
accelerator="" |
|
1435 |
/> |
|
1436 |
|
|
1437 |
<menu |
|
1438 |
name="layer-modify-clipboard-paste" |
|
1439 |
text="Layer/Modify/_Paste_features_from_clipboard" |
|
1440 |
/> |
|
1441 |
|
|
1442 |
<tool-bar name="edit"> |
|
1443 |
<action-tool |
|
1444 |
name="layer-modify-clipboard-paste" |
|
1445 |
/> |
|
1446 |
</tool-bar> |
|
1447 |
</extension>--> |
|
1448 | 1404 |
<extension class-name="org.gvsig.app.extension.clipboard.PasteAlphanumericValuesFromClipboardExtension" |
1449 | 1405 |
description="Paste alphanumeric values from system clipboard into editing feature" |
1450 | 1406 |
active="true"> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/RedoViewExtension.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.app.extension; |
|
25 |
|
|
26 |
import org.gvsig.andami.IconThemeHelper; |
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.messages.NotificationManager; |
|
29 |
import org.gvsig.andami.plugins.Extension; |
|
30 |
import org.gvsig.app.ApplicationLocator; |
|
31 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
33 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
35 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
36 |
import org.gvsig.tools.undo.RedoException; |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* Extensi?n encargada de gestionar el rehacer un comando anteriormente |
|
42 |
* deshecho. |
|
43 |
* |
|
44 |
* @author Vicente Caballero Navarro |
|
45 |
*/ |
|
46 |
public class RedoViewExtension extends Extension { |
|
47 |
/** |
|
48 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
49 |
*/ |
|
50 |
public void initialize() { |
|
51 |
IconThemeHelper.registerIcon("action", "edit-redo", this); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
56 |
*/ |
|
57 |
public void execute(String s) { |
|
58 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
59 |
MapControl mapControl = vista.getMapControl(); |
|
60 |
|
|
61 |
if (s.compareTo("edit-redo-layer") == 0) { |
|
62 |
try { |
|
63 |
FLayers layers=mapControl.getMapContext().getLayers(); |
|
64 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
65 |
if (layers.getLayer(i) instanceof FLyrVect && layers.getLayer(i).isEditing() && layers.getLayer(i).isActive()){ |
|
66 |
((FLyrVect)layers.getLayer(i)).getFeatureStore().redo(); |
|
67 |
mapControl.drawMap(false); |
|
68 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
} catch (RedoException e) { |
|
73 |
NotificationManager.addError(e.getMessage(),e); |
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
80 |
*/ |
|
81 |
public boolean isEnabled() { |
|
82 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
83 |
MapControl mapControl = vista.getMapControl(); |
|
84 |
FLayers layers=mapControl.getMapContext().getLayers(); |
|
85 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
86 |
// try { |
|
87 |
if (layers.getLayer(i) instanceof FLyrVect && ((FLyrVect)layers.getLayer(i)).getFeatureStore().isEditing() && layers.getLayer(i).isActive()){ |
|
88 |
return ((FLyrVect)layers.getLayer(i)).getFeatureStore().canRedo(); |
|
89 |
} |
|
90 |
// } catch (ReadException e) { |
|
91 |
// // TODO Auto-generated catch block |
|
92 |
// e.printStackTrace(); |
|
93 |
// } catch (DataException e) { |
|
94 |
// // TODO Auto-generated catch block |
|
95 |
// e.printStackTrace(); |
|
96 |
// } |
|
97 |
|
|
98 |
} |
|
99 |
return false; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
104 |
*/ |
|
105 |
public boolean isVisible() { |
|
106 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
107 |
.getActiveWindow(); |
|
108 |
|
|
109 |
if (f == null) { |
|
110 |
return false; |
|
111 |
} |
|
112 |
|
|
113 |
if (f instanceof DefaultViewPanel) { |
|
114 |
MapControl mapControl = ((DefaultViewPanel)f).getMapControl(); |
|
115 |
FLayer[] layers=mapControl.getMapContext().getLayers().getActives(); |
|
116 |
FLayer layer; |
|
117 |
for (int i=0;i<layers.length;i++){ |
|
118 |
layer = layers[i]; |
|
119 |
if (!layer.isAvailable()){ |
|
120 |
continue; |
|
121 |
} |
|
122 |
// try { |
|
123 |
if (layer instanceof FLyrVect && ((FLyrVect)layer).getFeatureStore().isEditing()){ |
|
124 |
return true; |
|
125 |
} |
|
126 |
// } catch (ReadException e) { |
|
127 |
// // TODO Auto-generated catch block |
|
128 |
// e.printStackTrace(); |
|
129 |
// } |
|
130 |
} |
|
131 |
} |
|
132 |
return false; |
|
133 |
} |
|
134 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewCommandStackExtension.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.app.extension; |
|
25 |
|
|
26 |
import org.gvsig.andami.IconThemeHelper; |
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.plugins.Extension; |
|
29 |
import org.gvsig.app.gui.command.CommandStackDialog; |
|
30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
31 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
33 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
35 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
36 |
import org.gvsig.fmap.mapcontext.layers.LayersIterator; |
|
37 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* DOCUMENT ME! |
|
42 |
* |
|
43 |
* @author Vicente Caballero Navarro |
|
44 |
*/ |
|
45 |
public class ViewCommandStackExtension extends Extension { |
|
46 |
|
|
47 |
public static CommandStackDialog csd=null; |
|
48 |
/** |
|
49 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
50 |
*/ |
|
51 |
public void initialize() { |
|
52 |
IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
57 |
*/ |
|
58 |
public void execute(String s) { |
|
59 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
60 |
.getActiveWindow(); |
|
61 |
|
|
62 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
|
63 |
ViewDocument model = vista.getModel(); |
|
64 |
MapContext mapa = model.getMapContext(); |
|
65 |
FLayers layers = mapa.getLayers(); |
|
66 |
if (s.equals("edit-undo-redo-actions-layer")) { |
|
67 |
for (int i =0;i<layers.getLayersCount();i++){ |
|
68 |
if (layers.getLayer(i) instanceof FLyrVect){ |
|
69 |
FLyrVect lyrVect=(FLyrVect)layers.getLayer(i); |
|
70 |
if (lyrVect.isEditing() && lyrVect.isActive()){ |
|
71 |
FeatureStore featureStore=lyrVect.getFeatureStore(); |
|
72 |
csd=new CommandStackDialog(); |
|
73 |
csd.setModel(featureStore); |
|
74 |
PluginServices.getMDIManager().addWindow(csd); |
|
75 |
return; |
|
76 |
} |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
85 |
*/ |
|
86 |
public boolean isEnabled() { |
|
87 |
|
|
88 |
return true; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
93 |
*/ |
|
94 |
public boolean isVisible() { |
|
95 |
|
|
96 |
org.gvsig.andami.ui.mdiManager.IWindow f = |
|
97 |
PluginServices.getMDIManager().getActiveWindow(); |
|
98 |
if (f == null) { |
|
99 |
return false; |
|
100 |
} |
|
101 |
|
|
102 |
if (f instanceof DefaultViewPanel) { |
|
103 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
|
104 |
ViewDocument model = vista.getViewDocument(); |
|
105 |
MapContext mapa = model.getMapContext(); |
|
106 |
|
|
107 |
FLayers capas = mapa.getLayers(); |
|
108 |
|
|
109 |
int numActiveVectorial = 0; |
|
110 |
int numActiveVectorialEditable = 0; |
|
111 |
|
|
112 |
LayersIterator iter = new LayersIterator(capas); |
|
113 |
|
|
114 |
FLayer capa; |
|
115 |
while (iter.hasNext()) { |
|
116 |
capa = iter.nextLayer(); |
|
117 |
if (capa instanceof FLyrVect && capa.isActive() |
|
118 |
&& capa.isAvailable()) { |
|
119 |
numActiveVectorial++; |
|
120 |
if (capa.isEditing()) |
|
121 |
numActiveVectorialEditable++; |
|
122 |
} |
|
123 |
|
|
124 |
} |
|
125 |
|
|
126 |
if (numActiveVectorialEditable == 1 && numActiveVectorial == 1) { |
|
127 |
return true; |
|
128 |
} |
|
129 |
} |
|
130 |
return false; |
|
131 |
} |
|
132 |
|
|
133 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/UndoViewExtension.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.app.extension; |
|
25 |
|
|
26 |
import org.gvsig.andami.IconThemeHelper; |
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.messages.NotificationManager; |
|
29 |
import org.gvsig.andami.plugins.Extension; |
|
30 |
import org.gvsig.app.ApplicationLocator; |
|
31 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
33 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
35 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
36 |
import org.gvsig.tools.undo.UndoException; |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* Extensi?n encargada de gestionar el deshacer los comandos anteriormente |
|
42 |
* aplicados. |
|
43 |
* |
|
44 |
* @author Vicente Caballero Navarro |
|
45 |
*/ |
|
46 |
public class UndoViewExtension extends Extension { |
|
47 |
/** |
|
48 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
49 |
*/ |
|
50 |
public void initialize() { |
|
51 |
IconThemeHelper.registerIcon("action", "edit-undo", this); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
56 |
*/ |
|
57 |
public void execute(String s) { |
|
58 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
59 |
|
|
60 |
|
|
61 |
if (s.compareTo("edit-undo-layer") == 0) { |
|
62 |
undo(vista); |
|
63 |
|
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
private void undo(DefaultViewPanel vista) { |
|
68 |
MapControl mapControl = vista.getMapControl(); |
|
69 |
try { |
|
70 |
FLayers layers=mapControl.getMapContext().getLayers(); |
|
71 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
72 |
if (layers.getLayer(i) instanceof FLyrVect && layers.getLayer(i).isEditing() && layers.getLayer(i).isActive()){ |
|
73 |
((FLyrVect)layers.getLayer(i)).getFeatureStore().undo(); |
|
74 |
mapControl.drawMap(false); |
|
75 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
|
76 |
} |
|
77 |
} |
|
78 |
} catch (UndoException e) { |
|
79 |
NotificationManager.addError(e.getMessage(),e); |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
86 |
*/ |
|
87 |
public boolean isEnabled() { |
|
88 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
89 |
MapControl mapControl = vista.getMapControl(); |
|
90 |
FLayers layers=mapControl.getMapContext().getLayers(); |
|
91 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
92 |
// try { |
|
93 |
if (layers.getLayer(i) instanceof FLyrVect && ((FLyrVect)layers.getLayer(i)).getFeatureStore().isEditing() && layers.getLayer(i).isActive()){ |
|
94 |
return ((FLyrVect)layers.getLayer(i)).getFeatureStore().canUndo(); |
|
95 |
// VectorialEditableAdapter vea=(VectorialEditableAdapter)((FLyrVect)layers.getLayer(i)).getSource(); |
|
96 |
// if (vea==null)return false; |
|
97 |
// return vea.getCommandRecord().moreUndoCommands(); |
|
98 |
} |
|
99 |
// } catch (ReadException e) { |
|
100 |
// // TODO Auto-generated catch block |
|
101 |
// e.printStackTrace(); |
|
102 |
// } catch (DataException e) { |
|
103 |
// // TODO Auto-generated catch block |
|
104 |
// e.printStackTrace(); |
|
105 |
// } |
|
106 |
|
|
107 |
} |
|
108 |
return false; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
113 |
*/ |
|
114 |
public boolean isVisible() { |
|
115 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
116 |
.getActiveWindow(); |
|
117 |
|
|
118 |
if (f == null) { |
|
119 |
return false; |
|
120 |
} |
|
121 |
|
|
122 |
if (f instanceof DefaultViewPanel) { |
|
123 |
MapControl mapControl = ((DefaultViewPanel)f).getMapControl(); |
|
124 |
FLayer[] layers=mapControl.getMapContext().getLayers().getActives(); |
|
125 |
FLayer layer; |
|
126 |
for (int i=0;i<layers.length;i++){ |
|
127 |
layer = layers[i]; |
|
128 |
if (!layer.isAvailable()){ |
|
129 |
continue; |
|
130 |
} |
|
131 |
// try { |
|
132 |
if (layer instanceof FLyrVect && ((FLyrVect)layer).getFeatureStore().isEditing()){ |
|
133 |
return true; |
|
134 |
} |
|
135 |
// } catch (ReadException e) { |
|
136 |
// // TODO Auto-generated catch block |
|
137 |
// e.printStackTrace(); |
|
138 |
// } |
|
139 |
} |
|
140 |
} |
|
141 |
return false; |
|
142 |
} |
|
143 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/UndoRedoViewExtension.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.app.extension; |
|
25 |
|
|
26 |
import org.gvsig.andami.IconThemeHelper; |
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.plugins.Extension; |
|
29 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
|
30 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
|
31 |
import org.gvsig.app.ApplicationLocator; |
|
32 |
import org.gvsig.app.ApplicationManager; |
|
33 |
import org.gvsig.app.gui.command.CommandStackDialog; |
|
34 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
36 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
37 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
38 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
39 |
import org.gvsig.tools.undo.RedoException; |
|
40 |
import org.gvsig.tools.undo.UndoException; |
|
41 |
|
|
42 |
/** |
|
43 |
* Extensi?n encargada de gestionar el deshacer los comandos anteriormente |
|
44 |
* aplicados. |
|
45 |
* |
|
46 |
* @author Vicente Caballero Navarro |
|
47 |
*/ |
|
48 |
public class UndoRedoViewExtension extends Extension { |
|
49 |
|
|
50 |
@Override |
|
51 |
public void initialize() { |
|
52 |
IconThemeHelper.registerIcon("action", "edit-undo", this); |
|
53 |
IconThemeHelper.registerIcon("action", "edit-redo", this); |
|
54 |
IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public void execute(String s) { |
|
59 |
switch (s) { |
|
60 |
case "edit-undo-layer": |
|
61 |
undo(); |
|
62 |
break; |
|
63 |
case "edit-redo-layer": |
|
64 |
redo(); |
|
65 |
break; |
|
66 |
case "edit-undo-redo-actions-layer": |
|
67 |
showHistory(); |
|
68 |
break; |
|
69 |
|
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
private void undo() { |
|
74 |
try { |
|
75 |
FLyrVect layer = getActiveAndEditingLayer(); |
|
76 |
if (layer == null) { |
|
77 |
return; |
|
78 |
} |
|
79 |
if (!layer.getFeatureStore().canUndo()) { |
|
80 |
return; |
|
81 |
} |
|
82 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
83 |
IView vista = (IView) application.getActiveWindow(); |
|
84 |
layer.getFeatureStore().undo(); |
|
85 |
vista.getMapControl().drawMap(false); |
|
86 |
application.refreshMenusAndToolBars(); |
|
87 |
} catch (UndoException ex) { |
|
88 |
logger.warn("Can't undo", ex); |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
private void showHistory() { |
|
93 |
FLyrVect layer = getActiveAndEditingLayer(); |
|
94 |
if (layer == null) { |
|
95 |
return; |
|
96 |
} |
|
97 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
98 |
MDIManager uiManager = application.getUIManager(); |
|
99 |
FeatureStore featureStore = layer.getFeatureStore(); |
|
100 |
CommandStackDialog csd = new CommandStackDialog(); |
|
101 |
csd.setModel(featureStore); |
|
102 |
csd.setLabelModel(featureStore.getName()); |
|
103 |
uiManager.addWindow(csd); |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
private void redo() { |
|
108 |
try { |
|
109 |
FLyrVect layer = getActiveAndEditingLayer(); |
|
110 |
if (layer == null) { |
|
111 |
return; |
|
112 |
} |
|
113 |
if (!layer.getFeatureStore().canRedo()) { |
|
114 |
return; |
|
115 |
} |
|
116 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
117 |
IView vista = (IView) application.getActiveWindow(); |
|
118 |
layer.getFeatureStore().redo(); |
|
119 |
vista.getMapControl().drawMap(false); |
|
120 |
application.refreshMenusAndToolBars(); |
|
121 |
} catch (RedoException ex) { |
|
122 |
logger.warn("Can't undo", ex); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public boolean canQueryByAction() { |
|
128 |
return true; |
|
129 |
} |
|
130 |
|
|
131 |
|
|
132 |
@Override |
|
133 |
public boolean isEnabled(String action) { |
|
134 |
FLyrVect layer = getActiveAndEditingLayer(); |
|
135 |
switch (action) { |
|
136 |
case "edit-undo-layer": |
|
137 |
if (layer == null) { |
|
138 |
return false; |
|
139 |
} |
|
140 |
return layer.getFeatureStore().canUndo(); |
|
141 |
case "edit-redo-layer": |
|
142 |
if (layer == null) { |
|
143 |
return false; |
|
144 |
} |
|
145 |
return layer.getFeatureStore().canRedo(); |
|
146 |
case "edit-undo-redo-actions-layer": |
|
147 |
return true; |
|
148 |
default: |
|
149 |
return false; |
|
150 |
} |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
private FLyrVect getActiveAndEditingLayer() { |
|
155 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
156 |
IView vista = (IView) application.getActiveWindow(); |
|
157 |
MapControl mapControl = vista.getMapControl(); |
|
158 |
FLayer[] activeLayers = mapControl.getMapContext().getLayers().getActives(); |
|
159 |
if (activeLayers.length != 1) { |
|
160 |
return null; |
|
161 |
} |
|
162 |
FLayer layer = activeLayers[0]; |
|
163 |
if (layer instanceof FLyrVect && ((FLyrVect) layer).getFeatureStore().isEditing()) { |
|
164 |
return (FLyrVect) layer; |
|
165 |
} |
|
166 |
return null; |
|
167 |
|
|
168 |
} |
|
169 |
|
|
170 |
@Override |
|
171 |
public boolean isVisible(String action) { |
|
172 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
173 |
if(!(application.getActiveWindow() instanceof IView)) { |
|
174 |
return false; |
|
175 |
} |
|
176 |
|
|
177 |
return getActiveAndEditingLayer()!=null; |
|
178 |
} |
|
179 |
|
|
180 |
@Override |
|
181 |
public boolean isEnabled() { |
|
182 |
return true; |
|
183 |
} |
|
184 |
|
|
185 |
@Override |
|
186 |
public boolean isVisible() { |
|
187 |
return true; |
|
188 |
} |
|
189 |
} |
|
0 | 190 |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/command/CommandStackDialog.java | ||
---|---|---|
39 | 39 |
import javax.swing.SwingUtilities; |
40 | 40 |
import javax.swing.table.DefaultTableCellRenderer; |
41 | 41 |
import javax.swing.table.TableColumn; |
42 |
import org.apache.commons.lang3.StringUtils; |
|
42 | 43 |
|
43 | 44 |
import org.gvsig.andami.IconThemeHelper; |
44 | 45 |
import org.gvsig.andami.PluginServices; |
... | ... | |
51 | 52 |
import org.gvsig.app.project.documents.view.ViewManager; |
52 | 53 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
53 | 54 |
import org.gvsig.gui.beans.DefaultBean; |
55 |
import org.gvsig.tools.ToolsLocator; |
|
56 |
import org.gvsig.tools.i18n.I18nManager; |
|
54 | 57 |
import org.gvsig.tools.observer.Observable; |
55 | 58 |
import org.gvsig.tools.observer.Observer; |
56 | 59 |
import org.gvsig.tools.undo.UndoRedoInfo; |
... | ... | |
79 | 82 |
private static final ImageIcon idel = IconThemeHelper.getImageIcon("edit-undo-redo-actions-delete"); |
80 | 83 |
|
81 | 84 |
private CommandTableModel commandTableModel = null; |
85 |
private String labelModel; |
|
82 | 86 |
/** |
83 | 87 |
* This is the default constructor |
84 | 88 |
*/ |
... | ... | |
193 | 197 |
public WindowInfo getWindowInfo() { |
194 | 198 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.ICONIFIABLE | |
195 | 199 |
WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.PALETTE); |
196 |
m_viewinfo.setTitle(PluginServices.getText(this, |
|
197 |
"pila_de_comandos")); |
|
200 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
201 |
if(StringUtils.isBlank(this.labelModel)){ |
|
202 |
m_viewinfo.setTitle(i18n.getTranslation("pila_de_comandos")); |
|
203 |
} else { |
|
204 |
m_viewinfo.setTitle( |
|
205 |
i18n.getTranslation("pila_de_comandos")+ |
|
206 |
" - "+this.labelModel |
|
207 |
); |
|
208 |
} |
|
198 | 209 |
return m_viewinfo; |
199 | 210 |
} |
200 | 211 |
|
201 | 212 |
public Object getWindowModel() { |
202 |
return commandTableModel.getClass().getName();
|
|
213 |
return this.undoRedoStack;
|
|
203 | 214 |
} |
204 | 215 |
|
205 | 216 |
public void windowActivated() { |
... | ... | |
419 | 430 |
public Object getWindowProfile() { |
420 | 431 |
return WindowInfo.DIALOG_PROFILE; |
421 | 432 |
} |
433 |
|
|
434 |
public void setLabelModel (String labelModel) { |
|
435 |
this.labelModel = labelModel; |
|
436 |
} |
|
422 | 437 |
} |
Also available in: Unified diff