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