root / trunk / extensions / extDataLocator / src / com / iver / gvsig / datalocator / DataLocatorExtension.java @ 7411
History | View | Annotate | Download (5.41 KB)
1 |
/*
|
---|---|
2 |
* Created on 22-jun-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.gvsig.datalocator; |
45 |
|
46 |
import java.util.prefs.Preferences; |
47 |
|
48 |
import com.iver.andami.PluginServices; |
49 |
import com.iver.andami.plugins.Extension; |
50 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
51 |
import com.iver.cit.gvsig.fmap.MapContext; |
52 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
53 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
54 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
55 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
56 |
import com.iver.gvsig.datalocator.gui.DataSelectionPanel; |
57 |
|
58 |
/**
|
59 |
* The DataLocatorExtension class allows to make a quick zoom based on an
|
60 |
* alphanumeric attribute.
|
61 |
*
|
62 |
* @author jmorell
|
63 |
*/
|
64 |
public class DataLocatorExtension extends Extension { |
65 |
|
66 |
boolean bFirstTimeOpened = false; |
67 |
|
68 |
/* (non-Javadoc)
|
69 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
70 |
*/
|
71 |
public void initialize() { |
72 |
bFirstTimeOpened = false;
|
73 |
|
74 |
} |
75 |
|
76 |
/* (non-Javadoc)
|
77 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
78 |
*/
|
79 |
public void execute(String actionCommand) { |
80 |
View vista = (View)PluginServices.getMDIManager().getActiveWindow(); |
81 |
MapContext mapContext = vista.getModel().getMapContext(); |
82 |
DataSelectionPanel dataSelectionPanel = new DataSelectionPanel(mapContext);
|
83 |
WindowInfo vi = dataSelectionPanel.getWindowInfo(); |
84 |
vi.setX(Preferences.userRoot().getInt("gvSIG.DataLocator.x", vi.getX())); |
85 |
vi.setY(Preferences.userRoot().getInt("gvSIG.DataLocator.y", vi.getY())); |
86 |
// vi.setWidth(Preferences.userRoot().getInt("gvSIG.DataLocator.w", vi.getWidth()));
|
87 |
// vi.setHeight(Preferences.userRoot().getInt("gvSIG.DataLocator.h", vi.getHeight()));
|
88 |
|
89 |
PluginServices.getMDIManager().addWindow(dataSelectionPanel); |
90 |
|
91 |
bFirstTimeOpened = true;
|
92 |
} |
93 |
|
94 |
/* (non-Javadoc)
|
95 |
* @see com.iver.andami.plugins.Extension#isEnabled()
|
96 |
*/
|
97 |
public boolean isEnabled() { |
98 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
99 |
.getActiveWindow(); |
100 |
if (f == null) { |
101 |
return false; |
102 |
} |
103 |
if (f.getClass() == View.class) { |
104 |
// Si la vista tiene el tema con el que est? configurado
|
105 |
// el DataLocator y el usuario ha decidido que se abra
|
106 |
// autom?ticamente, la abrimos inmediatamente.
|
107 |
if (!bFirstTimeOpened)
|
108 |
{ |
109 |
View vista = (View) f; |
110 |
IProjectView model = vista.getModel(); |
111 |
MapContext mapContext = model.getMapContext(); |
112 |
int userOpen = Preferences.userRoot().getInt("gvSIG.DataLocator.open_first_time", -1); |
113 |
if (userOpen == 1) |
114 |
{ |
115 |
String layerName = Preferences.userRoot().get("LAYERNAME_FOR_DATA_LOCATION", ""); |
116 |
FLayer lyr = mapContext.getLayers().getLayer(layerName); |
117 |
if (lyr != null) |
118 |
{ |
119 |
DataSelectionPanel dataSelectionPanel = new DataSelectionPanel(mapContext);
|
120 |
WindowInfo vi = dataSelectionPanel.getWindowInfo(); |
121 |
vi.setX(Preferences.userRoot().getInt("gvSIG.DataLocator.x", vi.getX())); |
122 |
vi.setY(Preferences.userRoot().getInt("gvSIG.DataLocator.y", vi.getY())); |
123 |
// vi.setWidth(Preferences.userRoot().getInt("gvSIG.DataLocator.w", vi.getWidth()));
|
124 |
// vi.setHeight(Preferences.userRoot().getInt("gvSIG.DataLocator.h", vi.getHeight()));
|
125 |
|
126 |
PluginServices.getMDIManager().addWindow(dataSelectionPanel); |
127 |
bFirstTimeOpened = true;
|
128 |
} |
129 |
} |
130 |
} |
131 |
} |
132 |
return true; |
133 |
} |
134 |
|
135 |
/* (non-Javadoc)
|
136 |
* @see com.iver.andami.plugins.Extension#isVisible()
|
137 |
*/
|
138 |
public boolean isVisible() { |
139 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
140 |
.getActiveWindow(); |
141 |
if (f == null) { |
142 |
return false; |
143 |
} |
144 |
if (f.getClass() == View.class) { |
145 |
View vista = (View) f; |
146 |
IProjectView model = vista.getModel(); |
147 |
MapContext mapa = model.getMapContext(); |
148 |
if (mapa.getLayers().getLayersCount() > 0) { |
149 |
boolean vectLayers = false; |
150 |
for (int i=0;i<mapa.getLayers().getLayersCount();i++) { |
151 |
FLayer lyr = mapa.getLayers().getLayer(i); |
152 |
if (lyr instanceof FLyrVect && lyr.isAvailable()) { |
153 |
vectLayers = true;
|
154 |
break;
|
155 |
} |
156 |
} |
157 |
return vectLayers;
|
158 |
} else {
|
159 |
return false; |
160 |
} |
161 |
} else {
|
162 |
return false; |
163 |
} |
164 |
} |
165 |
|
166 |
} |