Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / InfoToolExtension.java @ 28153

History | View | Annotate | Download (3.72 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 20994 jmvivo
import org.gvsig.fmap.mapcontext.MapContext;
50
import org.gvsig.fmap.mapcontext.layers.FLayer;
51
import org.gvsig.fmap.mapcontrol.MapControl;
52 28033 cordinyana
import org.slf4j.Logger;
53
import org.slf4j.LoggerFactory;
54 6778 jmvivo
55 5967 ldiaz
import com.iver.andami.PluginServices;
56
import com.iver.andami.plugins.Extension;
57 9532 caballero
import com.iver.cit.gvsig.project.documents.ProjectDocument;
58 7392 sbayarri
import com.iver.cit.gvsig.project.documents.view.IProjectView;
59 12210 jcampos
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
60 5967 ldiaz
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 28033 cordinyana
    private static final Logger logger = LoggerFactory
68
            .getLogger(InfoToolExtension.class);
69 5967 ldiaz
70
        public void execute(String s) {
71 12210 jcampos
                BaseView vista = (BaseView) PluginServices.getMDIManager().getActiveWindow();
72 5967 ldiaz
                MapControl mapCtrl = vista.getMapControl();
73
                logger.debug("Comand : " + s);
74 9532 caballero
75 5967 ldiaz
                if (s.compareTo("INFO") == 0) {
76
                        mapCtrl.setTool("info");
77 9532 caballero
                        ((ProjectDocument)vista.getModel()).setModified(true);
78 5967 ldiaz
                }
79
        }
80
81
82
        /**
83
         * @see com.iver.mdiApp.plugins.IExtension#isVisible()
84
         */
85
        public boolean isEnabled() {
86 6877 cesar
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
87 6880 cesar
                                                                                                                         .getActiveWindow();
88 5967 ldiaz
89
                if (f == null) {
90
                        return false;
91
                }
92
93 12210 jcampos
                if (f instanceof BaseView) {
94
                        BaseView vista = (BaseView) f;
95 7392 sbayarri
                        IProjectView model = vista.getModel();
96 6878 cesar
                        MapContext mapa = model.getMapContext();
97 5967 ldiaz
98 6778 jmvivo
                        FLayer[] layers =mapa.getLayers().getActives();
99
                        for (int i=0;i<layers.length;i++) {
100
                                if (layers[i].isAvailable()) return true;
101
                        }
102 5967 ldiaz
                }
103 6778 jmvivo
                return false;
104 5967 ldiaz
        }
105
106
        /**
107
         * @see com.iver.andami.plugins.IExtension#initialize()
108
         */
109
        public void initialize() {
110 14821 jmvivo
                registerIcons();
111 5967 ldiaz
        }
112
113 14821 jmvivo
        private void registerIcons(){
114 15647 jmvivo
                PluginServices.getIconTheme().registerDefault(
115 14821 jmvivo
                                "view-query-information",
116
                                InfoToolExtension.class.getClassLoader().getResource("images/Identify.png")
117
                );
118
        }
119
120 5967 ldiaz
        /**
121
         * @see com.iver.andami.plugins.IExtension#isEnabled()
122
         */
123
        public boolean isVisible() {
124 6880 cesar
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
125 5988 ldiaz
126
                if (f == null) {
127
                        return false;
128
                }
129 14821 jmvivo
130 12210 jcampos
                if (f instanceof BaseView) {
131
                        BaseView vista = (BaseView) f;
132 7392 sbayarri
                        IProjectView model = vista.getModel();
133 6878 cesar
                        MapContext mapa = model.getMapContext();
134 5988 ldiaz
                        return mapa.getLayers().getLayersCount() > 0;
135
                } else {
136
                        return false;
137
                }
138 5967 ldiaz
        }
139
}