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