01: package net.sourceforge.squirrel_sql.client.session.action;
02:
03: /*
04: * Copyright (C) 2006 Rob Manning
05: * manningr@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library 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 GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; 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: import java.util.List;
23:
24: import net.sourceforge.squirrel_sql.client.IApplication;
25: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
26: import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
27: import net.sourceforge.squirrel_sql.fw.gui.Dialogs;
28: import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
29: import net.sourceforge.squirrel_sql.fw.util.StringManager;
30: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
31:
32: /**
33: * @version $Id: DeleteSelectedTablesAction.java,v 1.3 2007/03/11 03:01:29 manningr Exp $
34: * @author Rob Manning
35: */
36: public class DeleteSelectedTablesAction extends SquirrelAction
37: implements IObjectTreeAction {
38: /** Internationalized strings for this class. */
39: private static final StringManager s_stringMgr = StringManagerFactory
40: .getStringManager(DeleteSelectedTablesAction.class);
41:
42: /** Title for confirmation dialog. */
43: private static String TITLE = s_stringMgr
44: .getString("DeleteSelectedTablesAction.title");
45:
46: /** Message for confirmation dialog. */
47: private static String MSG = s_stringMgr
48: .getString("DeleteSelectedTablesAction.message");
49:
50: /** API for the current tree. */
51: private IObjectTreeAPI _tree;
52:
53: /**
54: * @param app Application API.
55: */
56: public DeleteSelectedTablesAction(IApplication app) {
57: super (app);
58: }
59:
60: /**
61: * Set the current object tree API.
62: *
63: * @param tree Current ObjectTree
64: */
65: public void setObjectTree(IObjectTreeAPI tree) {
66: _tree = tree;
67: setEnabled(null != _tree);
68: }
69:
70: /**
71: * Drop selected tables in the object tree.
72: */
73: public void actionPerformed(ActionEvent e) {
74: if (_tree != null) {
75: List<ITableInfo> tables = _tree.getSelectedTables();
76: if (tables.size() > 0) {
77: if (Dialogs.showYesNo(getApplication().getMainFrame(),
78: MSG, TITLE)) {
79: DeleteTablesCommand command = new DeleteTablesCommand(
80: _tree, tables);
81: command.execute();
82: }
83: }
84: }
85: }
86: }
|