svn-gvsig-desktop / trunk / libraries / libUI / src / org / gvsig / gui / beans / filterPanel / filterButtons / FilterButtonsJPanel.java @ 9726
History | View | Annotate | Download (17.6 KB)
1 | 7961 | ppiqueras | 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 | 9033 | ppiqueras | |
19 | import org.gvsig.gui.beans.Messages; |
||
20 | 7961 | ppiqueras | import org.gvsig.gui.beans.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 | 8094 | ppiqueras | private static final long serialVersionUID = -8707991552239900454L; |
74 | |||
75 | 7961 | ppiqueras | public static final int default_FilterButtonsJPanelWidth = 190; |
76 | 9491 | ppiqueras | public static final int default_FilterButtonsJPanelHeight = 120; |
77 | 7961 | ppiqueras | private final int buttonsGroupJPanelWidth = 190; |
78 | 8390 | ppiqueras | private final int buttonsGroupJPanelHeight = 100; |
79 | private final int buttonHeight = 20; |
||
80 | private final int buttonWidthUnit = 40; |
||
81 | 7961 | ppiqueras | |
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 | 8390 | ppiqueras | private javax.swing.JButton btnDeleteText = null; |
94 | private javax.swing.JPanel buttonsJPanel = null; |
||
95 | 7961 | ppiqueras | 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 | 8390 | ppiqueras | public static final int PARENTHESIS = 11; |
119 | public static final int DELETE_TEXT = 12; |
||
120 | 7961 | ppiqueras | |
121 | // Values of the type of event fired
|
||
122 | 8390 | ppiqueras | public static final int BUTTON_CLICKED_ACTION_ID = 13; |
123 | 7961 | ppiqueras | 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 | 9491 | ppiqueras | this.setPreferredSize(new Dimension(default_FilterButtonsJPanelWidth, default_FilterButtonsJPanelHeight)); |
176 | 7961 | ppiqueras | 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 | 8742 | ppiqueras | buttonsJPanel.add(getBtnDate()); |
199 | 7961 | ppiqueras | 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 | 8742 | ppiqueras | buttonsJPanel.add(getBtnParenthesis()); |
207 | 8390 | ppiqueras | buttonsJPanel.add(getBtnDeleteText()); |
208 | 7961 | ppiqueras | } |
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 | 8390 | ppiqueras | btnDistinct.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
224 | 9726 | ppiqueras | btnDistinct.setToolTipText(Messages.getText("operator_distinct_explanation"));
|
225 | 7961 | ppiqueras | map.put("!=", new Integer(FilterButtonsJPanel.DISTINCT)); |
226 | |||
227 | btnDistinct.addActionListener(this.getActionListener());
|
||
228 | } |
||
229 | |||
230 | return btnDistinct;
|
||
231 | } |
||
232 | |||
233 | 8034 | ppiqueras | |
234 | 7961 | ppiqueras | /**
|
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 | 8390 | ppiqueras | btnEqual.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
245 | 9726 | ppiqueras | btnEqual.setToolTipText(Messages.getText("operator_equal_explanation"));
|
246 | 7961 | ppiqueras | 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 | 8390 | ppiqueras | btnGreater.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
265 | 9726 | ppiqueras | btnGreater.setToolTipText(Messages.getText("operator_greater_explanation"));
|
266 | 7961 | ppiqueras | 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 | 8390 | ppiqueras | btnEqualGreater.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
285 | 9726 | ppiqueras | btnEqualGreater.setToolTipText(Messages.getText("operator_equal_greater_explanation"));
|
286 | 7961 | ppiqueras | 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 | 8390 | ppiqueras | btnSmaller.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
305 | 9726 | ppiqueras | btnSmaller.setToolTipText(Messages.getText("operator_smaller_explanation"));
|
306 | 7961 | ppiqueras | 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 | 8390 | ppiqueras | btnEqualSmaller.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
325 | 9726 | ppiqueras | btnEqualSmaller.setToolTipText(Messages.getText("operator_equal_smaller_explanation"));
|
326 | 7961 | ppiqueras | 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 | 8390 | ppiqueras | btnDate.setPreferredSize(new java.awt.Dimension(86, buttonHeight)); |
345 | 9726 | ppiqueras | btnDate.setToolTipText(Messages.getText("date_button_explanation"));
|
346 | 7961 | ppiqueras | 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 | 8094 | ppiqueras | getCDD().show(); |
355 | 7961 | ppiqueras | } |
356 | 7997 | ppiqueras | }); |
357 | 7961 | ppiqueras | } |
358 | |||
359 | return btnDate;
|
||
360 | } |
||
361 | |||
362 | /**
|
||
363 | * This method initializes a JCalendarDateDialog
|
||
364 | *
|
||
365 | 9692 | ppiqueras | * @return A JCalendarDateDialog
|
366 | 7961 | ppiqueras | */
|
367 | 8094 | ppiqueras | protected JCalendarDateDialog getCDD() {
|
368 | 7961 | ppiqueras | if (jCalendarDateDialog == null) { |
369 | jCalendarDateDialog = new JCalendarDateDialog(350, 230); |
||
370 | jCalendarDateDialog.setModal(true);
|
||
371 | jCalendarDateDialog.setLocationRelativeTo(btnDate); |
||
372 | |||
373 | // Adds a listener for get the date when the
|
||
374 | jCalendarDateDialog.addComponentListener(new ComponentAdapter() { |
||
375 | /*
|
||
376 | * (non-Javadoc)
|
||
377 | * @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
||
378 | */
|
||
379 | public void componentHidden(ComponentEvent e) { |
||
380 | lastSelectedDate = jCalendarDateDialog.getDate(); |
||
381 | |||
382 | actionListener.actionPerformed(new ActionEvent(btnDate, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND)); |
||
383 | |||
384 | } |
||
385 | }); |
||
386 | |||
387 | } |
||
388 | |||
389 | return jCalendarDateDialog;
|
||
390 | 9692 | ppiqueras | } |
391 | |||
392 | 7961 | ppiqueras | /**
|
393 | 9692 | ppiqueras | * This method initializes btnAnd
|
394 | *
|
||
395 | * @return javax.swing.JButton
|
||
396 | */
|
||
397 | private javax.swing.JButton getBtnAnd() {
|
||
398 | if (btnAnd == null) { |
||
399 | btnAnd = new javax.swing.JButton();
|
||
400 | btnAnd.setText("And");
|
||
401 | btnAnd.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
402 | btnAnd.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
||
403 | 9726 | ppiqueras | btnAnd.setToolTipText(Messages.getText("operator_and_explanation"));
|
404 | 9692 | ppiqueras | map.put("And", new Integer(FilterButtonsJPanel.AND)); |
405 | |||
406 | btnAnd.addActionListener(this.getActionListener());
|
||
407 | } |
||
408 | |||
409 | return btnAnd;
|
||
410 | } |
||
411 | |||
412 | /**
|
||
413 | 7961 | ppiqueras | * This method initializes btnNot
|
414 | *
|
||
415 | * @return javax.swing.JButton
|
||
416 | */
|
||
417 | private javax.swing.JButton getBtnNot() {
|
||
418 | if (btnNot == null) { |
||
419 | btnNot = new javax.swing.JButton();
|
||
420 | btnNot.setText("Not");
|
||
421 | btnNot.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
422 | 9692 | ppiqueras | btnNot.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
423 | 9726 | ppiqueras | btnNot.setToolTipText(Messages.getText("operator_not_explanation"));
|
424 | 7961 | ppiqueras | map.put("Not", new Integer(FilterButtonsJPanel.NOT)); |
425 | |||
426 | btnNot.addMouseListener(new MouseAdapter() { |
||
427 | /*
|
||
428 | * (non-Javadoc)
|
||
429 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||
430 | */
|
||
431 | public void mouseClicked(MouseEvent e) { |
||
432 | new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
||
433 | } |
||
434 | }); |
||
435 | |||
436 | btnNot.addActionListener(this.getActionListener());
|
||
437 | |||
438 | } |
||
439 | |||
440 | return btnNot;
|
||
441 | } |
||
442 | |||
443 | /**
|
||
444 | * This method initializes btnOr
|
||
445 | *
|
||
446 | * @return javax.swing.JButton
|
||
447 | */
|
||
448 | private javax.swing.JButton getBtnOr() {
|
||
449 | if (btnOr == null) { |
||
450 | btnOr = new javax.swing.JButton();
|
||
451 | btnOr.setText("Or");
|
||
452 | btnOr.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
453 | 8390 | ppiqueras | btnOr.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
454 | 9726 | ppiqueras | btnOr.setToolTipText(Messages.getText("operator_or_explanation"));
|
455 | 7961 | ppiqueras | map.put("Or", new Integer(FilterButtonsJPanel.OR)); |
456 | |||
457 | btnOr.addMouseListener(new MouseAdapter() { |
||
458 | /*
|
||
459 | * (non-Javadoc)
|
||
460 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||
461 | */
|
||
462 | public void mouseClicked(MouseEvent e) { |
||
463 | new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
||
464 | } |
||
465 | }); |
||
466 | |||
467 | btnOr.addActionListener(this.getActionListener());
|
||
468 | } |
||
469 | |||
470 | return btnOr;
|
||
471 | } |
||
472 | |||
473 | /**
|
||
474 | * This method initializes btnParenthesis
|
||
475 | *
|
||
476 | * @return javax.swing.JButton
|
||
477 | */
|
||
478 | private javax.swing.JButton getBtnParenthesis() {
|
||
479 | if (btnParenthesis == null) { |
||
480 | btnParenthesis = new javax.swing.JButton();
|
||
481 | btnParenthesis.setText("()");
|
||
482 | btnParenthesis.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
||
483 | 8390 | ppiqueras | btnParenthesis.setPreferredSize(new java.awt.Dimension(buttonWidthUnit, buttonHeight));
|
484 | 9726 | ppiqueras | btnParenthesis.setToolTipText(Messages.getText("parenthesis_explanation"));
|
485 | 7961 | ppiqueras | map.put("()", new Integer(FilterButtonsJPanel.PARENTHESIS)); |
486 | |||
487 | btnParenthesis.addMouseListener(new MouseAdapter() { |
||
488 | /*
|
||
489 | * (non-Javadoc)
|
||
490 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||
491 | */
|
||
492 | public void mouseClicked(MouseEvent e) { |
||
493 | new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
||
494 | } |
||
495 | }); |
||
496 | |||
497 | 8390 | ppiqueras | btnParenthesis.addActionListener(this.getActionListener());
|
498 | } |
||
499 | 7961 | ppiqueras | |
500 | return btnParenthesis;
|
||
501 | } |
||
502 | |||
503 | /**
|
||
504 | 8390 | ppiqueras | * This method initializes btnDeleteText
|
505 | *
|
||
506 | * @return javax.swing.JButton
|
||
507 | */
|
||
508 | private javax.swing.JButton getBtnDeleteText() {
|
||
509 | if (btnDeleteText == null) { |
||
510 | btnDeleteText = new javax.swing.JButton();
|
||
511 | 9033 | ppiqueras | btnDeleteText.setText(Messages.getText("deleteText"));
|
512 | 8390 | ppiqueras | btnDeleteText.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
513 | btnDeleteText.setPreferredSize(new java.awt.Dimension(176, buttonHeight)); |
||
514 | 9726 | ppiqueras | btnDeleteText.setToolTipText(Messages.getText("deleteText_on_filter_use_explanation"));
|
515 | 9033 | ppiqueras | map.put(Messages.getText("deleteText"), new Integer(FilterButtonsJPanel.DELETE_TEXT)); |
516 | 8390 | ppiqueras | |
517 | btnDeleteText.addMouseListener(new MouseAdapter() { |
||
518 | /*
|
||
519 | * (non-Javadoc)
|
||
520 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||
521 | */
|
||
522 | public void mouseClicked(MouseEvent e) { |
||
523 | new ActionEvent(this, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_ID, FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND); |
||
524 | } |
||
525 | }); |
||
526 | |||
527 | btnDeleteText.addActionListener(this.getActionListener());
|
||
528 | } |
||
529 | |||
530 | return btnDeleteText;
|
||
531 | } |
||
532 | |||
533 | /**
|
||
534 | 7961 | ppiqueras | * This method initializes the "actionListener" ActionListener
|
535 | *
|
||
536 | * @return ActionListener
|
||
537 | */
|
||
538 | private ActionListener getActionListener() { |
||
539 | if (actionListener == null) { |
||
540 | actionListener = new ActionListener() { |
||
541 | /*
|
||
542 | * (non-Javadoc)
|
||
543 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||
544 | */
|
||
545 | public void actionPerformed(ActionEvent event) { |
||
546 | // Notifies that has been clicked a button
|
||
547 | changes.firePropertyChange(FilterButtonsJPanel.BUTTON_CLICKED_ACTION_COMMAND, FilterButtonsJPanel.DEFAULT, ((Integer) map.get( ((javax.swing.JButton)event.getSource()).getText())).intValue());
|
||
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 | 8074 | ppiqueras | |
566 | /**
|
||
567 | * Returns the 'DateFormat' private attribute
|
||
568 | *
|
||
569 | * @return A 'DateFormat' reference
|
||
570 | */
|
||
571 | public DateFormat getDateFormat() { |
||
572 | return dateFormat;
|
||
573 | } |
||
574 | 7961 | ppiqueras | |
575 | /**
|
||
576 | * Adds a "Property Change Listener"
|
||
577 | */
|
||
578 | public void addPropertyChangeListener(PropertyChangeListener l) { |
||
579 | changes.addPropertyChangeListener(l); |
||
580 | } |
||
581 | |||
582 | /**
|
||
583 | * Removes a "Property Change Listener"
|
||
584 | */
|
||
585 | public void removePropertyChangeListener(PropertyChangeListener l) { |
||
586 | changes.removePropertyChangeListener(l); |
||
587 | 7997 | ppiqueras | } |
588 | 7961 | ppiqueras | } |