[jsword-svn] r1168 - in trunk/common-swing/src/main/java/org/crosswire/common: config/swing progress/swing swing swing/desktop swing/plaf

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Thu Oct 19 14:48:06 MST 2006


Author: dmsmith
Date: 2006-10-19 14:47:42 -0700 (Thu, 19 Oct 2006)
New Revision: 1168

Modified:
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/ButtonPane.java
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/PathField.java
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/StringArrayField.java
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/TreeConfigEditor.java
   trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
   trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/CWAction.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/CatchingThreadGroup.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/ExceptionPane.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/QuickHelpDialog.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/MDIViewLayout.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/plaf/AbstractLFCustoms.java
Log:
cleanup of issues identified by pmd

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -162,7 +162,7 @@
         {
             if (i > 1)
             {
-                path.append("."); //$NON-NLS-1$
+                path.append('.');
             }
 
             path.append(list[i].toString());
@@ -213,13 +213,13 @@
                 {
                     // Chop off the similar start
                     temp = temp.substring(path.length());
-                    if (temp.startsWith(".")) //$NON-NLS-1$
+                    if (temp.charAt(0) == '.')
                     {
                         temp = temp.substring(1);
                     }
 
                     // Chop off all after the first dot
-                    int dotPos = temp.indexOf("."); //$NON-NLS-1$
+                    int dotPos = temp.indexOf('.');
                     if (dotPos != -1)
                     {
                         temp = temp.substring(0, dotPos);

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/ButtonPane.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/ButtonPane.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/ButtonPane.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -58,7 +58,7 @@
     /**
      * GUI init.
      */
-    protected void init()
+    private void init()
     {
         actions = new ActionFactory(ButtonPane.class, this);
 

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/PathField.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/PathField.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/PathField.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -125,12 +125,12 @@
     }
 
     /**
-     * Set the current value using a hashtable
+     * Set the current value using a String array
      * @param value The new text
      */
     public void setArray(String[] value)
     {
-        model = new DefaultComboBoxModel(value);
+        model = new DefaultComboBoxModel((String[]) value.clone());
         list.setModel(model);
     }
 

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/StringArrayField.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/StringArrayField.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/StringArrayField.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -132,7 +132,7 @@
      */
     public void setArray(String[] value)
     {
-        list_model = new DefaultComboBoxModel(value);
+        list_model = new DefaultComboBoxModel((String[]) value.clone());
         list.setModel(list_model);
     }
 

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/TreeConfigEditor.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/TreeConfigEditor.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/TreeConfigEditor.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -203,7 +203,7 @@
         {
             if (i > 1)
             {
-                path.append("."); //$NON-NLS-1$
+                path.append('.');
             }
 
             path.append(list[i].toString());
@@ -288,13 +288,13 @@
                 {
                     // Chop off the similar start
                     temp = temp.substring(path.length());
-                    if (temp.startsWith(".")) //$NON-NLS-1$
+                    if (temp.charAt(0) == '.')
                     {
                         temp = temp.substring(1);
                     }
 
                     // Chop off all after the first dot
-                    int dot_pos = temp.indexOf("."); //$NON-NLS-1$
+                    int dot_pos = temp.indexOf('.');
                     if (dot_pos != -1)
                     {
                         temp = temp.substring(0, dot_pos);

Modified: trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -122,7 +122,7 @@
     /**
      * Create a new set of components for the new Job
      */
-    protected synchronized void addJob(Job job)
+    /*private*/ final synchronized void addJob(Job job)
     {
         job.addWorkListener(this);
 

Modified: trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -122,7 +122,7 @@
     /**
      * Create a new set of components for the new Job
      */
-    protected void addJob(final Job job)
+    /*private*/ final void addJob(final Job job)
     {
         int i = findEmptyPosition();
         log.debug("adding job to panel at " + i + ": " + job.getJobDescription()); //$NON-NLS-1$ //$NON-NLS-2$

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/CWAction.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/CWAction.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/CWAction.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -110,7 +110,7 @@
         sb.append(isEnabled());
         sb.append("\n    ObjectID:"); //$NON-NLS-1$
         sb.append(System.identityHashCode(this));
-        sb.append("\n"); //$NON-NLS-1$
+        sb.append('\n');
 
         return sb.toString();
     }

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/CatchingThreadGroup.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/CatchingThreadGroup.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/CatchingThreadGroup.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -55,7 +55,7 @@
     /* @Override */
     public void uncaughtException(Thread t, Throwable ex)
     {
-        ex.printStackTrace();
+        ex.printStackTrace(System.err);
         ExceptionPane.showExceptionDialog(null, ex);
     }
 }

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/ExceptionPane.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/ExceptionPane.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/ExceptionPane.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -35,6 +35,7 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.LineNumberReader;
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -87,7 +88,8 @@
      */
     private void initialise()
     {
-        String exmsg = "<html><font size=\"-1\">" + Msg.ERROR_OCCURED + "</font> " + ExceptionPane.getHTMLDescription(ex); //$NON-NLS-1$ //$NON-NLS-2$
+        MessageFormat msgFormat = new MessageFormat("<html><font size=\"-1\">{0}</font> {1}"); //$NON-NLS-1$
+        String exmsg = msgFormat.format(new Object[] { Msg.ERROR_OCCURED.toString(), ExceptionPane.getHTMLDescription(ex) });
 
         // The upper pane
         JLabel message = new JLabel();
@@ -471,7 +473,7 @@
                             {
                                 break;
                             }
-                            data.append(line).append("\n"); //$NON-NLS-1$
+                            data.append(line).append('\n');
 
                             int current_line = in.getLineNumber();
                             if (current_line == line_num - 1)
@@ -514,13 +516,13 @@
             }
 
             // If we can't find a matching file
-            String error = Msg.SOURCE_NOT_FOUND.toString(new Object[] { st.getClassName(level), errorLine });
+            StringBuffer error = new StringBuffer(Msg.SOURCE_NOT_FOUND.toString(new Object[] { st.getClassName(level), errorLine }));
             for (int i = 0; i < srcs.length; i++)
             {
-                error += Msg.SOURCE_ATTEMPT.toString(new Object[] { srcs[i].getAbsolutePath() + name });
+                error.append(Msg.SOURCE_ATTEMPT.toString(new Object[] { srcs[i].getAbsolutePath() + name }));
             }
 
-            mytext.setText(error);
+            mytext.setText(error.toString());
             SwingUtilities.getRoot(mylabel).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         }
 

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -66,7 +66,7 @@
      * Change the map that we report on
      * @param map The map we are getting our data from
      */
-    public void setMap(Map map)
+    public final void setMap(Map map)
     {
         this.map = map;
         list.clear();

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/QuickHelpDialog.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/QuickHelpDialog.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/QuickHelpDialog.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -142,7 +142,7 @@
     /**
      * 
      */
-    public void close()
+    public final void close()
     {
         setVisible(false);
     }

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/MDIViewLayout.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/MDIViewLayout.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/MDIViewLayout.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -252,12 +252,10 @@
         {
             // Don't allow the last one to be closed.
             String name = evt.getPropertyName();
-            if (name.equals(JInternalFrame.IS_CLOSED_PROPERTY))
+            if (name.equals(JInternalFrame.IS_CLOSED_PROPERTY)
+                && MDIViewLayout.this.desk.getComponentCount() == 1)
             {
-                if (MDIViewLayout.this.desk.getComponentCount() == 1)
-                {
-                    throw new PropertyVetoException("Cannot close the last window", evt); //$NON-NLS-1$
-                }
+                throw new PropertyVetoException("Cannot close the last window", evt); //$NON-NLS-1$
             }
         }
 

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -116,7 +116,7 @@
     /* (non-Javadoc)
      * @see org.crosswire.common.swing.desktop.Viewable#addView(java.awt.Component)
      */
-    public void addView(Component component)
+    public final void addView(Component component)
     {
         getViewLayout().addView(component);
     }
@@ -172,7 +172,7 @@
     /**
      * Adds a view to the list in this Desktop.
      */
-    public Component addView()
+    public final Component addView()
     {
 
         Component view = generator.createView();
@@ -363,7 +363,7 @@
     /* (non-Javadoc)
      * @see org.crosswire.common.swing.desktop.Viewable#addViewEventListener(org.crosswire.common.swing.desktop.event.ViewEventListener)
      */
-    public void addViewEventListener(ViewEventListener listener)
+    public final void addViewEventListener(ViewEventListener listener)
     {
         LayoutType.MDI.getLayout().addViewEventListener(listener);
         LayoutType.TDI.getLayout().addViewEventListener(listener);
@@ -388,7 +388,7 @@
         return contextActions.getAction(key);
     }
 
-    protected Object getConstraint()
+    /*private*/ final Object getConstraint()
     {
         return gbc;
     }

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/plaf/AbstractLFCustoms.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/plaf/AbstractLFCustoms.java	2006-10-19 21:47:05 UTC (rev 1167)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/plaf/AbstractLFCustoms.java	2006-10-19 21:47:42 UTC (rev 1168)
@@ -58,7 +58,5 @@
      * This method does nothing. Subclass should override this to install platform
      * specific UI defaults.
      */
-    protected void initPlatformUIDefaults()
-    {
-    }
+    protected abstract void initPlatformUIDefaults();
 }




More information about the jsword-svn mailing list