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.tree.DefaultMutableTreeNode;
24: import javax.swing.tree.DefaultTreeModel;
25:
26: import de.finix.contelligent.client.base.ComponentFactory;
27: import de.finix.contelligent.client.base.ComponentNotFoundException;
28: import de.finix.contelligent.client.base.ComponentReference;
29: import de.finix.contelligent.client.gui.ContelligentAction;
30: import de.finix.contelligent.client.i18n.Resources;
31: import de.finix.contelligent.client.util.ExceptionDialog;
32:
33: public class UpAction extends AbstractAction implements
34: ContelligentAction {
35: /**
36: *
37: */
38: private final ExplorerEditor editor;
39:
40: public UpAction(ExplorerEditor editor) {
41: super ("up_action", Resources.upIcon);
42: this .editor = editor;
43: putValue(ROLLOVER_ICON, Resources.upIconRollOver);
44: putValue(TYPE, PUSH_ACTION);
45: putValue(ACTION_TYPE, NAVIGATION_ACTION);
46: putValue(MENU_TARGET, MENU);
47: putValue(BUTTON_TARGET, TOOLBAR);
48: }
49:
50: public void actionPerformed(ActionEvent e) {
51: try {
52: String parentPath = this .editor.browseRootComponent
53: .getParentPath();
54: this .editor.browseRootComponent = ComponentFactory
55: .getInstance().getComponent(parentPath);
56: if (this .editor.browseRootComponent != this .editor.rootComponent) {
57: setEnabled(true);
58: } else {
59: setEnabled(false);
60: }
61: DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(
62: new ComponentReference(
63: this .editor.browseRootComponent));
64: this .editor.addSubcomponents(
65: this .editor.browseRootComponent, rootNode);
66: this .editor.tree.setModel(new DefaultTreeModel(rootNode));
67: this .editor.setActions(this .editor.getActions());
68: } catch (ComponentNotFoundException cnfe) {
69: ExceptionDialog.show(cnfe);
70: }
71: }
72: }
|