gvsig-gazetteer / trunk / extGazetteer / src / org / gvsig / gazetteer / gui / SearchDialog.java @ 14
History | View | Annotate | Download (6.44 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.gazetteer.gui; |
42 |
|
43 |
import java.awt.Frame; |
44 |
import java.awt.geom.Rectangle2D; |
45 |
|
46 |
import javax.swing.Icon; |
47 |
import javax.swing.JDialog; |
48 |
|
49 |
import org.gvsig.andami.PluginServices; |
50 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
51 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
52 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
53 |
import org.gvsig.catalog.querys.Coordinates; |
54 |
import org.gvsig.catalog.utils.Frames; |
55 |
import org.gvsig.fmap.mapcontext.events.ColorEvent; |
56 |
import org.gvsig.fmap.mapcontext.events.ExtentEvent; |
57 |
import org.gvsig.fmap.mapcontext.events.ProjectionEvent; |
58 |
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener; |
59 |
import org.gvsig.gazetteer.GazetteerClient; |
60 |
import org.gvsig.gazetteer.querys.Feature; |
61 |
import org.gvsig.gazetteer.ui.search.SearchDialogPanel; |
62 |
import org.gvsig.i18n.Messages; |
63 |
|
64 |
|
65 |
|
66 |
/**
|
67 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
68 |
*/
|
69 |
public class SearchDialog extends SearchDialogPanel |
70 |
implements IWindow,ViewPortListener{
|
71 |
public WindowInfo m_windowInfo = null; |
72 |
public ConnectDialog parentDialog = null; |
73 |
public JDialog frame = null; |
74 |
|
75 |
public SearchDialog(GazetteerClient client,Object serverConnectFrame){ |
76 |
super(client,serverConnectFrame);
|
77 |
parentDialog = (ConnectDialog)serverConnectFrame; |
78 |
setViewChangeListener(); |
79 |
loadViewPortCoordinates(); |
80 |
} |
81 |
|
82 |
/* (non-Javadoc)
|
83 |
* @see com.iver.andami.ui.mdiManager.View#getViewInfo()
|
84 |
*/
|
85 |
public WindowInfo getWindowInfo() {
|
86 |
if (m_windowInfo == null){ |
87 |
m_windowInfo = new WindowInfo(WindowInfo.PALETTE);
|
88 |
m_windowInfo.setTitle(Messages.getText("gazetteer_search") + " [" + |
89 |
getCurrentServer() + "]");
|
90 |
m_windowInfo.setHeight(80);
|
91 |
m_windowInfo.setWidth(525);
|
92 |
} |
93 |
return m_windowInfo;
|
94 |
|
95 |
} |
96 |
public Object getWindowProfile(){ |
97 |
return WindowInfo.TOOL_PROFILE;
|
98 |
} |
99 |
|
100 |
protected void showResultsActionPerformed(Feature[] features) { |
101 |
JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false); |
102 |
Frames.centerFrame(panel,420,258); |
103 |
panel.setTitle(Messages.getText( "gazetteer_search"));
|
104 |
panel.setResizable(false);
|
105 |
|
106 |
ShowResultsDialog dialog = new ShowResultsDialog(panel,
|
107 |
client, |
108 |
features, |
109 |
lowerPanel.getResultsByPage(), |
110 |
getQuery()); |
111 |
|
112 |
panel.getContentPane().add(dialog); |
113 |
panel.show(); |
114 |
} |
115 |
|
116 |
protected void closeButtonActionPerformed() { |
117 |
closeJDialog(); |
118 |
} |
119 |
|
120 |
/**
|
121 |
* Size button action performed
|
122 |
*/
|
123 |
protected void resizeButtonActionPerformed(){ |
124 |
if (isMinimized){
|
125 |
frame.setSize(frame.getWidth(),450);
|
126 |
frame.doLayout(); |
127 |
getLowerPanel().setVisible(true);
|
128 |
getUpperPanel().setIcon(getUpIcon()); |
129 |
}else{
|
130 |
frame.setSize(frame.getWidth(),115);
|
131 |
getLowerPanel().setVisible(false);
|
132 |
getUpperPanel().setIcon(getDownIcon()); |
133 |
} |
134 |
isMinimized = !isMinimized; |
135 |
} |
136 |
|
137 |
/*
|
138 |
* (non-Javadoc)
|
139 |
* @see org.gvsig.gazetteer.ui.search.SearchDialogPanel#getUpIcon()
|
140 |
*/
|
141 |
protected Icon getUpIcon(){ |
142 |
return PluginServices.getIconTheme().get("gazetteer-up"); |
143 |
} |
144 |
|
145 |
/*
|
146 |
* (non-Javadoc)
|
147 |
* @see org.gvsig.gazetteer.ui.search.SearchDialogPanel#getDownIcon()
|
148 |
*/
|
149 |
protected Icon getDownIcon(){ |
150 |
return PluginServices.getIconTheme().get("gazetteer-down"); |
151 |
} |
152 |
|
153 |
/**
|
154 |
* Return button action
|
155 |
*/
|
156 |
protected void lastButtonActionPerformed() { |
157 |
closeJDialog(); |
158 |
ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame; |
159 |
parentDialog.setVisible(true);
|
160 |
parentDialog.getControlsPanel().enableSearchButton(false);
|
161 |
PluginServices.getMDIManager().addWindow(serverConnect); |
162 |
} |
163 |
|
164 |
public void closeJDialog() { |
165 |
frame.setVisible(false);
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* This method loads the view coordinates to the catalog search dialog
|
170 |
*
|
171 |
*/
|
172 |
private void loadViewPortCoordinates(){ |
173 |
AbstractViewPanel activeView = |
174 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
175 |
|
176 |
Rectangle2D r2d= activeView.getMapControl().getViewPort().getExtent();
|
177 |
|
178 |
try{
|
179 |
getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(),
|
180 |
r2d.getMaxY(), |
181 |
r2d.getMaxX(), |
182 |
r2d.getMinY())); |
183 |
}catch(NullPointerException E){ |
184 |
//We cant retrieve the coordinates if it doesn't
|
185 |
//exist a loaded layer
|
186 |
} |
187 |
} |
188 |
/*
|
189 |
* This method joins the viewPort event to the listener
|
190 |
*/
|
191 |
private void setViewChangeListener(){ |
192 |
AbstractViewPanel activeView = |
193 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
194 |
|
195 |
activeView.getMapControl().getViewPort().addViewPortListener(this);
|
196 |
|
197 |
} |
198 |
|
199 |
public void extentChanged(ExtentEvent e) { |
200 |
loadViewPortCoordinates(); |
201 |
|
202 |
} |
203 |
|
204 |
public void backColorChanged(ColorEvent e) { |
205 |
// TODO Auto-generated method stub
|
206 |
|
207 |
} |
208 |
|
209 |
public void projectionChanged(ProjectionEvent e) { |
210 |
loadViewPortCoordinates(); |
211 |
} |
212 |
|
213 |
/**
|
214 |
* @param frame the frame to set
|
215 |
*/
|
216 |
public void setFrame(JDialog dialog) { |
217 |
this.frame = dialog;
|
218 |
} |
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
} |