01: package net.sourceforge.squirrel_sql.plugins.dbdiff.commands;
02:
03: /*
04: * Copyright (C) 2007 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:
22: import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
23: import net.sourceforge.squirrel_sql.client.session.ISession;
24: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
25: import net.sourceforge.squirrel_sql.fw.util.ICommand;
26: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
27: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
28: import net.sourceforge.squirrel_sql.plugins.dbdiff.DBDiffPlugin;
29:
30: public class SelectCommand implements ICommand {
31: /**
32: * Current session.
33: */
34: private ISession _session;
35:
36: /**
37: * Current plugin.
38: */
39: private final DBDiffPlugin _plugin;
40:
41: /** Logger for this class. */
42: private final static ILogger log = LoggerController
43: .createLogger(SelectCommand.class);
44:
45: /**
46: * Ctor specifying the current session.
47: */
48: public SelectCommand(ISession session, DBDiffPlugin plugin) {
49: super ();
50: _session = session;
51: _plugin = plugin;
52: }
53:
54: /**
55: * Execute this command. Save the session and selected objects in the plugin
56: * for use in paste command.
57: */
58: public void execute() {
59: IObjectTreeAPI api = _session
60: .getObjectTreeAPIOfActiveSessionWindow();
61: if (api != null) {
62: IDatabaseObjectInfo[] dbObjs = api
63: .getSelectedDatabaseObjects();
64: try {
65: _plugin.setDiffSourceSession(_session);
66: _plugin.setSelectedDatabaseObjects(dbObjs);
67: _plugin.setCompareMenuEnabled(true);
68: } catch (Exception e) {
69: log.error("Unexected exception: ", e);
70: }
71: }
72: }
73:
74: }
|