root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / filterPanel / filterButtons / FilterButtonsJPanel.java @ 13136
History | View | Annotate | Download (17.8 KB)
1 |
package org.gvsig.gui.beans.filterPanel.filterButtons; |
---|---|
2 |
|
3 |
import java.awt.LayoutManager; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
6 |
import java.awt.event.ComponentAdapter; |
7 |
import java.awt.event.ComponentEvent; |
8 |
import java.awt.event.MouseAdapter; |
9 |
import java.awt.event.MouseEvent; |
10 |
import java.beans.PropertyChangeListener; |
11 |
import java.beans.PropertyChangeSupport; |
12 |
import java.io.Serializable; |
13 |
import java.text.DateFormat; |
14 |
import java.util.Date; |
15 |
import java.util.HashMap; |
16 |
|
17 |
import javax.swing.JPanel; |
18 |
|
19 |
import org.gvsig.gui.beans.Messages; |
20 |
import org.gvsig.gui.beans.swing.textBoxWithCalendar.JCalendarDateDialog; |
21 |
|
22 |
import java.awt.Dimension; |
23 |
import java.awt.GridBagLayout; |
24 |
import java.awt.GridBagConstraints; |
25 |
|
26 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
27 |
*
|
28 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
29 |
*
|
30 |
* This program is free software; you can redistribute it and/or
|
31 |
* modify it under the terms of the GNU General Public License
|
32 |
* as published by the Free Software Foundation; either version 2
|
33 |
* of the License, or (at your option) any later version.
|
34 |
*
|
35 |
* This program is distributed in the hope that it will be useful,
|
36 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
37 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
38 |
* GNU General Public License for more details.
|
39 |
*
|
40 |
* You should have received a copy of the GNU General Public License
|
41 |
* along with this program; if not, write to the Free Software
|
42 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
43 |
*
|
44 |
* For more information, contact:
|
45 |
*
|
46 |
* Generalitat Valenciana
|
47 |
* Conselleria d'Infraestructures i Transport
|
48 |
* Av. Blasco Ib??ez, 50
|
49 |
* 46010 VALENCIA
|
50 |
* SPAIN
|
51 |
*
|
52 |
* +34 963862235
|
53 |
* gvsig@gva.es
|
54 |
* www.gvsig.gva.es
|
55 |
*
|
56 |
* or
|
57 |
*
|
58 |
* IVER T.I. S.A
|
59 |
* Salamanca 50
|
60 |
* 46005 Valencia
|
61 |
* Spain
|
62 |
*
|
63 |
* +34 963163400
|
64 |
* dac@iver.es
|
65 |
*/
|
66 |
|
67 |
/**
|
68 |
* This class is a panel with buttons for filter operations: AND, OR, NOT, >, <, ...
|
69 |
*
|
70 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
71 |
*/
|
72 |
public class FilterButtonsJPanel extends JPanel implements Serializable { |
73 |
private static final long serialVersionUID = 2457364243627267035L; |
74 |
|
75 |
public static final int default_FilterButtonsJPanelWidth = 190; |
76 |
public static final int default_FilterButtonsJPanelHeight = 104; |
77 |
private final int buttonsGroupJPanelWidth = default_FilterButtonsJPanelWidth; |
78 |
private final int buttonsGroupJPanelHeight = default_FilterButtonsJPanelHeight; |
79 |
private final int buttonHeight = 20; |
80 |
private final int buttonWidthUnit = 40; |
81 |
|
82 |
private javax.swing.JButton btnEqual = null; |
83 |
private javax.swing.JButton btnDistinct = null; |
84 |
private javax.swing.JButton btnGreater = null; |
85 |
private javax.swing.JButton btnSmaller = null; |
86 |
private javax.swing.JButton btnEqualGreater = null; |
87 |
private javax.swing.JButton btnEqualSmaller = null; |
88 |
private javax.swing.JButton btnAnd = null; |
89 |
private javax.swing.JButton btnOr = null; |
90 |
private javax.swing.JButton btnNot = null; |
91 |
private javax.swing.JButton btnDate = null; |
92 |
private javax.swing.JButton btnParenthesis = null; |
93 |
private javax.swing.JButton btnDeleteText = null; |
94 |
private javax.swing.JPanel buttonsJPanel = null; |
95 |
private javax.swing.JPanel referenceToFilterButtonsJPanel = null; |
96 |
|
97 |
// Last selected date
|
98 |
private DateFormat dateFormat = DateFormat.getDateInstance(); |
99 |
private Date lastSelectedDate = null; |
100 |
|
101 |
private JCalendarDateDialog jCalendarDateDialog = null; |
102 |
|
103 |
// Listener for property change support
|
104 |
private PropertyChangeSupport changes = new PropertyChangeSupport(this); |
105 |
|
106 |
// Values of the events fired when has been clicked a button
|
107 |
public static final int DEFAULT = 0; |
108 |
public static final int EQUAL = 1; |
109 |
public static final int DISTINCT = 2; |
110 |
public static final int GREATER = 3; |
111 |
public static final int SMALLER = 4; |
112 |
public static final int EQUALGREATER = 5; |
113 |
public static final int EQUALSMALLER = 6; |
114 |
public static final int AND = 7; |
115 |
public static final int OR = 8; |
116 |
public static final int NOT = 9; |
117 |
public static final int DATE = 10; |
118 |
public static final int PARENTHESIS = 11; |
119 |
public static final int DELETE_TEXT = 12; |
120 |
|
121 |
// Values of the type of event fired
|
122 |
public static final int BUTTON_CLICKED_ACTION_ID = 13; |
123 |
public static final String BUTTON_CLICKED_ACTION_COMMAND = "Button Clicked"; |
124 |
|
125 |
// Hash map for the items
|
126 |
private HashMap map; |
127 |
|
128 |
// Action listener for notify (fire) some events that had happened to this component
|
129 |
private ActionListener actionListener = null; |
130 |
|
131 |
/**
|
132 |
* @see JPanel#JPanel()
|
133 |
*/
|
134 |
public FilterButtonsJPanel() {
|
135 |
super();
|
136 |
map = new HashMap(); |
137 |
referenceToFilterButtonsJPanel = this;
|
138 |
initialize(); |
139 |
} |
140 |
|
141 |
/**
|
142 |
* @see JPanel#JPanel(boolean)
|
143 |
*/
|
144 |
public FilterButtonsJPanel(boolean isDoubleBuffered) { |
145 |
super(isDoubleBuffered);
|
146 |
map = new HashMap(); |
147 |
referenceToFilterButtonsJPanel = this;
|
148 |
initialize(); |
149 |
} |
150 |
|
151 |
/**
|
152 |
* @see JPanel#JPanel(java.awt.LayoutManager, boolean)
|
153 |
*/
|
154 |
public FilterButtonsJPanel(LayoutManager layout, boolean isDoubleBuffered) { |
155 |
super(layout, isDoubleBuffered);
|
156 |
map = new HashMap(); |
157 |
referenceToFilterButtonsJPanel = this;
|
158 |
initialize(); |
159 |
} |
160 |
|
161 |
/**
|
162 |
* @see JPanel#JPanel(java.awt.LayoutManager)
|
163 |
*/
|
164 |
public FilterButtonsJPanel(LayoutManager layout) { |
165 |
super(layout);
|
166 |
map = new HashMap(); |
167 |
referenceToFilterButtonsJPanel = this;
|
168 |
initialize(); |
169 |
} |
170 |
|
171 |
/**
|
172 |
* This method initializes this
|
173 |
*/
|
174 |
private void initialize() { |
175 |
this.setPreferredSize(new Dimension(default_FilterButtonsJPanelWidth, default_FilterButtonsJPanelHeight)); |
176 |
this.setLayout(new GridBagLayout()); |
177 |
|
178 |
// Vertical center
|
179 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
180 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
181 |
gridBagConstraints.anchor = GridBagConstraints.CENTER;
|
182 |
|
183 |
this.add(getButtonsJPanel(), gridBagConstraints);
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* This method initializes buttonsJPanel
|
188 |
*
|
189 |
* @return javax.swing.JPanel
|
190 |
*/
|
191 |
private javax.swing.JPanel getButtonsJPanel() {
|
192 |
if (buttonsJPanel == null) { |
193 |
buttonsJPanel = new JPanel(); |
194 |
|
195 |
buttonsJPanel.setPreferredSize(new Dimension(buttonsGroupJPanelWidth, buttonsGroupJPanelHeight)); |
196 |
buttonsJPanel.add(getBtnEqual()); |
197 |
buttonsJPanel.add(getBtnDistinct()); |
198 |
buttonsJPanel.add(getBtnDate()); |
199 |
buttonsJPanel.add(getBtnSmaller()); |
200 |
buttonsJPanel.add(getBtnGreater()); |
201 |
buttonsJPanel.add(getBtnEqualSmaller()); |
202 |
buttonsJPanel.add(getBtnEqualGreater()); |
203 |
buttonsJPanel.add(getBtnAnd()); |
204 |
buttonsJPanel.add(getBtnOr()); |
205 |
buttonsJPanel.add(getBtnNot()); |
206 |
buttonsJPanel.add(getBtnParenthesis()); |
207 |
buttonsJPanel.add(getBtnDeleteText()); |
208 |
} |
209 |
|
210 |
return buttonsJPanel;
|
211 |
} |
212 |
|
213 |
/**
|
214 |
* This method initializes btnDistinct
|
215 |
*
|
216 |
* @return javax.swing.JButton
|
217 |
*/
|
218 |
private javax.swing.JButton getBtnDistinct() {
|
219 |
if (btnDistinct == null) { |
220 |
btnDistinct = new javax.swing.JButton();
|
221 |
btnDistinct.setText("!=");
|
222 |
btnDistinct.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
223 |
btnDistinct.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
224 |
btnDistinct.setToolTipText(Messages.getText("operator_distinct_explanation"));
|
225 |
map.put("!=", new Integer(FilterButtonsJPanel.DISTINCT)); |
226 |
|
227 |
btnDistinct.addActionListener(this.getActionListener());
|
228 |
} |
229 |
|
230 |
return btnDistinct;
|
231 |
} |
232 |
|
233 |
|
234 |
/**
|
235 |
* This method initializes btnEqua
|
236 |
*
|
237 |
* @return javax.swing.JButton
|
238 |
*/
|
239 |
private javax.swing.JButton getBtnEqual() {
|
240 |
if (btnEqual == null) { |
241 |
btnEqual = new javax.swing.JButton();
|
242 |
btnEqual.setText("=");
|
243 |
btnEqual.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
244 |
btnEqual.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
245 |
btnEqual.setToolTipText(Messages.getText("operator_equal_explanation"));
|
246 |
map.put("=", new Integer(FilterButtonsJPanel.EQUAL)); |
247 |
|
248 |
btnEqual.addActionListener(this.getActionListener());
|
249 |
} |
250 |
|
251 |
return btnEqual;
|
252 |
} |
253 |
|
254 |
/**
|
255 |
* This method initializes btnGreater
|
256 |
*
|
257 |
* @return javax.swing.JButton
|
258 |
*/
|
259 |
private javax.swing.JButton getBtnGreater() {
|
260 |
if (btnGreater == null) { |
261 |
btnGreater = new javax.swing.JButton();
|
262 |
btnGreater.setText(">");
|
263 |
btnGreater.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
264 |
btnGreater.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
265 |
btnGreater.setToolTipText(Messages.getText("operator_greater_explanation"));
|
266 |
map.put(">", new Integer(FilterButtonsJPanel.GREATER)); |
267 |
|
268 |
btnGreater.addActionListener(this.getActionListener());
|
269 |
} |
270 |
|
271 |
return btnGreater;
|
272 |
} |
273 |
|
274 |
/**
|
275 |
* This method initializes btnEqualGreater
|
276 |
*
|
277 |
* @return javax.swing.JButton
|
278 |
*/
|
279 |
private javax.swing.JButton getBtnEqualGreater() {
|
280 |
if (btnEqualGreater == null) { |
281 |
btnEqualGreater = new javax.swing.JButton();
|
282 |
btnEqualGreater.setText(">=");
|
283 |
btnEqualGreater.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
284 |
btnEqualGreater.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
285 |
btnEqualGreater.setToolTipText(Messages.getText("operator_equal_greater_explanation"));
|
286 |
map.put(">=", new Integer(FilterButtonsJPanel.EQUALGREATER)); |
287 |
|
288 |
btnEqualGreater.addActionListener(this.getActionListener());
|
289 |
} |
290 |
|
291 |
return btnEqualGreater;
|
292 |
} |
293 |
|
294 |
/**
|
295 |
* This method initializes btnSmaller
|
296 |
*
|
297 |
* @return javax.swing.JButton
|
298 |
*/
|
299 |
private javax.swing.JButton getBtnSmaller() {
|
300 |
if (btnSmaller == null) { |
301 |
btnSmaller = new javax.swing.JButton();
|
302 |
btnSmaller.setText("<");
|
303 |
btnSmaller.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
304 |
btnSmaller.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
305 |
btnSmaller.setToolTipText(Messages.getText("operator_smaller_explanation"));
|
306 |
map.put("<", new Integer(FilterButtonsJPanel.SMALLER)); |
307 |
|
308 |
btnSmaller.addActionListener(this.getActionListener());
|
309 |
} |
310 |
|
311 |
return btnSmaller;
|
312 |
} |
313 |
|
314 |
/**
|
315 |
* This method initializes btnEqualSmaller
|
316 |
*
|
317 |
* @return javax.swing.JButton
|
318 |
*/
|
319 |
private javax.swing.JButton getBtnEqualSmaller() {
|
320 |
if (btnEqualSmaller == null) { |
321 |
btnEqualSmaller = new javax.swing.JButton();
|
322 |
btnEqualSmaller.setText("<=");
|
323 |
btnEqualSmaller.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
324 |
btnEqualSmaller.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
325 |
btnEqualSmaller.setToolTipText(Messages.getText("operator_equal_smaller_explanation"));
|
326 |
map.put("<=", new Integer(FilterButtonsJPanel.EQUALSMALLER)); |
327 |
|
328 |
btnEqualSmaller.addActionListener(this.getActionListener());
|
329 |
} |
330 |
|
331 |
return btnEqualSmaller;
|
332 |
} |
333 |
|
334 |
/**
|
335 |
* This method initializes btnDate
|
336 |
*
|
337 |
* @return javax.swing.JButton
|
338 |
*/
|
339 |
private javax.swing.JButton getBtnDate() {
|
340 |
if (btnDate == null) { |
341 |
btnDate = new javax.swing.JButton();
|
342 |
btnDate.setText("Date");
|
343 |
btnDate.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
344 |
btnDate.setPreferredSize(new java.awt.Dimension(86, buttonHeight)); |
345 |
btnDate.setToolTipText(Messages.getText("date_button_explanation"));
|
346 |
map.put("Date", new Integer(FilterButtonsJPanel.DATE)); |
347 |
|
348 |
btnDate.addMouseListener(new MouseAdapter() { |
349 |
/*
|
350 |
* (non-Javadoc)
|
351 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
352 |
*/
|
353 |
public void mouseClicked(MouseEvent e) { |
354 |
getCDD().show(); |
355 |
} |
356 |
}); |
357 |
} |
358 |
|
359 |
return btnDate;
|
360 |
} |
361 |
|
362 |
/**
|
363 |
* This method initializes a JCalendarDateDialog
|
364 |
*
|
365 |
* @return A JCalendarDateDialog
|
366 |
*/
|
367 |
protected JCalendarDateDialog getCDD() {
|
368 |
if (jCalendarDateDialog == null) { |
369 |
jCalendarDateDialog = new JCalendarDateDialog(350, 230); |
370 |
jCalendarDateDialog.setModal(true);
|
371 |
jCalendarDateDialog.setLocationRelativeTo(btnDate); |
372 |
jCalendarDateDialog.setMinimumWidth(350);
|
373 |
jCalendarDateDialog.setMinimumHeight(170);
|
374 |
jCalendarDateDialog.setMaximumWidth(500);
|
375 |
jCalendarDateDialog.setMaximumHeight(400);
|
376 |
|
377 |
// Adds a listener for get the date when the
|
378 |
jCalendarDateDialog.addComponentListener(new ComponentAdapter() { |
379 |
/*
|
380 |
* (non-Javadoc)
|
381 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
382 |
*/
|
383 |
public void componentHidden(ComponentEvent e) { |
384 |
lastSelectedDate = jCalendarDateDialog.getDate(); |
385 |
|
386 |
actionListener.actionPerformed(new ActionEvent(btnDate, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND)); |
387 |
|
388 |
} |
389 |
}); |
390 |
|
391 |
} |
392 |
|
393 |
return jCalendarDateDialog;
|
394 |
} |
395 |
|
396 |
/**
|
397 |
* This method initializes btnAnd
|
398 |
*
|
399 |
* @return javax.swing.JButton
|
400 |
*/
|
401 |
private javax.swing.JButton getBtnAnd() {
|
402 |
if (btnAnd == null) { |
403 |
btnAnd = new javax.swing.JButton();
|
404 |
btnAnd.setText("And");
|
405 |
btnAnd.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
406 |
btnAnd.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
407 |
btnAnd.setToolTipText(Messages.getText("operator_and_explanation"));
|
408 |
map.put("And", new Integer(FilterButtonsJPanel.AND)); |
409 |
|
410 |
btnAnd.addActionListener(this.getActionListener());
|
411 |
} |
412 |
|
413 |
return btnAnd;
|
414 |
} |
415 |
|
416 |
/**
|
417 |
* This method initializes btnNot
|
418 |
*
|
419 |
* @return javax.swing.JButton
|
420 |
*/
|
421 |
private javax.swing.JButton getBtnNot() {
|
422 |
if (btnNot == null) { |
423 |
btnNot = new javax.swing.JButton();
|
424 |
btnNot.setText("Not");
|
425 |
btnNot.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
426 |
btnNot.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
427 |
btnNot.setToolTipText(Messages.getText("operator_not_explanation"));
|
428 |
map.put("Not", new Integer(FilterButtonsJPanel.NOT)); |
429 |
|
430 |
btnNot.addMouseListener(new MouseAdapter() { |
431 |
/*
|
432 |
* (non-Javadoc)
|
433 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
434 |
*/
|
435 |
public void mouseClicked(MouseEvent e) { |
436 |
new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
437 |
} |
438 |
}); |
439 |
|
440 |
btnNot.addActionListener(this.getActionListener());
|
441 |
|
442 |
} |
443 |
|
444 |
return btnNot;
|
445 |
} |
446 |
|
447 |
/**
|
448 |
* This method initializes btnOr
|
449 |
*
|
450 |
* @return javax.swing.JButton
|
451 |
*/
|
452 |
private javax.swing.JButton getBtnOr() {
|
453 |
if (btnOr == null) { |
454 |
btnOr = new javax.swing.JButton();
|
455 |
btnOr.setText("Or");
|
456 |
btnOr.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
457 |
btnOr.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
458 |
btnOr.setToolTipText(Messages.getText("operator_or_explanation"));
|
459 |
map.put("Or", new Integer(FilterButtonsJPanel.OR)); |
460 |
|
461 |
btnOr.addMouseListener(new MouseAdapter() { |
462 |
/*
|
463 |
* (non-Javadoc)
|
464 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
465 |
*/
|
466 |
public void mouseClicked(MouseEvent e) { |
467 |
new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
468 |
} |
469 |
}); |
470 |
|
471 |
btnOr.addActionListener(this.getActionListener());
|
472 |
} |
473 |
|
474 |
return btnOr;
|
475 |
} |
476 |
|
477 |
/**
|
478 |
* This method initializes btnParenthesis
|
479 |
*
|
480 |
* @return javax.swing.JButton
|
481 |
*/
|
482 |
private javax.swing.JButton getBtnParenthesis() {
|
483 |
if (btnParenthesis == null) { |
484 |
btnParenthesis = new javax.swing.JButton();
|
485 |
btnParenthesis.setText("()");
|
486 |
btnParenthesis.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
487 |
btnParenthesis.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
488 |
btnParenthesis.setToolTipText(Messages.getText("parenthesis_explanation"));
|
489 |
map.put("()", new Integer(FilterButtonsJPanel.PARENTHESIS)); |
490 |
|
491 |
btnParenthesis.addMouseListener(new MouseAdapter() { |
492 |
/*
|
493 |
* (non-Javadoc)
|
494 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
495 |
*/
|
496 |
public void mouseClicked(MouseEvent e) { |
497 |
new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
498 |
} |
499 |
}); |
500 |
|
501 |
btnParenthesis.addActionListener(this.getActionListener());
|
502 |
} |
503 |
|
504 |
return btnParenthesis;
|
505 |
} |
506 |
|
507 |
/**
|
508 |
* This method initializes btnDeleteText
|
509 |
*
|
510 |
* @return javax.swing.JButton
|
511 |
*/
|
512 |
private javax.swing.JButton getBtnDeleteText() {
|
513 |
if (btnDeleteText == null) { |
514 |
btnDeleteText = new javax.swing.JButton();
|
515 |
btnDeleteText.setText(Messages.getText("deleteText"));
|
516 |
btnDeleteText.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
517 |
btnDeleteText.setPreferredSize(new java.awt.Dimension(176, buttonHeight)); |
518 |
btnDeleteText.setToolTipText(Messages.getText("deleteText_on_filter_use_explanation"));
|
519 |
map.put(Messages.getText("deleteText"), new Integer(FilterButtonsJPanel.DELETE_TEXT)); |
520 |
|
521 |
btnDeleteText.addMouseListener(new MouseAdapter() { |
522 |
/*
|
523 |
* (non-Javadoc)
|
524 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
525 |
*/
|
526 |
public void mouseClicked(MouseEvent e) { |
527 |
new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
528 |
} |
529 |
}); |
530 |
|
531 |
btnDeleteText.addActionListener(this.getActionListener());
|
532 |
} |
533 |
|
534 |
return btnDeleteText;
|
535 |
} |
536 |
|
537 |
/**
|
538 |
* This method initializes the "actionListener" ActionListener
|
539 |
*
|
540 |
* @return ActionListener
|
541 |
*/
|
542 |
private ActionListener getActionListener() { |
543 |
if (actionListener == null) { |
544 |
actionListener = new ActionListener() { |
545 |
/*
|
546 |
* (non-Javadoc)
|
547 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
548 |
*/
|
549 |
public void actionPerformed(ActionEvent event) { |
550 |
// Notifies that has been clicked a button
|
551 |
changes.firePropertyChange(FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND, FilterButtonsJPanel.DEFAULT, ((Integer) map.get( ((javax.swing.JButton)event.getSource()).getText())).intValue());
|
552 |
} |
553 |
}; |
554 |
} |
555 |
return actionListener;
|
556 |
} |
557 |
|
558 |
/**
|
559 |
* Returns the las selected date, formatted
|
560 |
*
|
561 |
* @return A formatted date
|
562 |
*/
|
563 |
public String getLastSelectedDate() { |
564 |
if (lastSelectedDate == null) |
565 |
return ""; |
566 |
else
|
567 |
return "Date(" + dateFormat.format(lastSelectedDate) + ")"; |
568 |
} |
569 |
|
570 |
/**
|
571 |
* Returns the 'DateFormat' private attribute
|
572 |
*
|
573 |
* @return A 'DateFormat' reference
|
574 |
*/
|
575 |
public DateFormat getDateFormat() { |
576 |
return dateFormat;
|
577 |
} |
578 |
|
579 |
/**
|
580 |
* Adds a "Property Change Listener"
|
581 |
*/
|
582 |
public void addPropertyChangeListener(PropertyChangeListener l) { |
583 |
changes.addPropertyChangeListener(l); |
584 |
} |
585 |
|
586 |
/**
|
587 |
* Removes a "Property Change Listener"
|
588 |
*/
|
589 |
public void removePropertyChangeListener(PropertyChangeListener l) { |
590 |
changes.removePropertyChangeListener(l); |
591 |
} |
592 |
} |