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 javax.swing.JOptionPane;
21:
22: import net.sourceforge.squirrel_sql.fw.util.ICommand;
23: import net.sourceforge.squirrel_sql.fw.util.StringManager;
24: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
25:
26: import net.sourceforge.squirrel_sql.plugins.mysql.MysqlPlugin;
27:
28: import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
29: import net.sourceforge.squirrel_sql.client.session.ISession;
30:
31: /*
32: * CreateDatabaseCommand.java
33: *
34: * Created on June 9, 2003, 11:16 AM
35: *
36: * @author Arun Kapilan.P
37: */
38: public class CreateDatabaseCommand implements ICommand {
39: private static final StringManager s_stringMgr = StringManagerFactory
40: .getStringManager(CreateDatabaseCommand.class);
41:
42: /** Current session. */
43: private ISession _session;
44:
45: /** Current plugin. */
46: private final MysqlPlugin _plugin;
47:
48: /**
49: * Ctor specifying the current session.
50: */
51: public CreateDatabaseCommand(ISession session, MysqlPlugin plugin) {
52: super ();
53: _session = session;
54: _plugin = plugin;
55: }
56:
57: public void execute() {
58: // i18n[mysql.enterDbName=Enter database name]
59: String dbName = JOptionPane.showInputDialog(s_stringMgr
60: .getString("mysql.enterDbName"));
61: if (dbName != null) {
62: final StringBuffer buf = new StringBuffer();
63: buf.append("create database ").append(dbName);
64: _session.getSessionInternalFrame().getSQLPanelAPI()
65: .executeSQL(buf.toString());
66: IObjectTreeAPI api = _session.getSessionInternalFrame()
67: .getObjectTreeAPI();
68: api.refreshTree();
69: }
70:
71: }
72: }
|