01: /*
02: * CopySelectedAsTextAction.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.actions;
13:
14: import java.awt.event.ActionEvent;
15: import workbench.gui.components.ClipBoardCopier;
16: import workbench.gui.components.WbTable;
17:
18: import workbench.resource.ResourceMgr;
19:
20: /**
21: * Action to copy the selected content of a WbTable as tab-separated text to the clipboard
22: * @see workbench.gui.components.ClipBoardCopier
23: * @author support@sql-workbench.net
24: */
25: public class CopySelectedAsTextAction extends WbAction {
26: private WbTable client;
27:
28: public CopySelectedAsTextAction(WbTable aClient) {
29: this (aClient, "MnuTxtCopySelectedAsText");
30: }
31:
32: public CopySelectedAsTextAction(WbTable aClient, String labelKey) {
33: super ();
34: this .client = aClient;
35: this .setMenuItemName(ResourceMgr.MNU_TXT_COPY_SELECTED);
36: this .initMenuDefinition(labelKey, null);
37: this .setEnabled(false);
38: }
39:
40: public boolean hasCtrlModifier() {
41: return true;
42: }
43:
44: public boolean hasShiftModifier() {
45: return true;
46: }
47:
48: public void executeAction(ActionEvent e) {
49: ClipBoardCopier copier = new ClipBoardCopier(this .client);
50: copier.copyDataToClipboard(!isShiftPressed(e), true,
51: isCtrlPressed(e));
52: }
53: }
|