root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / ViewSelectionControls.java @ 6837
History | View | Annotate | Download (4.26 KB)
1 | 6513 | jaume | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2005 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 | |||
42 | /* CVS MESSAGES:
|
||
43 | *
|
||
44 | * $Id$
|
||
45 | * $Log$
|
||
46 | 6779 | jmvivo | * Revision 1.3 2006-08-18 08:40:04 jmvivo
|
47 | * Actualizado para que el isEnabled tenga en cuenta que las capas esten 'avialable'
|
||
48 | *
|
||
49 | * Revision 1.2 2006/07/27 06:20:28 jaume
|
||
50 | 6533 | jaume | * *** empty log message ***
|
51 | *
|
||
52 | * Revision 1.1 2006/07/26 09:53:05 jaume
|
||
53 | 6513 | jaume | * separadas las herramientas de selecci?n del viewControls al ViewSelectionControls
|
54 | *
|
||
55 | *
|
||
56 | */
|
||
57 | package com.iver.cit.gvsig; |
||
58 | |||
59 | import org.apache.log4j.Logger; |
||
60 | |||
61 | import com.iver.andami.PluginServices; |
||
62 | import com.iver.andami.plugins.Extension; |
||
63 | import com.iver.cit.gvsig.fmap.FMap; |
||
64 | import com.iver.cit.gvsig.fmap.MapControl; |
||
65 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
66 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
67 | import com.iver.cit.gvsig.gui.View; |
||
68 | import com.iver.cit.gvsig.gui.selectionByTheme.DefaultSelectionByThemeModel; |
||
69 | import com.iver.cit.gvsig.gui.selectionByTheme.MySelectionByThemeListener; |
||
70 | import com.iver.cit.gvsig.gui.selectionByTheme.SelectionByTheme; |
||
71 | import com.iver.cit.gvsig.project.ProjectView; |
||
72 | |||
73 | /**
|
||
74 | * Extension that handles the selection tools, selection tools have sense on vectorial
|
||
75 | * layers only.
|
||
76 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
77 | *
|
||
78 | */
|
||
79 | public class ViewSelectionControls extends Extension { |
||
80 | private static Logger logger = Logger.getLogger(ViewControls.class.getName()); |
||
81 | |||
82 | public void initialize() { |
||
83 | // TODO Auto-generated method stub
|
||
84 | |||
85 | } |
||
86 | |||
87 | public void execute(String actionCommand) { |
||
88 | View vista = (View) PluginServices.getMDIManager().getActiveView(); |
||
89 | ProjectView model = vista.getModel(); |
||
90 | FMap mapa = model.getMapContext(); |
||
91 | MapControl mapCtrl = vista.getMapControl(); |
||
92 | logger.debug("Comand : " + actionCommand);
|
||
93 | if (actionCommand.equals("SELRECT") ) { |
||
94 | mapCtrl.setTool("rectSelection");
|
||
95 | } else if (actionCommand.equals("SELPOINT") ) { |
||
96 | mapCtrl.setTool("pointSelection");
|
||
97 | } else if (actionCommand.equals("SELECTIONBYSHAPE") ) { |
||
98 | SelectionByTheme dlg = new SelectionByTheme();
|
||
99 | //FLayer[] layers = mapa.getLayers().getActives();
|
||
100 | //int count = 0;
|
||
101 | dlg.setModel(new DefaultSelectionByThemeModel());
|
||
102 | dlg.addSelectionListener(new MySelectionByThemeListener());
|
||
103 | PluginServices.getMDIManager().addView(dlg); |
||
104 | } |
||
105 | } |
||
106 | |||
107 | public boolean isEnabled() { |
||
108 | com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
||
109 | .getActiveView(); |
||
110 | if (f instanceof View) { |
||
111 | |||
112 | View vista = (View) f; |
||
113 | ProjectView model = vista.getModel(); |
||
114 | FMap mapa = model.getMapContext(); |
||
115 | |||
116 | for (int i = 0; i < mapa.getLayers().getActives().length; i++) { |
||
117 | FLayer lyr = mapa.getLayers().getActives()[i]; |
||
118 | 6779 | jmvivo | if (lyr.isAvailable() && lyr instanceof FLyrVect) { |
119 | 6513 | jaume | return true; |
120 | } |
||
121 | } |
||
122 | return false; |
||
123 | } |
||
124 | return true; |
||
125 | } |
||
126 | |||
127 | public boolean isVisible() { |
||
128 | com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
||
129 | .getActiveView(); |
||
130 | |||
131 | 6533 | jaume | if (f != null && f instanceof View) { |
132 | 6513 | jaume | View vista = (View) f; |
133 | ProjectView model = vista.getModel(); |
||
134 | FMap mapa = model.getMapContext(); |
||
135 | |||
136 | for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) { |
||
137 | FLayer lyr = mapa.getLayers().getLayer(i); |
||
138 | if (lyr instanceof FLyrVect) { |
||
139 | return true; |
||
140 | } |
||
141 | } |
||
142 | } |
||
143 | 6533 | jaume | return false; |
144 | 6513 | jaume | } |
145 | 6533 | jaume | } |