Revision 34057
tags/v2_0_0_Build_2021/applications/appGazetteer/src/org/gvsig/gazetteer/ui/showresults/ShowResultsDialog.java | ||
---|---|---|
1 |
|
|
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 |
*/ |
|
42 |
package org.gvsig.gazetteer.ui.showresults; |
|
43 |
import java.awt.Dimension; |
|
44 |
import java.awt.event.WindowEvent; |
|
45 |
import java.awt.event.WindowListener; |
|
46 |
|
|
47 |
import javax.swing.JDialog; |
|
48 |
|
|
49 |
import org.gvsig.catalog.utils.Frames; |
|
50 |
import org.gvsig.gazetteer.GazetteerClient; |
|
51 |
import org.gvsig.gazetteer.querys.Feature; |
|
52 |
import org.gvsig.gazetteer.querys.GazetteerQuery; |
|
53 |
|
|
54 |
|
|
55 |
/** |
|
56 |
* DOCUMENT ME! |
|
57 |
* |
|
58 |
* |
|
59 |
* @author luisw |
|
60 |
*/ |
|
61 |
public class ShowResultsDialog extends JDialog implements WindowListener { |
|
62 |
|
|
63 |
/** |
|
64 |
* |
|
65 |
* |
|
66 |
*/ |
|
67 |
int recordsByPage; |
|
68 |
|
|
69 |
/** |
|
70 |
* <p></p> |
|
71 |
* |
|
72 |
* |
|
73 |
*/ |
|
74 |
protected org.gvsig.gazetteer.ui.showresults.ShowResultsDialogPanel showResultsDialogPanel = null; |
|
75 |
|
|
76 |
/** |
|
77 |
* Crea un nuevo ShowResultsDialog. |
|
78 |
* @param client Gazetteer Client |
|
79 |
* @param features The found features |
|
80 |
*/ |
|
81 |
public ShowResultsDialog(GazetteerClient client, Feature[] features, int recordsByPage,GazetteerQuery query) { |
|
82 |
super(); |
|
83 |
this.recordsByPage = recordsByPage; |
|
84 |
initialize(client,features,query); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* This method initializes jDialog |
|
89 |
* |
|
90 |
* |
|
91 |
* @param gazetteerClient |
|
92 |
* @param features |
|
93 |
*/ |
|
94 |
private void initialize(org.gvsig.gazetteer.GazetteerClient gazetteerClient, Feature[] features, GazetteerQuery query) { |
|
95 |
Frames.centerFrame(this, 420, 257); |
|
96 |
this.setSize(new Dimension(420, 257)); |
|
97 |
this.setTitle("Cliente Gazetteer"); |
|
98 |
ShowResultsDialogPanel panel = new ShowResultsDialogPanel(gazetteerClient, |
|
99 |
features, recordsByPage, query); |
|
100 |
panel.setParent(this); |
|
101 |
getContentPane().add(panel); |
|
102 |
this.setVisible(true); |
|
103 |
} |
|
104 |
/* (non-Javadoc) |
|
105 |
* @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent) |
|
106 |
*/ |
|
107 |
|
|
108 |
/** |
|
109 |
* |
|
110 |
* |
|
111 |
* |
|
112 |
* @param e |
|
113 |
*/ |
|
114 |
public void windowActivated(WindowEvent e) { |
|
115 |
// TODO Auto-generated method stub |
|
116 |
} |
|
117 |
/* (non-Javadoc) |
|
118 |
* @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent) |
|
119 |
*/ |
|
120 |
|
|
121 |
/** |
|
122 |
* |
|
123 |
* |
|
124 |
* |
|
125 |
* @param e |
|
126 |
*/ |
|
127 |
public void windowClosed(WindowEvent e) { |
|
128 |
// TODO Auto-generated method stub |
|
129 |
} |
|
130 |
/* (non-Javadoc) |
|
131 |
* @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent) |
|
132 |
*/ |
|
133 |
|
|
134 |
/** |
|
135 |
* |
|
136 |
* |
|
137 |
* |
|
138 |
* @param e |
|
139 |
*/ |
|
140 |
public void windowClosing(WindowEvent e) { |
|
141 |
// TODO Auto-generated method stub |
|
142 |
} |
|
143 |
/* (non-Javadoc) |
|
144 |
* @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent) |
|
145 |
*/ |
|
146 |
|
|
147 |
/** |
|
148 |
* |
|
149 |
* |
|
150 |
* |
|
151 |
* @param e |
|
152 |
*/ |
|
153 |
public void windowDeactivated(WindowEvent e) { |
|
154 |
// TODO Auto-generated method stub |
|
155 |
} |
|
156 |
/* (non-Javadoc) |
|
157 |
* @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent) |
|
158 |
*/ |
|
159 |
|
|
160 |
/** |
|
161 |
* |
|
162 |
* |
|
163 |
* |
|
164 |
* @param e |
|
165 |
*/ |
|
166 |
public void windowDeiconified(WindowEvent e) { |
|
167 |
// TODO Auto-generated method stub |
|
168 |
} |
|
169 |
/* (non-Javadoc) |
|
170 |
* @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent) |
|
171 |
*/ |
|
172 |
|
|
173 |
/** |
|
174 |
* |
|
175 |
* |
|
176 |
* |
|
177 |
* @param e |
|
178 |
*/ |
|
179 |
public void windowIconified(WindowEvent e) { |
|
180 |
// TODO Auto-generated method stub |
|
181 |
} |
|
182 |
/* (non-Javadoc) |
|
183 |
* @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent) |
|
184 |
*/ |
|
185 |
|
|
186 |
/** |
|
187 |
* |
|
188 |
* |
|
189 |
* |
|
190 |
* @param e |
|
191 |
*/ |
|
192 |
public void windowOpened(WindowEvent e) { |
|
193 |
// TODO Auto-generated method stub |
|
194 |
} |
|
195 |
} |
|
0 | 196 |
tags/v2_0_0_Build_2021/applications/appGazetteer/src/org/gvsig/gazetteer/ui/showresults/ShowResultsDialogPanel.java | ||
---|---|---|
1 |
|
|
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 |
*/ |
|
42 |
package org.gvsig.gazetteer.ui.showresults; |
|
43 |
import java.awt.event.ActionEvent; |
|
44 |
import java.awt.event.ActionListener; |
|
45 |
|
|
46 |
import javax.swing.JButton; |
|
47 |
import javax.swing.JDialog; |
|
48 |
import javax.swing.JPanel; |
|
49 |
|
|
50 |
import org.gvsig.gazetteer.GazetteerClient; |
|
51 |
import org.gvsig.gazetteer.querys.Feature; |
|
52 |
import org.gvsig.gazetteer.querys.GazetteerQuery; |
|
53 |
|
|
54 |
|
|
55 |
/** |
|
56 |
* |
|
57 |
* |
|
58 |
* |
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
60 |
*/ |
|
61 |
public class ShowResultsDialogPanel extends JPanel implements ActionListener { |
|
62 |
private JDialog parent; |
|
63 |
protected ShowResultsPanel ppalPanel = null; |
|
64 |
protected GazetteerClient client = null; |
|
65 |
private int currentPage = 0; |
|
66 |
private int recordsByPage = 0; |
|
67 |
private JButton nextButton = null; |
|
68 |
private JButton lastButton = null; |
|
69 |
private JButton mapButton = null; |
|
70 |
private JButton closeButton = null; |
|
71 |
private int featuresLength = 0; |
|
72 |
protected GazetteerQuery query = null; |
|
73 |
|
|
74 |
/** |
|
75 |
* @param client |
|
76 |
* @param features |
|
77 |
* @param recordsByPage |
|
78 |
* @param translator |
|
79 |
*/ |
|
80 |
public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, int recordsByPage, GazetteerQuery query) { |
|
81 |
this.client = client; |
|
82 |
this.currentPage = 1; |
|
83 |
this.recordsByPage = recordsByPage; |
|
84 |
this.query = query; |
|
85 |
initialize(client,features,recordsByPage); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* |
|
90 |
* |
|
91 |
* |
|
92 |
* @param client |
|
93 |
* @param features |
|
94 |
* @param recordsByPage |
|
95 |
*/ |
|
96 |
public void initialize(GazetteerClient client, Feature[] features, int recordsByPage) { |
|
97 |
this.featuresLength = features.length; |
|
98 |
this.currentPage = 1; |
|
99 |
this.recordsByPage = recordsByPage; |
|
100 |
ppalPanel = new ShowResultsPanel(features,getNumPages(),recordsByPage); |
|
101 |
setDefaultButtonListeners(); |
|
102 |
|
|
103 |
add(ppalPanel); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* |
|
108 |
* |
|
109 |
*/ |
|
110 |
private void setDefaultButtonListeners() { |
|
111 |
nextButton = ppalPanel.getNextButton(); |
|
112 |
lastButton = ppalPanel.getLastButton(); |
|
113 |
mapButton = ppalPanel.getMapButton(); |
|
114 |
closeButton = ppalPanel.getCloseButton(); |
|
115 |
|
|
116 |
nextButton.addActionListener(this); |
|
117 |
lastButton.addActionListener(this); |
|
118 |
mapButton.addActionListener(this); |
|
119 |
closeButton.addActionListener(this); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* |
|
124 |
* |
|
125 |
* |
|
126 |
* @param e |
|
127 |
*/ |
|
128 |
public void actionPerformed(ActionEvent e) { |
|
129 |
if (e.getActionCommand().equals("next")) { |
|
130 |
nextButtonActionPerformed(); |
|
131 |
} |
|
132 |
if (e.getActionCommand().equals("last")) { |
|
133 |
lastButtonActionPerformed(); |
|
134 |
} |
|
135 |
if (e.getActionCommand().equals("localize")) { |
|
136 |
loadButtonActionPerformed(); |
|
137 |
} |
|
138 |
if (e.getActionCommand().equals("close")) { |
|
139 |
closeButtonActionPerformed(); |
|
140 |
} |
|
141 |
|
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* |
|
146 |
* |
|
147 |
* |
|
148 |
* @return |
|
149 |
*/ |
|
150 |
private int getNumPages() { |
|
151 |
if ((featuresLength % recordsByPage) == 0) |
|
152 |
return featuresLength/recordsByPage; |
|
153 |
return (featuresLength/recordsByPage) + 1; |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* |
|
158 |
* |
|
159 |
*/ |
|
160 |
public void nextButtonActionPerformed() { |
|
161 |
this.currentPage = this.currentPage + 1; |
|
162 |
|
|
163 |
if (this.currentPage == getNumPages()) { |
|
164 |
nextButton.setEnabled(false); |
|
165 |
} else { |
|
166 |
nextButton.setEnabled(true); |
|
167 |
} |
|
168 |
lastButton.setEnabled(true); |
|
169 |
ppalPanel.actualizaLabel(currentPage,recordsByPage); |
|
170 |
|
|
171 |
|
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* |
|
176 |
* |
|
177 |
*/ |
|
178 |
public void lastButtonActionPerformed() { |
|
179 |
this.currentPage = this.currentPage - 1; |
|
180 |
if (this.currentPage == 1) { |
|
181 |
lastButton.setEnabled(false); |
|
182 |
} else { |
|
183 |
lastButton.setEnabled(true); |
|
184 |
} |
|
185 |
nextButton.setEnabled(true); |
|
186 |
|
|
187 |
ppalPanel.actualizaLabel(currentPage,recordsByPage); |
|
188 |
|
|
189 |
|
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* |
|
194 |
* |
|
195 |
*/ |
|
196 |
public void loadButtonActionPerformed() { |
|
197 |
Feature feature = ppalPanel.getFeature(); |
|
198 |
|
|
199 |
if (feature != null){ |
|
200 |
System.out.println("ID: " + feature.getId()); |
|
201 |
System.out.println("NAME: " + feature.getName()); |
|
202 |
System.out.println("DESCRIPTION: " + feature.getDescription()); |
|
203 |
System.out.println("COORDINATES: X=" + feature.getCoordinates().getX() + " Y=" + feature.getCoordinates().getY()); |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* |
|
209 |
* |
|
210 |
*/ |
|
211 |
public void closeButtonActionPerformed() { |
|
212 |
parent.setVisible(false); |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* |
|
217 |
* |
|
218 |
* |
|
219 |
* @param parent The parent to set. |
|
220 |
*/ |
|
221 |
public void setParent(JDialog parent) { |
|
222 |
this.parent = parent; |
|
223 |
} |
|
224 |
} |
|
0 | 225 |
tags/v2_0_0_Build_2021/applications/appGazetteer/src/org/gvsig/gazetteer/ui/showresults/ShowResultsPanel.java | ||
---|---|---|
1 |
|
|
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 |
*/ |
|
42 |
package org.gvsig.gazetteer.ui.showresults; |
|
43 |
import java.awt.Dimension; |
|
44 |
import java.awt.FlowLayout; |
|
45 |
|
|
46 |
import javax.swing.BoxLayout; |
|
47 |
import javax.swing.DefaultListModel; |
|
48 |
import javax.swing.JButton; |
|
49 |
import javax.swing.JLabel; |
|
50 |
import javax.swing.JList; |
|
51 |
import javax.swing.JPanel; |
|
52 |
import javax.swing.JScrollPane; |
|
53 |
|
|
54 |
import org.gvsig.gazetteer.querys.Feature; |
|
55 |
import org.gvsig.i18n.Messages; |
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* |
|
60 |
* |
|
61 |
* |
|
62 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
63 |
*/ |
|
64 |
public class ShowResultsPanel extends JPanel { |
|
65 |
/** |
|
66 |
* <p></p> |
|
67 |
* |
|
68 |
* |
|
69 |
* |
|
70 |
* @poseidon-type es.gva.cit.gazetteer.querys.Feature |
|
71 |
*/ |
|
72 |
public java.util.Collection features = new java.util.ArrayList(); |
|
73 |
/** |
|
74 |
* |
|
75 |
* |
|
76 |
*/ |
|
77 |
private JPanel descriptionPanel = null; |
|
78 |
/** |
|
79 |
* |
|
80 |
* |
|
81 |
*/ |
|
82 |
private JPanel linksPanel = null; |
|
83 |
/** |
|
84 |
* |
|
85 |
* |
|
86 |
*/ |
|
87 |
private JButton mapButton = null; |
|
88 |
// @jve:decl-index=0: |
|
89 |
/** |
|
90 |
* |
|
91 |
* |
|
92 |
*/ |
|
93 |
private JScrollPane descriptionScroll = null; |
|
94 |
// @jve:decl-index=0: |
|
95 |
/** |
|
96 |
* |
|
97 |
* |
|
98 |
*/ |
|
99 |
private JLabel jLabel1 = null; |
|
100 |
/** |
|
101 |
* |
|
102 |
* |
|
103 |
*/ |
|
104 |
private JPanel nextLastPanel = null; |
|
105 |
/** |
|
106 |
* |
|
107 |
* |
|
108 |
*/ |
|
109 |
private JButton lastButton = null; |
|
110 |
/** |
|
111 |
* |
|
112 |
* |
|
113 |
*/ |
|
114 |
private JLabel textLabel = null; |
|
115 |
/** |
|
116 |
* |
|
117 |
* |
|
118 |
*/ |
|
119 |
private JButton nextButton = null; |
|
120 |
|
|
121 |
/** |
|
122 |
* |
|
123 |
* |
|
124 |
*/ |
|
125 |
private int numPages; |
|
126 |
/** |
|
127 |
* |
|
128 |
* |
|
129 |
*/ |
|
130 |
private JButton closeButton = null; |
|
131 |
/** |
|
132 |
* |
|
133 |
* |
|
134 |
*/ |
|
135 |
private DefaultListModel listModel = null; |
|
136 |
/** |
|
137 |
* |
|
138 |
* |
|
139 |
*/ |
|
140 |
private JList descriptionList = null; |
|
141 |
|
|
142 |
/** |
|
143 |
* |
|
144 |
* |
|
145 |
* |
|
146 |
* @param features |
|
147 |
* @param numPages |
|
148 |
* @param recordsByPage |
|
149 |
* @param translator |
|
150 |
*/ |
|
151 |
public ShowResultsPanel(Feature[] features, int numPages, int recordsByPage) { |
|
152 |
super(); |
|
153 |
setFeatures(features); |
|
154 |
this.numPages = numPages; |
|
155 |
initialize(recordsByPage); |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* This method initializes this |
|
160 |
* |
|
161 |
* |
|
162 |
* @param recordsByPage |
|
163 |
*/ |
|
164 |
private void initialize(int recordsByPage) { |
|
165 |
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
|
166 |
this.setPreferredSize(new java.awt.Dimension(410,230)); |
|
167 |
this.add(getNextLastPanel(), null); |
|
168 |
this.add(getDescriptionPanel(), null); |
|
169 |
this.add(getLinksPanel(), null); |
|
170 |
actualizaLabel(1,recordsByPage); |
|
171 |
|
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* It loads the feature list |
|
176 |
* |
|
177 |
* |
|
178 |
* @param first |
|
179 |
* @param last |
|
180 |
*/ |
|
181 |
private void loadList(int first, int last) { |
|
182 |
if (features.size() < last) |
|
183 |
last = features.size() - 1; |
|
184 |
|
|
185 |
listModel.removeAllElements(); |
|
186 |
|
|
187 |
int index = 0; |
|
188 |
for (int i=first ; i<=last ; i++) |
|
189 |
if (i < features.size()){ |
|
190 |
listModel.add(index,getAllFeatures()[i]); |
|
191 |
index++; |
|
192 |
} |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* Actualiza el valor de la cadena de taexto que muestra los resultados |
|
197 |
* |
|
198 |
* |
|
199 |
* @param number Registro actual |
|
200 |
* @param recordsByPage |
|
201 |
*/ |
|
202 |
public void actualizaLabel(int number, int recordsByPage) { |
|
203 |
textLabel.setText(Messages.getText("results") + |
|
204 |
": "+String.valueOf(features.size()) + |
|
205 |
". " + |
|
206 |
Messages.getText("page") + " " + |
|
207 |
String.valueOf(number) + " " + |
|
208 |
Messages.getText("of") + " " + |
|
209 |
" " + |
|
210 |
String.valueOf(this.numPages)); |
|
211 |
loadList((number * recordsByPage) - recordsByPage,(number * recordsByPage)-1); |
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 |
* |
|
216 |
* |
|
217 |
* |
|
218 |
* @param mapButton The mapButton to set. |
|
219 |
*/ |
|
220 |
public void setMapButton(JButton mapButton) { |
|
221 |
this.mapButton = mapButton; |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* This method initializes jPanel |
|
226 |
* |
|
227 |
* |
|
228 |
* @return javax.swing.JPanel |
|
229 |
*/ |
|
230 |
private JPanel getDescriptionPanel() { |
|
231 |
if (descriptionPanel == null) { |
|
232 |
jLabel1 = new JLabel(); |
|
233 |
descriptionPanel = new JPanel(); |
|
234 |
descriptionPanel.setLayout(new FlowLayout()); |
|
235 |
descriptionPanel.setPreferredSize(new java.awt.Dimension(400,155)); |
|
236 |
jLabel1.setText(""); |
|
237 |
jLabel1.setPreferredSize(new java.awt.Dimension(40, 0)); |
|
238 |
descriptionPanel.add(getDescriptionScroll(), null); |
|
239 |
|
|
240 |
} |
|
241 |
return descriptionPanel; |
|
242 |
} |
|
243 |
|
|
244 |
/** |
|
245 |
* This method initializes jPanel |
|
246 |
* |
|
247 |
* |
|
248 |
* @return javax.swing.JPanel |
|
249 |
*/ |
|
250 |
private JPanel getLinksPanel() { |
|
251 |
if (linksPanel == null) { |
|
252 |
linksPanel = new JPanel(); |
|
253 |
FlowLayout flowLayout = new FlowLayout(); |
|
254 |
flowLayout.setAlignment(FlowLayout.RIGHT); |
|
255 |
linksPanel = new JPanel(flowLayout); |
|
256 |
linksPanel.add(getMapButton(), null); |
|
257 |
linksPanel.add(getCloseButton(), null); |
|
258 |
} |
|
259 |
return linksPanel; |
|
260 |
} |
|
261 |
|
|
262 |
/** |
|
263 |
* This method initializes jButton 1 |
|
264 |
* |
|
265 |
* |
|
266 |
* @return javax.swing.JButton |
|
267 |
*/ |
|
268 |
public JButton getMapButton() { |
|
269 |
if (mapButton == null) { |
|
270 |
mapButton = new JButton(); |
|
271 |
mapButton.setText(Messages.getText("localize")); |
|
272 |
mapButton.setActionCommand("localize"); |
|
273 |
mapButton.setPreferredSize(new Dimension(80, 23)); |
|
274 |
} |
|
275 |
return mapButton; |
|
276 |
} |
|
277 |
|
|
278 |
/** |
|
279 |
* This method initializes jScrollPane |
|
280 |
* |
|
281 |
* |
|
282 |
* @return javax.swing.JScrollPane |
|
283 |
*/ |
|
284 |
public JScrollPane getDescriptionScroll() { |
|
285 |
if (descriptionScroll == null) { |
|
286 |
descriptionScroll = new JScrollPane(); |
|
287 |
descriptionScroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
288 |
descriptionScroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
289 |
descriptionScroll.setPreferredSize(new java.awt.Dimension(400,150)); |
|
290 |
descriptionScroll.setViewportView(getDescriptionList()); |
|
291 |
} |
|
292 |
return descriptionScroll; |
|
293 |
} |
|
294 |
|
|
295 |
/** |
|
296 |
* This method initializes jPanel2 |
|
297 |
* |
|
298 |
* |
|
299 |
* @return javax.swing.JPanel |
|
300 |
*/ |
|
301 |
private JPanel getNextLastPanel() { |
|
302 |
if (nextLastPanel == null) { |
|
303 |
textLabel = new JLabel(); |
|
304 |
nextLastPanel = new JPanel(); |
|
305 |
textLabel.setText("JLabel"); |
|
306 |
nextLastPanel.add(getLastButton(), null); |
|
307 |
nextLastPanel.add(textLabel, null); |
|
308 |
nextLastPanel.add(getNextButton(), null); |
|
309 |
} |
|
310 |
return nextLastPanel; |
|
311 |
} |
|
312 |
|
|
313 |
/** |
|
314 |
* This method initializes jButton |
|
315 |
* |
|
316 |
* |
|
317 |
* @return javax.swing.JButton |
|
318 |
*/ |
|
319 |
public JButton getLastButton() { |
|
320 |
if (lastButton == null) { |
|
321 |
lastButton = new JButton(); |
|
322 |
lastButton.setText(Messages.getText("last")); |
|
323 |
lastButton.setActionCommand("last"); |
|
324 |
lastButton.setEnabled(false); |
|
325 |
lastButton.setPreferredSize(new Dimension(80, 23)); |
|
326 |
} |
|
327 |
return lastButton; |
|
328 |
} |
|
329 |
|
|
330 |
/** |
|
331 |
* This method initializes jButton |
|
332 |
* |
|
333 |
* |
|
334 |
* @return javax.swing.JButton |
|
335 |
*/ |
|
336 |
public JButton getNextButton() { |
|
337 |
if (nextButton == null) { |
|
338 |
nextButton = new JButton(); |
|
339 |
nextButton.setText(Messages.getText("next")); |
|
340 |
nextButton.setActionCommand("next"); |
|
341 |
nextButton.setPreferredSize(new Dimension(80, 23)); |
|
342 |
if (this.numPages < 2) { |
|
343 |
nextButton.setEnabled(false); |
|
344 |
} |
|
345 |
} |
|
346 |
return nextButton; |
|
347 |
} |
|
348 |
|
|
349 |
/** |
|
350 |
* This method initializes jButton |
|
351 |
* |
|
352 |
* |
|
353 |
* @return javax.swing.JButton |
|
354 |
*/ |
|
355 |
public JButton getCloseButton() { |
|
356 |
if (closeButton == null) { |
|
357 |
closeButton = new JButton(); |
|
358 |
closeButton.setText(Messages.getText("close")); |
|
359 |
closeButton.setActionCommand("close"); |
|
360 |
closeButton.setPreferredSize(new Dimension(80, 23)); |
|
361 |
} |
|
362 |
return closeButton; |
|
363 |
} |
|
364 |
|
|
365 |
/** |
|
366 |
* This method initializes jList |
|
367 |
* |
|
368 |
* |
|
369 |
* @return javax.swing.JList |
|
370 |
*/ |
|
371 |
private JList getDescriptionList() { |
|
372 |
if (descriptionList == null) { |
|
373 |
listModel = new DefaultListModel(); |
|
374 |
descriptionList = new JList(listModel); |
|
375 |
} |
|
376 |
return descriptionList; |
|
377 |
} |
|
378 |
|
|
379 |
/** |
|
380 |
* |
|
381 |
* |
|
382 |
* |
|
383 |
* @return |
|
384 |
*/ |
|
385 |
public Feature getFeature() { |
|
386 |
if (descriptionList.getSelectedIndex() == -1) |
|
387 |
return null; |
|
388 |
return (Feature) listModel.getElementAt(descriptionList.getSelectedIndex()); |
|
389 |
} |
|
390 |
|
|
391 |
/** |
|
392 |
* |
|
393 |
* |
|
394 |
* |
|
395 |
* @return |
|
396 |
*/ |
|
397 |
public Feature[] getAllFeatures() { |
|
398 |
Feature[] aux = new Feature[features.size()]; |
|
399 |
for (int i=0 ; i<aux.length ; i++){ |
|
400 |
aux[i] = (Feature)features.toArray()[i]; |
|
401 |
} |
|
402 |
return aux; |
|
403 |
} |
|
404 |
|
|
405 |
/** |
|
406 |
* |
|
407 |
* |
|
408 |
* |
|
409 |
* @param features |
|
410 |
*/ |
|
411 |
public void setFeatures(Feature[] features) { |
|
412 |
this.features = new java.util.ArrayList(); |
|
413 |
for (int i=0 ; i<features.length ; i++){ |
|
414 |
this.features.add(features[i]); |
|
415 |
} |
|
416 |
} |
|
417 |
} |
|
418 |
// @jve:decl-index=0:visual-constraint="107,10" |
|
0 | 419 |
tags/v2_0_0_Build_2021/applications/appGazetteer/src/org/gvsig/gazetteer/ui/search/SearchDialog.java | ||
---|---|---|
1 |
|
|
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 |
*/ |
|
42 |
package org.gvsig.gazetteer.ui.search; |
|
43 |
import java.awt.event.WindowEvent; |
|
44 |
import java.awt.event.WindowListener; |
|
45 |
|
|
46 |
import javax.swing.JFrame; |
|
47 |
|
|
48 |
import org.gvsig.catalog.utils.Frames; |
|
49 |
import org.gvsig.gazetteer.GazetteerClient; |
|
50 |
|
|
51 |
|
|
52 |
/** |
|
53 |
* This class represents the search frame. |
|
54 |
* |
|
55 |
* |
|
56 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
57 |
*/ |
|
58 |
public class SearchDialog extends JFrame implements WindowListener { |
|
59 |
|
|
60 |
/** |
|
61 |
* Crea un nuevo SearchDialog. |
|
62 |
* |
|
63 |
* @param cliente DOCUMENT ME! |
|
64 |
* |
|
65 |
* @param gazetterClient |
|
66 |
*/ |
|
67 |
public SearchDialog(GazetteerClient gazetterClient,Object serverConnectFrame) { |
|
68 |
super(); |
|
69 |
initialize(gazetterClient, serverConnectFrame); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* This method initializes jDialog |
|
74 |
* |
|
75 |
* |
|
76 |
* @param gazetterClient |
|
77 |
*/ |
|
78 |
private void initialize(org.gvsig.gazetteer.GazetteerClient gazetterClient,Object serverConnectFrame) { |
|
79 |
Frames.centerFrame(this,525,115); |
|
80 |
|
|
81 |
this.setTitle("B?squeda por Nomencl?tor"); |
|
82 |
setName("search"); |
|
83 |
SearchDialogPanel panel = new SearchDialogPanel(gazetterClient,serverConnectFrame); |
|
84 |
panel.setGazetteerClient(gazetterClient); |
|
85 |
panel.setParent(this); |
|
86 |
getContentPane().add(panel); |
|
87 |
addWindowListener(this); |
|
88 |
setVisible(true); |
|
89 |
} |
|
90 |
/* (non-Javadoc) |
|
91 |
* @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent) |
|
92 |
*/ |
|
93 |
|
|
94 |
/** |
|
95 |
* |
|
96 |
* |
|
97 |
* |
|
98 |
* @param e |
|
99 |
*/ |
|
100 |
public void windowActivated(WindowEvent e) { |
|
101 |
// your code here |
|
102 |
} |
|
103 |
/* (non-Javadoc) |
|
104 |
* @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent) |
|
105 |
*/ |
|
106 |
|
|
107 |
/** |
|
108 |
* |
|
109 |
* |
|
110 |
* |
|
111 |
* @param e |
|
112 |
*/ |
|
113 |
public void windowClosed(WindowEvent e) { |
|
114 |
System.exit(0); |
|
115 |
} |
|
116 |
/* (non-Javadoc) |
|
117 |
* @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent) |
|
118 |
*/ |
|
119 |
|
|
120 |
/** |
|
121 |
* |
|
122 |
* |
|
123 |
* |
|
124 |
* @param arg0 |
|
125 |
*/ |
|
126 |
public void windowClosing(WindowEvent arg0) { |
|
127 |
System.exit(0); |
|
128 |
} |
|
129 |
/* (non-Javadoc) |
|
130 |
* @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent) |
|
131 |
*/ |
|
132 |
|
|
133 |
/** |
|
134 |
* |
|
135 |
* |
|
136 |
* |
|
137 |
* @param e |
|
138 |
*/ |
|
139 |
public void windowDeactivated(WindowEvent e) { |
|
140 |
// your code here |
|
141 |
} |
|
142 |
/* (non-Javadoc) |
|
143 |
* @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent) |
|
144 |
*/ |
|
145 |
|
|
146 |
/** |
|
147 |
* |
|
148 |
* |
|
149 |
* |
|
150 |
* @param e |
|
151 |
*/ |
|
152 |
public void windowDeiconified(WindowEvent e) { |
|
153 |
// your code here |
|
154 |
} |
|
155 |
/* (non-Javadoc) |
|
156 |
* @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent) |
|
157 |
*/ |
|
158 |
|
|
159 |
/** |
|
160 |
* |
|
161 |
* |
|
162 |
* |
|
163 |
* @param e |
|
164 |
*/ |
|
165 |
public void windowIconified(WindowEvent e) { |
|
166 |
// your code here |
|
167 |
} |
|
168 |
/* (non-Javadoc) |
|
169 |
* @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent) |
|
170 |
*/ |
|
171 |
|
|
172 |
/** |
|
173 |
* |
|
174 |
* |
|
175 |
* |
|
176 |
* @param e |
|
177 |
*/ |
|
178 |
public void windowOpened(WindowEvent e) { |
|
179 |
// your code here |
|
180 |
} |
|
181 |
} |
|
0 | 182 |
tags/v2_0_0_Build_2021/applications/appGazetteer/src/org/gvsig/gazetteer/ui/search/SearchDialogPanel.java | ||
---|---|---|
1 |
|
|
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 |
*/ |
|
42 |
package org.gvsig.gazetteer.ui.search; |
|
43 |
import java.awt.BorderLayout; |
|
44 |
import java.awt.Cursor; |
|
45 |
import java.awt.event.ActionEvent; |
|
46 |
import java.awt.event.ActionListener; |
|
47 |
import java.util.Collection; |
|
48 |
|
|
49 |
import javax.swing.Icon; |
|
50 |
import javax.swing.ImageIcon; |
|
51 |
import javax.swing.JFrame; |
|
52 |
import javax.swing.JOptionPane; |
|
53 |
import javax.swing.JPanel; |
|
54 |
|
|
55 |
import org.gvsig.catalog.ui.search.SearchButtonPanel; |
|
56 |
import org.gvsig.catalog.utils.CatalogConstants; |
|
57 |
import org.gvsig.gazetteer.GazetteerClient; |
|
58 |
import org.gvsig.gazetteer.querys.Feature; |
|
59 |
import org.gvsig.gazetteer.querys.FeatureType; |
|
60 |
import org.gvsig.gazetteer.querys.FeatureTypeAttribute; |
|
61 |
import org.gvsig.gazetteer.querys.GazetteerQuery; |
|
62 |
import org.gvsig.gazetteer.ui.showresults.ShowResultsDialog; |
|
63 |
import org.gvsig.i18n.Messages; |
|
64 |
|
|
65 |
|
|
66 |
/** |
|
67 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
68 |
*/ |
|
69 |
public class SearchDialogPanel extends JPanel implements ActionListener { |
|
70 |
private JFrame parent; |
|
71 |
private GazetteerQuery query = null; |
|
72 |
protected Object serverConnectFrame; |
|
73 |
protected SearchUpperPanel upperPanel = null; |
|
74 |
protected SearchLowerPanel lowerPanel = null; |
|
75 |
protected SearchButtonPanel buttonsPanel = null; |
|
76 |
protected GazetteerClient client = null; |
|
77 |
protected boolean isMinimized = true; |
|
78 |
protected Feature[] features = null; |
|
79 |
private Collection searchThreads = null; |
|
80 |
private String currentServer = null; |
|
81 |
private String featureAttribute = null; |
|
82 |
|
|
83 |
/** |
|
84 |
* This method initializes |
|
85 |
* |
|
86 |
* |
|
87 |
* @param client |
|
88 |
* @param translator |
|
89 |
*/ |
|
90 |
public SearchDialogPanel(GazetteerClient client, Object serverConnectFrame) { |
|
91 |
super(); |
|
92 |
searchThreads = new java.util.ArrayList(); |
|
93 |
this.client = client; |
|
94 |
this.isMinimized = true; |
|
95 |
this.serverConnectFrame = serverConnectFrame; |
|
96 |
initialize(); |
|
97 |
getUpperPanel().setIcon(getDownIcon()); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* This method initializes this |
|
102 |
*/ |
|
103 |
private void initialize() { |
|
104 |
setLayout(new BorderLayout()); |
|
105 |
add(getUpperPanel(),BorderLayout.NORTH); |
|
106 |
add(getLowerPanel(),BorderLayout.CENTER); |
|
107 |
add(getButtonPanel(),BorderLayout.SOUTH); |
|
108 |
getLowerPanel().setVisible(false); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* It Gets the upperPanel |
|
113 |
* @return |
|
114 |
*/ |
|
115 |
public SearchUpperPanel getUpperPanel() { |
|
116 |
if (upperPanel == null){ |
|
117 |
upperPanel = new SearchUpperPanel(); |
|
118 |
upperPanel.addActionListener(this); |
|
119 |
} |
|
120 |
return upperPanel; |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* It Gets the lowePanel |
|
126 |
* @return |
|
127 |
*/ |
|
128 |
public SearchLowerPanel getLowerPanel() { |
|
129 |
if (lowerPanel == null){ |
|
130 |
FeatureType[] types = null; |
|
131 |
try { |
|
132 |
types = ((GazetteerClient)client).getFeatureTypes(); |
|
133 |
} catch (Exception e) { |
|
134 |
//The thesaurus will not loaded |
|
135 |
} |
|
136 |
lowerPanel = new SearchLowerPanel(types, |
|
137 |
client.getAditionalSearchPanel()); |
|
138 |
lowerPanel.addResultsByPageNumber(10); |
|
139 |
lowerPanel.addResultsByPageNumber(25); |
|
140 |
lowerPanel.addResultsByPageNumber(50); |
|
141 |
lowerPanel.addCoordinatesRelationship( |
|
142 |
Messages.getText("coordinatesContains")); |
|
143 |
lowerPanel.addCoordinatesRelationship( |
|
144 |
Messages.getText("coordinatesFullyOutsideOf")); |
|
145 |
} |
|
146 |
return lowerPanel; |
|
147 |
} |
|
148 |
|
|
149 |
/** |
|
150 |
* Set the gazetteer client |
|
151 |
* @param |
|
152 |
* Gazetteer client to set |
|
153 |
*/ |
|
154 |
public void setGazetteerClient(GazetteerClient gazetteerClient) { |
|
155 |
this.client = gazetteerClient; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* @return the buttons panel |
|
160 |
*/ |
|
161 |
public JPanel getButtonPanel() { |
|
162 |
if (buttonsPanel == null) { |
|
163 |
buttonsPanel = new SearchButtonPanel(); |
|
164 |
buttonsPanel.addActionListener(this); |
|
165 |
} |
|
166 |
return buttonsPanel; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* @return |
|
171 |
*/ |
|
172 |
public FeatureType getFeatureSelected() { |
|
173 |
return lowerPanel.getType(); |
|
174 |
} |
|
175 |
|
|
176 |
/* |
|
177 |
* (non-Javadoc) |
|
178 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
179 |
*/ |
|
180 |
public void actionPerformed(ActionEvent e) { |
|
181 |
if (e.getActionCommand().compareTo(CatalogConstants.SEARCH_BUTTON_ACTION_COMMAND)==0) { |
|
182 |
searchButtonActionPerformed(); |
|
183 |
}else if (e.getActionCommand().compareTo(CatalogConstants.CLOSE_BUTTON_ACTION_COMMAND)==0){ |
|
184 |
closeButtonActionPerformed(); |
|
185 |
}else if(e.getActionCommand().compareTo(CatalogConstants.RESIZE_BUTTON_ACTION_COMMAND)==0){ |
|
186 |
resizeButtonActionPerformed(); |
|
187 |
}else if (e.getActionCommand().compareTo(CatalogConstants.CANCEL_BUTTON_ACTION_COMMAND)==0){ |
|
188 |
cancelSearchesButtonActionPerformed(); |
|
189 |
}else if (e.getActionCommand().compareTo(CatalogConstants.LAST_BUTTON_ACTION_COMMAND)==0){ |
|
190 |
lastButtonActionPerformed(); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
/** |
|
195 |
* thrown when the resize button is clicked |
|
196 |
*/ |
|
197 |
protected void resizeButtonActionPerformed() { |
|
198 |
if (isMinimized){ |
|
199 |
parent.setSize(parent.getWidth(),450); |
|
200 |
parent.doLayout(); |
|
201 |
getLowerPanel().setVisible(true); |
|
202 |
getUpperPanel().setIcon(getUpIcon()); |
|
203 |
}else{ |
|
204 |
parent.setSize(parent.getWidth(),115); |
|
205 |
getLowerPanel().setVisible(false); |
|
206 |
getUpperPanel().setIcon(getDownIcon()); |
|
207 |
} |
|
208 |
isMinimized = !isMinimized; |
|
209 |
} |
|
210 |
|
|
211 |
|
|
212 |
protected Icon getUpIcon(){ |
|
213 |
return new ImageIcon("./gvSIG/extensiones/org.gvsig.catalog/images/up.png"); |
|
214 |
} |
|
215 |
|
|
216 |
protected Icon getDownIcon(){ |
|
217 |
return new ImageIcon("./gvSIG/extensiones/org.gvsig.catalog/images/down.png"); |
|
218 |
} |
|
219 |
|
|
220 |
|
|
221 |
/** |
|
222 |
* thrown when the search button is clicked |
|
223 |
* @throws Exception |
|
224 |
*/ |
|
225 |
protected void searchButtonActionPerformed() { |
|
226 |
FeatureType featureType = lowerPanel.getType(); |
|
227 |
if (client.isDescribeFeatureTypeNeeded()){ |
|
228 |
try { |
|
229 |
FeatureTypeAttribute atribute = getAttribute(featureType); |
|
230 |
if (atribute == null){ |
|
231 |
return; |
|
232 |
}else{ |
|
233 |
featureAttribute = atribute.getName(); |
|
234 |
} |
|
235 |
} catch (Exception e) { |
|
236 |
e.printStackTrace(); |
|
237 |
return; |
|
238 |
} |
|
239 |
} |
|
240 |
searchThread st = new searchThread(); |
|
241 |
searchThreads.add(st); |
|
242 |
setCursor(new Cursor(Cursor.WAIT_CURSOR)); |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* This method open a Jdialog panel and shows a list of |
|
247 |
* attributes to choose one of them. |
|
248 |
* @param featureType |
|
249 |
* Feature |
|
250 |
* @return |
|
251 |
* The selected attribute |
|
252 |
* @throws Exception |
|
253 |
*/ |
|
254 |
private FeatureTypeAttribute getAttribute(FeatureType featureType) throws Exception{ |
|
255 |
if ((featureType == null) || |
|
256 |
(lowerPanel.getType().getName().equals(Messages.getText("ThesaurusRoot")))){ |
|
257 |
JOptionPane.showMessageDialog( |
|
258 |
this, |
|
259 |
Messages.getText("errorNotThesaurusSelected"), |
|
260 |
"WFS", |
|
261 |
JOptionPane.ERROR_MESSAGE |
|
262 |
); |
|
263 |
return null; |
|
264 |
} |
|
265 |
FeatureTypeAttribute[] atributes = |
|
266 |
client.describeFeatureType(featureType.getName()); |
|
267 |
FeatureTypeAttribute attribute = (FeatureTypeAttribute)JOptionPane.showInputDialog( |
|
268 |
this, |
|
269 |
Messages.getText("chooseAttribute"), |
|
270 |
null, |
|
271 |
JOptionPane.PLAIN_MESSAGE, |
|
272 |
null, |
|
273 |
atributes, |
|
274 |
featureType.getName()); |
|
275 |
if (attribute == null) { |
|
276 |
JOptionPane.showMessageDialog( |
|
277 |
this, |
|
278 |
Messages.getText("chooseAttribute"), |
|
279 |
"WFS", |
|
280 |
JOptionPane.ERROR_MESSAGE |
|
281 |
); |
|
282 |
} |
|
283 |
return attribute; |
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* thrown when the last button is clicked |
|
288 |
*/ |
|
289 |
protected void lastButtonActionPerformed() { |
|
290 |
((JFrame)serverConnectFrame).setVisible(true); |
|
291 |
parent.setVisible(false); |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* thrown when the cancel button is clicked |
|
296 |
*/ |
|
297 |
protected void cancelSearchesButtonActionPerformed() { |
|
298 |
for (int i=0 ; i<searchThreads.size() ; i++){ |
|
299 |
searchThread st = (searchThread)searchThreads.toArray()[i]; |
|
300 |
st.stop(); |
|
301 |
} |
|
302 |
searchThreads.clear(); |
|
303 |
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
|
304 |
} |
|
305 |
|
|
306 |
/** |
|
307 |
* thrown when the close button is clicked |
|
308 |
*/ |
|
309 |
protected void closeButtonActionPerformed() { |
|
310 |
parent.setVisible(false); |
|
311 |
} |
|
312 |
|
|
313 |
/** |
|
314 |
* @return the selected query |
|
315 |
*/ |
|
316 |
protected GazetteerQuery doQuery() { |
|
317 |
query = client.createNewQuery(); |
|
318 |
query.setName(upperPanel.getName()); |
|
319 |
query.setNameFilter(lowerPanel.getConcordancia()); |
|
320 |
query.setFieldAttribute(featureAttribute); |
|
321 |
query.setFeatures(lowerPanel.getAllTypes()); |
|
322 |
query.setRecsByPage(lowerPanel.getResultsByPage()); |
|
323 |
query.setCoordinates(lowerPanel.getCoordinates()); |
|
324 |
query.setCoordinatesFilter(lowerPanel.getCoordinatesOption()); |
|
325 |
query.setCoordinatesClicked(upperPanel.isRestrictAreaClicked()); |
|
326 |
query.getOptions().getAspect().setGoTo(lowerPanel.isGoToClicked()); |
|
327 |
query.getOptions().getAspect().setKeepOld(lowerPanel.isKeepOldClicked()); |
|
328 |
query.getOptions().getAspect().setPaintCurrent(lowerPanel.isMarkedPlaceClicked()); |
|
329 |
query.getOptions().getSearch().setWithAccents(lowerPanel.isAccentsSearchEnabled()); |
|
330 |
query.setProperties(lowerPanel.getProperties()); |
|
331 |
return query; |
|
332 |
} |
|
333 |
|
|
334 |
/** |
|
335 |
* It returns the query that the user has selected |
|
336 |
* @throws Exception |
|
337 |
* |
|
338 |
*/ |
|
339 |
private void doSearch() throws Exception { |
|
340 |
features = client.getFeature(doQuery()); |
|
341 |
if (features == null) { |
|
342 |
JOptionPane.showMessageDialog(this, |
|
343 |
Messages.getText("errorGetRecords"), |
|
344 |
"Error", |
|
345 |
JOptionPane.ERROR_MESSAGE); |
|
346 |
} |
|
347 |
} |
|
348 |
|
|
349 |
/** |
|
350 |
* Show the results |
|
351 |
*/ |
|
352 |
private void showResults() { |
|
353 |
if (features.length == 0){ |
|
354 |
JOptionPane.showMessageDialog(this, |
|
355 |
Messages.getText("anyResult"), |
|
356 |
Messages.getText("gazetteer_search"), |
|
357 |
JOptionPane.INFORMATION_MESSAGE); |
|
358 |
}else{ |
|
359 |
showResultsActionPerformed(features); |
|
360 |
} |
|
361 |
} |
|
362 |
|
|
363 |
/** |
|
364 |
* @param features |
|
365 |
*/ |
|
366 |
protected void showResultsActionPerformed(Feature[] features) { |
|
367 |
new ShowResultsDialog(client, |
|
368 |
features, |
|
369 |
lowerPanel.getResultsByPage(), |
|
370 |
doQuery()); |
|
371 |
} |
|
372 |
|
|
373 |
/** |
|
374 |
* |
|
375 |
* @param parent The parent to set. |
|
376 |
*/ |
|
377 |
public void setParent(JFrame parent) { |
|
378 |
this.parent = parent; |
|
379 |
} |
|
380 |
|
|
381 |
/** |
|
382 |
* This class is used to manage the searches. |
|
383 |
* It contains method to start and to stop a thread. It is |
|
384 |
* necessary to create because "stop" method (for the Thread class) |
|
385 |
* is deprecated. |
|
386 |
* |
|
387 |
* |
|
388 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
389 |
*/ |
|
390 |
private class searchThread implements Runnable { |
|
391 |
volatile Thread myThread = null; |
|
392 |
|
|
393 |
public searchThread() { |
|
394 |
myThread = new Thread(this); |
|
395 |
myThread.start(); |
|
396 |
} |
|
397 |
|
|
398 |
public void stop() { |
|
399 |
myThread.stop(); |
|
400 |
} |
|
401 |
|
|
402 |
/* |
|
403 |
* (non-Javadoc) |
|
404 |
* @see java.lang.Runnable#run() |
|
405 |
*/ |
|
406 |
public void run() { |
|
407 |
try { |
|
408 |
doSearch(); |
|
409 |
} catch (Exception e) { |
|
410 |
e.printStackTrace(); |
|
411 |
} |
|
412 |
if ((features != null) && (features.length >= 0)) { |
|
413 |
showResults(); |
|
414 |
} |
|
415 |
searchThreads.remove(this); |
|
416 |
if (searchThreads.size() == 0){ |
|
417 |
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
|
418 |
} |
|
419 |
} |
|
420 |
} |
|
421 |
|
|
422 |
public GazetteerQuery getQuery() { |
|
423 |
return query; |
|
424 |
} |
|
425 |
|
|
426 |
public String getCurrentServer() { |
Also available in: Unified diff