Revision 22758 branches/v2_0_0_prep/libraries/libUIComponent/src/org/gvsig/gui/beans/filterPanel/AbstractFilterQueryJPanel.java

View differences:

AbstractFilterQueryJPanel.java
81 81

  
82 82
/**
83 83
 * This abstract class represents the common components of the FilterQuery panels
84
 *
84
 * 
85 85
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
86 86
 */
87 87
public abstract class AbstractFilterQueryJPanel extends AbstractPanel implements Serializable {
88 88
	public static final int DefaultHeight = 280;
89
	public static final int DefaultWidth = 490;
90

  
89
	public static final int DefaultWidth = 490; 
90
	
91 91
	protected final int fieldsJPanelHeight = 145;
92 92
	protected final int fieldsJPanelWidth = 145;
93 93
	protected final int valuesJPanelHeight = fieldsJPanelHeight;
......
102 102
	protected final int defaultTopJPanelHeight = 145;
103 103
	protected int fieldsAndValuesJScrollPaneHeight = 110;
104 104
	protected int fieldsAndValuesJScrollPaneWidth = fieldsJPanelWidth;
105

  
105
	
106 106
	protected JLabelML fieldsJLabel = null;
107 107
	protected JLabelML valuesJLabel = null;
108 108
	protected JPanelML fieldsJPanel = null;
......
115 115
	protected JTreeML fieldsJTree = null;
116 116
	protected JListML valuesJList = null;
117 117
	protected JScrollPaneML fieldsJScrollPane = null;
118
	protected JScrollPaneML valuesJScrollPane = null;
118
	protected JScrollPaneML valuesJScrollPane = null;		
119 119

  
120 120
	protected String title;
121

  
121
	
122 122
	protected DefaultTreeModel defaultTreeModel;
123 123
	protected DefaultListModel valuesListModel;
124

  
124
		
125 125
	// A set with all simbols or operator names used
126 126
	private Set<String> operatorSymbols;
127

  
128

  
127
	
128
	
129 129
	/**
130 130
	 * This is the default constructor
131 131
	 */
132
	public AbstractFilterQueryJPanel(String _title) {
132
	public AbstractFilterQueryJPanel(String _title) {		
133 133
		super();
134 134
		title = _title;
135 135
	}
136 136
	/**
137 137
	 * This is the default constructor
138 138
	 */
139
	public AbstractFilterQueryJPanel() {
139
	public AbstractFilterQueryJPanel() {		
140 140
		super();
141 141
	}
142

  
142
	
143 143
	/**
144 144
	 * This method initializes this
145 145
	 */
146 146
	protected void initialize() {
147 147
		operatorSymbols = new HashSet<String>();
148

  
148
			
149 149
		operatorSymbols.add("and");
150 150
//		operatorSymbols.add("Date");
151 151
		operatorSymbols.add("<>"); // In SQL this is the formal operator
......
161 161
		operatorSymbols.add("<");
162 162

  
163 163
		this.setPreferredSize(new Dimension(DefaultWidth, DefaultHeight));
164

  
164
		
165 165
		this.setLayout(new GridBagLayout());
166 166
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
167 167
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
......
173 173
		gridBagConstraints.anchor = GridBagConstraints.SOUTH;
174 174
		this.add(getBottomJPanel(), gridBagConstraints);
175 175
	}
176

  
176
	
177 177
	/**
178 178
	 * This method initializes topJPanel
179
	 *
179
	 * 
180 180
	 * @return javax.swing.JPanel
181 181
	 */
182 182
	protected abstract javax.swing.JPanel getTopJPanel();
183

  
183
	
184 184
	/**
185 185
	 * This method initializes bottomJPanel
186
	 *
186
	 * 
187 187
	 * @return javax.swing.JPanel
188 188
	 */
189
	protected abstract JPanel getBottomJPanel();
190

  
189
	protected abstract JPanel getBottomJPanel();	
190
	
191 191
	/**
192 192
	 * This method initializes fieldsJLabel
193 193
	 *
......
200 200
		}
201 201

  
202 202
		return fieldsJLabel;
203
	}
203
	}	
204 204

  
205 205
	/**
206 206
	 * This method initializes valuesJList
......
208 208
	 * @return javax.swing.JList
209 209
	 */
210 210
	protected abstract javax.swing.JList getValuesJList();
211

  
211
	
212 212
	/**
213 213
	 * This method initializes fieldsJPanel
214 214
	 *
......
236 236

  
237 237
		return valuesJLabel;
238 238
	}
239

  
239
	
240 240
	/**
241 241
	 * This method initializes valuesJPanel
242 242
	 *
243 243
	 * @return javax.swing.JPanel
244 244
	 */
245 245
	protected abstract JPanel getValuesJPanel();
246

  
246
	
247 247
	/**
248 248
	 * This method initializes jScrollPane1
249 249
	 *
250 250
	 * @return javax.swing.JScrollPane
251 251
	 */
252 252
	protected abstract javax.swing.JScrollPane getValuesJScrollPane();
253

  
253
	
254 254
	/**
255 255
	 * This method initializes filterJScrollPane
256 256
	 *
......
264 264
	 * @return javax.swing.JTextArea
265 265
	 */
266 266
	protected abstract javax.swing.JTextArea getTxtExpression();
267

  
267
	
268 268
	/**
269 269
	 * Adds a symbol to the filter expression.
270 270
	 *
......
272 272
	 */
273 273
	protected void putSymbol(String symbol) {
274 274
		int position = getTxtExpression().getCaretPosition();
275

  
275
		
276 276
		getTxtExpression().setText(insert(getTxtExpression().getText(), position, symbol));
277 277

  
278 278
		if (symbol.equals(" () ")) {
......
283 283

  
284 284
		getTxtExpression().setCaretPosition(position);
285 285
	}
286

  
286
	
287 287
	/**
288 288
	 * This method initializes fieldsJTree
289 289
	 *
......
292 292
	protected javax.swing.JTree getFieldsJTree() {
293 293
		if (fieldsJTree == null) {
294 294
			fieldsJTree = new JTreeML(new Vector(0,1));
295

  
295
			
296 296
			// Remove icons:
297 297
			DefaultTreeCellRenderer defaultTreeCellRenderer = new DefaultTreeCellRenderer();
298 298
			defaultTreeCellRenderer.setOpenIcon(null);
299 299
			defaultTreeCellRenderer.setClosedIcon(null);
300 300
			defaultTreeCellRenderer.setLeafIcon(null);
301

  
301
			
302 302
			// Root not visible
303 303
			fieldsJTree.setRootVisible(false);
304 304
			fieldsJTree.setCellRenderer(defaultTreeCellRenderer);
......
306 306

  
307 307
		return fieldsJTree;
308 308
	}
309

  
309
	
310 310
    /**
311 311
     * Inserts an <i>string</i> at a position of another one.
312 312
     *
......
336 336
				 */
337 337
				public void propertyChange(PropertyChangeEvent arg0) {
338 338
					if (arg0.getPropertyName().equals(FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND)) {
339

  
339
		            	
340 340
						switch(Integer.parseInt(arg0.getNewValue().toString()))	{
341 341
							case FilterButtonsJPanel.AND:
342 342
								putSymbol(" and ");
......
345 345
								putSymbol( ((FilterButtonsJPanel)arg0.getSource()).getLastSelectedDate() );
346 346
								break;
347 347
							case FilterButtonsJPanel.DISTINCT:
348
								putSymbol(" != ");
348
								putSymbol(" <> ");
349 349
								break;
350 350
							case FilterButtonsJPanel.EQUAL:
351 351
								putSymbol(" = ");
......
377 377
							default: // do anything
378 378
				        }
379 379
					}
380
				}
380
				}			
381 381
			});
382 382
		}
