root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / RedoViewExtension.java @ 38564
History | View | Annotate | Download (4.27 KB)
1 | 4024 | caballero | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 29616 | jpiera | package org.gvsig.editing; |
42 | 4024 | caballero | |
43 | 29616 | jpiera | import org.gvsig.andami.PluginServices; |
44 | import org.gvsig.andami.messages.NotificationManager; |
||
45 | import org.gvsig.andami.plugins.Extension; |
||
46 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
47 | 26215 | jmvivo | import org.gvsig.fmap.mapcontext.layers.FLayer; |
48 | 21666 | vcaballero | import org.gvsig.fmap.mapcontext.layers.FLayers; |
49 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
50 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
51 | 25069 | vcaballero | import org.gvsig.tools.undo.RedoException; |
52 | 21666 | vcaballero | |
53 | 4024 | caballero | |
54 | |||
55 | /**
|
||
56 | * Extensi?n encargada de gestionar el rehacer un comando anteriormente
|
||
57 | * deshecho.
|
||
58 | *
|
||
59 | * @author Vicente Caballero Navarro
|
||
60 | */
|
||
61 | 5005 | jorpiell | public class RedoViewExtension extends Extension { |
62 | 4024 | caballero | /**
|
63 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#initialize()
|
64 | 4024 | caballero | */
|
65 | 5005 | jorpiell | public void initialize() { |
66 | 4024 | caballero | } |
67 | |||
68 | /**
|
||
69 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
70 | 4024 | caballero | */
|
71 | public void execute(String s) { |
||
72 | 31496 | jjdelcerro | DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
73 | 6604 | caballero | MapControl mapControl = vista.getMapControl(); |
74 | 4024 | caballero | |
75 | 38564 | jjdelcerro | if (s.compareTo("edit-redo-layer") == 0) { |
76 | 4024 | caballero | try {
|
77 | FLayers layers=mapControl.getMapContext().getLayers(); |
||
78 | for (int i=0;i<layers.getLayersCount();i++){ |
||
79 | 4058 | caballero | if (layers.getLayer(i) instanceof FLyrVect && layers.getLayer(i).isEditing() && layers.getLayer(i).isActive()){ |
80 | 24429 | vcaballero | ((FLyrVect)layers.getLayer(i)).getFeatureStore().redo(); |
81 | 23535 | vcaballero | mapControl.drawMap(false);
|
82 | 4024 | caballero | } |
83 | |||
84 | } |
||
85 | 25069 | vcaballero | } catch (RedoException e) {
|
86 | NotificationManager.addError(e.getMessage(),e); |
||
87 | 4024 | caballero | } |
88 | } |
||
89 | } |
||
90 | |||
91 | /**
|
||
92 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
93 | 4024 | caballero | */
|
94 | public boolean isEnabled() { |
||
95 | 31496 | jjdelcerro | DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
96 | 6604 | caballero | MapControl mapControl = vista.getMapControl(); |
97 | 4024 | caballero | FLayers layers=mapControl.getMapContext().getLayers(); |
98 | for (int i=0;i<layers.getLayersCount();i++){ |
||
99 | 30050 | cordinyana | // try {
|
100 | 22986 | vcaballero | if (layers.getLayer(i) instanceof FLyrVect && ((FLyrVect)layers.getLayer(i)).getFeatureStore().isEditing() && layers.getLayer(i).isActive()){ |
101 | 25069 | vcaballero | return ((FLyrVect)layers.getLayer(i)).getFeatureStore().canRedo();
|
102 | 22986 | vcaballero | } |
103 | 30050 | cordinyana | // } catch (ReadException e) {
|
104 | // // TODO Auto-generated catch block
|
||
105 | // e.printStackTrace();
|
||
106 | // } catch (DataException e) {
|
||
107 | // // TODO Auto-generated catch block
|
||
108 | // e.printStackTrace();
|
||
109 | // }
|
||
110 | 4024 | caballero | |
111 | } |
||
112 | return false; |
||
113 | } |
||
114 | |||
115 | /**
|
||
116 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#isVisible()
|
117 | 4024 | caballero | */
|
118 | public boolean isVisible() { |
||
119 | 29616 | jpiera | org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
120 | 6880 | cesar | .getActiveWindow(); |
121 | 4024 | caballero | |
122 | if (f == null) { |
||
123 | return false; |
||
124 | } |
||
125 | |||
126 | 31496 | jjdelcerro | if (f instanceof DefaultViewPanel) { |
127 | MapControl mapControl = ((DefaultViewPanel)f).getMapControl(); |
||
128 | 26215 | jmvivo | FLayer[] layers=mapControl.getMapContext().getLayers().getActives();
|
129 | FLayer layer; |
||
130 | for (int i=0;i<layers.length;i++){ |
||
131 | layer = layers[i]; |
||
132 | if (!layer.isAvailable()){
|
||
133 | continue;
|
||
134 | } |
||
135 | 30050 | cordinyana | // try {
|
136 | 26215 | jmvivo | if (layer instanceof FLyrVect && ((FLyrVect)layer).getFeatureStore().isEditing()){ |
137 | 22986 | vcaballero | return true; |
138 | } |
||
139 | 30050 | cordinyana | // } catch (ReadException e) {
|
140 | // // TODO Auto-generated catch block
|
||
141 | // e.printStackTrace();
|
||
142 | // }
|
||
143 | 6604 | caballero | } |
144 | 4024 | caballero | } |
145 | 6604 | caballero | return false; |
146 | 4024 | caballero | } |
147 | } |