01: /*--------------------------------------------------------------------------*
02: | Copyright (C) 2006 Christopher Kohlhaas, Bettina Lademann |
03: | |
04: | This program is free software; you can redistribute it and/or modify |
05: | it under the terms of the GNU General Public License as published by the |
06: | Free Software Foundation. A copy of the license has been included with |
07: | these distribution in the COPYING file, if not go to www.fsf.org |
08: | |
09: | As a special exception, you are granted the permissions to link this |
10: | program with every library, which license fulfills the Open Source |
11: | Definition as published by the Open Source Initiative (OSI). |
12: *--------------------------------------------------------------------------*/
13: package org.rapla.gui.internal.action;
14:
15: import java.awt.Component;
16: import java.awt.Point;
17: import java.awt.event.ActionEvent;
18:
19: import javax.swing.event.ChangeEvent;
20: import javax.swing.event.ChangeListener;
21:
22: import org.apache.avalon.framework.container.ContainerUtil;
23: import org.rapla.framework.RaplaContext;
24: import org.rapla.framework.RaplaException;
25: import org.rapla.gui.RaplaAction;
26: import org.rapla.gui.internal.common.CalendarSelectionModel;
27: import org.rapla.gui.internal.edit.FilterDialog;
28:
29: public class FilterAction extends RaplaAction implements ChangeListener {
30: FilterDialog dlg;
31: CalendarSelectionModel filter;
32: Component parent;
33: boolean isResourceOnly;
34:
35: public FilterAction(RaplaContext sm, Component parent, Point point)
36: throws RaplaException {
37: super (sm);
38: this .parent = parent;
39: this .setEnabled(true);
40: putValue(NAME, getString("filter"));
41: putValue(SMALL_ICON, getIcon("icon.filter"));
42: }
43:
44: public void setFilter(CalendarSelectionModel filter) {
45: this .filter = filter;
46: ContainerUtil.dispose(dlg);
47: // this.setEnabled( filter != null);
48: }
49:
50: public void setResourceOnly(boolean enable) {
51: isResourceOnly = enable;
52: }
53:
54: public void actionPerformed(ActionEvent evt) {
55: try {
56: if (dlg == null) {
57: dlg = new FilterDialog(getContext(), isResourceOnly);
58: dlg.addChangeListener(this );
59: }
60:
61: dlg.start(filter, getString("filter"), parent, false);
62: } catch (Exception ex) {
63: showException(ex, parent);
64: } // end of try-catch
65: }
66:
67: public void stateChanged(ChangeEvent evt) {
68: firePropertyChange("filter", new Object(), filter);
69: }
70:
71: }
|