root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / InfoToolExtension.java @ 11018
History | View | Annotate | Download (3.43 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 | package com.iver.cit.gvsig; |
||
48 | |||
49 | import org.apache.log4j.Logger; |
||
50 | 6778 | jmvivo | |
51 | 5967 | ldiaz | import com.iver.andami.PluginServices; |
52 | import com.iver.andami.plugins.Extension; |
||
53 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
54 | 5967 | ldiaz | import com.iver.cit.gvsig.fmap.MapControl; |
55 | 6778 | jmvivo | import com.iver.cit.gvsig.fmap.layers.FLayer; |
56 | 9532 | caballero | import com.iver.cit.gvsig.project.documents.ProjectDocument; |
57 | 7392 | sbayarri | import com.iver.cit.gvsig.project.documents.view.IProjectView; |
58 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
59 | 5967 | ldiaz | |
60 | |||
61 | /**
|
||
62 | * Extension that handles the info by point tool for a selected layer set
|
||
63 | * @author laura
|
||
64 | */
|
||
65 | public class InfoToolExtension extends Extension { |
||
66 | private static Logger logger = Logger.getLogger(InfoToolExtension.class.getName()); |
||
67 | |||
68 | public void execute(String s) { |
||
69 | 6880 | cesar | View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
70 | 5967 | ldiaz | MapControl mapCtrl = vista.getMapControl(); |
71 | logger.debug("Comand : " + s);
|
||
72 | 9532 | caballero | |
73 | 5967 | ldiaz | if (s.compareTo("INFO") == 0) { |
74 | mapCtrl.setTool("info");
|
||
75 | 9532 | caballero | ((ProjectDocument)vista.getModel()).setModified(true);
|
76 | 5967 | ldiaz | } |
77 | } |
||
78 | |||
79 | |||
80 | /**
|
||
81 | * @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
||
82 | */
|
||
83 | public boolean isEnabled() { |
||
84 | 6877 | cesar | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
85 | 6880 | cesar | .getActiveWindow(); |
86 | 5967 | ldiaz | |
87 | if (f == null) { |
||
88 | return false; |
||
89 | } |
||
90 | |||
91 | if (f.getClass() == View.class) { |
||
92 | View vista = (View) f; |
||
93 | 7392 | sbayarri | IProjectView model = vista.getModel(); |
94 | 6878 | cesar | MapContext mapa = model.getMapContext(); |
95 | 5967 | ldiaz | |
96 | 6778 | jmvivo | FLayer[] layers =mapa.getLayers().getActives();
|
97 | for (int i=0;i<layers.length;i++) { |
||
98 | if (layers[i].isAvailable()) return true; |
||
99 | } |
||
100 | 5967 | ldiaz | } |
101 | 6778 | jmvivo | return false; |
102 | 5967 | ldiaz | } |
103 | |||
104 | /**
|
||
105 | * @see com.iver.andami.plugins.IExtension#initialize()
|
||
106 | */
|
||
107 | public void initialize() { |
||
108 | } |
||
109 | |||
110 | /**
|
||
111 | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
||
112 | */
|
||
113 | public boolean isVisible() { |
||
114 | 6880 | cesar | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
115 | 5988 | ldiaz | |
116 | if (f == null) { |
||
117 | return false; |
||
118 | } |
||
119 | 9532 | caballero | |
120 | 5988 | ldiaz | if (f instanceof View) { |
121 | View vista = (View) f; |
||
122 | 7392 | sbayarri | IProjectView model = vista.getModel(); |
123 | 6878 | cesar | MapContext mapa = model.getMapContext(); |
124 | 5988 | ldiaz | return mapa.getLayers().getLayersCount() > 0; |
125 | } else {
|
||
126 | return false; |
||
127 | } |
||
128 | 5967 | ldiaz | } |
129 | } |