Revision: 6131
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6131&view=rev
Author: manningr
Date: 2011-01-02 22:37:33 +0000 (Sun, 02 Jan 2011)
Log Message:
-----------
Allow PluginResources implementation to be injected.
Modified Paths:
--------------
trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptAction.java
trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptPlugin.java
trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptSQLAction.java
Modified: trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptAction.java
===================================================================
--- trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptAction.java 2011-01-02 22:36:56 UTC (rev 6130)
+++ trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptAction.java 2011-01-02 22:37:33 UTC (rev 6131)
@@ -1,16 +1,16 @@
package net.sourceforge.squirrel_sql.plugins.userscript;
+import java.awt.event.ActionEvent;
+
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
-import net.sourceforge.squirrel_sql.fw.util.Resources;
+import net.sourceforge.squirrel_sql.fw.util.IResources;
import net.sourceforge.squirrel_sql.plugins.userscript.kernel.ScriptListController;
import net.sourceforge.squirrel_sql.plugins.userscript.kernel.UserScriptAdmin;
-import java.awt.event.ActionEvent;
-
public class UserScriptAction extends SquirrelAction implements ISessionAction
{
@@ -20,9 +20,9 @@
/** Current plugin. */
protected final UserScriptPlugin _plugin;
- public UserScriptAction(IApplication app, Resources rsrc, UserScriptPlugin plugin)
+ public UserScriptAction(IApplication app, IResources resources, UserScriptPlugin plugin)
{
- super(app, rsrc);
+ super(app, resources);
_plugin = plugin;
}
Modified: trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptPlugin.java
===================================================================
--- trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptPlugin.java 2011-01-02 22:36:56 UTC (rev 6130)
+++ trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptPlugin.java 2011-01-02 22:37:33 UTC (rev 6131)
@@ -18,236 +18,239 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+import java.net.URLClassLoader;
+import java.util.Hashtable;
+
+import javax.swing.JMenu;
+
import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.ActionCollection;
+import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
-import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
-import net.sourceforge.squirrel_sql.client.action.ActionCollection;
import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
+import net.sourceforge.squirrel_sql.client.plugin.IPluginResourcesFactory;
import net.sourceforge.squirrel_sql.client.plugin.PluginException;
-import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
+import net.sourceforge.squirrel_sql.client.plugin.PluginResourcesFactory;
import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+import net.sourceforge.squirrel_sql.fw.util.IResources;
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
import net.sourceforge.squirrel_sql.plugins.userscript.kernel.UserScriptAdmin;
-import javax.swing.*;
-import java.net.URLClassLoader;
-import java.util.Hashtable;
-
/**
* The SQL Script plugin class.
*/
public class UserScriptPlugin extends DefaultSessionPlugin
{
- private interface IMenuResourceKeys
- {
- String USER_SCRIPT = "userscript";
- }
+ private interface IMenuResourceKeys
+ {
+ String USER_SCRIPT = "userscript";
+ }
- /**
- * Logger for this class.
- */
- @SuppressWarnings("unused")
- private static ILogger s_log = LoggerController.createLogger(UserScriptPlugin.class);
+ /**
+ * Logger for this class.
+ */
+ @SuppressWarnings("unused")
+ private static ILogger s_log = LoggerController.createLogger(UserScriptPlugin.class);
- private PluginResources _resources;
+ /** Resources for this plugin. */
+ private IResources _resources;
- private Hashtable<IIdentifier, UserScriptAdmin> _userScriptAdminsBySessionId =
- new Hashtable<IIdentifier, UserScriptAdmin>();
- private URLClassLoader m_userScriptClassLoader;
+ private IPluginResourcesFactory _resourcesFactory = new PluginResourcesFactory();
- /**
- * Return the internal name of this plugin.
- *
- * @return the internal name of this plugin.
- */
- public String getInternalName()
- {
- return "userscript";
- }
+ /**
+ * @param resourcesFactory
+ * the resourcesFactory to set
+ */
+ public void setResourcesFactory(IPluginResourcesFactory resourcesFactory)
+ {
+ _resourcesFactory = resourcesFactory;
+ }
- /**
- * Return the descriptive name of this plugin.
- *
- * @return the descriptive name of this plugin.
- */
- public String getDescriptiveName()
- {
- return "User Scripts Plugin";
- }
+ private Hashtable<IIdentifier, UserScriptAdmin> _userScriptAdminsBySessionId =
+ new Hashtable<IIdentifier, UserScriptAdmin>();
- /**
- * Returns the current version of this plugin.
- *
- * @return the current version of this plugin.
- */
- public String getVersion()
- {
- return "0.01";
- }
+ private URLClassLoader m_userScriptClassLoader;
- /**
- * Returns the authors name.
- *
- * @return the authors name.
- */
- public String getAuthor()
- {
- return "Gerd Wagner";
- }
+ /**
+ * Return the internal name of this plugin.
+ *
+ * @return the internal name of this plugin.
+ */
+ public String getInternalName()
+ {
+ return "userscript";
+ }
- /**
- * Returns the name of the change log for the plugin. This should
- * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
- * directory.
- *
- * @return the changelog file name or <TT>null</TT> if plugin doesn't have
- * a change log.
- */
- public String getChangeLogFileName()
- {
- return "changes.txt";
- }
+ /**
+ * Return the descriptive name of this plugin.
+ *
+ * @return the descriptive name of this plugin.
+ */
+ public String getDescriptiveName()
+ {
+ return "User Scripts Plugin";
+ }
- /**
- * Returns the name of the Help file for the plugin. This should
- * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
- * directory.
- *
- * @return the Help file name or <TT>null</TT> if plugin doesn't have
- * a help file.
- */
- public String getHelpFileName()
- {
- return "readme.txt";
- }
+ /**
+ * Returns the current version of this plugin.
+ *
+ * @return the current version of this plugin.
+ */
+ public String getVersion()
+ {
+ return "0.01";
+ }
- /**
- * Returns the name of the Licence file for the plugin. This should
- * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
- * directory.
- *
- * @return the Licence file name or <TT>null</TT> if plugin doesn't have
- * a licence file.
- */
- public String getLicenceFileName()
- {
- return "licence.txt";
- }
+ /**
+ * Returns the authors name.
+ *
+ * @return the authors name.
+ */
+ public String getAuthor()
+ {
+ return "Gerd Wagner";
+ }
+ /**
+ * Returns the name of the change log for the plugin. This should be a text or HTML file residing in the
+ * <TT>getPluginAppSettingsFolder</TT> directory.
+ *
+ * @return the changelog file name or <TT>null</TT> if plugin doesn't have a change log.
+ */
+ public String getChangeLogFileName()
+ {
+ return "changes.txt";
+ }
- /**
- * Initialize this plugin.
- */
- public synchronized void initialize() throws PluginException
- {
- super.initialize();
- IApplication app = getApplication();
+ /**
+ * Returns the name of the Help file for the plugin. This should be a text or HTML file residing in the
+ * <TT>getPluginAppSettingsFolder</TT> directory.
+ *
+ * @return the Help file name or <TT>null</TT> if plugin doesn't have a help file.
+ */
+ public String getHelpFileName()
+ {
+ return "readme.txt";
+ }
- _resources =
- new PluginResources(
- "net.sourceforge.squirrel_sql.plugins.userscript.userscript",
- this);
+ /**
+ * Returns the name of the Licence file for the plugin. This should be a text or HTML file residing in the
+ * <TT>getPluginAppSettingsFolder</TT> directory.
+ *
+ * @return the Licence file name or <TT>null</TT> if plugin doesn't have a licence file.
+ */
+ public String getLicenceFileName()
+ {
+ return "licence.txt";
+ }
+ /**
+ * Initialize this plugin.
+ */
+ public synchronized void initialize() throws PluginException
+ {
+ super.initialize();
+ IApplication app = getApplication();
+ _resources =
+ _resourcesFactory.createResource("net.sourceforge.squirrel_sql.plugins.userscript.userscript", this);
- ActionCollection coll = app.getActionCollection();
- coll.add(new UserScriptAction(app, _resources, this));
- coll.add(new UserScriptSQLAction(app, _resources, this));
+ ActionCollection coll = app.getActionCollection();
+ coll.add(new UserScriptAction(app, _resources, this));
+ coll.add(new UserScriptSQLAction(app, _resources, this));
- createMenu();
- }
+ createMenu();
+ }
- /**
- * Application is shutting down so save data.
- */
- public void unload()
- {
- super.unload();
- }
+ /**
+ * Application is shutting down so save data.
+ */
+ public void unload()
+ {
+ super.unload();
+ }
- public boolean allowsSessionStartedInBackground()
- {
- return true;
- }
+ public boolean allowsSessionStartedInBackground()
+ {
+ return true;
+ }
- /**
- * Called when a session started. Add commands to popup menu
- * in object tree.
- *
- * @param session The session that is starting.
- * @return <TT>true</TT> to indicate that this plugin is
- * applicable to passed session.
- */
- public PluginSessionCallback sessionStarted(final ISession session)
- {
-
+ /**
+ * Called when a session started. Add commands to popup menu in object tree.
+ *
+ * @param session
+ * The session that is starting.
+ * @return <TT>true</TT> to indicate that this plugin is applicable to passed session.
+ */
+ public PluginSessionCallback sessionStarted(final ISession session)
+ {
- GUIUtils.processOnSwingEventThread(new Runnable() {
- public void run() {
- ActionCollection coll = getApplication().getActionCollection();
- IObjectTreeAPI api =
- session.getSessionInternalFrame().getObjectTreeAPI();
+ GUIUtils.processOnSwingEventThread(new Runnable()
+ {
+ public void run()
+ {
+ ActionCollection coll = getApplication().getActionCollection();
+ IObjectTreeAPI api = session.getSessionInternalFrame().getObjectTreeAPI();
- api.addToPopup(DatabaseObjectType.TABLE, coll.get(UserScriptAction.class));
- api.addToPopup(DatabaseObjectType.PROCEDURE, coll.get(UserScriptAction.class));
- api.addToPopup(DatabaseObjectType.SESSION, coll.get(UserScriptAction.class));
- }
- });
+ api.addToPopup(DatabaseObjectType.TABLE, coll.get(UserScriptAction.class));
+ api.addToPopup(DatabaseObjectType.PROCEDURE, coll.get(UserScriptAction.class));
+ api.addToPopup(DatabaseObjectType.SESSION, coll.get(UserScriptAction.class));
+ }
+ });
+ UserScriptAdmin adm = new UserScriptAdmin(this, session);
+ _userScriptAdminsBySessionId.put(session.getIdentifier(), adm);
- UserScriptAdmin adm = new UserScriptAdmin(this, session);
- _userScriptAdminsBySessionId.put(session.getIdentifier(), adm);
+ PluginSessionCallback ret = new PluginSessionCallback()
+ {
+ public void sqlInternalFrameOpened(SQLInternalFrame sqlInternalFrame, ISession sess)
+ {
+ // TODO
+ // Plugin supports only the main session window
+ }
- PluginSessionCallback ret = new PluginSessionCallback()
- {
- public void sqlInternalFrameOpened(SQLInternalFrame sqlInternalFrame, ISession sess)
- {
- // TODO
- // Plugin supports only the main session window
- }
+ public void objectTreeInternalFrameOpened(ObjectTreeInternalFrame objectTreeInternalFrame,
+ ISession sess)
+ {
+ // TODO
+ // Plugin supports only the main session window
+ }
+ };
+ return ret;
+ }
- public void objectTreeInternalFrameOpened(ObjectTreeInternalFrame objectTreeInternalFrame, ISession sess)
- {
- // TODO
- // Plugin supports only the main session window
- }
- };
- return ret;
- }
+ private void createMenu()
+ {
+ IApplication app = getApplication();
+ ActionCollection coll = app.getActionCollection();
+ JMenu menu = _resources.createMenu(IMenuResourceKeys.USER_SCRIPT);
- private void createMenu()
- {
- IApplication app = getApplication();
- ActionCollection coll = app.getActionCollection();
+ _resources.addToMenu(coll.get(UserScriptSQLAction.class), menu);
- JMenu menu = _resources.createMenu(IMenuResourceKeys.USER_SCRIPT);
+ app.addToMenu(IApplication.IMenuIDs.SESSION_MENU, menu);
+ }
- _resources.addToMenu(coll.get(UserScriptSQLAction.class), menu);
+ public UserScriptAdmin getUserScriptAdmin(ISession session)
+ {
+ return _userScriptAdminsBySessionId.get(session.getIdentifier());
+ }
- app.addToMenu(IApplication.IMenuIDs.SESSION_MENU, menu);
- }
+ public URLClassLoader getUserScriptClassLoader()
+ {
+ return m_userScriptClassLoader;
+ }
- public UserScriptAdmin getUserScriptAdmin(ISession session)
- {
- return _userScriptAdminsBySessionId.get(session.getIdentifier());
- }
+ public void setUserScriptClassLoader(URLClassLoader urlClassLoader)
+ {
+ m_userScriptClassLoader = urlClassLoader;
+ }
- public URLClassLoader getUserScriptClassLoader()
- {
- return m_userScriptClassLoader;
- }
-
- public void setUserScriptClassLoader(URLClassLoader urlClassLoader)
- {
- m_userScriptClassLoader = urlClassLoader;
- }
-
}
Modified: trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptSQLAction.java
===================================================================
--- trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptSQLAction.java 2011-01-02 22:36:56 UTC (rev 6130)
+++ trunk/sql12/plugins/userscript/src/main/java/net/sourceforge/squirrel_sql/plugins/userscript/UserScriptSQLAction.java 2011-01-02 22:37:33 UTC (rev 6131)
@@ -2,15 +2,15 @@
import net.sourceforge.squirrel_sql.client.IApplication;
-import net.sourceforge.squirrel_sql.fw.util.Resources;
+import net.sourceforge.squirrel_sql.fw.util.IResources;
import net.sourceforge.squirrel_sql.plugins.userscript.kernel.UserScriptAdmin;
public class UserScriptSQLAction extends UserScriptAction
{
- public UserScriptSQLAction(IApplication app, Resources rsrc, UserScriptPlugin plugin)
+ public UserScriptSQLAction(IApplication app, IResources resources, UserScriptPlugin plugin)
{
- super(app, rsrc, plugin);
+ super(app, resources, plugin);
}
protected boolean getTargetType()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|