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.explorer;
019:
020: import java.awt.event.ActionEvent;
021:
022: import javax.swing.AbstractAction;
023: import javax.swing.JOptionPane;
024: import javax.swing.tree.DefaultMutableTreeNode;
025:
026: import de.finix.contelligent.client.ContelligentClient;
027: import de.finix.contelligent.client.base.ComponentNotFoundException;
028: import de.finix.contelligent.client.base.ComponentReference;
029: import de.finix.contelligent.client.base.ContelligentComponent;
030: import de.finix.contelligent.client.gui.ContelligentAction;
031: import de.finix.contelligent.client.i18n.Resources;
032: import de.finix.contelligent.client.modules.preferences.PreferencesModule;
033: import de.finix.contelligent.client.remote.ActionResult;
034: import de.finix.contelligent.client.remote.Actions;
035: import de.finix.contelligent.client.remote.RemoteActionException;
036: import de.finix.contelligent.client.util.ExceptionDialog;
037:
038: public class SignAction extends AbstractAction implements
039: ContelligentAction {
040: /**
041: *
042: */
043: private final ExplorerEditor editor;
044:
045: public SignAction(ExplorerEditor editor) {
046: super ("sign_action", Resources.newWindowIcon);
047: this .editor = editor;
048: putValue(TYPE, PUSH_ACTION);
049: putValue(ACTION_TYPE, EDIT_ACTION);
050: putValue(ACTION_GROUP, EDIT_COPYPASTE_GROUP);
051: putValue(ACTION_POS, EDIT_COPYPASTE_SIGN);
052: putValue(MENU_TARGET, MENU);
053: putValue(BUTTON_TARGET, NO_BUTTON);
054: putValue(POPUP_TARGET, POPUP_MENU);
055: }
056:
057: public void actionPerformed(ActionEvent e) {
058: DefaultMutableTreeNode node = (DefaultMutableTreeNode) this .editor.tree
059: .getLastSelectedPathComponent();
060: if (node != null
061: && node.getUserObject() instanceof ComponentReference) {
062: try {
063: ContelligentComponent component = ((ComponentReference) node
064: .getUserObject()).getComponent();
065: int result = JOptionPane
066: .showOptionDialog(
067: ContelligentClient
068: .getTopLevelFrame(this .editor),
069: Resources.getLocalString(
070: "publisher_dialog",
071: new String[] { component
072: .getPath() }),
073: Resources
074: .getLocalString("publisher_dialog_title"),
075: JOptionPane.YES_NO_CANCEL_OPTION,
076: JOptionPane.WARNING_MESSAGE,
077: null,
078: new String[] {
079: Resources
080: .getLocalString("publisher_dialog_local_option"),
081: Resources
082: .getLocalString("publisher_dialog_subtree_option"),
083: Resources
084: .getLocalString("publisher_dialog_cancel_option") },
085: Resources
086: .getLocalString("publisher_dialog_cancel_option"));
087: boolean subTree;
088: if (result == JOptionPane.YES_OPTION) { // local_option
089: subTree = false;
090: } else if (result == JOptionPane.NO_OPTION) { // subtree_option
091: subTree = true;
092: } else { // cancel_option
093: return;
094: }
095: try {
096: ActionResult response = Actions.certifyComponent(
097: editor.getView().getEnvironment(), "", "",
098: component.getPath(), subTree, "user");
099: response.showErrors();
100: } catch (RemoteActionException rae) {
101: ExceptionDialog.show(rae);
102: }
103: } catch (ComponentNotFoundException cnfe) {
104: ExceptionDialog.show(cnfe);
105: }
106: }
107: }
108: }
|