001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.gui;
019:
020: import java.awt.BorderLayout;
021: import java.awt.Dimension;
022: import java.awt.event.ActionEvent;
023: import java.awt.event.ActionListener;
024: import java.util.Iterator;
025:
026: import javax.swing.AbstractAction;
027: import javax.swing.Action;
028: import javax.swing.JButton;
029: import javax.swing.JPanel;
030:
031: import de.finix.contelligent.client.base.ComponentFactory;
032: import de.finix.contelligent.client.i18n.Resources;
033: import de.finix.contelligent.client.modules.Module;
034: import de.finix.contelligent.client.modules.ModuleInitException;
035: import de.finix.contelligent.client.modules.event.ModuleEvent;
036: import de.finix.contelligent.client.modules.event.ModuleListener;
037: import de.finix.contelligent.client.util.TableLayout;
038:
039: public class CreateComponentDialogView extends AbstractView {
040:
041: public void init() throws ModuleInitException {
042: setLayout(new TableLayout(new double[][] {
043: { TableLayout.FILL, 10, TableLayout.FILL },
044: { TableLayout.FILL, 10, TableLayout.PREFERRED, 10 } }));
045: super .init();
046: JPanel guiPanel = new JPanel(new BorderLayout());
047: setGUIPanel(guiPanel);
048: add(guiPanel, "0,0,2,0");
049: setPreferredSize(new Dimension(600, 400));
050: setComponent(getRootComponent());
051: setEditStateActions(new Action[0]);
052: JButton cancelButton = new JButton(Resources
053: .getLocalString("cancel"));
054: cancelButton.setPreferredSize(new Dimension(100, 26));
055: cancelButton.addActionListener(new ActionListener() {
056: public void actionPerformed(ActionEvent e) {
057: CreateComponentDialogView.super .rollback();
058: fireDestroyModuleEvent();
059: }
060: });
061: JButton okButton = new JButton(Resources.getLocalString("ok"));
062: okButton.addActionListener(new ActionListener() {
063: public void actionPerformed(ActionEvent e) {
064: CreateComponentDialogView.super .commit();
065: fireDestroyModuleEvent();
066: }
067: });
068: okButton.setPreferredSize(new Dimension(100, 26));
069: add(guiPanel, "0,0,2,0");
070: add(cancelButton, "0,2,r,f");
071: add(okButton, "2,2,l,f");
072: begin();
073: }
074:
075: public class CommitAction extends AbstractAction implements
076: ContelligentAction {
077: public CommitAction() {
078: super ("commit_action", Resources.okIcon);
079: putValue(TYPE, PUSH_ACTION);
080: putValue(ACTION_TYPE, EDIT_ACTION);
081: putValue(MENU_TARGET, NO_MENU);
082: putValue(BUTTON_TARGET, NO_BUTTON);
083: }
084:
085: public void actionPerformed(ActionEvent e) {
086: // Collect all modified components from involved editors...
087: for (int i = 0; i < editor.length; i++) {
088: editor[i].commit();
089: }
090: if (ComponentFactory.getInstance().commit(environment)) {
091: editor = null;
092: // ...and send the changes to the server
093: // ...and close the window
094: fireDestroyModuleEvent();
095: }
096: }
097: }
098:
099: private void fireDestroyModuleEvent() {
100: // fire module activated event
101: for (Iterator i = getModuleListeners().iterator(); i.hasNext();) {
102: ((ModuleListener) i.next())
103: .moduleDestroyed(new ModuleEvent((Module) this));
104: }
105: }
106: }
|