01: package net.sourceforge.squirrel_sql.plugins.sqlscript.table_script;
02:
03: /*
04: * Copyright (C) 2006 Rob Manning
05: * manningr@users.sourceforge.net
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21: import java.awt.event.ActionEvent;
22:
23: import net.sourceforge.squirrel_sql.client.IApplication;
24: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
25: import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
26: import net.sourceforge.squirrel_sql.client.session.ISession;
27: import net.sourceforge.squirrel_sql.client.session.action.IObjectTreeAction;
28: import net.sourceforge.squirrel_sql.fw.util.Resources;
29: import net.sourceforge.squirrel_sql.plugins.sqlscript.SQLScriptPlugin;
30:
31: public class DropTableScriptAction extends SquirrelAction implements
32: IObjectTreeAction {
33:
34: /** Current session. */
35: private ISession _session;
36:
37: /** Current plugin. */
38: private final SQLScriptPlugin _plugin;
39:
40: public DropTableScriptAction(IApplication app, Resources rsrc,
41: SQLScriptPlugin plugin) {
42: super (app, rsrc);
43: _plugin = plugin;
44: }
45:
46: public void actionPerformed(ActionEvent evt) {
47: if (_session != null) {
48: new DropTableScriptCommand(_session, _plugin).execute();
49: }
50: }
51:
52: /**
53: * Set the current session.
54: *
55: * @param session The current session.
56: */
57: public void setSession(ISession session) {
58: _session = session;
59: }
60:
61: public void setObjectTree(IObjectTreeAPI tree) {
62: if (null != tree) {
63: _session = tree.getSession();
64: } else {
65: _session = null;
66: }
67: setEnabled(null != _session);
68: }
69: }
|