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 SwitchContextAction extends AbstractAction implements
32: ContelligentAction {
33: /**
34: *
35: */
36: private final ExplorerEditor editor;
37:
38: public SwitchContextAction(ExplorerEditor editor) {
39: super ("switch_context_action", Resources.switchContextIcon);
40: this .editor = editor;
41: putValue(ROLLOVER_ICON, Resources.switchContextIconRollOver);
42: putValue(Action.SHORT_DESCRIPTION,
43: "switch_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_SWITCH);
48: putValue(MENU_TARGET, MENU);
49: }
50:
51: public void actionPerformed(ActionEvent e) {
52: if (!this .editor.openEditors()) {
53: String contextName;
54: if ((contextName = (String) JOptionPane.showInputDialog(
55: this .editor, Resources
56: .getLocalString("switch_context_prompt"),
57: Resources.getLocalString("switch_context"),
58: JOptionPane.QUESTION_MESSAGE, null, ServerInfo
59: .getInstance().getShortContextNames()
60: .toArray(), ComponentFactory.getInstance()
61: .getCurrentContext().getShortName())) != null) {
62: if (!contextName.equals(ServerInfo.getInstance()
63: .getMainContextName())) {
64: contextName = ServerInfo.getInstance()
65: .getMainContextName()
66: + "." + contextName;
67: }
68: ComponentFactory.getInstance().switchCurrentContext(
69: contextName);
70: }
71: }
72: }
73: }
|