root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / extension / InfoToolExtension.java @ 38189
History | View | Annotate | Download (3.62 KB)
1 | 5967 | ldiaz | /*
|
---|---|---|---|
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 | 29596 | jpiera | package org.gvsig.app.extension; |
48 | 5967 | ldiaz | |
49 | 35485 | jjdelcerro | import org.slf4j.Logger; |
50 | import org.slf4j.LoggerFactory; |
||
51 | |||
52 | 29596 | jpiera | import org.gvsig.andami.PluginServices; |
53 | import org.gvsig.andami.plugins.Extension; |
||
54 | 35485 | jjdelcerro | import org.gvsig.andami.ui.mdiManager.IWindow; |
55 | import org.gvsig.app.ApplicationLocator; |
||
56 | import org.gvsig.app.project.documents.view.gui.IView; |
||
57 | 20994 | jmvivo | import org.gvsig.fmap.mapcontext.MapContext; |
58 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
59 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
60 | 6778 | jmvivo | |
61 | 5967 | ldiaz | |
62 | |||
63 | /**
|
||
64 | * Extension that handles the info by point tool for a selected layer set
|
||
65 | * @author laura
|
||
66 | */
|
||
67 | public class InfoToolExtension extends Extension { |
||
68 | 28033 | cordinyana | private static final Logger logger = LoggerFactory |
69 | .getLogger(InfoToolExtension.class); |
||
70 | 5967 | ldiaz | |
71 | 35485 | jjdelcerro | public void initialize() { |
72 | registerIcons(); |
||
73 | } |
||
74 | |||
75 | private void registerIcons(){ |
||
76 | PluginServices.getIconTheme().registerDefault( |
||
77 | "view-query-information",
|
||
78 | InfoToolExtension.class.getClassLoader().getResource("images/Identify.png")
|
||
79 | ); |
||
80 | } |
||
81 | |||
82 | 5967 | ldiaz | public void execute(String s) { |
83 | 35485 | jjdelcerro | logger.debug("Comand : " + s);
|
84 | 9532 | caballero | |
85 | 35485 | jjdelcerro | IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
86 | if( window instanceof IView ) { |
||
87 | IView view = (IView) window; |
||
88 | MapControl mapCtrl = view.getMapControl(); |
||
89 | |||
90 | if (s.compareTo("INFO") == 0) { |
||
91 | mapCtrl.setTool("info");
|
||
92 | view.getDocument().setModified(true);
|
||
93 | } |
||
94 | } |
||
95 | 5967 | ldiaz | } |
96 | |||
97 | public boolean isEnabled() { |
||
98 | 35485 | jjdelcerro | IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
99 | 5967 | ldiaz | |
100 | 35485 | jjdelcerro | if (window == null) { |
101 | 5967 | ldiaz | return false; |
102 | } |
||
103 | |||
104 | 35485 | jjdelcerro | if (window instanceof IView) { |
105 | IView view = (IView) window; |
||
106 | MapContext mapa = view.getViewDocument().getMapContext(); |
||
107 | 5967 | ldiaz | |
108 | 6778 | jmvivo | FLayer[] layers =mapa.getLayers().getActives();
|
109 | for (int i=0;i<layers.length;i++) { |
||
110 | 35485 | jjdelcerro | if (layers[i].isAvailable()) {
|
111 | return true; |
||
112 | } |
||
113 | 6778 | jmvivo | } |
114 | 5967 | ldiaz | } |
115 | 6778 | jmvivo | return false; |
116 | 5967 | ldiaz | } |
117 | |||
118 | public boolean isVisible() { |
||
119 | 35485 | jjdelcerro | IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
120 | 5988 | ldiaz | |
121 | 35485 | jjdelcerro | if (window == null) { |
122 | return false; |
||
123 | } |
||
124 | 14821 | jmvivo | |
125 | 35485 | jjdelcerro | if (window instanceof IView) { |
126 | IView view = (IView) window; |
||
127 | MapContext mapa = view.getViewDocument().getMapContext(); |
||
128 | 5988 | ldiaz | return mapa.getLayers().getLayersCount() > 0; |
129 | } else {
|
||
130 | return false; |
||
131 | } |
||
132 | 5967 | ldiaz | } |
133 | } |