Statistics
| Revision:

svn-gvsig-desktop / tags / Root_gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / LinkControls.java @ 1648

History | View | Annotate | Download (3.17 KB)

1
/*
2
 * Created on 01-jun-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 com.iver.andami.PluginServices;
50
import com.iver.andami.plugins.Extension;
51

    
52
import com.iver.cit.gvsig.fmap.FMap;
53
import com.iver.cit.gvsig.fmap.MapControl;
54
import com.iver.cit.gvsig.fmap.layers.FLayer;
55
import com.iver.cit.gvsig.gui.View;
56
import com.iver.cit.gvsig.project.ProjectView;
57

    
58
import org.apache.log4j.Logger;
59

    
60

    
61
/**
62
 * Extensi?n para gestionar los hiperlinks.
63
 *
64
 * @author Vicente Caballero Navarro
65
 */
66
public class LinkControls implements Extension {
67
        private static Logger logger = Logger.getLogger(LinkControls.class.getName());
68

    
69
        /**
70
         * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
71
         */
72
        public void execute(String s) {
73
                View vista = (View) PluginServices.getMDIManager().getActiveView();
74
                ProjectView model = vista.getModel();
75
                FMap mapa = model.getMapContext();
76
                MapControl mapCtrl = vista.getMapControl().getMapControl();
77
                logger.debug("Comand : " + s);
78

    
79
                if (s.compareTo("LINK") == 0) {
80
                        mapCtrl.setTool("link");
81
                }
82
        }
83

    
84
        /**
85
         * @see com.iver.mdiApp.plugins.Extension#isVisible()
86
         */
87
        public boolean isVisible() {
88
                com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
89
                                                                                                                         .getActiveView();
90

    
91
                if (f == null) {
92
                        return false;
93
                }
94

    
95
                if (f.getClass() == View.class) {
96
                        FMap mapa = ((View) f).getModel().getMapContext();
97

    
98
                        View v = (View) f;
99

    
100
                        return mapa.getLayers().getLayersCount() > 0;
101
                } else {
102
                        return false;
103
                }
104
        }
105

    
106
        /**
107
         * @see com.iver.andami.plugins.Extension#isEnabled()
108
         */
109
        public boolean isEnabled() {
110
                View f = (View) PluginServices.getMDIManager().getActiveView();
111

    
112
                if (f == null) {
113
                        return false;
114
                }
115

    
116
                FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
117

    
118
                return selected.length > 0;
119
        }
120

    
121
        /**
122
         * @see com.iver.andami.plugins.Extension#inicializar()
123
         */
124
        public void inicializar() {
125
        }
126
}