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.tree.DefaultMutableTreeNode;
23:
24: import de.finix.contelligent.client.base.ComponentNotFoundException;
25: import de.finix.contelligent.client.base.ComponentReference;
26: import de.finix.contelligent.client.base.ContelligentComponent;
27: import de.finix.contelligent.client.gui.ContelligentAction;
28: import de.finix.contelligent.client.gui.DefaultView;
29: import de.finix.contelligent.client.i18n.Resources;
30: import de.finix.contelligent.client.modules.ModuleFrame;
31: import de.finix.contelligent.client.modules.ModuleInitException;
32: import de.finix.contelligent.client.util.ExceptionDialog;
33: import de.finix.contelligent.client.util.MnemonicAbstractAction;
34:
35: public class NewWindowAction extends MnemonicAbstractAction implements
36: ContelligentAction {
37: /**
38: *
39: */
40: private final ExplorerEditor editor;
41:
42: public NewWindowAction(ExplorerEditor editor) {
43: super ("new_window_action", Resources.newWindowIcon);
44: this .editor = editor;
45: putValue(TYPE, PUSH_ACTION);
46: putValue(ACTION_TYPE, WINDOWS_ACTION);
47: putValue(MENU_TARGET, MENU);
48: putValue(BUTTON_TARGET, NO_BUTTON);
49: }
50:
51: public void actionPerformed(ActionEvent e) {
52: DefaultMutableTreeNode node = (DefaultMutableTreeNode) this .editor.tree
53: .getLastSelectedPathComponent();
54: if (node != null
55: && node.getUserObject() instanceof ComponentReference) {
56: try {
57: ContelligentComponent component = ((ComponentReference) node
58: .getUserObject()).getComponent();
59: DefaultView bookmark = new DefaultView();
60: bookmark.setModuleDescription(this .editor.getView()
61: .getModuleDescription());
62: bookmark.setRootGUIDescription(this .editor.getView()
63: .getRootGUIDescription());
64: bookmark.setGUIMapping(this .editor.getView()
65: .getGUIMapping());
66: bookmark.setRootComponent(component);
67: ModuleFrame moduleFrame = new ModuleFrame(Resources
68: .getLocalString("view")
69: + ": " + component.getPath(), bookmark, true);
70: moduleFrame.setSize(this .editor.getSize());
71: moduleFrame.pack();
72: moduleFrame.setVisible(true);
73: } catch (ModuleInitException mie) {
74: ExceptionDialog.show(mie);
75: } catch (ComponentNotFoundException cnfe) {
76: ExceptionDialog.show(cnfe);
77: }
78: }
79: }
80: }
|