svn-gvsig-desktop / branches / v10 / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / gui / SearchDialog.java @ 8604
History | View | Annotate | Download (5.86 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.geom.Rectangle2D; |
46 |
import java.util.Collection; |
47 |
|
48 |
import javax.swing.JDialog; |
49 |
|
50 |
import org.gvsig.i18n.Messages; |
51 |
|
52 |
import com.iver.andami.PluginServices; |
53 |
import com.iver.andami.ui.mdiManager.IWindow; |
54 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
55 |
import com.iver.cit.gvsig.fmap.ColorEvent; |
56 |
import com.iver.cit.gvsig.fmap.ExtentEvent; |
57 |
import com.iver.cit.gvsig.fmap.ProjectionEvent; |
58 |
import com.iver.cit.gvsig.fmap.ViewPortListener; |
59 |
import com.iver.cit.gvsig.gui.View; |
60 |
|
61 |
import es.gva.cit.catalogClient.CatalogClient; |
62 |
import es.gva.cit.catalogClient.querys.Coordinates; |
63 |
import es.gva.cit.catalogClient.ui.search.SearchDialogPanel; |
64 |
import es.gva.cit.catalogClient.ui.showResults.ShowResultsPanel; |
65 |
import es.gva.cit.catalogClient.utils.Frames; |
66 |
|
67 |
/**
|
68 |
* This class is used to search a record using the catalog client
|
69 |
* @author luisw
|
70 |
* @modified by Jorge Piera
|
71 |
*/
|
72 |
public class SearchDialog extends SearchDialogPanel implements |
73 |
IWindow,ViewPortListener { |
74 |
private JDialog frame = null; |
75 |
public WindowInfo m_viewinfo = null; |
76 |
|
77 |
public SearchDialog(JDialog frame,Object serverConnectFrame,CatalogClient client) { |
78 |
super(null,serverConnectFrame,client); |
79 |
this.frame = frame;
|
80 |
setViewChangeListener(); |
81 |
loadViewPortCoordinates(); |
82 |
} |
83 |
|
84 |
/**
|
85 |
* This method opens the show results frame.
|
86 |
* @param nodes
|
87 |
* XML node returned by the query
|
88 |
*/
|
89 |
protected void showResults(Collection nodes) { |
90 |
JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false); |
91 |
Frames.centerFrame(panel,610,418); |
92 |
panel.setTitle(Messages.getText("search_results"));
|
93 |
panel.setResizable(false);
|
94 |
|
95 |
ShowResultsPanel.mustShowThumbnails = true;
|
96 |
ShowResultsDialog dialog = |
97 |
new ShowResultsDialog(panel,client,nodes,1); |
98 |
|
99 |
panel.getContentPane().add(dialog); |
100 |
panel.show(); |
101 |
} |
102 |
|
103 |
/**
|
104 |
* It Closes the dialog
|
105 |
*/
|
106 |
public void closeJDialog() { |
107 |
frame.setVisible(false);
|
108 |
|
109 |
} |
110 |
|
111 |
/* (non-Javadoc)
|
112 |
* @see com.iver.andami.ui.mdiManager.View#getViewInfo()
|
113 |
*/
|
114 |
public WindowInfo getWindowInfo() {
|
115 |
if (m_viewinfo == null){ |
116 |
m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
117 |
m_viewinfo.setTitle(getName()); |
118 |
} |
119 |
return m_viewinfo;
|
120 |
} |
121 |
|
122 |
|
123 |
/**
|
124 |
* Close button Action performed
|
125 |
*/
|
126 |
public void closeButtonActionPerformed() { |
127 |
closeJDialog(); |
128 |
} |
129 |
|
130 |
/**
|
131 |
* Size button action performed
|
132 |
*/
|
133 |
public void sizeButtonActionPerformed(){ |
134 |
if (isMinimized){
|
135 |
frame.setSize(525,503); |
136 |
ppalPanel.setPreferredSize(new Dimension(514,470)); |
137 |
getLowerPanel().setPreferredSize(new Dimension(514,470)); |
138 |
getLowerPanel().setVisible(true);
|
139 |
frame.setVisible(true);
|
140 |
getUpperPanel().setUpIcon(); |
141 |
}else{
|
142 |
frame.setSize(525,160); |
143 |
ppalPanel.setPreferredSize(new Dimension(514,150)); |
144 |
getLowerPanel().setPreferredSize(new Dimension(514,0)); |
145 |
getLowerPanel().setVisible(false);
|
146 |
frame.setVisible(true);
|
147 |
getUpperPanel().setDownIcon(); |
148 |
} |
149 |
isMinimized = !isMinimized; |
150 |
} |
151 |
|
152 |
/**
|
153 |
* Return button action
|
154 |
*/
|
155 |
public void returnButtonActionPerformed() { |
156 |
closeJDialog(); |
157 |
ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame; |
158 |
serverConnect.setVisible(true);
|
159 |
serverConnect.getSearchButton().setEnabled(false);
|
160 |
PluginServices.getMDIManager().addWindow(serverConnect); |
161 |
|
162 |
|
163 |
} |
164 |
|
165 |
|
166 |
/**
|
167 |
* This method loads the view coordinates to the catalog search dialog
|
168 |
*
|
169 |
*/
|
170 |
private void loadViewPortCoordinates(){ |
171 |
View activeView =
|
172 |
(View) PluginServices.getMDIManager().getActiveWindow();
|
173 |
|
174 |
Rectangle2D r2d= activeView.getMapControl().getViewPort().getAdjustedExtent();
|
175 |
|
176 |
try{
|
177 |
getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(),
|
178 |
r2d.getMaxY(), |
179 |
r2d.getMaxX(), |
180 |
r2d.getMinY())); |
181 |
}catch(NullPointerException E){ |
182 |
//We cant retrieve the coordinates if it doesn't
|
183 |
//exist a loaded layer
|
184 |
} |
185 |
} |
186 |
|
187 |
/**
|
188 |
* This methos joins the viewPort event to the listener
|
189 |
*/
|
190 |
private void setViewChangeListener(){ |
191 |
View activeView =
|
192 |
(View) PluginServices.getMDIManager().getActiveWindow();
|
193 |
|
194 |
activeView.getMapControl().getViewPort().addViewPortListener(this);
|
195 |
} |
196 |
|
197 |
public void extentChanged(ExtentEvent e) { |
198 |
loadViewPortCoordinates(); |
199 |
|
200 |
} |
201 |
|
202 |
public void backColorChanged(ColorEvent e) { |
203 |
// TODO Auto-generated method stub
|
204 |
|
205 |
} |
206 |
|
207 |
public void projectionChanged(ProjectionEvent e) { |
208 |
loadViewPortCoordinates(); |
209 |
} |
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
} |