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 PublisherAction extends AbstractAction implements
039: ContelligentAction {
040: /**
041: *
042: */
043: private final ExplorerEditor editor;
044:
045: public PublisherAction(ExplorerEditor editor) {
046: super ("publisher_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_PUBLISHER);
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: String pName = PreferencesModule
066: .getPublisherPreferences()
067: .get(
068: PreferencesModule.PUBLISHER_NAME,
069: PreferencesModule.DEFAULT_PUBLISHER_NAME);
070: if (pName.equals("xinifxinif")) {
071: JOptionPane
072: .showMessageDialog(
073: null,
074: "Brought to you by:\n"
075: + "Alexander Sack\n"
076: + "Andy Adiwidjaja\n"
077: + "Bernd Brade\n"
078: + "Christian Becher\n"
079: + "Daniel Florey\n"
080: + "Friedemann Florey\n"
081: + "Jan Stoevesand\n"
082: + "Joerg Fenin\n"
083: + "Marcus Rating\n"
084: + "Oliver Rossmueller\n"
085: + "Oliver Zeigermann\n"
086: + "Olrik van Dijk\n"
087: + "Oskar Werewka\n"
088: + "Raphael Vaino\n"
089: + "Richard Struben\n"
090: + "Robin Sander\n"
091: + "Thorsten Preuss\n"
092: + "\nThe system was finished, the tests were concluded,\n"
093: + "The users' last changes were even included.\n"
094: + "And the users exclaimed, with a snarl and a taunt,\n"
095: + "\"It's just what we asked for, but not what we want!\"",
096: "Greetings from the Contelligent team!",
097: JOptionPane.INFORMATION_MESSAGE);
098: return;
099: }
100: String pId = PreferencesModule
101: .getPublisherPreferences().get(
102: PreferencesModule.PUBLISHER_ID,
103: PreferencesModule.DEFAULT_PUBLISHER_ID);
104: int result = JOptionPane
105: .showOptionDialog(
106: ContelligentClient
107: .getTopLevelFrame(this .editor),
108: Resources.getLocalString(
109: "publisher_dialog",
110: new String[] { component
111: .getPath() }),
112: Resources
113: .getLocalString("publisher_dialog_title"),
114: JOptionPane.YES_NO_CANCEL_OPTION,
115: JOptionPane.WARNING_MESSAGE,
116: null,
117: new String[] {
118: Resources
119: .getLocalString("publisher_dialog_local_option"),
120: Resources
121: .getLocalString("publisher_dialog_subtree_option"),
122: Resources
123: .getLocalString("publisher_dialog_cancel_option") },
124: Resources
125: .getLocalString("publisher_dialog_cancel_option"));
126: boolean subTree;
127: if (result == JOptionPane.YES_OPTION) { // local_option
128: subTree = false;
129: } else if (result == JOptionPane.NO_OPTION) { // subtree_option
130: subTree = true;
131: } else { // cancel_option
132: return;
133: }
134: try {
135: ActionResult response = Actions.certifyComponent(
136: editor.getView().getEnvironment(), pName,
137: pId, component.getPath(), subTree, "basic");
138: response.showErrors();
139: } catch (RemoteActionException rae) {
140: ExceptionDialog.show(rae);
141: }
142: } catch (ComponentNotFoundException cnfe) {
143: ExceptionDialog.show(cnfe);
144: }
145: }
146: }
147: }
|