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