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 / ViewCommandStackExtension.java @ 44437
History | View | Annotate | Download (4.07 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
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 | 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.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 | 42037 | fdiaz | import org.gvsig.fmap.mapcontext.layers.FLayer; |
35 | 40435 | jjdelcerro | import org.gvsig.fmap.mapcontext.layers.FLayers; |
36 | 42037 | fdiaz | import org.gvsig.fmap.mapcontext.layers.LayersIterator; |
37 | 40435 | jjdelcerro | 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 | 42037 | fdiaz | IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this); |
53 | 40435 | jjdelcerro | } |
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 | 42037 | fdiaz | public boolean isVisible() { |
95 | 40435 | jjdelcerro | |
96 | 42037 | fdiaz | org.gvsig.andami.ui.mdiManager.IWindow f = |
97 | PluginServices.getMDIManager().getActiveWindow(); |
||
98 | if (f == null) { |
||
99 | return false; |
||
100 | } |
||
101 | 40435 | jjdelcerro | |
102 | 42037 | fdiaz | if (f instanceof DefaultViewPanel) { |
103 | DefaultViewPanel vista = (DefaultViewPanel) f; |
||
104 | ViewDocument model = vista.getViewDocument(); |
||
105 | MapContext mapa = model.getMapContext(); |
||
106 | 40435 | jjdelcerro | |
107 | 42037 | fdiaz | 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 | 40435 | jjdelcerro | } |