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