svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / RedoViewExtension.java @ 40557
History | View | Annotate | Download (4.12 KB)
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.editing; |
25 |
|
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.andami.messages.NotificationManager; |
28 |
import org.gvsig.andami.plugins.Extension; |
29 |
import org.gvsig.app.ApplicationLocator; |
30 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
32 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
33 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
34 |
import org.gvsig.fmap.mapcontrol.MapControl; |
35 |
import org.gvsig.tools.undo.RedoException; |
36 |
|
37 |
|
38 |
|
39 |
/**
|
40 |
* Extensi?n encargada de gestionar el rehacer un comando anteriormente
|
41 |
* deshecho.
|
42 |
*
|
43 |
* @author Vicente Caballero Navarro
|
44 |
*/
|
45 |
public class RedoViewExtension extends Extension { |
46 |
/**
|
47 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
48 |
*/
|
49 |
public void initialize() { |
50 |
} |
51 |
|
52 |
/**
|
53 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
54 |
*/
|
55 |
public void execute(String s) { |
56 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
57 |
MapControl mapControl = vista.getMapControl(); |
58 |
|
59 |
if (s.compareTo("edit-redo-layer") == 0) { |
60 |
try {
|
61 |
FLayers layers=mapControl.getMapContext().getLayers(); |
62 |
for (int i=0;i<layers.getLayersCount();i++){ |
63 |
if (layers.getLayer(i) instanceof FLyrVect && layers.getLayer(i).isEditing() && layers.getLayer(i).isActive()){ |
64 |
((FLyrVect)layers.getLayer(i)).getFeatureStore().redo(); |
65 |
mapControl.drawMap(false);
|
66 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
67 |
} |
68 |
|
69 |
} |
70 |
} catch (RedoException e) {
|
71 |
NotificationManager.addError(e.getMessage(),e); |
72 |
} |
73 |
} |
74 |
} |
75 |
|
76 |
/**
|
77 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
78 |
*/
|
79 |
public boolean isEnabled() { |
80 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
81 |
MapControl mapControl = vista.getMapControl(); |
82 |
FLayers layers=mapControl.getMapContext().getLayers(); |
83 |
for (int i=0;i<layers.getLayersCount();i++){ |
84 |
// try {
|
85 |
if (layers.getLayer(i) instanceof FLyrVect && ((FLyrVect)layers.getLayer(i)).getFeatureStore().isEditing() && layers.getLayer(i).isActive()){ |
86 |
return ((FLyrVect)layers.getLayer(i)).getFeatureStore().canRedo();
|
87 |
} |
88 |
// } catch (ReadException e) {
|
89 |
// // TODO Auto-generated catch block
|
90 |
// e.printStackTrace();
|
91 |
// } catch (DataException e) {
|
92 |
// // TODO Auto-generated catch block
|
93 |
// e.printStackTrace();
|
94 |
// }
|
95 |
|
96 |
} |
97 |
return false; |
98 |
} |
99 |
|
100 |
/**
|
101 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
102 |
*/
|
103 |
public boolean isVisible() { |
104 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
105 |
.getActiveWindow(); |
106 |
|
107 |
if (f == null) { |
108 |
return false; |
109 |
} |
110 |
|
111 |
if (f instanceof DefaultViewPanel) { |
112 |
MapControl mapControl = ((DefaultViewPanel)f).getMapControl(); |
113 |
FLayer[] layers=mapControl.getMapContext().getLayers().getActives();
|
114 |
FLayer layer; |
115 |
for (int i=0;i<layers.length;i++){ |
116 |
layer = layers[i]; |
117 |
if (!layer.isAvailable()){
|
118 |
continue;
|
119 |
} |
120 |
// try {
|
121 |
if (layer instanceof FLyrVect && ((FLyrVect)layer).getFeatureStore().isEditing()){ |
122 |
return true; |
123 |
} |
124 |
// } catch (ReadException e) {
|
125 |
// // TODO Auto-generated catch block
|
126 |
// e.printStackTrace();
|
127 |
// }
|
128 |
} |
129 |
} |
130 |
return false; |
131 |
} |
132 |
} |