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:
24: import de.finix.contelligent.client.base.ComponentFactory;
25: import de.finix.contelligent.client.base.ContelligentComponent;
26: import de.finix.contelligent.client.gui.ContelligentAction;
27:
28: public class DeleteTypeOnlyAction extends AbstractAction implements
29: ContelligentAction {
30:
31: /**
32: *
33: */
34: private final ExplorerEditor editor;
35:
36: public DeleteTypeOnlyAction(ExplorerEditor editor) {
37: super ("delete_blueprint_action");
38: this .editor = editor;
39: putValue(TYPE, PUSH_ACTION);
40: putValue(ACTION_TYPE, EDIT_ACTION);
41: putValue(ACTION_GROUP, EDIT_BLUEPRINT_GROUP);
42: putValue(ACTION_POS, EDIT_BLUEPRINT_DELETE);
43: putValue(MENU_TARGET, NO_MENU);
44: putValue(BUTTON_TARGET, NO_BUTTON);
45: putValue(POPUP_TARGET, POPUP_SUBMENU);
46: putValue(POPUP_PARENT_ACTION, this .editor.typeAction);
47: }
48:
49: public void actionPerformed(ActionEvent e) {
50: if (!this .editor.getView().isEditInProgress()) {
51: String typeName = this .editor
52: .findTypeNameOfSelectedComponent();
53: if (typeName != null) {
54: this .editor.deleteType(typeName, false, false);
55: }
56: }
57: }
58:
59: public void update() {
60: ContelligentComponent component = this.editor
61: .getSelectedComponent();
62: setEnabled(component != null && component.isBlueprint()
63: && !this.editor.getView().isEditInProgress()
64: && this.editor.getView().getAllowBlueprintDefinition()
65: && ComponentFactory.getInstance().isRootContext());
66: }
67: }
|