Revision 41264
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/SelectAllExtension.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.selectiontools.app.extension; |
25 | 25 |
|
26 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
27 |
* |
|
28 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
29 |
* of the Valencian Government (CIT) |
|
30 |
* |
|
31 |
* This program is free software; you can redistribute it and/or |
|
32 |
* modify it under the terms of the GNU General Public License |
|
33 |
* as published by the Free Software Foundation; either version 2 |
|
34 |
* of the License, or (at your option) any later version. |
|
35 |
* |
|
36 |
* This program is distributed in the hope that it will be useful, |
|
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
39 |
* GNU General Public License for more details. |
|
40 |
* |
|
41 |
* You should have received a copy of the GNU General Public License |
|
42 |
* along with this program; if not, write to the Free Software |
|
43 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
44 |
* MA 02110-1301, USA. |
|
45 |
* |
|
46 |
*/ |
|
47 |
|
|
48 | 26 |
import org.gvsig.andami.IconThemeHelper; |
49 | 27 |
import org.gvsig.andami.PluginServices; |
50 | 28 |
import org.gvsig.andami.messages.NotificationManager; |
51 | 29 |
import org.gvsig.andami.plugins.Extension; |
52 | 30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 |
import org.gvsig.app.ApplicationLocator; |
|
32 |
import org.gvsig.app.ApplicationManager; |
|
53 | 33 |
import org.gvsig.app.project.documents.view.ViewDocument; |
54 | 34 |
import org.gvsig.app.project.documents.view.gui.IView; |
55 | 35 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
60 | 40 |
import org.gvsig.fmap.mapcontrol.MapControl; |
61 | 41 |
|
62 | 42 |
/** |
63 |
* <p> |
|
64 | 43 |
* Extension to add support for selecting all the features of a vector layer. |
65 |
* </p> |
|
66 | 44 |
* |
67 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
68 | 45 |
*/ |
69 | 46 |
public class SelectAllExtension extends Extension { |
70 | 47 |
|
71 |
/* |
|
72 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
73 |
*/ |
|
74 | 48 |
public void initialize() { |
75 | 49 |
IconThemeHelper.registerIcon("action", "selection-select-all", this); |
76 | 50 |
} |
77 | 51 |
|
78 |
/* |
|
79 |
* (non-Javadoc) |
|
80 |
* |
|
81 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
82 |
*/ |
|
83 | 52 |
public void execute(String actionCommand) { |
84 | 53 |
if (actionCommand.equals("SELALL")) { |
85 | 54 |
IWindow view = PluginServices.getMDIManager().getActiveWindow(); |
... | ... | |
109 | 78 |
} |
110 | 79 |
} |
111 | 80 |
|
112 |
/* |
|
113 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
114 |
*/ |
|
115 | 81 |
public boolean isVisible() { |
116 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
82 |
ApplicationManager application = ApplicationLocator.getManager();
|
|
117 | 83 |
|
118 |
if (f == null) { |
|
84 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
85 |
if (view == null) { |
|
119 | 86 |
return false; |
120 | 87 |
} |
121 |
|
|
122 |
if (f instanceof IView) { |
|
123 |
IView vista = (IView) f; |
|
124 |
ViewDocument viewDocument = vista.getViewDocument(); // .getModel(); |
|
125 |
MapContext mapa = viewDocument.getMapContext(); |
|
126 |
|
|
127 |
return mapa.getLayers().getLayersCount() > 0; |
|
128 |
} |
|
129 |
|
|
130 |
return false; |
|
88 |
ViewDocument document = view.getViewDocument(); |
|
89 |
MapContext mapa = document.getMapContext(); |
|
90 |
return mapa.getLayers().getLayersCount() > 0; |
|
131 | 91 |
} |
132 | 92 |
|
133 |
/* |
|
134 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
135 |
*/ |
|
136 | 93 |
public boolean isEnabled() { |
137 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
94 |
ApplicationManager application = ApplicationLocator.getManager();
|
|
138 | 95 |
|
139 |
if (f == null) { |
|
96 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
97 |
if (view == null) { |
|
140 | 98 |
return false; |
141 | 99 |
} |
142 |
|
|
143 |
if (f instanceof IView) { |
|
144 |
IView vista = (IView) f; |
|
145 |
ViewDocument viewDocument = vista.getViewDocument(); |
|
146 |
MapContext mapa = viewDocument.getMapContext(); |
|
147 |
|
|
148 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
149 |
FLayer layer; |
|
150 |
|
|
151 |
for (int i = 0; i < layers.length; i++) { |
|
152 |
layer = layers[i]; |
|
153 |
|
|
154 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
155 |
&& (layer.isActive())) |
|
156 |
return true; |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
return false; |
|
100 |
ViewDocument document = view.getViewDocument(); |
|
101 |
return document.getMapContext().hasActiveVectorLayers(); |
|
161 | 102 |
} |
162 | 103 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/SelectByCircleExtension.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.selectiontools.app.extension; |
25 | 24 |
|
26 | 25 |
import org.gvsig.andami.IconThemeHelper; |
27 |
import org.gvsig.andami.PluginServices; |
|
28 | 26 |
import org.gvsig.andami.plugins.Extension; |
29 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
27 |
import org.gvsig.app.ApplicationLocator; |
|
28 |
import org.gvsig.app.ApplicationManager; |
|
30 | 29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
31 | 30 |
import org.gvsig.app.project.documents.view.gui.IView; |
32 | 31 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
33 | 32 |
import org.gvsig.fmap.mapcontext.MapContext; |
34 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
35 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
36 | 33 |
import org.gvsig.fmap.mapcontrol.MapControl; |
37 | 34 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
38 | 35 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
39 | 36 |
import org.gvsig.selectiontools.app.extension.tools.CircleSelectListener; |
40 | 37 |
import org.gvsig.selectiontools.app.extension.tools.behavior.CircleSelectionBehavior; |
41 | 38 |
|
42 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
43 |
* |
|
44 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
45 |
* of the Valencian Government (CIT) |
|
46 |
* |
|
47 |
* This program is free software; you can redistribute it and/or |
|
48 |
* modify it under the terms of the GNU General Public License |
|
49 |
* as published by the Free Software Foundation; either version 2 |
|
50 |
* of the License, or (at your option) any later version. |
|
51 |
* |
|
52 |
* This program is distributed in the hope that it will be useful, |
|
53 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
54 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
55 |
* GNU General Public License for more details. |
|
56 |
* |
|
57 |
* You should have received a copy of the GNU General Public License |
|
58 |
* along with this program; if not, write to the Free Software |
|
59 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
60 |
* MA 02110-1301, USA. |
|
61 |
* |
|
62 |
*/ |
|
63 |
|
|
64 | 39 |
/** |
65 |
* <p> |
|
66 | 40 |
* Extension to add support for selecting the geometries of the active vector |
67 | 41 |
* layers that intersect with a circle defined by the user. |
68 |
* </p> |
|
69 |
* |
|
70 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
71 | 42 |
*/ |
72 | 43 |
public class SelectByCircleExtension extends Extension { |
73 | 44 |
|
74 | 45 |
public static final String CIRCLE_SELECTION_TOOL_NAME = "circleSelection"; |
75 | 46 |
|
76 |
/* |
|
77 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
78 |
*/ |
|
79 | 47 |
public void initialize() { |
80 |
IconThemeHelper.registerIcon("action", "selection-select-by-circle", this);
|
|
81 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-circle", this);
|
|
48 |
IconThemeHelper.registerIcon("action", "selection-select-by-circle", this);
|
|
49 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-circle", this);
|
|
82 | 50 |
} |
83 | 51 |
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* |
|
87 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
88 |
*/ |
|
89 | 52 |
public void execute(String actionCommand) { |
90 |
if (actionCommand.equals("SELCIRCLE")) { |
|
91 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
92 |
if (window instanceof IView) { |
|
93 |
IView view = (IView) window; |
|
94 |
// Selection by circle |
|
95 |
MapControl mc = view.getMapControl(); |
|
53 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
96 | 54 |
|
97 |
// If current's view MapControl doesn't have the |
|
98 |
// "CircleSelection" tool, adds it |
|
99 |
if (!mc.getNamesMapTools() |
|
100 |
.containsKey(CIRCLE_SELECTION_TOOL_NAME)) { |
|
101 |
CircleSelectListener circleSelListener = |
|
102 |
new CircleSelectListener(mc); |
|
103 |
mc.addBehavior(CIRCLE_SELECTION_TOOL_NAME, new Behavior[] { |
|
104 |
new CircleSelectionBehavior(circleSelListener), |
|
105 |
new MouseMovementBehavior(new StatusBarListener(mc)) }); |
|
106 |
} |
|
107 |
|
|
108 |
mc.setTool(CIRCLE_SELECTION_TOOL_NAME); |
|
55 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
56 |
if (view == null) { |
|
57 |
return; |
|
58 |
} |
|
59 |
if (actionCommand.equals("SELCIRCLE")) { |
|
60 |
MapControl mc = view.getMapControl(); |
|
61 |
/* |
|
62 |
If current's view MapControl doesn't have the |
|
63 |
"CircleSelection" tool, adds it |
|
64 |
*/ |
|
65 |
if (!mc.getNamesMapTools().containsKey(CIRCLE_SELECTION_TOOL_NAME)) { |
|
66 |
CircleSelectListener circleSelListener = new CircleSelectListener(mc); |
|
67 |
mc.addBehavior( |
|
68 |
CIRCLE_SELECTION_TOOL_NAME, |
|
69 |
new Behavior[]{ |
|
70 |
new CircleSelectionBehavior(circleSelListener), |
|
71 |
new MouseMovementBehavior(new StatusBarListener(mc)) |
|
72 |
}); |
|
109 | 73 |
} |
74 |
mc.setTool(CIRCLE_SELECTION_TOOL_NAME); |
|
110 | 75 |
} |
111 | 76 |
} |
112 | 77 |
|
113 |
/* |
|
114 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
115 |
*/ |
|
116 | 78 |
public boolean isVisible() { |
117 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
79 |
ApplicationManager application = ApplicationLocator.getManager();
|
|
118 | 80 |
|
119 |
if (f == null) { |
|
81 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
82 |
if (view == null) { |
|
120 | 83 |
return false; |
121 | 84 |
} |
122 |
|
|
123 |
if (f instanceof IView) { |
|
124 |
IView vista = (IView) f; |
|
125 |
ViewDocument model = vista.getViewDocument(); |
|
126 |
MapContext mapa = model.getMapContext(); |
|
127 |
|
|
128 |
return mapa.getLayers().getLayersCount() > 0; |
|
129 |
} |
|
130 |
|
|
131 |
return false; |
|
85 |
ViewDocument document = view.getViewDocument(); |
|
86 |
MapContext mapa = document.getMapContext(); |
|
87 |
return mapa.getLayers().getLayersCount() > 0; |
|
132 | 88 |
} |
133 | 89 |
|
134 |
/* |
|
135 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
136 |
*/ |
|
137 | 90 |
public boolean isEnabled() { |
138 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
91 |
ApplicationManager application = ApplicationLocator.getManager();
|
|
139 | 92 |
|
140 |
if (f == null) { |
|
93 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
94 |
if (view == null) { |
|
141 | 95 |
return false; |
142 | 96 |
} |
143 |
|
|
144 |
if (f instanceof IView) { |
|
145 |
IView vista = (IView) f; |
|
146 |
ViewDocument model = vista.getViewDocument(); |
|
147 |
MapContext mapa = model.getMapContext(); |
|
148 |
|
|
149 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
150 |
FLayer layer; |
|
151 |
|
|
152 |
for (int i = 0; i < layers.length; i++) { |
|
153 |
layer = layers[i]; |
|
154 |
|
|
155 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
156 |
&& (layer.isActive())) |
|
157 |
return true; |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
return false; |
|
97 |
ViewDocument document = view.getViewDocument(); |
|
98 |
return document.getMapContext().hasActiveVectorLayers(); |
|
162 | 99 |
} |
163 | 100 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/tools/buffer/gui/BufferConfigurationPanel.java | ||
---|---|---|
51 | 51 |
import java.awt.event.ActionListener; |
52 | 52 |
import java.awt.event.ComponentAdapter; |
53 | 53 |
import java.awt.event.ComponentEvent; |
54 |
import java.text.DecimalFormat; |
|
55 | 54 |
import java.util.ArrayList; |
56 | 55 |
import java.util.Arrays; |
57 | 56 |
import java.util.Iterator; |
57 |
import java.util.List; |
|
58 | 58 |
|
59 | 59 |
import javax.swing.BorderFactory; |
60 | 60 |
import javax.swing.JCheckBox; |
... | ... | |
62 | 62 |
import javax.swing.JOptionPane; |
63 | 63 |
import javax.swing.JPanel; |
64 | 64 |
import javax.swing.JTextField; |
65 |
import javax.swing.text.NumberFormatter; |
|
66 | 65 |
|
67 | 66 |
import org.gvsig.andami.PluginServices; |
68 | 67 |
import org.gvsig.andami.messages.NotificationManager; |
... | ... | |
111 | 110 |
private JPanel sidePanel = null; |
112 | 111 |
private JPanel optionsPanel = null; |
113 | 112 |
private AdaptedAcceptCancelPanel acceptCancelPanel = null; |
114 |
private FLyrVect[] layers;
|
|
113 |
private List<FLyrVect> layers;
|
|
115 | 114 |
private MapControl mapControl; |
116 | 115 |
private IView view; |
117 | 116 |
private JCheckBox multiLayerSelectionCBox; |
118 | 117 |
private SideInfo outside, inside, out_in_side; |
119 | 118 |
|
120 | 119 |
/** |
121 |
* <p> |
|
122 | 120 |
* Creates a new form where user can define the option of the buffer. |
123 |
* </p> |
|
124 | 121 |
*/ |
125 |
public BufferConfigurationPanel(FLyrVect[] array, IView view) {
|
|
122 |
public BufferConfigurationPanel(List<FLyrVect> layers, IView view) {
|
|
126 | 123 |
super(); |
127 | 124 |
|
128 |
layers = array;
|
|
125 |
this.layers = layers;
|
|
129 | 126 |
this.view = view; |
130 |
mapControl = view.getMapControl(); |
|
127 |
this.mapControl = view.getMapControl();
|
|
131 | 128 |
|
132 | 129 |
initialize(); |
133 | 130 |
} |
134 | 131 |
|
132 |
public BufferConfigurationPanel(FLyrVect[] array, IView view) { |
|
133 |
this(Arrays.asList(array),view); |
|
134 |
} |
|
135 |
|
|
135 | 136 |
/** |
136 |
* <p> |
|
137 | 137 |
* Initializes this component. |
138 |
* </p> |
|
139 | 138 |
*/ |
140 | 139 |
private void initialize() { |
141 | 140 |
outside = |
... | ... | |
537 | 536 |
|
538 | 537 |
/* 3- Creates the process */ |
539 | 538 |
// checks layers to proccess if multilayer is not selected |
540 |
ArrayList<FLyrVect> tmpLayersToProccess = |
|
541 |
new ArrayList<FLyrVect>(layers.length); |
|
542 |
tmpLayersToProccess.addAll(Arrays.asList(layers)); |
|
539 |
List<FLyrVect> tmpLayersToProccess = new ArrayList<FLyrVect>(); |
|
540 |
tmpLayersToProccess.addAll(layers); |
|
543 | 541 |
if (!multiLayerSelectionCBox.isSelected()) { |
544 | 542 |
Iterator<FLyrVect> iter = |
545 | 543 |
tmpLayersToProccess.iterator(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/SelectByBufferExtension.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.selectiontools.app.extension; |
25 | 24 |
|
26 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
27 |
* |
|
28 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
29 |
* of the Valencian Government (CIT) |
|
30 |
* |
|
31 |
* This program is free software; you can redistribute it and/or |
|
32 |
* modify it under the terms of the GNU General Public License |
|
33 |
* as published by the Free Software Foundation; either version 2 |
|
34 |
* of the License, or (at your option) any later version. |
|
35 |
* |
|
36 |
* This program is distributed in the hope that it will be useful, |
|
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
39 |
* GNU General Public License for more details. |
|
40 |
* |
|
41 |
* You should have received a copy of the GNU General Public License |
|
42 |
* along with this program; if not, write to the Free Software |
|
43 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
44 |
* MA 02110-1301, USA. |
|
45 |
* |
|
46 |
*/ |
|
47 |
|
|
48 | 25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
|
49 | 27 |
|
50 | 28 |
import javax.swing.JOptionPane; |
51 | 29 |
|
... | ... | |
53 | 31 |
import org.slf4j.LoggerFactory; |
54 | 32 |
|
55 | 33 |
import org.gvsig.andami.IconThemeHelper; |
56 |
import org.gvsig.andami.PluginServices; |
|
57 | 34 |
import org.gvsig.andami.plugins.Extension; |
58 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
35 |
import org.gvsig.app.ApplicationLocator; |
|
36 |
import org.gvsig.app.ApplicationManager; |
|
59 | 37 |
import org.gvsig.app.project.documents.view.ViewDocument; |
60 | 38 |
import org.gvsig.app.project.documents.view.gui.IView; |
61 | 39 |
import org.gvsig.fmap.dal.exception.DataException; |
62 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
63 | 40 |
import org.gvsig.fmap.mapcontext.MapContext; |
64 | 41 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
65 | 42 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
66 | 43 |
import org.gvsig.selectiontools.app.extension.tools.buffer.gui.BufferConfigurationPanel; |
67 | 44 |
|
68 | 45 |
/** |
69 |
* <p> |
|
70 | 46 |
* Extension to add support for selecting the geometries of the active vector |
71 | 47 |
* layers that intersect with a buffer around their previously selected |
72 | 48 |
* geometries. |
73 |
* </p> |
|
74 |
* |
|
75 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
76 | 49 |
*/ |
77 | 50 |
public class SelectByBufferExtension extends Extension { |
78 | 51 |
|
79 |
private static Logger logger =
|
|
80 |
LoggerFactory.getLogger(SelectByBufferExtension.class); |
|
52 |
private static Logger logger |
|
53 |
= LoggerFactory.getLogger(SelectByBufferExtension.class);
|
|
81 | 54 |
public static final String BUFFER_SELECTION_TOOL_NAME = "bufferSelection"; |
82 | 55 |
|
83 |
/* |
|
84 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
85 |
*/ |
|
86 | 56 |
public void initialize() { |
87 |
IconThemeHelper.registerIcon("action", "selection-select-by-buffer", this);
|
|
88 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-buffer", this);
|
|
57 |
IconThemeHelper.registerIcon("action", "selection-select-by-buffer", this);
|
|
58 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-buffer", this);
|
|
89 | 59 |
} |
90 | 60 |
|
91 |
/* |
|
92 |
* (non-Javadoc) |
|
93 |
* |
|
94 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
95 |
*/ |
|
96 | 61 |
public void execute(String actionCommand) { |
97 |
if (actionCommand.equals("SELBUFFER")) { |
|
98 |
IWindow win = PluginServices.getMDIManager().getActiveWindow(); |
|
62 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
99 | 63 |
|
100 |
if (win instanceof IView) { |
|
101 |
IView view = (IView) win; |
|
102 |
ViewDocument model = view.getViewDocument(); |
|
64 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
65 |
if (view == null) { |
|
66 |
return; |
|
67 |
} |
|
68 |
ViewDocument document = view.getViewDocument(); |
|
103 | 69 |
|
104 |
/* |
|
105 |
* Unavaliable tool with views in geographic projections |
|
106 |
*/ |
|
107 |
/* |
|
108 |
* Removed restriction |
|
109 |
* |
|
110 |
if (!view.getMapControl().getProjection().isProjected()) { |
|
111 |
JOptionPane.showMessageDialog(null, |
|
112 |
PluginServices.getText(null, |
|
113 |
"Tool_unavaliable_with_view_in_geographic_projection"), |
|
114 |
PluginServices.getText(this, "Warning"), |
|
115 |
JOptionPane.ERROR_MESSAGE); |
|
116 |
return; |
|
117 |
} |
|
118 |
*/ |
|
70 |
if (actionCommand.equals("SELBUFFER")) { |
|
71 |
MapContext mapContext = document.getMapContext(); |
|
119 | 72 |
|
120 |
MapContext mapContext = model.getMapContext(); |
|
73 |
FLayer layers[] = mapContext.getLayers().getActives(); |
|
74 |
FLayer layer; |
|
75 |
List<FLyrVect> usefulLayers = new ArrayList<FLyrVect>(); |
|
76 |
int emptySelectionLayers = 0; |
|
121 | 77 |
|
122 |
// If there is at least one active vector layer that has |
|
123 |
// geometries selected -> can use this tool, otherwise notifies |
|
124 |
// the |
|
125 |
// limitation in a JOptionPane |
|
126 |
FLayer layers[] = mapContext.getLayers().getActives(); |
|
127 |
FLayer layer; |
|
128 |
ArrayList<FLyrVect> usefulLayers = new ArrayList<FLyrVect>(); |
|
129 |
int emptySelectionLayers = 0; |
|
130 |
|
|
131 |
for (int i = 0; i < layers.length; i++) { |
|
132 |
layer = layers[i]; |
|
133 |
|
|
134 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
135 |
&& (layer.isActive())) { |
|
136 |
|
|
137 |
usefulLayers.add((FLyrVect) layer); |
|
138 |
try { |
|
139 |
if (((FLyrVect) layer).getFeatureStore() |
|
140 |
.getFeatureSelection() |
|
141 |
.isEmpty()) { |
|
142 |
emptySelectionLayers++; |
|
143 |
} |
|
144 |
} catch (DataException e) { |
|
145 |
JOptionPane.showMessageDialog(null, |
|
146 |
PluginServices.getText(null, |
|
147 |
"Failed_selecting_layer") |
|
148 |
+ ": " |
|
149 |
+ layer.getName(), |
|
150 |
PluginServices.getText(null, "Warning"), |
|
151 |
JOptionPane.WARNING_MESSAGE); |
|
78 |
for (int i = 0; i < layers.length; i++) { |
|
79 |
layer = layers[i]; |
|
80 |
if ((layer instanceof FLyrVect) && layer.isAvailable() && layer.isActive()) { |
|
81 |
FLyrVect layervect = (FLyrVect) layer; |
|
82 |
usefulLayers.add(layervect); |
|
83 |
try { |
|
84 |
if (layervect.getFeatureStore().getFeatureSelection().isEmpty()) { |
|
85 |
emptySelectionLayers++; |
|
152 | 86 |
} |
87 |
} catch (DataException e) { |
|
88 |
logger.warn("Error While getting selection for layer '" + layer.getName() + "'.", e); |
|
89 |
application.messageDialog( |
|
90 |
application.translate("Failed_selecting_layer") + ": " + layer.getName(), |
|
91 |
application.translate("Warning"), |
|
92 |
JOptionPane.WARNING_MESSAGE); |
|
153 | 93 |
} |
154 | 94 |
} |
95 |
} |
|
155 | 96 |
|
156 |
if (usefulLayers.size() == 0 |
|
157 |
|| emptySelectionLayers == usefulLayers.size()) { |
|
158 |
JOptionPane.showMessageDialog(null, |
|
159 |
PluginServices.getText(null, |
|
160 |
"_There_are_no_geometries_selected"), |
|
161 |
PluginServices.getText(null, "Warning"), |
|
97 |
if (usefulLayers.isEmpty() || emptySelectionLayers == usefulLayers.size()) { |
|
98 |
application.messageDialog( |
|
99 |
application.translate("_There_are_no_geometries_selected"), |
|
100 |
application.translate("Warning"), |
|
162 | 101 |
JOptionPane.WARNING_MESSAGE); |
163 |
|
|
164 |
return; |
|
165 |
} |
|
166 |
|
|
167 |
// Creates and displays the configuration panel |
|
168 |
PluginServices.getMDIManager() |
|
169 |
.addWindow(new BufferConfigurationPanel( |
|
170 |
(FLyrVect[]) usefulLayers.toArray(new FLyrVect[0]), |
|
171 |
view)); |
|
102 |
return; |
|
172 | 103 |
} |
104 |
|
|
105 |
// Creates and displays the configuration panel |
|
106 |
application.getUIManager().addWindow( |
|
107 |
new BufferConfigurationPanel(usefulLayers, view)); |
|
173 | 108 |
} |
109 |
|
|
174 | 110 |
} |
175 | 111 |
|
176 |
/* |
|
177 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
178 |
*/ |
|
179 | 112 |
public boolean isVisible() { |
180 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
181 |
return (f instanceof IView); |
|
113 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
114 |
|
|
115 |
return application.getActiveComponent(ViewDocument.class) != null; |
|
182 | 116 |
} |
183 | 117 |
|
184 |
/* |
|
185 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
186 |
*/ |
|
187 | 118 |
public boolean isEnabled() { |
188 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
119 |
ApplicationManager application = ApplicationLocator.getManager();
|
|
189 | 120 |
|
190 |
if (f == null) { |
|
121 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
122 |
if (view == null) { |
|
191 | 123 |
return false; |
192 | 124 |
} |
125 |
ViewDocument document = view.getViewDocument(); |
|
126 |
MapContext mapa = document.getMapContext(); |
|
193 | 127 |
|
194 |
if (f instanceof IView) { |
|
195 |
IView vista = (IView) f; |
|
196 |
ViewDocument model = vista.getViewDocument(); |
|
197 |
|
|
198 |
/* |
|
199 |
* Unavaliable tool with views in geographic projections |
|
200 |
*/ |
|
201 |
/* Restriction removed, also for EPSG:4326 etc |
|
202 |
if (!(vista.getMapControl().getProjection().isProjected())) { |
|
203 |
return false; |
|
204 |
} |
|
205 |
*/ |
|
206 |
|
|
207 |
MapContext mapa = model.getMapContext(); |
|
208 |
|
|
209 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
210 |
FLayer layer; |
|
211 |
|
|
212 |
for (int i = 0; i < layers.length; i++) { |
|
213 |
layer = layers[i]; |
|
214 |
|
|
215 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
216 |
&& (layer.isActive())) { |
|
217 |
|
|
218 |
FLyrVect vect = (FLyrVect) layer; |
|
219 |
try { |
|
220 |
FeatureSelection selec = null; |
|
221 |
selec = (FeatureSelection) vect.getFeatureStore().getSelection(); |
|
222 |
if (selec.getSize() > 0) { |
|
223 |
return true; |
|
224 |
} |
|
225 |
} catch (DataException e) { |
|
226 |
logger.info("While getting layer selection.", e); |
|
128 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
129 |
FLayer layer; |
|
130 |
for (int i = 0; i < layers.length; i++) { |
|
131 |
layer = layers[i]; |
|
132 |
if ((layer instanceof FLyrVect) && layer.isAvailable() && layer.isActive()) { |
|
133 |
FLyrVect layervect = (FLyrVect) layer; |
|
134 |
try { |
|
135 |
if (!layervect.getFeatureStore().getFeatureSelection().isEmpty()) { |
|
136 |
return true; |
|
227 | 137 |
} |
138 |
} catch (DataException e) { |
|
139 |
logger.warn("Error While getting selection for layer '" + layer.getName() + "'.", e); |
|
228 | 140 |
} |
229 | 141 |
} |
230 | 142 |
} |
231 |
|
|
232 | 143 |
return false; |
233 | 144 |
} |
234 | 145 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/SelectByPolylineExtension.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.selectiontools.app.extension; |
25 | 24 |
|
26 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
27 |
* |
|
28 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
29 |
* of the Valencian Government (CIT) |
|
30 |
* |
|
31 |
* This program is free software; you can redistribute it and/or |
|
32 |
* modify it under the terms of the GNU General Public License |
|
33 |
* as published by the Free Software Foundation; either version 2 |
|
34 |
* of the License, or (at your option) any later version. |
|
35 |
* |
|
36 |
* This program is distributed in the hope that it will be useful, |
|
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
39 |
* GNU General Public License for more details. |
|
40 |
* |
|
41 |
* You should have received a copy of the GNU General Public License |
|
42 |
* along with this program; if not, write to the Free Software |
|
43 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
44 |
* MA 02110-1301, USA. |
|
45 |
* |
|
46 |
*/ |
|
47 |
|
|
48 | 25 |
import org.gvsig.andami.IconThemeHelper; |
49 |
import org.gvsig.andami.PluginServices; |
|
50 | 26 |
import org.gvsig.andami.plugins.Extension; |
51 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
27 |
import org.gvsig.app.ApplicationLocator; |
|
28 |
import org.gvsig.app.ApplicationManager; |
|
52 | 29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
53 | 30 |
import org.gvsig.app.project.documents.view.gui.IView; |
54 | 31 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
55 | 32 |
import org.gvsig.fmap.mapcontext.MapContext; |
56 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
57 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
58 | 33 |
import org.gvsig.fmap.mapcontrol.MapControl; |
59 | 34 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
60 | 35 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
... | ... | |
62 | 37 |
import org.gvsig.selectiontools.app.extension.tools.PolyLineSelectListener; |
63 | 38 |
|
64 | 39 |
/** |
65 |
* <p> |
|
66 | 40 |
* Extension to add support for selecting the geometries of the active vector |
67 | 41 |
* layers that intersect with a polyline defined by the user. |
68 |
* </p> |
|
69 |
* |
|
70 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
71 | 42 |
*/ |
72 | 43 |
public class SelectByPolylineExtension extends Extension { |
73 | 44 |
|
74 |
public static final String POLYLINE_SELECTION_TOOL_NAME =
|
|
75 |
"polylineSelection"; |
|
45 |
public static final String POLYLINE_SELECTION_TOOL_NAME |
|
46 |
= "polylineSelection";
|
|
76 | 47 |
|
77 |
/* |
|
78 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
79 |
*/ |
|
80 | 48 |
public void initialize() { |
81 |
IconThemeHelper.registerIcon("action", "selection-select-by-polyline", this);
|
|
82 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-polyline", this);
|
|
49 |
IconThemeHelper.registerIcon("action", "selection-select-by-polyline", this);
|
|
50 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-polyline", this);
|
|
83 | 51 |
} |
84 | 52 |
|
85 |
/* |
|
86 |
* (non-Javadoc) |
|
87 |
* |
|
88 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
89 |
*/ |
|
90 | 53 |
public void execute(String actionCommand) { |
91 |
if (actionCommand.equals("SELPOLYLINE")) { |
|
92 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
93 |
if (window instanceof IView) { |
|
94 |
IView view = (IView) window; |
|
95 |
// Selection by polyline |
|
96 |
MapControl mc = view.getMapControl(); |
|
54 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
97 | 55 |
|
98 |
// If current's view MapControl doesn't have the |
|
99 |
// "CircleSelection" tool, adds it |
|
100 |
if (!mc.getNamesMapTools() |
|
101 |
.containsKey(POLYLINE_SELECTION_TOOL_NAME)) { |
|
102 |
PolyLineSelectListener polylineSelListener = |
|
103 |
new PolyLineSelectListener(mc); |
|
104 |
mc.addBehavior(POLYLINE_SELECTION_TOOL_NAME, |
|
105 |
new Behavior[] { |
|
56 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
57 |
if (view == null) { |
|
58 |
return; |
|
59 |
} |
|
60 |
if (actionCommand.equals("SELPOLYLINE")) { |
|
61 |
MapControl mc = view.getMapControl(); |
|
62 |
/* |
|
63 |
If current's view MapControl doesn't have the |
|
64 |
"polylineSelection" tool, adds it |
|
65 |
*/ |
|
66 |
if (!mc.getNamesMapTools().containsKey(POLYLINE_SELECTION_TOOL_NAME)) { |
|
67 |
PolyLineSelectListener polylineSelListener = new PolyLineSelectListener(mc); |
|
68 |
mc.addBehavior( |
|
69 |
POLYLINE_SELECTION_TOOL_NAME, |
|
70 |
new Behavior[]{ |
|
106 | 71 |
new PolylineBehavior(polylineSelListener), |
107 |
new MouseMovementBehavior(new StatusBarListener(mc)) }); |
|
108 |
} |
|
109 |
|
|
110 |
mc.setTool(POLYLINE_SELECTION_TOOL_NAME); |
|
72 |
new MouseMovementBehavior(new StatusBarListener(mc)) |
|
73 |
}); |
|
111 | 74 |
} |
75 |
mc.setTool(POLYLINE_SELECTION_TOOL_NAME); |
|
112 | 76 |
} |
113 | 77 |
} |
114 | 78 |
|
115 |
/* |
|
116 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
117 |
*/ |
|
118 | 79 |
public boolean isVisible() { |
119 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
80 |
ApplicationManager application = ApplicationLocator.getManager();
|
|
120 | 81 |
|
121 |
if (f == null) { |
|
82 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
83 |
if (view == null) { |
|
122 | 84 |
return false; |
123 | 85 |
} |
124 |
|
|
125 |
if (f instanceof IView) { |
|
126 |
IView vista = (IView) f; |
|
127 |
ViewDocument model = vista.getViewDocument(); |
|
128 |
MapContext mapa = model.getMapContext(); |
|
129 |
|
|
130 |
return mapa.getLayers().getLayersCount() > 0; |
|
131 |
} |
|
132 |
|
|
133 |
return false; |
|
86 |
ViewDocument document = view.getViewDocument(); |
|
87 |
MapContext mapa = document.getMapContext(); |
|
88 |
return mapa.getLayers().getLayersCount() > 0; |
|
134 | 89 |
} |
135 | 90 |
|
136 |
/* |
|
137 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
138 |
*/ |
|
139 | 91 |
public boolean isEnabled() { |
140 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
92 |
ApplicationManager application = ApplicationLocator.getManager();
|
|
141 | 93 |
|
142 |
if (f == null) { |
|
94 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
95 |
if (view == null) { |
|
143 | 96 |
return false; |
144 | 97 |
} |
145 |
|
|
146 |
if (f instanceof IView) { |
|
147 |
IView vista = (IView) f; |
|
148 |
ViewDocument model = vista.getViewDocument(); |
|
149 |
MapContext mapa = model.getMapContext(); |
|
150 |
|
|
151 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
152 |
FLayer layer; |
|
153 |
|
|
154 |
for (int i = 0; i < layers.length; i++) { |
|
155 |
layer = layers[i]; |
|
156 |
|
|
157 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
158 |
&& (layer.isActive())) |
|
159 |
return true; |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
return false; |
|
98 |
ViewDocument document = view.getViewDocument(); |
|
99 |
return document.getMapContext().hasActiveVectorLayers(); |
|
164 | 100 |
} |
165 | 101 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/imp/DefaultAppgvSIGManager.java | ||
---|---|---|
29 | 29 |
import java.util.ArrayList; |
30 | 30 |
import java.util.Iterator; |
31 | 31 |
import java.util.List; |
32 |
import javax.swing.JComponent; |
|
32 | 33 |
|
33 | 34 |
import javax.swing.JFileChooser; |
34 | 35 |
import javax.swing.filechooser.FileFilter; |
... | ... | |
56 | 57 |
import org.gvsig.app.project.ProjectManager; |
57 | 58 |
import org.gvsig.app.project.documents.Document; |
58 | 59 |
import org.gvsig.app.project.documents.gui.IDocumentWindow; |
60 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
59 | 61 |
import org.gvsig.fmap.crs.CRSFactory; |
60 | 62 |
import org.gvsig.fmap.dal.DALLocator; |
61 | 63 |
import org.gvsig.fmap.dal.DataManager; |
... | ... | |
397 | 399 |
} |
398 | 400 |
return project.getActiveDocument(documentClass); |
399 | 401 |
} |
402 |
|
|
403 |
public JComponent getActiveComponent(Class<? extends Document> documentClass) { |
|
404 |
Document document = this.getActiveDocument(documentClass); |
|
405 |
if (document == null) { |
|
406 |
return null; |
|
407 |
} |
|
408 |
return document.getMainComponent(); |
|
409 |
} |
|
400 | 410 |
|
411 |
|
|
401 | 412 |
public IDocumentWindow getDocumentWindow(Document document) { |
402 | 413 |
Class<? extends IDocumentWindow> defaultDocumentClass = |
403 | 414 |
document.getFactory().getMainWindowClass(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/gui/IView.java | ||
---|---|---|
24 | 24 |
package org.gvsig.app.project.documents.view.gui; |
25 | 25 |
|
26 | 26 |
import org.gvsig.app.project.documents.gui.IDocumentWindow; |
27 |
import org.gvsig.app.project.documents.view.MapOverview; |
|
27 | 28 |
import org.gvsig.app.project.documents.view.ViewDocument; |
28 | 29 |
import org.gvsig.app.project.documents.view.toc.gui.TOC; |
29 | 30 |
import org.gvsig.fmap.mapcontrol.MapControl; |
... | ... | |
31 | 32 |
public interface IView extends IDocumentWindow { |
32 | 33 |
|
33 | 34 |
public MapControl getMapControl(); |
35 |
|
|
36 |
public MapOverview getMapOverview(); |
|
34 | 37 |
|
35 | 38 |
public TOC getTOC(); |
36 | 39 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewInvertSelection.java | ||
---|---|---|
29 | 29 |
import org.gvsig.app.ApplicationManager; |
30 | 30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
31 | 31 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
32 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
32 | 33 |
import org.gvsig.fmap.dal.DataStore; |
33 | 34 |
import org.gvsig.fmap.dal.exception.DataException; |
34 | 35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
... | ... | |
59 | 60 |
public void execute(String actionCommand) { |
60 | 61 |
ApplicationManager application = ApplicationLocator.getManager(); |
61 | 62 |
|
62 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
63 |
if (document == null) {
|
|
64 |
return; |
|
63 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
64 |
if (view == null) {
|
|
65 |
return ;
|
|
65 | 66 |
} |
67 |
ViewDocument document = view.getViewDocument(); |
|
66 | 68 |
|
67 | 69 |
MapContext mapa = document.getMapContext(); |
68 | 70 |
|
... | ... | |
88 | 90 |
public boolean isEnabled() { |
89 | 91 |
ApplicationManager application = ApplicationLocator.getManager(); |
90 | 92 |
|
91 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
92 |
if (document == null) {
|
|
93 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
94 |
if (view == null) {
|
|
93 | 95 |
return false; |
94 | 96 |
} |
97 |
ViewDocument document = view.getViewDocument(); |
|
95 | 98 |
return document.getMapContext().hasActiveVectorLayers(); |
96 | 99 |
} |
97 | 100 |
|
98 | 101 |
public boolean isVisible() { |
99 | 102 |
ApplicationManager application = ApplicationLocator.getManager(); |
100 | 103 |
|
101 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
102 |
if (document == null) {
|
|
104 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
105 |
if (view == null) {
|
|
103 | 106 |
return false; |
104 | 107 |
} |
108 |
ViewDocument document = view.getViewDocument(); |
|
105 | 109 |
return document.getMapContext().hasVectorLayers(); |
106 | 110 |
} |
107 | 111 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ZoomPrev.java | ||
---|---|---|
27 | 27 |
import org.gvsig.app.ApplicationLocator; |
28 | 28 |
import org.gvsig.app.ApplicationManager; |
29 | 29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
30 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
30 | 31 |
import org.gvsig.fmap.mapcontext.ViewPort; |
31 | 32 |
|
32 | 33 |
/** |
... | ... | |
45 | 46 |
public boolean isEnabled() { |
46 | 47 |
ApplicationManager application = ApplicationLocator.getManager(); |
47 | 48 |
|
48 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
49 |
if (document == null) {
|
|
49 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
50 |
if (view == null) {
|
|
50 | 51 |
return false; |
51 | 52 |
} |
53 |
ViewDocument document = view.getViewDocument(); |
|
52 | 54 |
ViewPort vp = document.getMapContext().getViewPort(); |
53 | 55 |
return vp.getEnvelopes().hasPrevious(); |
54 | 56 |
} |
... | ... | |
56 | 58 |
public boolean isVisible() { |
57 | 59 |
ApplicationManager application = ApplicationLocator.getManager(); |
58 | 60 |
|
59 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
60 |
if (document == null) {
|
|
61 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
62 |
if (view == null) {
|
|
61 | 63 |
return false; |
62 | 64 |
} |
65 |
ViewDocument document = view.getViewDocument(); |
|
63 | 66 |
return document.getMapContext().getLayers().getLayersCount() > 0; |
64 | 67 |
} |
65 | 68 |
|
66 | 69 |
public void execute(String arg0) { |
67 | 70 |
ApplicationManager application = ApplicationLocator.getManager(); |
68 | 71 |
|
69 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
70 |
if (document == null) {
|
|
72 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
73 |
if (view == null) {
|
|
71 | 74 |
return; |
72 | 75 |
} |
76 |
ViewDocument document = view.getViewDocument(); |
|
73 | 77 |
ViewPort vp = document.getMapContext().getViewPort(); |
74 | 78 |
|
75 | 79 |
vp.setPreviousEnvelope(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/BasicSymbologyExtension.java | ||
---|---|---|
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
23 | 23 |
*/ |
24 |
/* CVS MESSAGES: |
|
25 |
* |
|
26 |
* $Id: AdvancedSymbologyExtension.java 16205 2007-11-08 16:33:35Z jdominguez $ |
|
27 |
* $Log: AdvancedSymbologyExtension.java,v $ |
|
28 |
* Revision 1.12 2007/09/19 15:34:59 jaume |
|
29 |
* removed unnecessary imports |
|
30 |
* |
|
31 |
* Revision 1.11 2007/09/17 09:11:28 jaume |
|
32 |
* order of the elements inverted |
|
33 |
* |
|
34 |
* Revision 1.10 2007/09/13 11:37:09 jvidal |
|
35 |
* *** empty log message *** |
|
36 |
* |
|
37 |
* Revision 1.9 2007/09/04 10:53:10 caballero |
|
38 |
* show page |
|
39 |
* |
|
40 |
* Revision 1.8 2007/08/09 10:39:04 jaume |
|
41 |
* first round of found bugs fixed |
|
42 |
* |
|
43 |
* Revision 1.7 2007/08/01 13:03:31 jaume |
|
44 |
* plugable symbol editor |
|
45 |
* |
|
46 |
* Revision 1.6 2007/05/22 12:17:12 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.5 2007/05/17 09:32:37 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.4 2007/03/21 08:03:03 jaume |
|
53 |
* refactored to use ISymbol instead of FSymbol |
|
54 |
* |
|
55 |
* Revision 1.3 2007/03/13 16:57:35 jaume |
|
56 |
* Added MultiVariable legend |
|
57 |
* |
|
58 |
* Revision 1.2 2007/03/09 11:25:00 jaume |
|
59 |
* Advanced symbology (start committing) |
|
60 |
* |
|
61 |
* Revision 1.1.2.4 2007/02/21 07:35:14 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.1.2.3 2007/02/12 15:14:41 jaume |
|
65 |
* refactored interval legend and added graduated symbol legend |
|
66 |
* |
|
67 |
* Revision 1.1.2.2 2007/02/01 17:47:12 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.1.2.1 2007/02/01 12:12:41 jaume |
|
71 |
* theme manager window and all its components are now dynamic |
|
72 |
* |
|
73 |
*/ |
|
74 | 24 |
package org.gvsig.app.extension; |
75 | 25 |
|
76 | 26 |
import org.gvsig.andami.IconThemeHelper; |
... | ... | |
177 | 127 |
} |
178 | 128 |
|
179 | 129 |
public boolean isEnabled() { |
180 |
return true; // or whatever
|
|
130 |
return false;
|
|
181 | 131 |
} |
182 | 132 |
|
183 | 133 |
public boolean isVisible() { |
184 |
return true; // or whatever
|
|
134 |
return false;
|
|
185 | 135 |
} |
186 | 136 |
|
187 | 137 |
public IPreference[] getPreferencesPages() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewPropertiesExtension.java | ||
---|---|---|
31 | 31 |
import org.gvsig.app.gui.preferencespage.LayerOrderPage; |
32 | 32 |
import org.gvsig.app.gui.preferencespage.ViewBehaviorPage; |
33 | 33 |
import org.gvsig.app.project.documents.view.ViewDocument; |
34 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
34 | 35 |
import org.gvsig.app.project.documents.view.gui.ViewProperties; |
35 | 36 |
|
36 | 37 |
public class ViewPropertiesExtension extends Extension implements IPreferenceExtension { |
... | ... | |
46 | 47 |
public void execute(String s) { |
47 | 48 |
ApplicationManager application = ApplicationLocator.getManager(); |
48 | 49 |
|
49 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
50 |
if (document == null) {
|
|
50 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
51 |
if (view == null) {
|
|
51 | 52 |
return; |
52 | 53 |
} |
54 |
ViewDocument document = view.getViewDocument(); |
|
55 |
|
|
53 | 56 |
if (s.equalsIgnoreCase("view-properties")) { |
54 | 57 |
ViewProperties viewProperties = new ViewProperties(document); |
55 | 58 |
application.getUIManager().addWindow(viewProperties); |
... | ... | |
66 | 69 |
public boolean isVisible() { |
67 | 70 |
ApplicationManager application = ApplicationLocator.getManager(); |
68 | 71 |
|
69 |
return application.getActiveDocument(ViewDocument.class) != null;
|
|
72 |
return application.getActiveComponent(ViewDocument.class) != null;
|
|
70 | 73 |
} |
71 | 74 |
|
72 | 75 |
public IPreference[] getPreferencesPages() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ZoomToSelectExtension.java | ||
---|---|---|
28 | 28 |
import org.gvsig.app.ApplicationLocator; |
29 | 29 |
import org.gvsig.app.ApplicationManager; |
30 | 30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
31 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
31 | 32 |
import org.gvsig.fmap.geom.primitive.Envelope; |
32 | 33 |
import org.gvsig.fmap.mapcontext.MapContext; |
33 | 34 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
... | ... | |
52 | 53 |
public void execute(String s) { |
53 | 54 |
ApplicationManager application = ApplicationLocator.getManager(); |
54 | 55 |
|
55 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
56 |
if (document == null) {
|
|
56 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
57 |
if (view == null) {
|
|
57 | 58 |
return; |
58 | 59 |
} |
59 |
|
|
60 |
ViewDocument document = view.getViewDocument(); |
|
60 | 61 |
MapContext mapa = document.getMapContext(); |
61 | 62 |
Envelope selectedExtent = null; |
62 | 63 |
try { |
... | ... | |
72 | 73 |
public boolean isVisible() { |
73 | 74 |
ApplicationManager application = ApplicationLocator.getManager(); |
74 | 75 |
|
75 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
76 |
if (document == null) {
|
|
76 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
77 |
if (view == null) {
|
|
77 | 78 |
return false; |
78 | 79 |
} |
80 |
ViewDocument document = view.getViewDocument(); |
|
79 | 81 |
return document.getMapContext().getLayers().getLayersCount() > 0; |
80 | 82 |
} |
81 | 83 |
|
82 | 84 |
public boolean isEnabled() { |
83 | 85 |
ApplicationManager application = ApplicationLocator.getManager(); |
84 | 86 |
|
85 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
86 |
if (document == null) {
|
|
87 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
88 |
if (view == null) {
|
|
87 | 89 |
return false; |
88 | 90 |
} |
91 |
ViewDocument document = view.getViewDocument(); |
|
89 | 92 |
FLayer[] selected = document.getMapContext().getLayers().getActives(); |
90 | 93 |
if (selected.length == 1 && selected[0] instanceof FLyrVect && selected[0].isAvailable()) { |
91 | 94 |
FLyrVect layer = (FLyrVect) selected[0]; |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/AddLayer.java | ||
---|---|---|
86 | 86 |
public boolean isVisible() { |
87 | 87 |
ApplicationManager application = ApplicationLocator.getManager(); |
88 | 88 |
|
89 |
return application.getActiveDocument(ViewDocument.class) != null;
|
|
89 |
return application.getActiveComponent(ViewDocument.class) != null;
|
|
90 | 90 |
} |
91 | 91 |
|
92 | 92 |
public void postInitialize() { |
... | ... | |
133 | 133 |
public void execute(String actionCommand) { |
134 | 134 |
ApplicationManager application = ApplicationLocator.getManager(); |
135 | 135 |
|
136 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
137 |
if (document == null) {
|
|
136 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
137 |
if (view == null) {
|
|
138 | 138 |
return; |
139 | 139 |
} |
140 |
IView theView = (IView) document.getMainComponent();
|
|
141 |
|
|
142 |
MapControl mapControl = theView.getMapControl();
|
|
140 |
ViewDocument document = view.getViewDocument();
|
|
141 |
|
|
142 |
MapControl mapControl = view.getMapControl();
|
|
143 | 143 |
this.addLayers(mapControl); |
144 | 144 |
mapControl.getMapContext().callLegendChanged(); |
145 | 145 |
document.setModified(true); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/InfoToolExtension.java | ||
---|---|---|
37 | 37 |
/** |
38 | 38 |
* Extension that handles the info by point tool for a selected layer set |
39 | 39 |
* |
40 |
* @author laura |
|
41 | 40 |
*/ |
42 | 41 |
public class InfoToolExtension extends Extension { |
43 | 42 |
|
... | ... | |
51 | 50 |
public void execute(String s) { |
52 | 51 |
ApplicationManager application = ApplicationLocator.getManager(); |
53 | 52 |
|
54 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
55 |
if (document == null) {
|
|
53 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
54 |
if (view == null) {
|
|
56 | 55 |
return; |
57 | 56 |
} |
57 |
ViewDocument document = view.getViewDocument(); |
|
58 |
|
|
58 | 59 |
if (s.compareTo("layer-info-by-point") == 0) { |
59 |
IView view = (IView) document.getMainComponent(); |
|
60 | 60 |
MapControl mapCtrl = view.getMapControl(); |
61 | 61 |
mapCtrl.setTool("info"); |
62 |
view.getDocument().setModified(true);
|
|
62 |
document.setModified(true);
|
|
63 | 63 |
} |
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
public boolean isEnabled() { |
67 | 67 |
ApplicationManager application = ApplicationLocator.getManager(); |
68 | 68 |
|
69 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
70 |
if (document == null) {
|
|
69 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
70 |
if (view == null) {
|
|
71 | 71 |
return false; |
72 | 72 |
} |
73 |
ViewDocument document = view.getViewDocument(); |
|
73 | 74 |
MapContext mapa = document.getMapContext(); |
74 | 75 |
FLayer[] layers = mapa.getLayers().getActives(); |
75 | 76 |
for (int i = 0; i < layers.length; i++) { |
... | ... | |
83 | 84 |
public boolean isVisible() { |
84 | 85 |
ApplicationManager application = ApplicationLocator.getManager(); |
85 | 86 |
|
86 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
87 |
if (document == null) {
|
|
87 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
88 |
if (view == null) {
|
|
88 | 89 |
return false; |
89 | 90 |
} |
91 |
ViewDocument document = view.getViewDocument(); |
|
90 | 92 |
MapContext mapa = document.getMapContext(); |
91 | 93 |
return mapa.getLayers().getLayersCount() > 0; |
92 | 94 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ClearSelectionExtension.java | ||
---|---|---|
41 | 41 |
/** |
42 | 42 |
* Extensi?n encargada de limpiar la selecci?n. |
43 | 43 |
* |
44 |
* @author Vicente Caballero Navarro |
|
45 | 44 |
*/ |
46 | 45 |
public class ClearSelectionExtension extends Extension { |
47 | 46 |
|
48 |
/** |
|
49 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String) |
|
50 |
*/ |
|
47 |
|
|
51 | 48 |
public void execute(String s) { |
52 | 49 |
ApplicationManager application = ApplicationLocator.getManager(); |
53 | 50 |
|
54 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
55 |
if (document == null) {
|
|
51 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
52 |
if (view == null) {
|
|
56 | 53 |
return; |
57 | 54 |
} |
55 |
ViewDocument document = view.getViewDocument(); |
|
58 | 56 |
if (s.equalsIgnoreCase("selection-clear-view")) { |
59 |
IView vista = (IView) document.getMainComponent(); |
|
60 | 57 |
MapContext mapa = document.getMapContext(); |
61 |
MapControl mapCtrl = vista.getMapControl();
|
|
58 |
MapControl mapCtrl = view.getMapControl();
|
|
62 | 59 |
FLayers layers = mapa.getLayers(); |
63 | 60 |
boolean refresh = clearSelectionOfView(layers); |
64 | 61 |
if (refresh) { |
... | ... | |
100 | 97 |
|
101 | 98 |
public boolean isVisible() { |
102 | 99 |
ApplicationManager application = ApplicationLocator.getManager(); |
103 |
|
|
104 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class); |
|
105 |
if (document == null) { |
|
100 |
IView view = (IView) application.getActiveComponent(ViewDocument.class); |
|
101 |
if (view == null) { |
|
106 | 102 |
return false; |
107 | 103 |
} |
108 |
|
|
104 |
ViewDocument document = view.getViewDocument(); |
|
109 | 105 |
MapContext mapa = document.getMapContext(); |
110 | 106 |
return mapa.getLayers().getLayersCount() > 0; |
111 | 107 |
} |
... | ... | |
113 | 109 |
public boolean isEnabled() { |
114 | 110 |
ApplicationManager application = ApplicationLocator.getManager(); |
115 | 111 |
|
116 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
117 |
if (document == null) {
|
|
112 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
113 |
if (view == null) {
|
|
118 | 114 |
return false; |
119 | 115 |
} |
120 |
|
|
116 |
ViewDocument document = view.getViewDocument(); |
|
121 | 117 |
MapContext mapa = document.getMapContext(); |
122 | 118 |
return hasVectorLayersWithSelection(mapa.getLayers()); |
123 | 119 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSimpleSelectionControl.java | ||
---|---|---|
52 | 52 |
public void execute(String actionCommand) { |
53 | 53 |
ApplicationManager application = ApplicationLocator.getManager(); |
54 | 54 |
|
55 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
56 |
if (document == null) {
|
|
55 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
56 |
if (view == null) {
|
|
57 | 57 |
return; |
58 | 58 |
} |
59 |
IView view = (IView) document.getMainComponent();
|
|
59 |
ViewDocument document = view.getViewDocument();
|
|
60 | 60 |
MapControl mapCtrl = view.getMapControl(); |
61 | 61 |
if (actionCommand.equalsIgnoreCase("selection-simple-select-view")) { |
62 | 62 |
mapCtrl.setTool("pointSelection"); |
... | ... | |
67 | 67 |
public boolean isEnabled() { |
68 | 68 |
ApplicationManager application = ApplicationLocator.getManager(); |
69 | 69 |
|
70 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
71 |
if (document == null) {
|
|
70 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
71 |
if (view == null) {
|
|
72 | 72 |
return false; |
73 | 73 |
} |
74 |
ViewDocument document = view.getViewDocument(); |
|
74 | 75 |
return document.getMapContext().hasActiveVectorLayers(); |
75 | 76 |
} |
76 | 77 |
|
77 | 78 |
public boolean isVisible() { |
78 | 79 |
ApplicationManager application = ApplicationLocator.getManager(); |
79 | 80 |
|
80 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
81 |
if (document == null) {
|
|
81 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
82 |
if (view == null) {
|
|
82 | 83 |
return false; |
83 | 84 |
} |
85 |
ViewDocument document = view.getViewDocument(); |
|
84 | 86 |
return document.getMapContext().hasVectorLayers(); |
85 | 87 |
} |
86 | 88 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/FiltroExtension.java | ||
---|---|---|
35 | 35 |
import org.gvsig.app.gui.filter.ExpressionListener; |
36 | 36 |
import org.gvsig.app.gui.filter.FilterDialog; |
37 | 37 |
import org.gvsig.app.project.documents.view.ViewDocument; |
38 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
38 | 39 |
import org.gvsig.fmap.dal.DALLocator; |
39 | 40 |
import org.gvsig.fmap.dal.DataManager; |
40 | 41 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
63 | 64 |
} |
64 | 65 |
|
Also available in: Unified diff