Revision: 6103
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6103&view=rev
Author: manningr
Date: 2011-01-02 22:16:30 +0000 (Sun, 02 Jan 2011)
Log Message:
-----------
Extracted interface to allow Resources implementation to be mocked in tests.
Modified Paths:
--------------
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/Resources.java
Added Paths:
-----------
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/IResources.java
Added: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/IResources.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/IResources.java (rev 0)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/IResources.java 2011-01-02 22:16:30 UTC (rev 6103)
@@ -0,0 +1,70 @@
+package net.sourceforge.squirrel_sql.fw.util;
+
+import java.util.MissingResourceException;
+
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.KeyStroke;
+
+/*
+ * Copyright (C) 2011 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+public interface IResources
+{
+
+ public static final String ACCELERATOR_STRING = "SQuirreLAcceleratorString";
+
+ KeyStroke getKeyStroke(Action action);
+
+ JMenuItem addToPopupMenu(Action action, javax.swing.JPopupMenu menu) throws MissingResourceException;
+
+ JCheckBoxMenuItem addToMenuAsCheckBoxMenuItem(Action action, JMenu menu) throws MissingResourceException;
+
+ JCheckBoxMenuItem addToMenuAsCheckBoxMenuItem(Action action, JPopupMenu popupMenu);
+
+ JMenuItem addToMenu(Action action, JMenu menu) throws MissingResourceException;
+
+ JMenu createMenu(String menuKey) throws MissingResourceException;
+
+ /**
+ * Setup the passed action from the resource bundle.
+ *
+ * @param action
+ * Action being setup.
+ *
+ * @throws IllegalArgumentException
+ * thrown if <TT>null</TT> <TT>action</TT> passed.
+ */
+ void setupAction(Action action, boolean showColoricons);
+
+ ImageIcon getIcon(String keyName);
+
+ ImageIcon getIcon(Class<?> objClass, String propName);
+
+ ImageIcon getIcon(String keyName, String propName);
+
+ String getString(String key);
+
+ void configureMenuItem(Action action, JMenuItem item) throws MissingResourceException;
+
+}
\ No newline at end of file
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/Resources.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/Resources.java 2011-01-02 22:13:12 UTC (rev 6102)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/util/Resources.java 2011-01-02 22:16:30 UTC (rev 6103)
@@ -29,10 +29,8 @@
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-public abstract class Resources
+public abstract class Resources implements IResources
{
- public static final String ACCELERATOR_STRING = "SQuirreLAcceleratorString";
-
private interface ActionProperties
{
String DISABLED_IMAGE = "disabledimage";
@@ -91,6 +89,9 @@
_imagePath = _bundle.getString("path.images");
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#getKeyStroke(javax.swing.Action)
+ */
public KeyStroke getKeyStroke(Action action)
{
Utilities.checkNull("getKeyStroke", "action", action);
@@ -116,6 +117,9 @@
}
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#addToPopupMenu(javax.swing.Action, javax.swing.JPopupMenu)
+ */
public JMenuItem addToPopupMenu(Action action, javax.swing.JPopupMenu menu)
throws MissingResourceException
{
@@ -148,6 +152,9 @@
return item;
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#addToMenuAsCheckBoxMenuItem(javax.swing.Action, javax.swing.JMenu)
+ */
public JCheckBoxMenuItem addToMenuAsCheckBoxMenuItem(Action action, JMenu menu)
throws MissingResourceException
{
@@ -158,6 +165,9 @@
return item;
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#addToMenuAsCheckBoxMenuItem(javax.swing.Action, javax.swing.JPopupMenu)
+ */
public JCheckBoxMenuItem addToMenuAsCheckBoxMenuItem(Action action, JPopupMenu popupMenu)
{
final JCheckBoxMenuItem item = new JCheckBoxMenuItem(action);
@@ -166,6 +176,9 @@
return item;
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#addToMenu(javax.swing.Action, javax.swing.JMenu)
+ */
public JMenuItem addToMenu(Action action, JMenu menu) throws MissingResourceException
{
final JMenuItem item = menu.add(action);
@@ -173,6 +186,9 @@
return item;
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#createMenu(java.lang.String)
+ */
public JMenu createMenu(String menuKey) throws MissingResourceException
{
JMenu menu = new JMenu();
@@ -187,13 +203,7 @@
}
/**
- * Setup the passed action from the resource bundle.
- *
- * @param action
- * Action being setup.
- *
- * @throws IllegalArgumentException
- * thrown if <TT>null</TT> <TT>action</TT> passed.
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#setupAction(javax.swing.Action, boolean)
*/
public void setupAction(Action action, boolean showColoricons)
{
@@ -266,16 +276,25 @@
}
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#getIcon(java.lang.String)
+ */
public ImageIcon getIcon(String keyName)
{
return getIcon(keyName, "image");
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#getIcon(java.lang.Class, java.lang.String)
+ */
public ImageIcon getIcon(Class<?> objClass, String propName)
{
return getIcon(objClass.getName(), propName);
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#getIcon(java.lang.String, java.lang.String)
+ */
public ImageIcon getIcon(String keyName, String propName)
{
if (keyName == null)
@@ -309,12 +328,18 @@
return icon;
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#getString(java.lang.String)
+ */
public String getString(String key)
{
Utilities.checkNull("getString", "key", key);
return _bundle.getString(key);
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.IResources#configureMenuItem(javax.swing.Action, javax.swing.JMenuItem)
+ */
public void configureMenuItem(Action action, JMenuItem item) throws MissingResourceException
{
Utilities.checkNull("configureMenuItem", "action", action, "item", item);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|