01: package net.sourceforge.squirrel_sql.plugins.editextras;
02:
03: import net.sourceforge.squirrel_sql.client.IApplication;
04: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
05: import net.sourceforge.squirrel_sql.client.session.ISession;
06: import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
07: import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
08: import net.sourceforge.squirrel_sql.client.session.action.ISQLPanelAction;
09:
10: import java.awt.event.ActionEvent;
11: import java.awt.*;
12: import java.awt.datatransfer.StringSelection;
13:
14: public class CutSqlAction extends SquirrelAction implements
15: ISQLPanelAction {
16: private ISQLPanelAPI _panel;
17:
18: public CutSqlAction(IApplication app,
19: net.sourceforge.squirrel_sql.fw.util.Resources rsrc) {
20: super (app, rsrc);
21: }
22:
23: public void actionPerformed(ActionEvent e) {
24: int[] bounds = _panel.getSQLEntryPanel()
25: .getBoundsOfSQLToBeExecuted();
26:
27: if (bounds[0] == bounds[1]) {
28: return;
29: }
30:
31: String sqlToBeExecuted = _panel.getSQLEntryPanel()
32: .getSQLToBeExecuted();
33:
34: StringSelection contents = new StringSelection(sqlToBeExecuted);
35: Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
36: contents, contents);
37:
38: _panel.getSQLEntryPanel().setSelectionStart(bounds[0]);
39: _panel.getSQLEntryPanel().setSelectionEnd(bounds[1]);
40: _panel.getSQLEntryPanel().replaceSelection("");
41:
42: }
43:
44: public void setSQLPanel(ISQLPanelAPI panel) {
45: _panel = panel;
46: setEnabled(null != _panel);
47: }
48:
49: }
|