383

  
383
		
384 384
		return filterButtonsJPanel;
385 385
	}
386 386

  
387 387
	/**
388 388
	 * Returns a set with all symbols used as operators
389
	 *
389
	 * 
390 390
	 * @return A set
391 391
	 */
392 392
	protected Set<String> getAllOperatorSymbols() {
393
		return operatorSymbols;
393
		return operatorSymbols;		
394 394
	}
395 395

  
396 396
	/**
397 397
	 * Sets new height to the 'topJPanel', (new Height must be bigger than default, else do nothing)
398
	 *
398
	 * 
399 399
	 * @param new_Height New height
400 400
	 */
401 401
	public void resizeHeight(int new_Height) {
402 402
		int difference = new_Height - DefaultHeight;
403

  
403
		
404 404
		if (difference > 0) {
405 405
			this.setPreferredSize(new Dimension(this.getPreferredSize().width, this.getPreferredSize().height + difference));
406 406
			getTopJPanel().setPreferredSize(new Dimension(getTopJPanel().getPreferredSize().width, getTopJPanel().getPreferredSize().height + difference));
407

  
407
			
408 408
			getFieldsJPanel().setPreferredSize(new Dimension(getFieldsJPanel().getPreferredSize().width, getFieldsJPanel().getPreferredSize().height + difference));
409 409
			getFieldsJScrollPane().setPreferredSize(new Dimension(getFieldsJScrollPane().getPreferredSize().width, getFieldsJScrollPane().getPreferredSize().height + difference));
410

  
410
		
411 411
			getValuesJPanel().setPreferredSize(new Dimension(getValuesJPanel().getPreferredSize().width, getValuesJPanel().getPreferredSize().height + difference));
412 412
			getValuesJScrollPane().setPreferredSize(new Dimension(getValuesJScrollPane().getPreferredSize().width, getValuesJScrollPane().getPreferredSize().height + difference));
413 413
		}
......
415 415

  
416 416
	/**
417 417
	 * Sets the width to this JPanel
418
	 *
418
	 * 
419 419
	 * @param new_Width New width
420 420
	 */
421 421
	public abstract void resizeWidth(int new_Width);
......
429 429

  
430 430
		if (difference != 0)
431 431
			this.resizeHeight(height);
432

  
432
		
433 433
		this.resizeWidth(width);
434 434
	}
