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.explorer;
19:
20: import java.awt.event.ActionEvent;
21:
22: import javax.swing.AbstractAction;
23: import javax.swing.Action;
24: import javax.swing.JOptionPane;
25:
26: import de.finix.contelligent.client.base.ComponentFactory;
27: import de.finix.contelligent.client.base.ServerInfo;
28: import de.finix.contelligent.client.gui.ContelligentAction;
29: import de.finix.contelligent.client.i18n.Resources;
30:
31: final public class DiscardContextAction extends AbstractAction
32: implements ContelligentAction {
33: /**
34: *
35: */
36: private final ExplorerEditor editor;
37:
38: public DiscardContextAction(ExplorerEditor editor) {
39: super ("discard_context_action", Resources.discardContextIcon);
40: this .editor = editor;
41: putValue(ROLLOVER_ICON, Resources.discardContextIconRollOver);
42: putValue(Action.SHORT_DESCRIPTION,
43: "discard_context_action_description");
44: putValue(TYPE, PUSH_ACTION);
45: putValue(ACTION_TYPE, SERVER_ACTION);
46: putValue(ACTION_GROUP, SERVER_GLOBAL_GROUP);
47: putValue(ACTION_POS, SERVER_GLOBAL_DISCARD);
48: putValue(MENU_TARGET, MENU);
49: }
50:
51: public void actionPerformed(ActionEvent e) {
52: if (!this .editor.openEditors()) {
53: if (JOptionPane.showConfirmDialog(this .editor.getParent(),
54: Resources.getLocalString("discard_context",
55: new String[] { ComponentFactory
56: .getInstance().getCurrentContext()
57: .getShortName() }), Resources
58: .getLocalString("discard_context_title"),
59: JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
60: if (ComponentFactory.getInstance()
61: .discardCurrentContext(
62: editor.getView().getEnvironment())) {
63: ComponentFactory.getInstance()
64: .switchCurrentContext(
65: ServerInfo.getInstance()
66: .getMainContextName());
67: }
68: }
69: }
70: }
71: }
|