01: package net.sourceforge.squirrel_sql.plugins.userscript;
02:
03: import net.sourceforge.squirrel_sql.client.IApplication;
04: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
05: import net.sourceforge.squirrel_sql.client.session.ISession;
06: import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
07: import net.sourceforge.squirrel_sql.fw.util.Resources;
08: import net.sourceforge.squirrel_sql.plugins.userscript.kernel.ScriptListController;
09: import net.sourceforge.squirrel_sql.plugins.userscript.kernel.UserScriptAdmin;
10:
11: import java.awt.event.ActionEvent;
12:
13: public class UserScriptAction extends SquirrelAction implements
14: ISessionAction {
15:
16: /** Current session. */
17: protected ISession _session;
18:
19: /** Current plugin. */
20: protected final UserScriptPlugin _plugin;
21:
22: public UserScriptAction(IApplication app, Resources rsrc,
23: UserScriptPlugin plugin) {
24: super (app, rsrc);
25: _plugin = plugin;
26: }
27:
28: public void actionPerformed(ActionEvent evt) {
29: if (_session != null) {
30: UserScriptAdmin adm = _plugin.getUserScriptAdmin(_session);
31:
32: if (0 == adm.getTargets(getTargetType()).getAll().length) {
33: return;
34: }
35:
36: new ScriptListController(_session.getApplication()
37: .getMainFrame(), _plugin
38: .getUserScriptAdmin(_session), getTargetType());
39: }
40: }
41:
42: /**
43: * Is redefined in UserScriptSQLAction.
44: */
45: protected boolean getTargetType() {
46: return UserScriptAdmin.TARGET_TYPE_DB_OBJECT;
47: }
48:
49: /**
50: * Set the current session.
51: *
52: * @param session The current session.
53: */
54: public void setSession(ISession session) {
55: _session = session;
56: }
57: }
|