01: /*
02: * Copyright (C) 2003 Joseph Mocker
03: * mock-sf@misfit.dhs.org
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * as published by the Free Software Foundation; either version 2
08: * of the License, or any later version.
09: *
10: * This program is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU General Public License for more details.
14: *
15: * You should have received a copy of the GNU General Public License
16: * along with this program; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18: */
19:
20: package net.sourceforge.squirrel_sql.plugins.sqlbookmark;
21:
22: import java.awt.event.ActionEvent;
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.ISQLPanelAPI;
27: import net.sourceforge.squirrel_sql.client.session.ISession;
28: import net.sourceforge.squirrel_sql.client.session.action.ISQLPanelAction;
29: import net.sourceforge.squirrel_sql.fw.util.Resources;
30:
31: /**
32: * Prompt for name and add a new bookmark into the system.
33: *
34: * @author Joseph Mocker
35: */
36: public class AddBookmarkAction extends SquirrelAction implements
37: ISQLPanelAction {
38: private static final long serialVersionUID = 1L;
39: transient private ISession session;
40: transient private SQLBookmarkPlugin plugin;
41:
42: public AddBookmarkAction(IApplication app, Resources rsrc,
43: SQLBookmarkPlugin plugin) throws IllegalArgumentException {
44: super (app, rsrc);
45: if (plugin == null) {
46: throw new IllegalArgumentException("null IPlugin passed");
47: }
48: this .plugin = plugin;
49: }
50:
51: public void actionPerformed(ActionEvent evt) {
52: if (session != null) {
53: new AddBookmarkCommand(getParentFrame(evt), session, plugin)
54: .execute();
55: }
56: }
57:
58: public void setSQLPanel(ISQLPanelAPI panel) {
59: if (null != panel) {
60: session = panel.getSession();
61: } else {
62: session = null;
63: }
64: setEnabled(null != session);
65: }
66: }
|