root / branches / v10 / libraries / libUI / src / org / gvsig / gui / beans / filterPanel / filterQueryPanel / FilterQueryJPanel.java @ 10564
History | View | Annotate | Download (17.4 KB)
1 |
package org.gvsig.gui.beans.filterPanel.filterQueryPanel; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.GridBagConstraints; |
6 |
import java.awt.GridBagLayout; |
7 |
import java.io.Serializable; |
8 |
|
9 |
import javax.swing.BorderFactory; |
10 |
import javax.swing.DefaultListModel; |
11 |
import javax.swing.JLabel; |
12 |
import javax.swing.JPanel; |
13 |
import javax.swing.JScrollPane; |
14 |
|
15 |
import org.gvsig.gui.beans.Messages; |
16 |
import org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel; |
17 |
import org.gvsig.gui.beans.filterPanel.JLabelCellRenderer; |
18 |
|
19 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
20 |
*
|
21 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
22 |
*
|
23 |
* This program is free software; you can redistribute it and/or
|
24 |
* modify it under the terms of the GNU General Public License
|
25 |
* as published by the Free Software Foundation; either version 2
|
26 |
* of the License, or (at your option) any later version.
|
27 |
*
|
28 |
* This program is distributed in the hope that it will be useful,
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
31 |
* GNU General Public License for more details.
|
32 |
*
|
33 |
* You should have received a copy of the GNU General Public License
|
34 |
* along with this program; if not, write to the Free Software
|
35 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
36 |
*
|
37 |
* For more information, contact:
|
38 |
*
|
39 |
* Generalitat Valenciana
|
40 |
* Conselleria d'Infraestructures i Transport
|
41 |
* Av. Blasco Ib??ez, 50
|
42 |
* 46010 VALENCIA
|
43 |
* SPAIN
|
44 |
*
|
45 |
* +34 963862235
|
46 |
* gvsig@gva.es
|
47 |
* www.gvsig.gva.es
|
48 |
*
|
49 |
* or
|
50 |
*
|
51 |
* IVER T.I. S.A
|
52 |
* Salamanca 50
|
53 |
* 46005 Valencia
|
54 |
* Spain
|
55 |
*
|
56 |
* +34 963163400
|
57 |
* dac@iver.es
|
58 |
*/
|
59 |
|
60 |
/**
|
61 |
* This class is a version of the graphical interface of "FilterDialog" which was made by Fernando and is in 'appgvSIG' project.
|
62 |
* It's supposed that other classes will extend from this and will add the logic as is in the "FilterDialog" class.
|
63 |
*
|
64 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
65 |
*/
|
66 |
public class FilterQueryJPanel extends AbstractFilterQueryJPanel implements Serializable{ |
67 |
private static final long serialVersionUID = -5772343767095703604L; |
68 |
|
69 |
protected int filterJScrollPaneHeight = defaultBottomJPanelHeight - 10; |
70 |
protected int filterJScrollPanelWidth = defaultBottomJPanelWidth; |
71 |
|
72 |
/**
|
73 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel()
|
74 |
*/
|
75 |
public FilterQueryJPanel() {
|
76 |
super();
|
77 |
this.initialize();
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel(String)
|
82 |
*/
|
83 |
public FilterQueryJPanel(String _title) { |
84 |
super(_title);
|
85 |
this.initialize();
|
86 |
} |
87 |
|
88 |
/*
|
89 |
* (non-Javadoc)
|
90 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize()
|
91 |
*/
|
92 |
protected void initialize() { |
93 |
super.initialize();
|
94 |
this.setBorder(BorderFactory.createTitledBorder(Messages.getText("filterOnAWFSLayer"))); |
95 |
getValuesJList().setCellRenderer(new JLabelCellRenderer());
|
96 |
} |
97 |
|
98 |
/*
|
99 |
* (FilterQueryJPanel)
|
100 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFieldsJPanel()
|
101 |
*/
|
102 |
protected JPanel getFieldsJPanel() { |
103 |
if (fieldsJPanel == null) { |
104 |
fieldsJPanel = new javax.swing.JPanel();
|
105 |
fieldsJPanel.setPreferredSize(new java.awt.Dimension(fieldsJPanelWidth, fieldsJPanelHeight));
|
106 |
fieldsJPanel.setLayout(new GridBagLayout()); |
107 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
108 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
109 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
110 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
111 |
fieldsJPanel.add(getFieldsJLabel(), gridBagConstraints); |
112 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
113 |
fieldsJPanel.add(getFieldsJScrollPane(), gridBagConstraints); |
114 |
} |
115 |
|
116 |
return fieldsJPanel;
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* @see AbstractFilterQueryJPanel#getValuesJList()
|
121 |
*/
|
122 |
protected javax.swing.JList getValuesJList() {
|
123 |
if (valuesJList == null) { |
124 |
valuesJList = new javax.swing.JList(new DefaultListModel()); |
125 |
valuesListModel = new DefaultListModelForJLabelAsCell();
|
126 |
valuesJList.setModel(valuesListModel); |
127 |
valuesJList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
128 |
|
129 |
// valuesJList.addMouseListener(new MouseAdapter() {
|
130 |
// /*
|
131 |
// * (non-Javadoc)
|
132 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
133 |
// */
|
134 |
// public void mouseClicked(MouseEvent e) {
|
135 |
// if (e.getClickCount() == 2) {
|
136 |
// int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
|
137 |
//
|
138 |
// if (row > -1) {
|
139 |
// putSymbol(((DefaultListModel)valuesJList.getModel()).get(row).toString());
|
140 |
// }
|
141 |
// }
|
142 |
// }
|
143 |
// });
|
144 |
} |
145 |
|
146 |
return valuesJList;
|
147 |
} |
148 |
|
149 |
/*
|
150 |
* (non-Javadoc)
|
151 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFieldsJScrollPane()
|
152 |
*/
|
153 |
protected javax.swing.JScrollPane getFieldsJScrollPane() {
|
154 |
if (fieldsJScrollPane == null) { |
155 |
fieldsJScrollPane = new javax.swing.JScrollPane();
|
156 |
fieldsJScrollPane.setPreferredSize(new java.awt.Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight));
|
157 |
fieldsJScrollPane.setViewportView(getFieldsJTree()); |
158 |
} |
159 |
|
160 |
return fieldsJScrollPane;
|
161 |
} |
162 |
|
163 |
/*
|
164 |
* (non-Javadoc)
|
165 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getValuesJPanel()
|
166 |
*/
|
167 |
protected JPanel getValuesJPanel() { |
168 |
if (valuesJPanel == null) { |
169 |
valuesJPanel = new javax.swing.JPanel();
|
170 |
valuesJPanel.setPreferredSize(new java.awt.Dimension(valuesJPanelWidth, valuesJPanelHeight));
|
171 |
valuesJPanel.setLayout(new GridBagLayout()); |
172 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
173 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
174 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
175 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
176 |
valuesJPanel.add(getValuesJLabel(), gridBagConstraints); |
177 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
178 |
valuesJPanel.add(getValuesJScrollPane(), gridBagConstraints); |
179 |
} |
180 |
|
181 |
return valuesJPanel;
|
182 |
} |
183 |
|
184 |
/*
|
185 |
* (non-Javadoc)
|
186 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getValuesJScrollPane()
|
187 |
*/
|
188 |
protected javax.swing.JScrollPane getValuesJScrollPane() {
|
189 |
if (valuesJScrollPane == null) { |
190 |
valuesJScrollPane = new javax.swing.JScrollPane();
|
191 |
valuesJScrollPane.setPreferredSize(new Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight)); |
192 |
valuesJScrollPane.setViewportView(getValuesJList()); |
193 |
} |
194 |
|
195 |
return valuesJScrollPane;
|
196 |
} |
197 |
|
198 |
/*
|
199 |
* (non-Javadoc)
|
200 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFilterJScrollPane()
|
201 |
*/
|
202 |
protected JScrollPane getFilterJScrollPane() { |
203 |
if (filterJScrollPane == null) { |
204 |
filterJScrollPane = new javax.swing.JScrollPane();
|
205 |
filterJScrollPane.setPreferredSize(new java.awt.Dimension(filterJScrollPanelWidth, filterJScrollPaneHeight));
|
206 |
filterJScrollPane.setViewportView(getTxtExpression()); |
207 |
filterJScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
208 |
} |
209 |
|
210 |
return filterJScrollPane;
|
211 |
} |
212 |
|
213 |
/*
|
214 |
* (non-Javadoc)
|
215 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getTxtExpression()
|
216 |
*/
|
217 |
protected javax.swing.JTextArea getTxtExpression() {
|
218 |
if (txtExpression == null) { |
219 |
txtExpression = new javax.swing.JTextArea();
|
220 |
txtExpression.setLineWrap(true);
|
221 |
} |
222 |
|
223 |
return txtExpression;
|
224 |
} |
225 |
|
226 |
/*
|
227 |
* (non-Javadoc)
|
228 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getBottomJPanel()
|
229 |
*/
|
230 |
protected JPanel getBottomJPanel() { |
231 |
if (bottomJPanel == null) { |
232 |
bottomJPanel = new JPanel(); |
233 |
bottomJPanel.setPreferredSize(new Dimension(defaultBottomJPanelWidth, defaultBottomJPanelHeight)); |
234 |
bottomJPanel.add(getFilterJScrollPane(), null);
|
235 |
} |
236 |
|
237 |
return bottomJPanel;
|
238 |
} |
239 |
|
240 |
/*
|
241 |
* (non-Javadoc)
|
242 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#resizeWidth(int)
|
243 |
*/
|
244 |
public void resizeWidth(int new_Width) { |
245 |
int difference = new_Width - DefaultWidth;
|
246 |
|
247 |
if (difference != 0) { |
248 |
this.setPreferredSize(new Dimension(this.getPreferredSize().width + difference, this.getPreferredSize().height)); |
249 |
getTopJPanel().setPreferredSize(new Dimension(getTopJPanel().getPreferredSize().width + difference, getTopJPanel().getPreferredSize().height)); |
250 |
getBottomJPanel().setPreferredSize(new Dimension(getBottomJPanel().getPreferredSize().width + difference, getBottomJPanel().getPreferredSize().height)); |
251 |
getFilterJScrollPane().setPreferredSize(new Dimension(getFilterJScrollPane().getPreferredSize().width + difference, getFilterJScrollPane().getPreferredSize().height)); |
252 |
|
253 |
int halfDifference = difference / 2; |
254 |
|
255 |
getFieldsJLabel().setPreferredSize(new Dimension(getFieldsJLabel().getPreferredSize().width + halfDifference, getFieldsJLabel().getPreferredSize().height)); |
256 |
getFieldsJPanel().setPreferredSize(new Dimension(getFieldsJPanel().getPreferredSize().width + halfDifference, getFieldsJPanel().getPreferredSize().height)); |
257 |
getFieldsJScrollPane().setPreferredSize(new Dimension(getFieldsJScrollPane().getPreferredSize().width + halfDifference, getFieldsJScrollPane().getPreferredSize().height)); |
258 |
|
259 |
getValuesJLabel().setPreferredSize(new Dimension(getValuesJLabel().getPreferredSize().width + halfDifference, getValuesJLabel().getPreferredSize().height)); |
260 |
getValuesJPanel().setPreferredSize(new Dimension(getValuesJPanel().getPreferredSize().width + halfDifference, getValuesJPanel().getPreferredSize().height)); |
261 |
getValuesJScrollPane().setPreferredSize(new Dimension(getValuesJScrollPane().getPreferredSize().width + halfDifference, getValuesJScrollPane().getPreferredSize().height)); |
262 |
} |
263 |
} |
264 |
|
265 |
/**
|
266 |
* Extension of JLabel that has some specific characteristics -> Version for values that are loaded in layer in view
|
267 |
*
|
268 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
269 |
*/
|
270 |
protected final class JLabelValueLoaded extends JLabel implements Comparable { |
271 |
|
272 |
/**
|
273 |
* Default constructor without parameters
|
274 |
*/
|
275 |
public JLabelValueLoaded() {
|
276 |
super();
|
277 |
this.configure();
|
278 |
} |
279 |
|
280 |
/**
|
281 |
* Default constructor with a parameter
|
282 |
*
|
283 |
* @param text
|
284 |
*/
|
285 |
public JLabelValueLoaded(String text) { |
286 |
super(text);
|
287 |
this.configure();
|
288 |
} |
289 |
|
290 |
/**
|
291 |
* Configures some characteristics
|
292 |
*/
|
293 |
private void configure() { |
294 |
this.setBackground(Color.yellow); |
295 |
this.setForeground(Color.blue); |
296 |
} |
297 |
|
298 |
/*
|
299 |
* (non-Javadoc)
|
300 |
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
301 |
*/
|
302 |
public int compareTo(Object o) { |
303 |
// It's supposed that 'o' is an string
|
304 |
return this.getText().compareTo((String)o); |
305 |
} |
306 |
|
307 |
/*
|
308 |
* (non-Javadoc)
|
309 |
* @see java.lang.Object#toString()
|
310 |
*/
|
311 |
public String toString() { |
312 |
return this.getText(); |
313 |
} |
314 |
} |
315 |
|
316 |
/**
|
317 |
* Extension of JLabel that has some specific characteristics -> Version for values that aren't loaded in layer in view
|
318 |
*
|
319 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
320 |
*/
|
321 |
protected final class JLabelValueNotLoaded extends JLabel implements Comparable{ |
322 |
|
323 |
/**
|
324 |
* Default constructor without parameters
|
325 |
*/
|
326 |
public JLabelValueNotLoaded() {
|
327 |
super();
|
328 |
this.configure();
|
329 |
} |
330 |
|
331 |
/**
|
332 |
* Default constructor with a parameter
|
333 |
*
|
334 |
* @param text
|
335 |
*/
|
336 |
public JLabelValueNotLoaded(String text) { |
337 |
super(text);
|
338 |
this.configure();
|
339 |
} |
340 |
|
341 |
/**
|
342 |
* Configures some characteristics
|
343 |
*/
|
344 |
private void configure() { |
345 |
this.setBackground(Color.white); |
346 |
} |
347 |
|
348 |
/*
|
349 |
* (non-Javadoc)
|
350 |
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
351 |
*/
|
352 |
public int compareTo(Object o) { |
353 |
// It's supposed that 'o' is an string
|
354 |
return this.getText().compareTo((String)o); |
355 |
} |
356 |
|
357 |
/*
|
358 |
* (non-Javadoc)
|
359 |
* @see java.lang.Object#toString()
|
360 |
*/
|
361 |
public String toString() { |
362 |
return this.getText(); |
363 |
} |
364 |
} |
365 |
|
366 |
/**
|
367 |
* This class reimplements the "contains()" method of "DefaultListModel" for
|
368 |
*
|
369 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
370 |
*
|
371 |
*/
|
372 |
protected final class DefaultListModelForJLabelAsCell extends DefaultListModel{ |
373 |
|
374 |
/**
|
375 |
* Represents the start index of the group of not loaded values (that should be after the group of loaded values)
|
376 |
* -2 -> if elements aren't grouped (in two lists: first for loaded, after for not loaded)
|
377 |
* -1 -> if there isn't elements
|
378 |
* 0 -> if there are only not loaded elements
|
379 |
* = (capacity() -1) -> if there are only loaded elements
|
380 |
*/
|
381 |
private int startIndexOfNotLoadedValues; |
382 |
|
383 |
/**
|
384 |
* Default constructor without parameters
|
385 |
*/
|
386 |
public DefaultListModelForJLabelAsCell() {
|
387 |
super();
|
388 |
startIndexOfNotLoadedValues = -1;
|
389 |
} |
390 |
|
391 |
/**
|
392 |
* Method that returns true if there is a inner JLabel that has as inner text the same text as 'patternText'
|
393 |
*
|
394 |
* @param patternText
|
395 |
* @return A boolean value
|
396 |
*/
|
397 |
public boolean containsJLabelText(String patternText) { |
398 |
for (int i = 0; i < super.getSize(); i++) { |
399 |
if (((JLabel)super.get(i)).getText().compareTo(patternText) == 0) |
400 |
return true; |
401 |
} |
402 |
|
403 |
return false; |
404 |
} |
405 |
|
406 |
/**
|
407 |
* Returns the position of first JLabel that has as text the same text as 'patternText', or -1 if no JLabel has that text
|
408 |
*
|
409 |
* @param patternText An String
|
410 |
* @return An integer value
|
411 |
*/
|
412 |
public int getIndexOfJLabelText(String patternText) { |
413 |
for (int i = 0; i < super.getSize(); i++) { |
414 |
if (((JLabel)super.get(i)).getText().compareTo(patternText) == 0) |
415 |
return i;
|
416 |
} |
417 |
|
418 |
return -1; // If not found |
419 |
} |
420 |
|
421 |
/**
|
422 |
* Changes element to
|
423 |
*
|
424 |
* @param patternText
|
425 |
*/
|
426 |
public void changeElementThatHasTextToJLabelLoadedValue(String patternText) { |
427 |
int index = getIndexOfJLabelText(patternText);
|
428 |
|
429 |
if (index != -1) |
430 |
super.set(index, new JLabelValueLoaded(patternText)); |
431 |
} |
432 |
|
433 |
/**
|
434 |
* Sets all elements to 'JLabelValueNotLoaded'
|
435 |
*/
|
436 |
public void setAllElementsToNotLoaded() { |
437 |
if (startIndexOfNotLoadedValues == -1) { |
438 |
for (int i = 0; i < super.getSize(); i++) { |
439 |
if (super.get(i) instanceof JLabelValueLoaded) { |
440 |
JLabelValueNotLoaded jL = new JLabelValueNotLoaded(((JLabelValueLoaded)super.get(i)).getText()); |
441 |
super.remove(i);
|
442 |
super.add(i, jL);///// REIMPLEMENTATION OF SOME METHODS OF 'DefaultListModel' ///// |
443 |
} |
444 |
} |
445 |
} |
446 |
else {
|
447 |
for (int i = 0; i < startIndexOfNotLoadedValues; i++) { |
448 |
if (super.get(i) instanceof JLabelValueLoaded) { |
449 |
JLabelValueNotLoaded jL = new JLabelValueNotLoaded(((JLabelValueLoaded)super.get(i)).getText()); |
450 |
super.set(i, jL); // replacement |
451 |
} |
452 |
} |
453 |
} |
454 |
|
455 |
startIndexOfNotLoadedValues = 0;
|
456 |
} |
457 |
|
458 |
///// REIMPLEMENTATION OF SOME METHODS OF 'DefaultListModel' /////
|
459 |
|
460 |
/*
|
461 |
* (non-Javadoc)
|
462 |
* @see javax.swing.DefaultListModel#clear()
|
463 |
*/
|
464 |
public void clear() { |
465 |
super.clear();
|
466 |
startIndexOfNotLoadedValues = -1;
|
467 |
} |
468 |
|
469 |
/*
|
470 |
* (non-Javadoc)
|
471 |
* @see javax.swing.DefaultListModel#insertElementAt(java.lang.Object, int)
|
472 |
*/
|
473 |
public void insertElementAt(Object obj, int index) { |
474 |
super.insertElementAt(obj, index);
|
475 |
|
476 |
if ((obj instanceof JLabelValueNotLoaded) && (index > -1) && (index < startIndexOfNotLoadedValues)) |
477 |
startIndexOfNotLoadedValues = index; |
478 |
} |
479 |
|
480 |
/*
|
481 |
* (non-Javadoc)
|
482 |
* @see javax.swing.DefaultListModel#remove(int)
|
483 |
*/
|
484 |
public Object remove(int index) { |
485 |
if ( (index > -1) && (index == startIndexOfNotLoadedValues) && (index == (super.capacity() -1)) ) { |
486 |
startIndexOfNotLoadedValues = -1;
|
487 |
} |
488 |
|
489 |
return super.remove(index); |
490 |
} |
491 |
|
492 |
/*
|
493 |
* (non-Javadoc)
|
494 |
* @see javax.swing.DefaultListModel#removeAllElements()
|
495 |
*/
|
496 |
public void removeAllElements() { |
497 |
super.removeAllElements();
|
498 |
startIndexOfNotLoadedValues = -1;
|
499 |
} |
500 |
|
501 |
/*
|
502 |
* (non-Javadoc)
|
503 |
* @see javax.swing.DefaultListModel#removeElement(java.lang.Object)
|
504 |
*/
|
505 |
public boolean removeElement(Object obj) { |
506 |
int index = super.indexOf(obj); |
507 |
|
508 |
if ( (index > -1) && (index == startIndexOfNotLoadedValues) && (index == (super.capacity() -1)) ) { |
509 |
startIndexOfNotLoadedValues = -1;
|
510 |
} |
511 |
|
512 |
return super.removeElement(obj); |
513 |
} |
514 |
|
515 |
/*
|
516 |
* (non-Javadoc)
|
517 |
* @see javax.swing.DefaultListModel#removeElementAt(int)
|
518 |
*/
|
519 |
public void removeElementAt(int index) { |
520 |
if ( (index > -1) && (index == startIndexOfNotLoadedValues) && (index == (super.capacity() -1)) ) { |
521 |
startIndexOfNotLoadedValues = -1;
|
522 |
} |
523 |
|
524 |
super.removeElementAt(index);
|
525 |
} |
526 |
|
527 |
/*
|
528 |
* (non-Javadoc)
|
529 |
* @see javax.swing.DefaultListModel#removeRange(int, int)
|
530 |
*/
|
531 |
public void removeRange(int fromIndex, int toIndex) { |
532 |
super.removeRange(fromIndex, toIndex);
|
533 |
|
534 |
// Try to find any element of type 'JLabelNotLoadedValue'
|
535 |
for (int i = 0; i < super.capacity(); i++) { |
536 |
if (super.get(i) instanceof JLabelValueNotLoaded) { |
537 |
if ( ( (i == (super.capacity() -1) || (i < (super.capacity() -1)) && (super.get(super.capacity() -1) instanceof JLabelValueNotLoaded) ) ) ) |
538 |
startIndexOfNotLoadedValues = i; |
539 |
else
|
540 |
startIndexOfNotLoadedValues = -1;
|
541 |
} |
542 |
} |
543 |
} |
544 |
|
545 |
/*
|
546 |
* (non-Javadoc)
|
547 |
* @see javax.swing.DefaultListModel#set(int, java.lang.Object)
|
548 |
*/
|
549 |
public Object set(int index, Object element) { |
550 |
if ((element instanceof JLabelValueNotLoaded) && (index > -1) && (index < startIndexOfNotLoadedValues)) |
551 |
startIndexOfNotLoadedValues = index; |
552 |
|
553 |
return super.set(index, element); |
554 |
} |
555 |
|
556 |
/*
|
557 |
* (non-Javadoc)
|
558 |
* @see javax.swing.DefaultListModel#setElementAt(java.lang.Object, int)
|
559 |
*/
|
560 |
public void setElementAt(Object obj, int index) { |
561 |
super.setElementAt(obj, index);
|
562 |
|
563 |
if ((obj instanceof JLabelValueNotLoaded) && (index > -1) && (index < startIndexOfNotLoadedValues)) |
564 |
startIndexOfNotLoadedValues = index; |
565 |
} |
566 |
|
567 |
///// END REIMPLEMENTATION OF SOME METHODS OF 'DefaultListModel' /////
|
568 |
} |
569 |
} |