435 435

  
......
442 442

  
443 443
		if (difference != 0)
444 444
			this.resizeHeight(d.height);
445

  
445
		
446 446
		this.resizeWidth(d.width);
447 447
	}
448 448

  
......
465 465
	 * @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#cancel()
466 466
	 */
467 467
	public void cancel() {
468
	}
468
	}	
469 469

  
470 470
	/*
471 471
	 * (non-Javadoc)
472 472
	 * @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#selected()
473 473
	 */
474
	public void selected() {
474
	public void selected() {		
475 475
	}
476 476

  
477 477
	/**
478 478
	 * JCrollPane with multi line tool tip text.
479
	 *
479
	 * 
480 480
	 * @see JScrollPane
481
	 *
481
	 * 
482 482
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
483 483
	 */
484 484
	protected class JScrollPaneML extends JScrollPane {
......
511 511
		public JScrollPaneML(int vsbPolicy, int hsbPolicy) {
512 512
			super(vsbPolicy, hsbPolicy);
513 513
		}
514

  
514
		
515 515
		/*
516 516
		 * (non-Javadoc)
517 517
		 * @see javax.swing.JComponent#createToolTip()
......
526 526

  
527 527
	/**
528 528
	 * JLabel with multi line tool tip text.
529
	 *
529
	 * 
530 530
	 * @see JLabel
531
	 *
531
	 * 
532 532
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
533 533
	 */
534 534
	protected class JLabelML extends JLabel {
......
587 587
	    	return tip;
588 588
	    }
589 589
	}
590

  
590
	
591 591
	/**
592 592
	 * JPanel with multi line tool tip text.
593
	 *
593
	 * 
594 594
	 * @see JPanel
595
	 *
595
	 * 
596 596
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
597 597
	 */
598 598
	protected class JPanelML extends JPanel {
......
640 640

  
641 641
	/**
642 642
	 * Editable text area with multi line tool tip text.
643
	 *
643
	 * 
644 644
	 * @see JEditableTextArea
645
	 *
645
	 * 
646 646
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
647 647
	 */
648 648
	protected class JEditableTextAreaML extends JEditableTextArea {
......
699 699
	    	MultiLineToolTip tip = new MultiLineToolTip();
700 700
	    	tip.setComponent(this);
701 701
	    	return tip;
702
	    }
702
	    }	
703 703
	}
704 704

  
705 705
	/**
706 706
	 * JTree with multi line tool tip text.
707
	 *
707
	 * 
708 708
	 * @see JTree
709
	 *
709
	 * 
710 710
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
711 711
	 */
712 712
	protected class JTreeML extends JTree {
......
770 770
	    	MultiLineToolTip tip = new MultiLineToolTip();
771 771
	    	tip.setComponent(this);
772 772
	    	return tip;
773
	    }
773
	    }		
774 774
	}
775 775

  
776 776
	/**
777 777
	 * JList with multi line tool tip text.
778
	 *
778
	 * 
779 779
	 * @see JList
780
	 *
780
	 * 
781 781
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
782 782
	 */
783 783
	protected class JListML extends JList {
......
820 820
	    	MultiLineToolTip tip = new MultiLineToolTip();
821 821
	    	tip.setComponent(this);
822 822
	    	return tip;
823
	    }
823
	    }		
824 824
	}
825 825

  
826 826
	/**
827 827
	 * JCheckBox with multi line tool tip text.
828
	 *
828
	 * 
829 829
	 * @see JCheckBox
830
	 *
830
	 * 
831 831
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
832 832
	 */
833 833
	protected class JCheckBoxML extends JCheckBox {
......
898 898
	    	MultiLineToolTip tip = new MultiLineToolTip();
899 899
	    	tip.setComponent(this);
900 900
	    	return tip;
901
	    }
901
	    }		
902 902
	}
903 903

  
904 904
	/**
905 905
	 * JButton with multi line tool tip text.
906
	 *
906
	 * 
907 907
	 * @see JButton
908
	 *
908
	 * 
909 909
	 * @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
910 910
	 */
911 911
    protected class JButtonML extends JButton {
......
955 955
        	MultiLineToolTip tip = new MultiLineToolTip();
956 956
        	tip.setComponent(this);
957 957
        	return tip;
958
        }
958
        }		
959 959
    }
960 960
}

Also available in: Unified diff