01: /*
02: * CopyAsTextAction.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 java.awt.event.InputEvent;
16: import java.awt.event.KeyEvent;
17:
18: import javax.swing.KeyStroke;
19: import workbench.gui.components.ClipBoardCopier;
20: import workbench.gui.components.WbTable;
21:
22: import workbench.resource.ResourceMgr;
23:
24: /**
25: * Action to copy the contents of a WbTable as tab-separated text to the clipboard
26: * @see workbench.gui.components.ClipBoardCopier
27: * @author support@sql-workbench.net
28: */
29: public class CopyAsTextAction extends WbAction {
30: private WbTable client;
31: protected boolean copySelected;
32:
33: public CopyAsTextAction(WbTable aClient) {
34: super ();
35: this .client = aClient;
36: this .setMenuItemName(ResourceMgr.MNU_TXT_DATA);
37: this .initMenuDefinition("MnuTxtDataToClipboard", KeyStroke
38: .getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK));
39: copySelected = false;
40: }
41:
42: public boolean hasCtrlModifier() {
43: return true;
44: }
45:
46: public boolean hasShiftModifier() {
47: return true;
48: }
49:
50: public void executeAction(ActionEvent e) {
51: ClipBoardCopier copier = new ClipBoardCopier(this.client);
52: copier.copyDataToClipboard(!isShiftPressed(e), copySelected,
53: isCtrlPressed(e));
54: }
55:
56: }
|