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 / InfoToolExtension.java @ 40558
History | View | Annotate | Download (4.34 KB)
1 |
/**
|
---|---|
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 |
/*
|
25 |
* Created on 20-feb-2004
|
26 |
*
|
27 |
* To change the template for this generated file go to
|
28 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
29 |
*/
|
30 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
31 |
*
|
32 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
33 |
*
|
34 |
* This program is free software; you can redistribute it and/or
|
35 |
* modify it under the terms of the GNU General Public License
|
36 |
* as published by the Free Software Foundation; either version 2
|
37 |
* of the License, or (at your option) any later version.
|
38 |
*
|
39 |
* This program is distributed in the hope that it will be useful,
|
40 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
41 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
42 |
* GNU General Public License for more details.
|
43 |
*
|
44 |
* You should have received a copy of the GNU General Public License
|
45 |
* along with this program; if not, write to the Free Software
|
46 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
47 |
*
|
48 |
* For more information, contact:
|
49 |
*
|
50 |
* Generalitat Valenciana
|
51 |
* Conselleria d'Infraestructures i Transport
|
52 |
* Av. Blasco Ib??ez, 50
|
53 |
* 46010 VALENCIA
|
54 |
* SPAIN
|
55 |
*
|
56 |
* +34 963862235
|
57 |
* gvsig@gva.es
|
58 |
* www.gvsig.gva.es
|
59 |
*
|
60 |
* or
|
61 |
*
|
62 |
* IVER T.I. S.A
|
63 |
* Salamanca 50
|
64 |
* 46005 Valencia
|
65 |
* Spain
|
66 |
*
|
67 |
* +34 963163400
|
68 |
* dac@iver.es
|
69 |
*/
|
70 |
package org.gvsig.app.extension; |
71 |
|
72 |
import org.gvsig.andami.IconThemeHelper; |
73 |
import org.gvsig.andami.plugins.Extension; |
74 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
75 |
import org.gvsig.app.ApplicationLocator; |
76 |
import org.gvsig.app.project.documents.view.gui.IView; |
77 |
import org.gvsig.fmap.mapcontext.MapContext; |
78 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
79 |
import org.gvsig.fmap.mapcontrol.MapControl; |
80 |
import org.slf4j.Logger; |
81 |
import org.slf4j.LoggerFactory; |
82 |
|
83 |
|
84 |
|
85 |
/**
|
86 |
* Extension that handles the info by point tool for a selected layer set
|
87 |
* @author laura
|
88 |
*/
|
89 |
public class InfoToolExtension extends Extension { |
90 |
private static final Logger logger = LoggerFactory |
91 |
.getLogger(InfoToolExtension.class); |
92 |
|
93 |
public void initialize() { |
94 |
IconThemeHelper.registerIcon("action", "layer-info-by-point", this); |
95 |
} |
96 |
|
97 |
public void execute(String s) { |
98 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
99 |
if( window instanceof IView ) { |
100 |
IView view = (IView) window; |
101 |
MapControl mapCtrl = view.getMapControl(); |
102 |
|
103 |
if (s.compareTo("layer-info-by-point") == 0) { |
104 |
mapCtrl.setTool("info");
|
105 |
view.getDocument().setModified(true);
|
106 |
} |
107 |
} |
108 |
} |
109 |
|
110 |
public boolean isEnabled() { |
111 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
112 |
|
113 |
if (window == null) { |
114 |
return false; |
115 |
} |
116 |
|
117 |
if (window instanceof IView) { |
118 |
IView view = (IView) window; |
119 |
MapContext mapa = view.getViewDocument().getMapContext(); |
120 |
|
121 |
FLayer[] layers =mapa.getLayers().getActives();
|
122 |
for (int i=0;i<layers.length;i++) { |
123 |
if (layers[i].isAvailable()) {
|
124 |
return true; |
125 |
} |
126 |
} |
127 |
} |
128 |
return false; |
129 |
} |
130 |
|
131 |
public boolean isVisible() { |
132 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
133 |
|
134 |
if (window == null) { |
135 |
return false; |
136 |
} |
137 |
|
138 |
if (window instanceof IView) { |
139 |
IView view = (IView) window; |
140 |
MapContext mapa = view.getViewDocument().getMapContext(); |
141 |
return mapa.getLayers().getLayersCount() > 0; |
142 |
} else {
|
143 |
return false; |
144 |
} |
145 |
} |
146 |
} |
147 |
|