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.dnd.DnDConstants;
21: import java.awt.event.ActionEvent;
22: import java.awt.event.InputEvent;
23: import java.awt.event.KeyEvent;
24:
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: import de.finix.contelligent.client.i18n.Resources;
31: import de.finix.contelligent.client.util.ComponentMovement;
32: import de.finix.contelligent.client.util.CopyOptionPane;
33: import de.finix.contelligent.client.util.MnemonicAbstractAction;
34:
35: public class RenameComponentAction extends MnemonicAbstractAction
36: implements ContelligentAction {
37: /**
38: *
39: */
40: private final ExplorerEditor editor;
41:
42: public RenameComponentAction(ExplorerEditor editor) {
43: super ("rename_component_action", Resources.editMainIcon);
44: this .editor = editor;
45: putValue(TYPE, PUSH_ACTION);
46: putValue(ACTION_TYPE, EDIT_ACTION);
47: putValue(ACTION_GROUP, EDIT_COPYPASTE_GROUP);
48: putValue(ACTION_POS, EDIT_COPYPASTE_RENAME);
49: putValue(MENU_TARGET, MENU);
50: putValue(BUTTON_TARGET, TOOLBAR);
51: putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
52: KeyEvent.VK_R, InputEvent.CTRL_MASK));
53:
54: this .editor.canAccessSystemClipboard = false;
55: // canAccessSystemClipboard();
56: putValue(POPUP_TARGET, POPUP_MENU);
57: }
58:
59: public void actionPerformed(ActionEvent e) {
60: ContelligentComponent componentToRename = this .editor
61: .getSelectedComponent();
62: CopyOptionPane copyOptionPane = new CopyOptionPane();
63: if (copyOptionPane.showCopyDialog(Resources
64: .getLocalString("rename_component"), Resources
65: .getLocalString("target_component_name")
66: + ":", componentToRename.getName(),
67: DnDConstants.ACTION_MOVE, false,
68: DnDConstants.ACTION_MOVE) == CopyOptionPane.OK_OPTION) {
69: String name = copyOptionPane.getPath();
70: if (name.length() > 0) {
71: String environment = editor.getView().getEnvironment();
72: ComponentMovement.nonBlockingMove(environment,
73: environment, componentToRename, null, name,
74: false, false, this.editor.pathSelectionManager);
75: }
76: }
77: }
78: }
|