1 |
1 |
|
2 |
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
|
*
|
4 |
|
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
5 |
|
*
|
6 |
|
* This program is free software; you can redistribute it and/or
|
7 |
|
* modify it under the terms of the GNU General Public License
|
8 |
|
* as published by the Free Software Foundation; either version 2
|
9 |
|
* of the License, or (at your option) any later version.
|
10 |
|
*
|
11 |
|
* This program is distributed in the hope that it will be useful,
|
12 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
* GNU General Public License for more details.
|
15 |
|
*
|
16 |
|
* You should have received a copy of the GNU General Public License
|
17 |
|
* along with this program; if not, write to the Free Software
|
18 |
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
|
*
|
20 |
|
* For more information, contact:
|
21 |
|
*
|
22 |
|
* Generalitat Valenciana
|
23 |
|
* Conselleria d'Infraestructures i Transport
|
24 |
|
* Av. Blasco Ib??ez, 50
|
25 |
|
* 46010 VALENCIA
|
26 |
|
* SPAIN
|
27 |
|
*
|
28 |
|
* +34 963862235
|
29 |
|
* gvsig@gva.es
|
30 |
|
* www.gvsig.gva.es
|
31 |
|
*
|
32 |
|
* or
|
33 |
|
*
|
34 |
|
* IVER T.I. S.A
|
35 |
|
* Salamanca 50
|
36 |
|
* 46005 Valencia
|
37 |
|
* Spain
|
38 |
|
*
|
39 |
|
* +34 963163400
|
40 |
|
* dac@iver.es
|
41 |
|
*/
|
|
3 |
*
|
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or
|
|
7 |
* modify it under the terms of the GNU General Public License
|
|
8 |
* as published by the Free Software Foundation; either version 2
|
|
9 |
* of the License, or (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
|
19 |
*
|
|
20 |
* For more information, contact:
|
|
21 |
*
|
|
22 |
* Generalitat Valenciana
|
|
23 |
* Conselleria d'Infraestructures i Transport
|
|
24 |
* Av. Blasco Ib??ez, 50
|
|
25 |
* 46010 VALENCIA
|
|
26 |
* SPAIN
|
|
27 |
*
|
|
28 |
* +34 963862235
|
|
29 |
* gvsig@gva.es
|
|
30 |
* www.gvsig.gva.es
|
|
31 |
*
|
|
32 |
* or
|
|
33 |
*
|
|
34 |
* IVER T.I. S.A
|
|
35 |
* Salamanca 50
|
|
36 |
* 46005 Valencia
|
|
37 |
* Spain
|
|
38 |
*
|
|
39 |
* +34 963163400
|
|
40 |
* dac@iver.es
|
|
41 |
*/
|
42 |
42 |
package es.gva.cit.catalogClient.ui.search;
|
43 |
43 |
import es.gva.cit.catalogClient.CatalogClient;
|
44 |
44 |
import es.gva.cit.catalogClient.querys.Query;
|
... | ... | |
67 |
67 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
68 |
68 |
*/
|
69 |
69 |
public class SearchDialogPanel extends JPanel implements ItemListener, ActionListener {
|
70 |
|
//This component its used to resize the frame
|
71 |
|
/**
|
72 |
|
*
|
73 |
|
*
|
74 |
|
*/
|
75 |
|
private JFrame parent;
|
76 |
|
//Panels
|
77 |
|
/**
|
78 |
|
*
|
79 |
|
*
|
80 |
|
*/
|
81 |
|
protected JPanel ppalPanel = null;
|
82 |
|
/**
|
83 |
|
*
|
84 |
|
*
|
85 |
|
*/
|
86 |
|
protected SearchUpperPanel upperPanel = null;
|
87 |
|
/**
|
88 |
|
*
|
89 |
|
*
|
90 |
|
*/
|
91 |
|
protected SearchLowerPanel lowerPanel = null;
|
92 |
|
/**
|
93 |
|
*
|
94 |
|
*
|
95 |
|
*/
|
96 |
|
protected JPanel checkBoxPanel = null;
|
97 |
|
/**
|
98 |
|
*
|
99 |
|
*
|
100 |
|
*/
|
101 |
|
protected JPanel buttonsPanel = null;
|
102 |
|
//Buttons
|
103 |
|
/**
|
104 |
|
*
|
105 |
|
*
|
106 |
|
*/
|
107 |
|
private JButton searchButton = null;
|
108 |
|
/**
|
109 |
|
* <p></p>
|
110 |
|
*
|
111 |
|
*
|
112 |
|
*
|
113 |
|
* @poseidon-type es.gva.cit.catalogClient.metadataXML.XMLNode
|
114 |
|
*/
|
115 |
|
protected java.util.Collection nodes = new java.util.ArrayList();
|
116 |
|
/**
|
117 |
|
*
|
118 |
|
*
|
119 |
|
*/
|
120 |
|
private JButton closeButton = null;
|
121 |
|
/**
|
122 |
|
*
|
123 |
|
*
|
124 |
|
*/
|
125 |
|
private JButton cancelSearchesButton = null;
|
126 |
|
/**
|
127 |
|
*
|
128 |
|
*
|
129 |
|
*/
|
130 |
|
private JButton sizeButton = null;
|
131 |
|
/**
|
132 |
|
*
|
133 |
|
*
|
134 |
|
*/
|
135 |
|
private JCheckBox areaCheckBox = null;
|
136 |
|
//Otros
|
137 |
|
/**
|
138 |
|
*
|
139 |
|
*
|
140 |
|
*/
|
141 |
|
protected CatalogClient client = null;
|
|
70 |
// This component its used to resize the frame
|
|
71 |
/**
|
|
72 |
*
|
|
73 |
*
|
|
74 |
*/
|
|
75 |
private JFrame parent;
|
|
76 |
protected Object serverConnectFrame;
|
|
77 |
// Panels
|
|
78 |
/**
|
|
79 |
*
|
|
80 |
*
|
|
81 |
*/
|
|
82 |
protected JPanel ppalPanel = null;
|
|
83 |
/**
|
|
84 |
*
|
|
85 |
*
|
|
86 |
*/
|
|
87 |
protected SearchUpperPanel upperPanel = null;
|
|
88 |
/**
|
|
89 |
*
|
|
90 |
*
|
|
91 |
*/
|
|
92 |
protected SearchLowerPanel lowerPanel = null;
|
|
93 |
/**
|
|
94 |
*
|
|
95 |
*
|
|
96 |
*/
|
|
97 |
protected JPanel checkBoxPanel = null;
|
|
98 |
/**
|
|
99 |
*
|
|
100 |
*
|
|
101 |
*/
|
|
102 |
protected JPanel buttonsPanel = null;
|
|
103 |
// Buttons
|
|
104 |
/**
|
|
105 |
*
|
|
106 |
*
|
|
107 |
*/
|
|
108 |
private JButton searchButton = null;
|
|
109 |
/**
|
|
110 |
* <p></p>
|
|
111 |
*
|
|
112 |
*
|
|
113 |
*
|
|
114 |
* @poseidon-type es.gva.cit.catalogClient.metadataXML.XMLNode
|
|
115 |
*/
|
|
116 |
protected java.util.Collection nodes = new java.util.ArrayList();
|
|
117 |
/**
|
|
118 |
*
|
|
119 |
*
|
|
120 |
*/
|
|
121 |
private JButton closeButton = null;
|
|
122 |
/**
|
|
123 |
*
|
|
124 |
*
|
|
125 |
*/
|
|
126 |
private JButton cancelSearchesButton = null;
|
|
127 |
/**
|
|
128 |
*
|
|
129 |
*
|
|
130 |
*/
|
|
131 |
private JButton returnButton = null;
|
|
132 |
/**
|
|
133 |
*
|
|
134 |
*
|
|
135 |
*/
|
|
136 |
private JButton sizeButton = null;
|
|
137 |
/**
|
|
138 |
*
|
|
139 |
*
|
|
140 |
*/
|
|
141 |
private JCheckBox areaCheckBox = null;
|
|
142 |
// Otros
|
|
143 |
/**
|
|
144 |
*
|
|
145 |
*
|
|
146 |
*/
|
|
147 |
protected CatalogClient client = null;
|
142 |
148 |
|
143 |
|
/**
|
144 |
|
*
|
145 |
|
*
|
146 |
|
*/
|
147 |
|
protected boolean isMinimized = true;
|
|
149 |
/**
|
|
150 |
*
|
|
151 |
*
|
|
152 |
*/
|
|
153 |
protected boolean isMinimized = true;
|
148 |
154 |
|
149 |
|
/**
|
150 |
|
*
|
151 |
|
*
|
152 |
|
*/
|
153 |
|
protected String currentServer = null;
|
154 |
|
/**
|
155 |
|
*
|
156 |
|
*
|
157 |
|
*/
|
158 |
|
private ITranslator translator = null;
|
|
155 |
/**
|
|
156 |
*
|
|
157 |
*
|
|
158 |
*/
|
|
159 |
protected String currentServer = null;
|
|
160 |
/**
|
|
161 |
*
|
|
162 |
*
|
|
163 |
*/
|
|
164 |
private ITranslator translator = null;
|
159 |
165 |
|
160 |
|
/**
|
161 |
|
*
|
162 |
|
*
|
163 |
|
*/
|
164 |
|
private Collection searchThreads = null;
|
|
166 |
/**
|
|
167 |
*
|
|
168 |
*
|
|
169 |
*/
|
|
170 |
private Collection searchThreads = null;
|
165 |
171 |
|
166 |
|
/**
|
167 |
|
* This method initializes
|
168 |
|
*
|
169 |
|
*
|
170 |
|
* @param parent
|
171 |
|
* @param translator
|
172 |
|
* @param client
|
173 |
|
*/
|
174 |
|
public SearchDialogPanel(JFrame parent, ITranslator translator, CatalogClient client) {
|
175 |
|
super();
|
176 |
|
searchThreads = new java.util.ArrayList();
|
177 |
|
this.isMinimized = true;
|
178 |
|
this.parent = parent;
|
179 |
|
this.translator = translator;
|
180 |
|
this.client = client;
|
181 |
|
initialize();
|
182 |
|
}
|
|
172 |
/**
|
|
173 |
* This method initializes
|
|
174 |
*
|
|
175 |
*
|
|
176 |
* @param parent
|
|
177 |
* @param translator
|
|
178 |
* @param client
|
|
179 |
*/
|
|
180 |
public SearchDialogPanel(JFrame parent, Object serverConnectFrame,ITranslator translator, CatalogClient client) {
|
|
181 |
super();
|
|
182 |
searchThreads = new java.util.ArrayList();
|
|
183 |
this.isMinimized = true;
|
|
184 |
this.parent = parent;
|
|
185 |
this.translator = translator;
|
|
186 |
this.client = client;
|
|
187 |
this.serverConnectFrame = serverConnectFrame;
|
|
188 |
initialize();
|
|
189 |
}
|
183 |
190 |
|
184 |
|
/**
|
185 |
|
* This method initializes this
|
186 |
|
*
|
187 |
|
*/
|
188 |
|
protected void initialize() {
|
189 |
|
ppalPanel = null;
|
190 |
|
ppalPanel = new JPanel();
|
191 |
|
ppalPanel.setLayout(new BoxLayout(ppalPanel, BoxLayout.Y_AXIS));
|
192 |
|
ppalPanel.add(getUpperPanel());
|
193 |
|
ppalPanel.add(getLowerPanel());
|
194 |
|
ppalPanel.add(getButtonsPanel());
|
195 |
|
add(ppalPanel);
|
196 |
|
setDefaultButtonListeners();
|
197 |
|
|
198 |
|
getLowerPanel().setVisible(false);
|
199 |
|
setVisible(true);
|
200 |
|
|
201 |
|
}
|
|
191 |
/**
|
|
192 |
* This method initializes this
|
|
193 |
*
|
|
194 |
*/
|
|
195 |
protected void initialize() {
|
|
196 |
ppalPanel = null;
|
|
197 |
ppalPanel = new JPanel();
|
|
198 |
ppalPanel.setLayout(new BoxLayout(ppalPanel, BoxLayout.Y_AXIS));
|
|
199 |
ppalPanel.add(getUpperPanel());
|
|
200 |
ppalPanel.add(getLowerPanel());
|
|
201 |
ppalPanel.add(getButtonsPanel());
|
|
202 |
add(ppalPanel);
|
|
203 |
setDefaultButtonListeners();
|
202 |
204 |
|
203 |
|
/**
|
204 |
|
* It Gets the upperPanel
|
205 |
|
*
|
206 |
|
*
|
207 |
|
* @return
|
208 |
|
*/
|
209 |
|
public SearchUpperPanel getUpperPanel() {
|
210 |
|
if (upperPanel == null){
|
211 |
|
upperPanel = new SearchUpperPanel(translator,
|
212 |
|
client.getProtocol(),
|
213 |
|
client.getLnkICatalogServerDriver().getQueryProfile());
|
214 |
|
|
215 |
|
}
|
216 |
|
return upperPanel;
|
217 |
|
|
218 |
|
}
|
|
205 |
getLowerPanel().setVisible(false);
|
|
206 |
setVisible(true);
|
219 |
207 |
|
220 |
|
/**
|
221 |
|
* It Gets the lowePanel
|
222 |
|
*
|
223 |
|
*
|
224 |
|
* @return
|
225 |
|
*/
|
226 |
|
public SearchLowerPanel getLowerPanel() {
|
227 |
|
if (lowerPanel == null){
|
228 |
|
lowerPanel = new SearchLowerPanel(translator,
|
229 |
|
client.getProtocol(),
|
230 |
|
client.getLnkICatalogServerDriver().getQueryProfile());
|
231 |
|
|
232 |
|
}
|
233 |
|
return lowerPanel;
|
234 |
|
}
|
|
208 |
}
|
235 |
209 |
|
236 |
|
/**
|
237 |
|
* It gets the buttons panel
|
238 |
|
*
|
239 |
|
*
|
240 |
|
* @return
|
241 |
|
*/
|
242 |
|
public JPanel getButtonsPanel() {
|
243 |
|
if (buttonsPanel == null) {
|
244 |
|
buttonsPanel = new JPanel(new FlowLayout());
|
245 |
|
buttonsPanel.add(getSearchButton());
|
246 |
|
buttonsPanel.add(getCancelSearchesButton());
|
247 |
|
buttonsPanel.add(getCloseButton());
|
248 |
|
}
|
249 |
|
return buttonsPanel;
|
250 |
|
}
|
|
210 |
/**
|
|
211 |
* It Gets the upperPanel
|
|
212 |
*
|
|
213 |
*
|
|
214 |
* @return
|
|
215 |
*/
|
|
216 |
public SearchUpperPanel getUpperPanel() {
|
|
217 |
if (upperPanel == null){
|
|
218 |
upperPanel = new SearchUpperPanel(translator,
|
|
219 |
client.getProtocol(),
|
|
220 |
client.getLnkICatalogServerDriver().getQueryProfile());
|
251 |
221 |
|
252 |
|
/**
|
253 |
|
* It gets the search button
|
254 |
|
*
|
255 |
|
*
|
256 |
|
* @return
|
257 |
|
*/
|
258 |
|
public JButton getSearchButton() {
|
259 |
|
if (searchButton == null) {
|
260 |
|
searchButton = new JButton(Translator.getText(translator,"searchButton"));
|
261 |
|
searchButton.setPreferredSize(new Dimension(90, 25));
|
262 |
|
searchButton.setActionCommand("search");
|
263 |
|
}
|
264 |
|
return searchButton;
|
265 |
|
}
|
|
222 |
}
|
|
223 |
return upperPanel;
|
266 |
224 |
|
267 |
|
/**
|
268 |
|
* It gets the cancel searches button
|
269 |
|
*
|
270 |
|
*
|
271 |
|
* @return
|
272 |
|
*/
|
273 |
|
public JButton getCancelSearchesButton() {
|
274 |
|
if (cancelSearchesButton == null) {
|
275 |
|
cancelSearchesButton = new JButton(Translator.getText(translator,"cancelSearchButton"));
|
276 |
|
cancelSearchesButton.setPreferredSize(new Dimension(90, 25));
|
277 |
|
cancelSearchesButton.setActionCommand("cancel");
|
278 |
|
}
|
279 |
|
return cancelSearchesButton;
|
280 |
|
}
|
|
225 |
}
|
281 |
226 |
|
282 |
|
/**
|
283 |
|
* It gets the close button
|
284 |
|
*
|
285 |
|
*
|
286 |
|
* @return
|
287 |
|
*/
|
288 |
|
public JButton getCloseButton() {
|
289 |
|
if (closeButton == null) {
|
290 |
|
closeButton = new JButton(Translator.getText(translator,"close"));
|
291 |
|
closeButton.setPreferredSize(new Dimension(90, 25));
|
292 |
|
closeButton.setActionCommand("close");
|
293 |
|
}
|
294 |
|
return closeButton;
|
295 |
|
}
|
|
227 |
/**
|
|
228 |
* It Gets the lowePanel
|
|
229 |
*
|
|
230 |
*
|
|
231 |
* @return
|
|
232 |
*/
|
|
233 |
public SearchLowerPanel getLowerPanel() {
|
|
234 |
if (lowerPanel == null){
|
|
235 |
lowerPanel = new SearchLowerPanel(translator,
|
|
236 |
client.getProtocol(),
|
|
237 |
client.getLnkICatalogServerDriver().getQueryProfile());
|
296 |
238 |
|
297 |
|
/**
|
298 |
|
* It gets the change size button
|
299 |
|
*
|
300 |
|
*
|
301 |
|
* @return
|
302 |
|
*/
|
303 |
|
public JButton getSizeButton() {
|
304 |
|
if (sizeButton == null) {
|
305 |
|
sizeButton = upperPanel.getSizeButton();
|
306 |
|
sizeButton.setActionCommand("size");
|
307 |
|
}
|
308 |
|
return sizeButton;
|
309 |
|
}
|
|
239 |
}
|
|
240 |
return lowerPanel;
|
|
241 |
}
|
310 |
242 |
|
311 |
|
/**
|
312 |
|
* It gets the checkBox area component
|
313 |
|
*
|
314 |
|
*
|
315 |
|
* @return
|
316 |
|
*/
|
317 |
|
public JCheckBox getAreaCheckBox() {
|
318 |
|
if (areaCheckBox == null){
|
319 |
|
areaCheckBox = upperPanel.getCoordinatesCheckBox();
|
320 |
|
areaCheckBox.setActionCommand("areaCheckButton");
|
321 |
|
}
|
322 |
|
return areaCheckBox;
|
323 |
|
}
|
|
243 |
/**
|
|
244 |
* It gets the buttons panel
|
|
245 |
*
|
|
246 |
*
|
|
247 |
* @return
|
|
248 |
*/
|
|
249 |
public JPanel getButtonsPanel() {
|
|
250 |
if (buttonsPanel == null) {
|
|
251 |
buttonsPanel = new JPanel(new FlowLayout());
|
|
252 |
buttonsPanel.add(getSearchButton());
|
|
253 |
buttonsPanel.add(getCancelSearchesButton());
|
|
254 |
buttonsPanel.add(getReturnButton());
|
|
255 |
buttonsPanel.add(getCloseButton());
|
|
256 |
}
|
|
257 |
return buttonsPanel;
|
|
258 |
}
|
324 |
259 |
|
325 |
|
/**
|
326 |
|
* It sets the listeners
|
327 |
|
*
|
328 |
|
*/
|
329 |
|
public void setDefaultButtonListeners() {
|
330 |
|
getSearchButton().addActionListener(this);
|
331 |
|
getCloseButton().addActionListener(this);
|
332 |
|
getSizeButton().addActionListener(this);
|
333 |
|
getAreaCheckBox().addItemListener(this);
|
334 |
|
getCancelSearchesButton().addActionListener(this);
|
335 |
|
}
|
|
260 |
/**
|
|
261 |
* It gets the search button
|
|
262 |
*
|
|
263 |
*
|
|
264 |
* @return
|
|
265 |
*/
|
|
266 |
public JButton getSearchButton() {
|
|
267 |
if (searchButton == null) {
|
|
268 |
searchButton = new JButton(Translator.getText(translator,"searchButton"));
|
|
269 |
searchButton.setPreferredSize(new Dimension(90, 25));
|
|
270 |
searchButton.setActionCommand("search");
|
|
271 |
}
|
|
272 |
return searchButton;
|
|
273 |
}
|
336 |
274 |
|
337 |
|
/**
|
338 |
|
*
|
339 |
|
*
|
340 |
|
*
|
341 |
|
* @param e
|
342 |
|
*/
|
343 |
|
public void actionPerformed(ActionEvent e) {
|
344 |
|
//Buscar
|
345 |
|
if (e.getActionCommand() == "search") {
|
346 |
|
searchButtonActionPerformed();
|
347 |
|
}
|
348 |
|
if (e.getActionCommand() == "close") {
|
349 |
|
closeButtonActionPerformed();
|
350 |
|
}
|
351 |
|
if (e.getActionCommand() == "size") {
|
352 |
|
sizeButtonActionPerformed();
|
353 |
|
}
|
354 |
|
if (e.getActionCommand() == "cancel") {
|
355 |
|
cancelSearchesButtonActionPerformed();
|
356 |
|
}
|
357 |
|
}
|
|
275 |
/**
|
|
276 |
* It gets the cancel searches button
|
|
277 |
*
|
|
278 |
*
|
|
279 |
* @return
|
|
280 |
*/
|
|
281 |
public JButton getCancelSearchesButton() {
|
|
282 |
if (cancelSearchesButton == null) {
|
|
283 |
cancelSearchesButton = new JButton(Translator.getText(translator,"cancelSearchButton"));
|
|
284 |
cancelSearchesButton.setPreferredSize(new Dimension(90, 25));
|
|
285 |
cancelSearchesButton.setActionCommand("cancel");
|
|
286 |
}
|
|
287 |
return cancelSearchesButton;
|
|
288 |
}
|
358 |
289 |
|
359 |
|
/**
|
360 |
|
*
|
361 |
|
*
|
362 |
|
*/
|
363 |
|
protected void sizeButtonActionPerformed() {
|
364 |
|
if (isMinimized){
|
365 |
|
parent.setSize(525,450);
|
366 |
|
getLowerPanel().setVisible(true);
|
367 |
|
getLowerPanel().repaint();
|
368 |
|
getUpperPanel().setUpIcon();
|
369 |
|
parent.setVisible(true);
|
370 |
|
}else{
|
371 |
|
parent.setSize(525,115);
|
372 |
|
getLowerPanel().setVisible(false);
|
373 |
|
getUpperPanel().setDownIcon();
|
374 |
|
}
|
375 |
|
isMinimized = !isMinimized;
|
376 |
|
}
|
|
290 |
/**
|
|
291 |
* It gets the close button
|
|
292 |
*
|
|
293 |
*
|
|
294 |
* @return
|
|
295 |
*/
|
|
296 |
public JButton getCloseButton() {
|
|
297 |
if (closeButton == null) {
|
|
298 |
closeButton = new JButton(Translator.getText(translator,"close"));
|
|
299 |
closeButton.setPreferredSize(new Dimension(90, 25));
|
|
300 |
closeButton.setActionCommand("close");
|
|
301 |
}
|
|
302 |
return closeButton;
|
|
303 |
}
|
|
304 |
|
|
305 |
/**
|
|
306 |
* It gets the return button
|
|
307 |
*
|
|
308 |
*
|
|
309 |
* @return
|
|
310 |
*/
|
|
311 |
public JButton getReturnButton() {
|
|
312 |
if (returnButton == null) {
|
|
313 |
returnButton = new JButton(Translator.getText(translator,"return"));
|
|
314 |
returnButton.setPreferredSize(new Dimension(90, 25));
|
|
315 |
returnButton.setActionCommand("return");
|
|
316 |
}
|
|
317 |
return returnButton;
|
|
318 |
}
|
377 |
319 |
|
378 |
|
/**
|
379 |
|
*
|
380 |
|
*
|
381 |
|
*/
|
382 |
|
protected void searchButtonActionPerformed() {
|
383 |
|
searchThread st = new searchThread();
|
384 |
|
searchThreads.add(st);
|
385 |
|
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
386 |
|
}
|
|
320 |
/**
|
|
321 |
* It gets the change size button
|
|
322 |
*
|
|
323 |
*
|
|
324 |
* @return
|
|
325 |
*/
|
|
326 |
public JButton getSizeButton() {
|
|
327 |
if (sizeButton == null) {
|
|
328 |
sizeButton = upperPanel.getSizeButton();
|
|
329 |
sizeButton.setActionCommand("size");
|
|
330 |
}
|
|
331 |
return sizeButton;
|
|
332 |
}
|
387 |
333 |
|
388 |
|
/**
|
389 |
|
*
|
390 |
|
*
|
391 |
|
*/
|
392 |
|
protected void cancelSearchesButtonActionPerformed() {
|
393 |
|
for (int i=0 ; i<searchThreads.size() ; i++){
|
394 |
|
searchThread st = (searchThread)searchThreads.toArray()[i];
|
395 |
|
st.stop();
|
396 |
|
}
|
397 |
|
searchThreads.clear();
|
398 |
|
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
399 |
|
}
|
|
334 |
/**
|
|
335 |
* It gets the checkBox area component
|
|
336 |
*
|
|
337 |
*
|
|
338 |
* @return
|
|
339 |
*/
|
|
340 |
public JCheckBox getAreaCheckBox() {
|
|
341 |
if (areaCheckBox == null){
|
|
342 |
areaCheckBox = upperPanel.getCoordinatesCheckBox();
|
|
343 |
areaCheckBox.setActionCommand("areaCheckButton");
|
|
344 |
}
|
|
345 |
return areaCheckBox;
|
|
346 |
}
|
400 |
347 |
|
401 |
|
/**
|
402 |
|
*
|
403 |
|
*
|
404 |
|
*/
|
405 |
|
protected void closeButtonActionPerformed() {
|
406 |
|
parent.setVisible(false);
|
407 |
|
}
|
|
348 |
/**
|
|
349 |
* It sets the listeners
|
|
350 |
*
|
|
351 |
*/
|
|
352 |
public void setDefaultButtonListeners() {
|
|
353 |
getSearchButton().addActionListener(this);
|
|
354 |
getCloseButton().addActionListener(this);
|
|
355 |
getSizeButton().addActionListener(this);
|
|
356 |
getAreaCheckBox().addItemListener(this);
|
|
357 |
getReturnButton().addActionListener(this);
|
|
358 |
getCancelSearchesButton().addActionListener(this);
|
|
359 |
}
|
408 |
360 |
|
409 |
|
/**
|
410 |
|
* It returns the query that the user has selected
|
411 |
|
*
|
412 |
|
*
|
413 |
|
* @return
|
414 |
|
*/
|
415 |
|
private Query doQuery() {
|
416 |
|
Query query = client.createNewQuery();
|
417 |
|
query.setTitle(upperPanel.getTitle());
|
418 |
|
query.setTitleFilter(lowerPanel.getTitleOption());
|
419 |
|
query.setAbstract(lowerPanel.getAbstract());
|
420 |
|
query.setThemeKey(lowerPanel.getKeys());
|
421 |
|
query.setTopic(lowerPanel.getCathegory());
|
422 |
|
query.setScale(lowerPanel.getScale());
|
423 |
|
query.setProvider(lowerPanel.getProvider());
|
424 |
|
query.setDateFrom(lowerPanel.getDateFrom());
|
425 |
|
query.setDateTo(lowerPanel.getDateTo());
|
426 |
|
query.setCoordenates(lowerPanel.getCoordinates());
|
427 |
|
query.setCoordenatesFilter(lowerPanel.getCoordinatesOption());
|
428 |
|
query.setTranslator(translator);
|
429 |
|
query.setMinimized(isMinimized);
|
430 |
|
query.setCoordinatesClicked(upperPanel.getRestrictAreaClicked());
|
431 |
|
|
432 |
|
if (isMinimized){
|
433 |
|
query.setTitleFilter("E");
|
434 |
|
}
|
435 |
|
return query;
|
436 |
|
}
|
|
361 |
/**
|
|
362 |
*
|
|
363 |
*
|
|
364 |
*
|
|
365 |
* @param e
|
|
366 |
*/
|
|
367 |
public void actionPerformed(ActionEvent e) {
|
|
368 |
//Buscar
|
|
369 |
if (e.getActionCommand() == "search") {
|
|
370 |
searchButtonActionPerformed();
|
|
371 |
}
|
|
372 |
if (e.getActionCommand() == "close") {
|
|
373 |
closeButtonActionPerformed();
|
|
374 |
}
|
|
375 |
if (e.getActionCommand() == "size") {
|
|
376 |
sizeButtonActionPerformed();
|
|
377 |
}
|
|
378 |
if (e.getActionCommand() == "cancel") {
|
|
379 |
cancelSearchesButtonActionPerformed();
|
|
380 |
}
|
|
381 |
if (e.getActionCommand() == "return") {
|
|
382 |
returnButtonActionPerformed();
|
|
383 |
}
|
|
384 |
}
|
437 |
385 |
|
438 |
|
/**
|
439 |
|
* This method realizes the search
|
440 |
|
*
|
441 |
|
*/
|
442 |
|
private void doSearch() {
|
443 |
|
nodes = client.getRecords(client.getUrl(),
|
444 |
|
doQuery(), 1);
|
445 |
|
if (nodes == null) {
|
446 |
|
JOptionPane.showMessageDialog(this,
|
447 |
|
Translator.getText(translator,"errorGetRecords"),
|
448 |
|
"Error",
|
449 |
|
JOptionPane.ERROR_MESSAGE);
|
450 |
|
} else if (nodes.size() == 1) {
|
451 |
|
JOptionPane.showMessageDialog(this,
|
452 |
|
Translator.getText(translator,"anyResult"),
|
453 |
|
Translator.getText(translator,"catalog_search"),
|
454 |
|
JOptionPane.INFORMATION_MESSAGE);
|
455 |
|
}
|
456 |
|
}
|
|
386 |
/**
|
|
387 |
*
|
|
388 |
*
|
|
389 |
*/
|
|
390 |
protected void sizeButtonActionPerformed() {
|
|
391 |
if (isMinimized){
|
|
392 |
parent.setSize(525,450);
|
|
393 |
getLowerPanel().setVisible(true);
|
|
394 |
getLowerPanel().repaint();
|
|
395 |
getUpperPanel().setUpIcon();
|
|
396 |
parent.setVisible(true);
|
|
397 |
}else{
|
|
398 |
parent.setSize(525,115);
|
|
399 |
getLowerPanel().setVisible(false);
|
|
400 |
getUpperPanel().setDownIcon();
|
|
401 |
}
|
|
402 |
isMinimized = !isMinimized;
|
|
403 |
}
|
|
404 |
|
|
405 |
/**
|
|
406 |
* Return button
|
|
407 |
*
|
|
408 |
*/
|
|
409 |
protected void returnButtonActionPerformed() {
|
|
410 |
((JFrame)serverConnectFrame).setVisible(true);
|
|
411 |
parent.setVisible(false);
|
|
412 |
}
|
457 |
413 |
|
458 |
|
/**
|
459 |
|
* This methos calls to present results form
|
460 |
|
*
|
461 |
|
*
|
462 |
|
* @param nodes
|
463 |
|
*/
|
464 |
|
protected void showResults(Collection nodes) {
|
465 |
|
new ShowResultsDialog(client, nodes, 1);
|
466 |
|
}
|
467 |
|
/* (non-Javadoc)
|
468 |
|
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
469 |
|
* This methodhave to be implemented in gvSIG to load the bbox to o the search
|
470 |
|
*/
|
471 |
414 |
|
472 |
|
/**
|
473 |
|
*
|
474 |
|
*
|
475 |
|
*
|
476 |
|
* @param e
|
477 |
|
*/
|
478 |
|
public void itemStateChanged(ItemEvent e) {
|
479 |
|
|
480 |
|
|
481 |
|
}
|
|
415 |
/**
|
|
416 |
*
|
|
417 |
*
|
|
418 |
*/
|
|
419 |
protected void searchButtonActionPerformed() {
|
|
420 |
searchThread st = new searchThread();
|
|
421 |
searchThreads.add(st);
|
|
422 |
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
|
423 |
}
|
482 |
424 |
|
483 |
|
/**
|
484 |
|
*
|
485 |
|
*
|
486 |
|
*
|
487 |
|
* @param isMinimized The isMinimized to set.
|
488 |
|
*/
|
489 |
|
public void setMinimized(boolean isMinimized) {
|
490 |
|
this.isMinimized = isMinimized;
|
491 |
|
}
|
|
425 |
/**
|
|
426 |
*
|
|
427 |
*
|
|
428 |
*/
|
|
429 |
protected void cancelSearchesButtonActionPerformed() {
|
|
430 |
for (int i=0 ; i<searchThreads.size() ; i++){
|
|
431 |
searchThread st = (searchThread)searchThreads.toArray()[i];
|
|
432 |
st.stop();
|
|
433 |
}
|
|
434 |
searchThreads.clear();
|
|
435 |
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
436 |
}
|
492 |
437 |
|
493 |
|
/**
|
494 |
|
*
|
495 |
|
*
|
496 |
|
*
|
497 |
|
* @return Returns the currentServer.
|
498 |
|
*/
|
499 |
|
public String getCurrentServer() {
|
500 |
|
return currentServer;
|
501 |
|
}
|
|
438 |
/**
|
|
439 |
*
|
|
440 |
*
|
|
441 |
*/
|
|
442 |
protected void closeButtonActionPerformed() {
|
|
443 |
parent.setVisible(false);
|
|
444 |
}
|
502 |
445 |
|
503 |
|
/**
|
504 |
|
*
|
505 |
|
*
|
506 |
|
*
|
507 |
|
* @param currentServer The currentServer to set.
|
508 |
|
*/
|
509 |
|
public void setCurrentServer(String currentServer) {
|
510 |
|
this.currentServer = currentServer;
|
511 |
|
}
|
|
446 |
/**
|
|
447 |
* It returns the query that the user has selected
|
|
448 |
*
|
|
449 |
*
|
|
450 |
* @return
|
|
451 |
*/
|
|
452 |
private Query doQuery() {
|
|
453 |
Query query = client.createNewQuery();
|
|
454 |
query.setTitle(upperPanel.getTitle());
|
|
455 |
query.setTitleFilter(lowerPanel.getTitleOption());
|
|
456 |
query.setAbstract(lowerPanel.getAbstract());
|
|
457 |
query.setThemeKey(lowerPanel.getKeys());
|
|
458 |
query.setTopic(lowerPanel.getCathegory());
|
|
459 |
query.setScale(lowerPanel.getScale());
|
|
460 |
query.setProvider(lowerPanel.getProvider());
|
|
461 |
query.setDateFrom(lowerPanel.getDateFrom());
|
|
462 |
query.setDateTo(lowerPanel.getDateTo());
|
|
463 |
query.setCoordenates(lowerPanel.getCoordinates());
|
|
464 |
query.setCoordenatesFilter(lowerPanel.getCoordinatesOption());
|
|
465 |
query.setTranslator(translator);
|
|
466 |
query.setMinimized(isMinimized);
|
|
467 |
query.setCoordinatesClicked(upperPanel.getRestrictAreaClicked());
|
512 |
468 |
|
513 |
|
/**
|
514 |
|
*
|
515 |
|
*
|
516 |
|
*
|
517 |
|
* @param parent The parent to set.
|
518 |
|
*/
|
519 |
|
public void setParent(JFrame parent) {
|
520 |
|
this.parent = parent;
|
521 |
|
}
|
522 |
|
/**
|
523 |
|
* This class is used to manage the searches.
|
524 |
|
* It contains method to start and to stop a thread. It is
|
525 |
|
* necessary to create because "stop" method (for the Thread class)
|
526 |
|
* is deprecated.
|
527 |
|
*
|
528 |
|
*
|
529 |
|
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
530 |
|
*/
|
531 |
|
private class searchThread implements Runnable {
|
|
469 |
if (isMinimized){
|
|
470 |
query.setTitleFilter("E");
|
|
471 |
}
|
|
472 |
return query;
|
|
473 |
}
|
532 |
474 |
|
533 |
|
/**
|
534 |
|
*
|
535 |
|
*
|
536 |
|
*/
|
537 |
|
volatile Thread myThread = null;
|
|
475 |
/**
|
|
476 |
* This method realizes the search
|
|
477 |
*
|
|
478 |
*/
|
|
479 |
private void doSearch() {
|
|
480 |
nodes = client.getRecords(client.getUrl(),
|
|
481 |
doQuery(), 1);
|
|
482 |
if (nodes == null) {
|
|
483 |
JOptionPane.showMessageDialog(this,
|
|
484 |
Translator.getText(translator,"errorGetRecords"),
|
|
485 |
"Error",
|
|
486 |
JOptionPane.ERROR_MESSAGE);
|
|
487 |
} else if (nodes.size() == 1) {
|
|
488 |
JOptionPane.showMessageDialog(this,
|
|
489 |
Translator.getText(translator,"anyResult"),
|
|
490 |
Translator.getText(translator,"catalog_search"),
|
|
491 |
JOptionPane.INFORMATION_MESSAGE);
|
|
492 |
}
|
|
493 |
}
|
538 |
494 |
|
539 |
|
/**
|
540 |
|
*
|
541 |
|
*
|
542 |
|
*/
|
543 |
|
public searchThread() {
|
544 |
|
myThread = new Thread(this);
|
545 |
|
myThread.start();
|
546 |
|
}
|
|
495 |
/**
|
|
496 |
* This methos calls to present results form
|
|
497 |
*
|
|
498 |
*
|
|
499 |
* @param nodes
|
|
500 |
*/
|
|
501 |
protected void showResults(Collection nodes) {
|
|
502 |
new ShowResultsDialog(client, nodes, 1);
|
|
503 |
}
|
|
504 |
/* (non-Javadoc)
|
|
505 |
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
|
|
506 |
* This methodhave to be implemented in gvSIG to load the bbox to o the search
|
|
507 |
*/
|
547 |
508 |
|
548 |
|
/**
|
549 |
|
*
|
550 |
|
*
|
551 |
|
*/
|
552 |
|
public void stop() {
|
553 |
|
myThread.stop();
|
554 |
|
}
|
|
509 |
/**
|
|
510 |
*
|
|
511 |
*
|
|
512 |
*
|
|
513 |
* @param e
|
|
514 |
*/
|
|
515 |
public void itemStateChanged(ItemEvent e) {
|
555 |
516 |
|
556 |
|
/**
|
557 |
|
*
|
558 |
|
*
|
559 |
|
*/
|
560 |
|
public void run() {
|
561 |
|
doSearch();
|
562 |
|
if ((nodes != null) && (nodes.size() > 1)) {
|
563 |
|
showResults(nodes);
|
564 |
|
}
|
565 |
|
searchThreads.remove(this);
|
566 |
|
if (searchThreads.size() == 0){
|
567 |
|
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
568 |
|
}
|
569 |
|
}
|
570 |
|
}
|
571 |
|
}
|
|
517 |
|
|
518 |
}
|
|
519 |
|
|
520 |
/**
|
|
521 |
*
|
|
522 |
*
|
|
523 |
*
|
|
524 |
* @param isMinimized The isMinimized to set.
|
|
525 |
*/
|
|
526 |
public void setMinimized(boolean isMinimized) {
|
|
527 |
this.isMinimized = isMinimized;
|
|
528 |
}
|
|
529 |
|
|
530 |
/**
|
|
531 |
*
|
|
532 |
*
|
|
533 |
*
|
|
534 |
* @return Returns the currentServer.
|
|
535 |
*/
|
|
536 |
public String getCurrentServer() {
|
|
537 |
return currentServer;
|
|
538 |
}
|
|
539 |
|
|
540 |
/**
|
|
541 |
*
|
|
542 |
*
|
|
543 |
*
|
|
544 |
* @param currentServer The currentServer to set.
|
|
545 |
*/
|
|
546 |
public void setCurrentServer(String currentServer) {
|
|
547 |
this.currentServer = currentServer;
|
|
548 |
}
|
|
549 |
|
|
550 |
/**
|
|
551 |
*
|
|
552 |
*
|
|
553 |
*
|
|
554 |
* @param parent The parent to set.
|
|
555 |
*/
|
|
556 |
public void setParent(JFrame parent) {
|
|
557 |
this.parent = parent;
|
|
558 |
}
|
|
559 |
/**
|
|
560 |
* This class is used to manage the searches.
|
|
561 |
* It contains method to start and to stop a thread. It is
|
|
562 |
* necessary to create because "stop" method (for the Thread class)
|
|
563 |
* is deprecated.
|
|
564 |
*
|
|
565 |
*
|
|
566 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
|
567 |
*/
|
|
568 |
private class searchThread implements Runnable {
|
|
569 |
|
|
570 |
/**
|
|
571 |
*
|
|
572 |
*
|
|
573 |
*/
|
|
574 |
volatile Thread myThread = null;
|
|
575 |
|
|
576 |
/**
|
|
577 |
*
|
|
578 |
*
|
|
579 |
*/
|
|
580 |
public searchThread() {
|
|
581 |
myThread = new Thread(this);
|
|
582 |
myThread.start();
|
|
583 |
}
|
|
584 |
|
|
585 |
/**
|
|
586 |
*
|
|
587 |
*
|
|
588 |
*/
|
|
589 |
public void stop() {
|
|
590 |
myThread.stop();
|
|
591 |
}
|
|
592 |
|
|
593 |
/**
|
|
594 |
*
|
|
595 |
*
|
|
596 |
*/
|
|
597 |
public void run() {
|
|
598 |
doSearch();
|
|
599 |
if ((nodes != null) && (nodes.size() > 1)) {
|
|
600 |
showResults(nodes);
|
|
601 |
}
|
|
602 |
searchThreads.remove(this);
|
|
603 |
if (searchThreads.size() == 0){
|
|
604 |
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
605 |
}
|
|
606 |
}
|
|
607 |
}
|
|
608 |
}
|