01: package net.sourceforge.squirrel_sql.plugins.sqlbookmark;
02:
03: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
04: import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
05: import net.sourceforge.squirrel_sql.client.session.ISession;
06: import net.sourceforge.squirrel_sql.client.session.event.SQLPanelEvent;
07: import net.sourceforge.squirrel_sql.client.session.event.SQLPanelAdapter;
08: import net.sourceforge.squirrel_sql.client.IApplication;
09: import net.sourceforge.squirrel_sql.client.preferences.GlobalPreferencesSheet;
10: import net.sourceforge.squirrel_sql.fw.util.Resources;
11:
12: import java.awt.event.ActionEvent;
13:
14: public class EditBookmarksAction extends SquirrelAction implements
15: ISessionAction {
16: private SQLBookmarkPlugin _plugin;
17: private ISession _session;
18:
19: public EditBookmarksAction(IApplication app, Resources rsrc,
20: SQLBookmarkPlugin plugin) throws IllegalArgumentException {
21: super (app, rsrc);
22: if (plugin == null) {
23: throw new IllegalArgumentException("null IPlugin passed");
24: }
25: _plugin = plugin;
26: }
27:
28: public void actionPerformed(ActionEvent evt) {
29: _plugin.addSQLPanelAPIListeningForBookmarks(_session
30: .getSQLPanelAPIOfActiveSessionWindow());
31:
32: _session.getSQLPanelAPIOfActiveSessionWindow()
33: .addSQLPanelListener(new SQLPanelAdapter() {
34: public void sqlEntryAreaClosed(SQLPanelEvent evt) {
35: _plugin
36: .removeSQLPanelAPIListeningForBookmarks(evt
37: .getSQLPanel());
38: }
39: });
40:
41: GlobalPreferencesSheet.showSheet(_plugin.getApplication(),
42: SQLBookmarkPreferencesPanel.class);
43: }
44:
45: public void setSession(ISession session) {
46: _session = session;
47: }
48: }
|