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: import java.awt.event.InputEvent;
22: import java.awt.event.KeyEvent;
23:
24: import javax.swing.AbstractAction;
25: import javax.swing.Action;
26: import javax.swing.KeyStroke;
27:
28: import de.finix.contelligent.client.base.ContelligentComponent;
29: import de.finix.contelligent.client.gui.ContelligentAction;
30:
31: public class GoToBlueprintAction extends AbstractAction implements
32: ContelligentAction {
33: /**
34: *
35: */
36: private final ExplorerEditor editor;
37:
38: public GoToBlueprintAction(ExplorerEditor editor) {
39: super ("blueprint_master_action");
40: this .editor = editor;
41: putValue(TYPE, PUSH_ACTION);
42: putValue(ACTION_TYPE, NAVIGATION_ACTION);
43: putValue(ACTION_GROUP, NAVIGATION_REFERENCES_GROUP);
44: putValue(ACTION_POS, NAVIGATION_REFERENCES_BLUEPRINT);
45: putValue(MENU_TARGET, MENU);
46: putValue(BUTTON_TARGET, NO_BUTTON);
47: putValue(POPUP_TARGET, POPUP_SUBMENU);
48: putValue(POPUP_PARENT_ACTION, this .editor.goToAction);
49: putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
50: KeyEvent.VK_B, InputEvent.CTRL_MASK));
51: }
52:
53: public void actionPerformed(ActionEvent e) {
54: ContelligentComponent component = this .editor
55: .getSelectedComponent();
56: if (component.isBlueprintInstance()) {
57: String path = component.getType().getBlueprintPath();
58: if (path != null)
59: this .editor.selectComponent(path);
60: }
61: }
62:
63: public void update() {
64: ContelligentComponent component = this.editor
65: .getSelectedComponent();
66: setEnabled(component != null && component.isBlueprintInstance());
67: }
68: }
|