svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / LinkControls.java @ 28940
History | View | Annotate | Download (4.07 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 org.apache.log4j.Logger; |
50 |
|
51 |
import com.iver.andami.PluginServices; |
52 |
import com.iver.andami.plugins.Extension; |
53 |
import com.iver.cit.gvsig.fmap.MapContext; |
54 |
import com.iver.cit.gvsig.fmap.MapControl; |
55 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
56 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
57 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
58 |
|
59 |
|
60 |
/**
|
61 |
* Extensi?n para gestionar los hiperlinks.
|
62 |
*
|
63 |
* @author Vicente Caballero Navarro
|
64 |
*/
|
65 |
public class LinkControls extends Extension { |
66 |
private static Logger logger = Logger.getLogger(LinkControls.class.getName()); |
67 |
|
68 |
/**
|
69 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
70 |
*/
|
71 |
public void execute(String s) { |
72 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
73 |
//ProjectView model = vista.getModel();
|
74 |
//FMap mapa = model.getMapContext();
|
75 |
MapControl mapCtrl = vista.getMapControl(); |
76 |
logger.debug("Comand : " + s);
|
77 |
|
78 |
if (s.compareTo("LINK") == 0) { |
79 |
mapCtrl.setTool("link");
|
80 |
} |
81 |
} |
82 |
|
83 |
/**
|
84 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
85 |
*/
|
86 |
public boolean isVisible() { |
87 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
88 |
.getActiveWindow(); |
89 |
|
90 |
if (f == null) { |
91 |
return false; |
92 |
} |
93 |
|
94 |
if (f instanceof View) { |
95 |
|
96 |
MapContext mapa = ((View) f).getModel().getMapContext();
|
97 |
|
98 |
return mapa.getLayers().getLayersCount() > 0; |
99 |
} else {
|
100 |
return false; |
101 |
} |
102 |
} |
103 |
|
104 |
/**
|
105 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
106 |
*/
|
107 |
public boolean isEnabled() { |
108 |
View f = (View) PluginServices.getMDIManager().getActiveWindow(); |
109 |
|
110 |
if (f == null) { |
111 |
return false; |
112 |
} |
113 |
|
114 |
if (f instanceof com.iver.cit.gvsig.project.documents.view.gui.View) { |
115 |
com.iver.cit.gvsig.project.documents.view.gui.View view = (com.iver.cit.gvsig.project.documents.view.gui.View) f; |
116 |
IProjectView model = view.getModel(); |
117 |
Boolean p=null; |
118 |
|
119 |
|
120 |
FLayer[] activas = model.getMapContext().getLayers().getActives();
|
121 |
|
122 |
//Utilizo esta comprobaci?n para poner el bot?n de la herramienta desactivado
|
123 |
//cuando se carga la ventana (comprobar que hay alguna capa activa)
|
124 |
if(activas.length==0) |
125 |
return false; |
126 |
|
127 |
for (int i = 0; i < activas.length; i++) { |
128 |
if (!activas[i].isAvailable()) {
|
129 |
return false; |
130 |
} |
131 |
if(!activas[i].allowLinks())return false; |
132 |
if(activas[i].getLinkProperties()==null || activas[i].getLinkProperties().getField()==null) |
133 |
return false; |
134 |
} |
135 |
} |
136 |
return true; |
137 |
} |
138 |
|
139 |
/**
|
140 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
141 |
*/
|
142 |
public void initialize() { |
143 |
registerIcons(); |
144 |
} |
145 |
|
146 |
private void registerIcons(){ |
147 |
|
148 |
PluginServices.getIconTheme().registerDefault( |
149 |
"view-query-link",
|
150 |
this.getClass().getClassLoader().getResource("images/Link.png") |
151 |
); |
152 |
} |
153 |
} |