Revision 3566 trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/gazetteer/ui/showResults/ShowResultsDialogPanel.java
ShowResultsDialogPanel.java | ||
---|---|---|
1 |
|
|
1 | 2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
2 | 3 |
* |
3 | 4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
... | ... | |
39 | 40 |
* dac@iver.es |
40 | 41 |
*/ |
41 | 42 |
package es.gva.cit.gazetteer.ui.showResults; |
42 |
|
|
43 |
|
|
44 | 43 |
import es.gva.cit.catalogClient.traductor.ITranslator; |
45 | 44 |
import es.gva.cit.gazetteer.GazetteerClient; |
46 | 45 |
import es.gva.cit.gazetteer.querys.Feature; |
47 |
|
|
48 | 46 |
import java.awt.event.ActionEvent; |
49 | 47 |
import java.awt.event.ActionListener; |
50 |
|
|
51 | 48 |
import javax.swing.JButton; |
52 | 49 |
import javax.swing.JDialog; |
53 | 50 |
import javax.swing.JPanel; |
54 | 51 |
|
55 |
|
|
56 |
|
|
57 | 52 |
/** |
53 |
* |
|
54 |
* |
|
55 |
* |
|
58 | 56 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
59 | 57 |
*/ |
60 | 58 |
public class ShowResultsDialogPanel extends JPanel implements ActionListener { |
61 |
// It is needed to close the frame |
|
59 |
// It is needed to close the frame |
|
60 |
/** |
|
61 |
* |
|
62 |
* |
|
63 |
*/ |
|
62 | 64 |
private JDialog parent; |
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* |
|
67 |
* |
|
68 |
*/ |
|
65 | 69 |
protected ShowResultsPanel ppalPanel = null; |
66 |
protected Feature[] features = null; |
|
70 |
/** |
|
71 |
* |
|
72 |
* |
|
73 |
*/ |
|
67 | 74 |
protected GazetteerClient client = null; |
75 |
|
|
76 |
/** |
|
77 |
* |
|
78 |
* |
|
79 |
*/ |
|
68 | 80 |
protected boolean isGotoClicked; |
81 |
|
|
82 |
/** |
|
83 |
* |
|
84 |
* |
|
85 |
*/ |
|
69 | 86 |
protected boolean isKeepOldClicked; |
70 | 87 |
|
71 |
|
|
88 |
/** |
|
89 |
* |
|
90 |
* |
|
91 |
*/ |
|
72 | 92 |
private int currentPage = 0; |
93 |
|
|
94 |
/** |
|
95 |
* |
|
96 |
* |
|
97 |
*/ |
|
73 | 98 |
private int recordsByPage = 0; |
74 |
|
|
99 |
/** |
|
100 |
* |
|
101 |
* |
|
102 |
*/ |
|
75 | 103 |
private JButton nextButton = null; |
104 |
/** |
|
105 |
* |
|
106 |
* |
|
107 |
*/ |
|
76 | 108 |
private JButton lastButton = null; |
109 |
/** |
|
110 |
* |
|
111 |
* |
|
112 |
*/ |
|
77 | 113 |
private JButton mapButton = null; |
114 |
/** |
|
115 |
* |
|
116 |
* |
|
117 |
*/ |
|
78 | 118 |
private JButton closeButton = null; |
119 |
/** |
|
120 |
* |
|
121 |
* |
|
122 |
*/ |
|
79 | 123 |
private ITranslator translator = null; |
80 | 124 |
|
81 |
public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, |
|
82 |
int recordsByPage,ITranslator translator,boolean isGotoClicked, boolean isKeepOldClicked) { |
|
83 |
this.features = features; |
|
84 |
this.client = client; |
|
125 |
/** |
|
126 |
* |
|
127 |
* |
|
128 |
*/ |
|
129 |
private int featuresLength = 0; |
|
130 |
|
|
131 |
/** |
|
132 |
* |
|
133 |
* |
|
134 |
* |
|
135 |
* @param client |
|
136 |
* @param features |
|
137 |
* @param recordsByPage |
|
138 |
* @param translator |
|
139 |
* @param isGotoClicked |
|
140 |
* @param isKeepOldClicked |
|
141 |
*/ |
|
142 |
public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, int recordsByPage, ITranslator translator, boolean isGotoClicked, boolean isKeepOldClicked) { |
|
85 | 143 |
this.currentPage = 1; |
86 | 144 |
this.recordsByPage = recordsByPage; |
87 | 145 |
this.translator = translator; |
88 | 146 |
this.isGotoClicked = isGotoClicked; |
89 | 147 |
this.isKeepOldClicked = isKeepOldClicked; |
90 | 148 |
initialize(client,features,recordsByPage); |
91 |
} |
|
149 |
}
|
|
92 | 150 |
|
93 |
public void initialize(GazetteerClient client, Feature[] features, |
|
94 |
int recordsByPage){ |
|
95 |
this.features = features; |
|
96 |
this.client = client; |
|
151 |
/** |
|
152 |
* |
|
153 |
* |
|
154 |
* |
|
155 |
* @param client |
|
156 |
* @param features |
|
157 |
* @param recordsByPage |
|
158 |
*/ |
|
159 |
public void initialize(GazetteerClient client, Feature[] features, int recordsByPage) { |
|
160 |
this.featuresLength = features.length; |
|
97 | 161 |
this.currentPage = 1; |
98 | 162 |
this.recordsByPage = recordsByPage; |
99 | 163 |
ppalPanel = new ShowResultsPanel(features,getNumPages(),recordsByPage,translator); |
100 |
|
|
101 | 164 |
setDefaultButtonListeners(); |
102 | 165 |
|
103 | 166 |
add(ppalPanel); |
104 |
} |
|
105 |
|
|
106 |
|
|
107 |
private void setDefaultButtonListeners() { |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* |
|
171 |
* |
|
172 |
*/ |
|
173 |
private void setDefaultButtonListeners() { |
|
108 | 174 |
nextButton = ppalPanel.getNextButton(); |
109 | 175 |
lastButton = ppalPanel.getLastButton(); |
110 | 176 |
mapButton = ppalPanel.getMapButton(); |
... | ... | |
114 | 180 |
lastButton.addActionListener(this); |
115 | 181 |
mapButton.addActionListener(this); |
116 | 182 |
closeButton.addActionListener(this); |
117 |
} |
|
183 |
}
|
|
118 | 184 |
|
119 |
private JButton getMapButton() { |
|
185 |
/** |
|
186 |
* |
|
187 |
* |
|
188 |
* |
|
189 |
* @return |
|
190 |
*/ |
|
191 |
private JButton getMapButton() { |
|
120 | 192 |
return mapButton; |
121 |
} |
|
122 |
|
|
123 |
private JButton getCloseButton(){ |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* |
|
197 |
* |
|
198 |
* |
|
199 |
* @return |
|
200 |
*/ |
|
201 |
private JButton getCloseButton() { |
|
124 | 202 |
return closeButton; |
125 |
} |
|
203 |
}
|
|
126 | 204 |
|
127 |
public void actionPerformed(ActionEvent e) { |
|
205 |
/** |
|
206 |
* |
|
207 |
* |
|
208 |
* |
|
209 |
* @param e |
|
210 |
*/ |
|
211 |
public void actionPerformed(ActionEvent e) { |
|
128 | 212 |
if (e.getActionCommand().equals("next")) { |
129 | 213 |
nextButtonActionPerformed(); |
130 | 214 |
} |
... | ... | |
138 | 222 |
closeButtonActionPerformed(); |
139 | 223 |
} |
140 | 224 |
|
141 |
} |
|
142 |
|
|
143 |
private int getNumPages(){ |
|
144 |
if ((features.length % recordsByPage) == 0) |
|
145 |
return features.length/recordsByPage; |
|
146 |
return (features.length/recordsByPage) + 1; |
|
147 |
} |
|
225 |
} |
|
148 | 226 |
|
149 |
public void nextButtonActionPerformed() { |
|
227 |
/** |
|
228 |
* |
|
229 |
* |
|
230 |
* |
|
231 |
* @return |
|
232 |
*/ |
|
233 |
private int getNumPages() { |
|
234 |
if ((featuresLength % recordsByPage) == 0) |
|
235 |
return featuresLength/recordsByPage; |
|
236 |
return (featuresLength/recordsByPage) + 1; |
|
237 |
} |
|
238 |
|
|
239 |
/** |
|
240 |
* |
|
241 |
* |
|
242 |
*/ |
|
243 |
public void nextButtonActionPerformed() { |
|
150 | 244 |
this.currentPage = this.currentPage + 1; |
151 | 245 |
|
152 | 246 |
if (this.currentPage == getNumPages()) { |
... | ... | |
154 | 248 |
} else { |
155 | 249 |
nextButton.setEnabled(true); |
156 | 250 |
} |
157 |
|
|
158 | 251 |
lastButton.setEnabled(true); |
159 |
|
|
160 | 252 |
ppalPanel.actualizaLabel(currentPage,recordsByPage); |
161 | 253 |
|
162 | 254 |
|
163 |
} |
|
255 |
}
|
|
164 | 256 |
|
165 |
public void lastButtonActionPerformed() { |
|
257 |
/** |
|
258 |
* |
|
259 |
* |
|
260 |
*/ |
|
261 |
public void lastButtonActionPerformed() { |
|
166 | 262 |
this.currentPage = this.currentPage - 1; |
167 |
|
|
168 | 263 |
if (this.currentPage == 1) { |
169 | 264 |
lastButton.setEnabled(false); |
170 | 265 |
} else { |
171 | 266 |
lastButton.setEnabled(true); |
172 | 267 |
} |
173 |
|
|
174 | 268 |
nextButton.setEnabled(true); |
175 | 269 |
|
176 | 270 |
ppalPanel.actualizaLabel(currentPage,recordsByPage); |
177 | 271 |
|
178 | 272 |
|
179 |
} |
|
273 |
}
|
|
180 | 274 |
|
181 |
public void loadButtonActionPerformed() { |
|
275 |
/** |
|
276 |
* |
|
277 |
* |
|
278 |
*/ |
|
279 |
public void loadButtonActionPerformed() { |
|
182 | 280 |
Feature feature = ppalPanel.getFeature(); |
183 | 281 |
|
184 | 282 |
if (feature != null){ |
... | ... | |
187 | 285 |
System.out.println("DESCRIPTION: " + feature.getDescription()); |
188 | 286 |
System.out.println("COORDINATES: X=" + feature.getCoordinates().getX() + " Y=" + feature.getCoordinates().getY()); |
189 | 287 |
} |
190 |
} |
|
191 |
|
|
192 |
public void closeButtonActionPerformed() { |
|
288 |
} |
|
289 |
|
|
290 |
/** |
|
291 |
* |
|
292 |
* |
|
293 |
*/ |
|
294 |
public void closeButtonActionPerformed() { |
|
193 | 295 |
parent.setVisible(false); |
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* @param parent The parent to set. |
|
198 |
*/ |
|
199 |
public void setParent(JDialog parent) { |
|
296 |
} |
|
297 |
|
|
298 |
/** |
|
299 |
* |
|
300 |
* |
|
301 |
* |
|
302 |
* @param parent The parent to set. |
|
303 |
*/ |
|
304 |
public void setParent(JDialog parent) { |
|
200 | 305 |
this.parent = parent; |
201 |
} |
|
202 |
|
|
203 |
|
|
204 |
} |
|
306 |
} |
|
307 |
} |
Also available in: Unified diff