svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / RedoViewExtension.java @ 44172
History | View | Annotate | Download (4.24 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40557 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40557 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40557 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40435 | jjdelcerro | *
|
21 | 40557 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | 42037 | fdiaz | package org.gvsig.app.extension; |
25 | 40435 | jjdelcerro | |
26 | 42037 | fdiaz | import org.gvsig.andami.IconThemeHelper; |
27 | 40435 | jjdelcerro | 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 | 42037 | fdiaz | IconThemeHelper.registerIcon("action", "edit-redo", this); |
52 | 40435 | jjdelcerro | } |
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 | } |