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.datatransfer.Clipboard;
21: import java.awt.dnd.DnDConstants;
22: import java.awt.event.ActionEvent;
23:
24: import javax.swing.Action;
25: import javax.swing.KeyStroke;
26: import javax.swing.TransferHandler;
27:
28: import de.finix.contelligent.client.gui.ContelligentAction;
29: import de.finix.contelligent.client.i18n.Resources;
30: import de.finix.contelligent.client.util.MnemonicAbstractAction;
31:
32: public class CopyComponentAction extends MnemonicAbstractAction
33: implements ContelligentAction {
34: /**
35: *
36: */
37: private final ExplorerEditor editor;
38:
39: public CopyComponentAction(ExplorerEditor editor) {
40: super ("copy_component_action", Resources.copyIcon);
41: this .editor = editor;
42: putValue(ROLLOVER_ICON, Resources.copyIconRollOver);
43: putValue(TYPE, PUSH_ACTION);
44: putValue(ACTION_TYPE, EDIT_ACTION);
45: putValue(ACTION_GROUP, EDIT_COPYPASTE_GROUP);
46: putValue(ACTION_POS, EDIT_COPYPASTE_COPY);
47: // putValue(ACTION_MNEMONIC, new Integer(KeyEvent.VK_C));
48: putValue(MENU_TARGET, MENU);
49: putValue(BUTTON_TARGET, TOOLBAR);
50:
51: // putValue(Action.ACCELERATOR_KEY,
52: // KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK));
53: putValue(Action.ACCELERATOR_KEY, KeyStroke
54: .getKeyStroke("control C"));
55:
56: this .editor.canAccessSystemClipboard = true;
57: this .editor.canAccessSystemClipboard();
58: putValue(POPUP_TARGET, POPUP_MENU);
59: }
60:
61: public void actionPerformed(ActionEvent e) {
62: ExplorerEditor.componentToCopy = this .editor
63: .getSelectedComponent();
64: TransferHandler th = this .editor.tree.getTransferHandler();
65: Clipboard clipboard = this.editor
66: .getClipboard(this.editor.tree);
67: if ((clipboard != null) && (th != null)) {
68: th.exportToClipboard(this.editor.tree, clipboard,
69: DnDConstants.ACTION_COPY);
70: }
71: }
72: }
|