Revision 8390 trunk/libraries/libUI/src/org/gvsig/gui/beans/filterPanel/AbstractFilterQueryJPanel.java
AbstractFilterQueryJPanel.java | ||
---|---|---|
68 | 68 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
69 | 69 |
*/ |
70 | 70 |
public abstract class AbstractFilterQueryJPanel extends JPanel implements Serializable { |
71 |
protected final int defaultHeight = 280;
|
|
72 |
protected final int defaultWidth = 490;
|
|
71 |
public static final int DefaultHeight = 280;
|
|
72 |
public static final int DefaultWidth = 490;
|
|
73 | 73 |
|
74 | 74 |
protected final int fieldsJPanelHeight = 135; |
75 | 75 |
protected final int fieldsJPanelWidth = 145; |
... | ... | |
102 | 102 |
|
103 | 103 |
protected String title; |
104 | 104 |
|
105 |
protected DefaultMutableTreeNode jtreeRoot; |
|
106 | 105 |
protected DefaultTreeModel defaultTreeModel; |
107 |
protected LayerFeaturesFields layerFeaturesFields;
|
|
106 |
protected DefaultListModel valuesListModel;
|
|
108 | 107 |
|
109 | 108 |
|
110 | 109 |
/** |
... | ... | |
125 | 124 |
* This method initializes this |
126 | 125 |
*/ |
127 | 126 |
protected void initialize() { |
128 |
this.setPreferredSize(new Dimension(defaultWidth, defaultHeight));
|
|
129 |
this.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "filterOnAWFSLayer"))); |
|
127 |
this.setPreferredSize(new Dimension(DefaultWidth, DefaultHeight));
|
|
128 |
|
|
130 | 129 |
this.setLayout(new GridBagLayout()); |
131 | 130 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
132 | 131 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
... | ... | |
137 | 136 |
|
138 | 137 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH; |
139 | 138 |
this.add(getBottomJPanel(), gridBagConstraints); |
140 |
|
|
141 |
layerFeaturesFields = new LayerFeaturesFields(); |
|
142 | 139 |
} |
143 | 140 |
|
144 | 141 |
/** |
... | ... | |
266 | 263 |
// Root not visible |
267 | 264 |
fieldsJTree.setRootVisible(false); |
268 | 265 |
fieldsJTree.setCellRenderer(defaultTreeCellRenderer); |
269 |
|
|
270 |
jtreeRoot = new DefaultMutableTreeNode(fieldsJTree.getModel().getRoot()); |
|
271 | 266 |
} |
272 | 267 |
|
273 | 268 |
return fieldsJTree; |
... | ... | |
281 | 276 |
protected javax.swing.JList getValuesJList() { |
282 | 277 |
if (valuesJList == null) { |
283 | 278 |
valuesJList = new javax.swing.JList(new DefaultListModel()); |
279 |
valuesListModel = new DefaultListModel(); |
|
280 |
valuesJList.setModel(valuesListModel); |
|
281 |
valuesJList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
|
284 | 282 |
|
285 |
valuesJList.addMouseListener(new MouseAdapter() { |
|
286 |
/* |
|
287 |
* (non-Javadoc) |
|
288 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
289 |
*/ |
|
290 |
public void mouseClicked(MouseEvent e) { |
|
291 |
if (e.getClickCount() == 2) { |
|
292 |
int row = fieldsJTree.getRowForLocation(e.getX(), e.getY()); |
|
293 |
|
|
294 |
if (row > -1) { |
|
295 |
putSymbol(((DefaultListModel)valuesJList.getModel()).get(row).toString()); |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
}); |
|
283 |
// valuesJList.addMouseListener(new MouseAdapter() {
|
|
284 |
// /*
|
|
285 |
// * (non-Javadoc)
|
|
286 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
|
287 |
// */
|
|
288 |
// public void mouseClicked(MouseEvent e) {
|
|
289 |
// if (e.getClickCount() == 2) {
|
|
290 |
// int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
|
|
291 |
// |
|
292 |
// if (row > -1) {
|
|
293 |
// putSymbol(((DefaultListModel)valuesJList.getModel()).get(row).toString());
|
|
294 |
// }
|
|
295 |
// }
|
|
296 |
// }
|
|
297 |
// });
|
|
300 | 298 |
} |
301 | 299 |
|
302 | 300 |
return valuesJList; |
... | ... | |
368 | 366 |
case FilterButtonsJPanel.SMALLER: |
369 | 367 |
putSymbol(" < "); |
370 | 368 |
break; |
369 |
case FilterButtonsJPanel.DELETE_TEXT: |
|
370 |
txtExpression.setText(""); |
|
371 |
break; |
|
371 | 372 |
default: // do anything |
372 | 373 |
} |
373 | 374 |
} |
... | ... | |
384 | 385 |
* @param new_Height New height |
385 | 386 |
*/ |
386 | 387 |
public void resizeHeight(int new_Height) { |
387 |
int difference = new_Height - defaultHeight;
|
|
388 |
int difference = new_Height - DefaultHeight;
|
|
388 | 389 |
|
389 | 390 |
if (difference > 0) { |
390 | 391 |
this.setPreferredSize(new Dimension(this.getPreferredSize().width, this.getPreferredSize().height + difference)); |
... | ... | |
410 | 411 |
* @see java.awt.Component#resize(int, int) |
411 | 412 |
*/ |
412 | 413 |
public void resize(int width, int height) { |
413 |
int difference = height - defaultHeight;
|
|
414 |
int difference = height - DefaultHeight;
|
|
414 | 415 |
|
415 | 416 |
if (difference != 0) |
416 | 417 |
this.resizeHeight(height); |
... | ... | |
423 | 424 |
* @see java.awt.Component#resize(java.awt.Dimension) |
424 | 425 |
*/ |
425 | 426 |
public void resize(Dimension d) { |
426 |
int difference = d.height - defaultHeight;
|
|
427 |
int difference = d.height - DefaultHeight;
|
|
427 | 428 |
|
428 | 429 |
if (difference != 0) |
429 | 430 |
this.resizeHeight(d.height); |
430 | 431 |
|
431 | 432 |
this.resizeWidth(d.width); |
432 | 433 |
} |
433 |
|
|
434 |
|
|
435 |
/** |
|
436 |
* This class cointains the data of features of a layer |
|
437 |
* |
|
438 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
439 |
*/ |
|
440 |
protected class LayerFeaturesFields { |
|
441 |
Vector layerFeaturesFields; |
|
442 |
Vector layerFeaturesValues; |
|
443 |
|
|
444 |
/** |
|
445 |
* @see Vector#Vector() |
|
446 |
*/ |
|
447 |
public LayerFeaturesFields() { |
|
448 |
initialize(); |
|
449 |
} |
|
450 |
|
|
451 |
/** |
|
452 |
* Initializes the attributes of this class |
|
453 |
*/ |
|
454 |
private void initialize() { |
|
455 |
layerFeaturesFields = new Vector(0, 1); |
|
456 |
layerFeaturesValues = new Vector(0, 1); |
|
457 |
} |
|
458 |
|
|
459 |
/** |
|
460 |
* Adds a new field |
|
461 |
* |
|
462 |
* @param _field An object |
|
463 |
*/ |
|
464 |
public void addField(Object _field) { |
|
465 |
layerFeaturesFields.add(_field); |
|
466 |
layerFeaturesValues.add(new Vector(0, 1)); |
|
467 |
} |
|
468 |
|
|
469 |
/** |
|
470 |
* Adds a new field |
|
471 |
* |
|
472 |
* @param _field An object |
|
473 |
* @param _values A Vector |
|
474 |
*/ |
|
475 |
public void addFieldAndValues(Object _field, Vector _values) { |
|
476 |
layerFeaturesFields.add(_field); |
|
477 |
layerFeaturesValues.add(_values); |
|
478 |
} |
|
479 |
|
|
480 |
/** |
|
481 |
* Adds a new value for a field |
|
482 |
* |
|
483 |
* @param _field An object |
|
484 |
* @param _values An object |
|
485 |
*/ |
|
486 |
public void addValue(Object _field, Object _value) { |
|
487 |
Vector values = this.getValues(_field); |
|
488 |
|
|
489 |
if (values != null) { |
|
490 |
values.add(_value); |
|
491 |
} |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* Adds a values for a field |
|
496 |
* |
|
497 |
* @param _field An object |
|
498 |
* @param _values A vector |
|
499 |
*/ |
|
500 |
public void addValues(Object _field, Vector _values) { |
|
501 |
// layerFeaturesValues.add(getFieldIndex(_field), _values); |
|
502 |
int index = getFieldIndex(_field); |
|
503 |
|
|
504 |
layerFeaturesValues.remove(index); |
|
505 |
layerFeaturesValues.add(index, _values); |
|
506 |
} |
|
507 |
|
|
508 |
/** |
|
509 |
* Returns a field |
|
510 |
* |
|
511 |
* @param fieldPosition A position |
|
512 |
* @return An object |
|
513 |
*/ |
|
514 |
public Object getField(int fieldPosition) { |
|
515 |
if (fieldPosition == -1) |
|
516 |
return null; |
|
517 |
else |
|
518 |
return layerFeaturesFields.get(fieldPosition); |
|
519 |
} |
|
520 |
|
|
521 |
/** |
|
522 |
* Returns the values associated to a field |
|
523 |
* |
|
524 |
* @param fieldPosition A position |
|
525 |
* @return A Vector |
|
526 |
*/ |
|
527 |
public Vector getValues(int fieldPosition) { |
|
528 |
if (fieldPosition == -1) |
|
529 |
return null; |
|
530 |
else |
|
531 |
return (Vector)layerFeaturesValues.get(fieldPosition); |
|
532 |
} |
|
533 |
|
|
534 |
/** |
|
535 |
* Returns the values associated to a field |
|
536 |
* |
|
537 |
* @param field An object |
|
538 |
* @return A Vector |
|
539 |
*/ |
|
540 |
public Vector getValues(Object field) { |
|
541 |
return (Vector)layerFeaturesValues.get(this.getFieldIndex(field)); |
|
542 |
} |
|
543 |
|
|
544 |
|
|
545 |
/** |
|
546 |
* Returns the index of a 'field' |
|
547 |
* |
|
548 |
* @param _field An object |
|
549 |
* @return A position |
|
550 |
*/ |
|
551 |
public int getFieldIndex(Object _field) { |
|
552 |
return layerFeaturesFields.indexOf(_field); |
|
553 |
} |
|
554 |
|
|
555 |
/** |
|
556 |
* Removes a field |
|
557 |
* |
|
558 |
* @param fieldPosition A position |
|
559 |
*/ |
|
560 |
public void removeField(int fieldPosition) { |
|
561 |
layerFeaturesFields.remove(fieldPosition); |
|
562 |
layerFeaturesValues.remove(fieldPosition); |
|
563 |
} |
|
564 |
|
|
565 |
/** |
|
566 |
* Removes a field |
|
567 |
* |
|
568 |
* @param field An object |
|
569 |
*/ |
|
570 |
public void removeField(Object field) { |
|
571 |
layerFeaturesValues.remove(this.getFieldIndex(field)); |
|
572 |
layerFeaturesFields.remove(field); |
|
573 |
} |
|
574 |
|
|
575 |
/** |
|
576 |
* @see Vector#clear() |
|
577 |
*/ |
|
578 |
public void clear() { |
|
579 |
layerFeaturesFields.clear(); |
|
580 |
layerFeaturesValues.clear(); |
|
581 |
} |
|
582 |
} |
|
583 | 434 |
} |
Also available in: Unified diff