svn-gvsig-desktop / trunk / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / gui / SearchDialog.java @ 6877
History | View | Annotate | Download (5.99 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 es.gva.cit.gvsig.catalogClient.gui; |
42 |
|
43 |
import java.awt.Dimension; |
44 |
import java.awt.Frame; |
45 |
import java.awt.event.MouseEvent; |
46 |
import java.awt.event.MouseListener; |
47 |
import java.awt.geom.Rectangle2D; |
48 |
import java.util.Collection; |
49 |
|
50 |
import javax.swing.JDialog; |
51 |
import javax.swing.JFrame; |
52 |
|
53 |
import org.gvsig.i18n.Messages; |
54 |
|
55 |
import com.iver.andami.PluginServices; |
56 |
import com.iver.andami.ui.mdiManager.IWindow; |
57 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
58 |
import com.iver.cit.gvsig.fmap.ColorEvent; |
59 |
import com.iver.cit.gvsig.fmap.ExtentEvent; |
60 |
import com.iver.cit.gvsig.fmap.ProjectionEvent; |
61 |
import com.iver.cit.gvsig.fmap.ViewPortListener; |
62 |
|
63 |
import es.gva.cit.catalogClient.CatalogClient; |
64 |
import es.gva.cit.catalogClient.querys.Coordinates; |
65 |
import es.gva.cit.catalogClient.ui.search.SearchDialogPanel; |
66 |
import es.gva.cit.catalogClient.ui.showResults.ShowResultsPanel; |
67 |
import es.gva.cit.catalogClient.utils.Frames; |
68 |
|
69 |
/**
|
70 |
* This class is used to search a record using the catalog client
|
71 |
* @author luisw
|
72 |
* @modified by Jorge Piera
|
73 |
*/
|
74 |
public class SearchDialog extends SearchDialogPanel implements |
75 |
IWindow,ViewPortListener { |
76 |
private JDialog frame = null; |
77 |
public ViewInfo m_viewinfo = null; |
78 |
|
79 |
public SearchDialog(JDialog frame,Object serverConnectFrame,CatalogClient client) { |
80 |
super(null,serverConnectFrame,client); |
81 |
this.frame = frame;
|
82 |
setViewChangeListener(); |
83 |
loadViewPortCoordinates(); |
84 |
} |
85 |
|
86 |
/**
|
87 |
* This method opens the show results frame.
|
88 |
* @param nodes
|
89 |
* XML node returned by the query
|
90 |
*/
|
91 |
protected void showResults(Collection nodes) { |
92 |
JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false); |
93 |
Frames.centerFrame(panel,610,418); |
94 |
panel.setTitle(Messages.getText("search_results"));
|
95 |
panel.setResizable(false);
|
96 |
|
97 |
ShowResultsPanel.mustShowThumbnails = true;
|
98 |
ShowResultsDialog dialog = |
99 |
new ShowResultsDialog(panel,client,nodes,1); |
100 |
|
101 |
panel.getContentPane().add(dialog); |
102 |
panel.show(); |
103 |
} |
104 |
|
105 |
/**
|
106 |
* It Closes the dialog
|
107 |
*/
|
108 |
public void closeJDialog() { |
109 |
frame.setVisible(false);
|
110 |
|
111 |
} |
112 |
|
113 |
/* (non-Javadoc)
|
114 |
* @see com.iver.andami.ui.mdiManager.View#getViewInfo()
|
115 |
*/
|
116 |
public ViewInfo getViewInfo() {
|
117 |
if (m_viewinfo == null){ |
118 |
m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
119 |
m_viewinfo.setTitle(getName()); |
120 |
} |
121 |
return m_viewinfo;
|
122 |
} |
123 |
|
124 |
|
125 |
/**
|
126 |
* Close button Action performed
|
127 |
*/
|
128 |
public void closeButtonActionPerformed() { |
129 |
closeJDialog(); |
130 |
} |
131 |
|
132 |
/**
|
133 |
* Size button action performed
|
134 |
*/
|
135 |
public void sizeButtonActionPerformed(){ |
136 |
if (isMinimized){
|
137 |
frame.setSize(525,457); |
138 |
ppalPanel.setPreferredSize(new Dimension(514,423)); |
139 |
getLowerPanel().setPreferredSize(new Dimension(514,440)); |
140 |
getLowerPanel().setVisible(true);
|
141 |
frame.setVisible(true);
|
142 |
getUpperPanel().setUpIcon(); |
143 |
}else{
|
144 |
frame.setSize(525,118); |
145 |
ppalPanel.setPreferredSize(new Dimension(514,91)); |
146 |
getLowerPanel().setPreferredSize(new Dimension(514,0)); |
147 |
getLowerPanel().setVisible(false);
|
148 |
frame.setVisible(true);
|
149 |
getUpperPanel().setDownIcon(); |
150 |
} |
151 |
isMinimized = !isMinimized; |
152 |
} |
153 |
|
154 |
/**
|
155 |
* Return button action
|
156 |
*/
|
157 |
public void returnButtonActionPerformed() { |
158 |
closeJDialog(); |
159 |
ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame; |
160 |
serverConnect.setVisible(true);
|
161 |
serverConnect.getSearchButton().setEnabled(false);
|
162 |
PluginServices.getMDIManager().addView(serverConnect); |
163 |
|
164 |
|
165 |
} |
166 |
|
167 |
|
168 |
/**
|
169 |
* This method loads the view coordinates to the catalog search dialog
|
170 |
*
|
171 |
*/
|
172 |
private void loadViewPortCoordinates(){ |
173 |
com.iver.cit.gvsig.gui.View activeView = |
174 |
(com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
175 |
|
176 |
Rectangle2D r2d= activeView.getMapControl().getViewPort().getAdjustedExtent();
|
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 |
/**
|
190 |
* This methos joins the viewPort event to the listener
|
191 |
*/
|
192 |
private void setViewChangeListener(){ |
193 |
com.iver.cit.gvsig.gui.View activeView = |
194 |
(com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
195 |
|
196 |
activeView.getMapControl().getViewPort().addViewPortListener(this);
|
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 |
|
215 |
|
216 |
|
217 |
} |