01: package net.sourceforge.squirrel_sql.plugins.mysql.action;
02:
03: /*
04: * Copyright (C) 2003 Arun Kapilan.P
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: import java.awt.event.ActionEvent;
21:
22: import net.sourceforge.squirrel_sql.client.IApplication;
23: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
24: import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
25: import net.sourceforge.squirrel_sql.client.session.ISession;
26: import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
27: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
28: import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
29: import net.sourceforge.squirrel_sql.fw.util.Resources;
30: import net.sourceforge.squirrel_sql.fw.util.StringManager;
31: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
32: import net.sourceforge.squirrel_sql.plugins.mysql.MysqlPlugin;
33:
34: /**
35: * CreateColumnAction.java
36: *
37: * Created on June 10, 2003, 11:35 AM
38: *
39: * @author Arun Kapilan.P
40: */
41: public class AlterTableAction extends SquirrelAction implements
42: ISessionAction {
43: /** Internationalized strings for this class. */
44: private static final StringManager s_stringMgr = StringManagerFactory
45: .getStringManager(AlterTableAction.class);
46:
47: /** Current session. */
48: private ISession _session;
49:
50: /** Current plugin. */
51: private final MysqlPlugin _plugin;
52:
53: public AlterTableAction(IApplication app, Resources rsrc,
54: MysqlPlugin plugin) {
55: super (app, rsrc);
56: _plugin = plugin;
57: }
58:
59: public void actionPerformed(ActionEvent evt) {
60: if (_session != null) {
61: IObjectTreeAPI treeAPI = _session.getSessionInternalFrame()
62: .getObjectTreeAPI();
63: IDatabaseObjectInfo[] tables = treeAPI
64: .getSelectedDatabaseObjects();
65: if (tables.length == 1 && tables[0] instanceof ITableInfo) {
66: try {
67: // TODO: Refresh
68: new AlterTableCommand(_session, _plugin,
69: (ITableInfo) tables[0]).execute();
70: } catch (Throwable th) {
71: _session.showErrorMessage(th);
72: }
73: } else {
74: String msg = s_stringMgr
75: .getString("AlterTableAction.error.wrongobjcount");
76: _session.showErrorMessage(msg);
77: }
78: }
79: }
80:
81: /**
82: * Set the current session.
83: *
84: * @param session The current session.
85: */
86: public void setSession(ISession session) {
87: _session = session;
88: }
89: }
|