01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui;
19:
20: import java.awt.event.ActionEvent;
21: import java.util.Iterator;
22:
23: import javax.swing.AbstractAction;
24: import javax.swing.Action;
25:
26: import de.finix.contelligent.client.i18n.Resources;
27: import de.finix.contelligent.client.modules.Module;
28: import de.finix.contelligent.client.modules.ModuleInitException;
29: import de.finix.contelligent.client.modules.event.ModuleEvent;
30: import de.finix.contelligent.client.modules.event.ModuleListener;
31:
32: public class DialogView extends AbstractView {
33:
34: public void init() throws ModuleInitException {
35: super .init();
36:
37: try {
38: editStateActions = new Action[] { new CommitAction() };
39: renderStateActions = new Action[] { new BeginAction() };
40: setComponent(getRootComponent());
41: } catch (Throwable t) {
42: throw new ModuleInitException("Could not init DialogView",
43: t);
44: }
45: }
46:
47: private void fireDestroyModuleEvent() {
48: // fire module activated event
49: for (Iterator i = getModuleListeners().iterator(); i.hasNext();) {
50: ((ModuleListener) i.next())
51: .moduleDestroyed(new ModuleEvent((Module) this ));
52: }
53: }
54:
55: public class CommitAction extends AbstractAction implements
56: ContelligentAction {
57: public CommitAction() {
58: super ("commit_action", Resources.okIcon);
59: putValue(TYPE, PUSH_ACTION);
60: putValue(ACTION_TYPE, EDIT_ACTION);
61: putValue(MENU_TARGET, MENU);
62: putValue(BUTTON_TARGET, TOOLBAR);
63: }
64:
65: public void actionPerformed(ActionEvent e) {
66: commit();
67:
68: // ...and close the window
69: fireDestroyModuleEvent();
70: }
71: }
72:
73: }
|