JAL-3048 response() renamed addResponse(); checkstyle warning fixes
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 6 Dec 2018 15:02:15 +0000 (15:02 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 6 Dec 2018 15:02:15 +0000 (15:02 +0000)
15 files changed:
src/jalview/gui/AlignExportOptions.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/Desktop.java
src/jalview/gui/EditNameDialog.java
src/jalview/gui/FeatureEditor.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/JvOptionPane.java
src/jalview/gui/LineartOptions.java
src/jalview/gui/TextColourChooser.java
src/jalview/gui/UserDefinedColours.java
src/jalview/io/JalviewFileChooser.java
src/jalview/util/dialogrunner/DialogRunner.java
src/jalview/util/dialogrunner/DialogRunnerI.java
src/jalview/util/dialogrunner/RunResponse.java

index 5667744..ecf89cc 100644 (file)
@@ -122,7 +122,7 @@ public class AlignExportOptions extends JPanel
    */
   public void setResponseAction(RunResponse action)
   {
-    dialog.response(action);
+    dialog.addResponse(action);
   }
 
   /**
index f9f5cfd..f2ff1d4 100644 (file)
@@ -1472,7 +1472,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             MessageManager.getString("label.load_jalview_annotations"));
     chooser.setToolTipText(
             MessageManager.getString("label.load_jalview_annotations"));
-    chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
+    chooser.addResponse(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
     {
 
       @Override
@@ -3966,7 +3966,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     chooser.setToolTipText(
             MessageManager.getString("label.load_tree_file"));
 
-    chooser.response(new jalview.util.dialogrunner.RunResponse(
+    chooser.addResponse(new jalview.util.dialogrunner.RunResponse(
             JalviewFileChooser.APPROVE_OPTION)
     {
       @Override
@@ -5697,7 +5697,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     chooser.setDialogTitle(MessageManager.getString("label.load_vcf_file"));
     chooser.setToolTipText(MessageManager.getString("label.load_vcf_file"));
     final AlignFrame us = this;
-    chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
+    chooser.addResponse(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
     {
       @Override
       public void run()
index 53ab6fc..ee61308 100644 (file)
@@ -771,21 +771,21 @@ public class AlignViewport extends AlignmentViewport
      * in reverse order)
      */
     JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop)
-            .response(new RunResponse(0)
+            .addResponse(new RunResponse(0)
             {
               @Override
               public void run()
               {
                   addDataToAlignment(al);
               }
-            }).response(new RunResponse(1)
+            }).addResponse(new RunResponse(1)
             {
               @Override
               public void run()
               {
                 us.openLinkedAlignmentAs(al, title, true);
               }
-            }).response(new RunResponse(2)
+            }).addResponse(new RunResponse(2)
             {
               @Override
               public void run()
index 701d778..320ebc2 100644 (file)
@@ -1125,7 +1125,7 @@ public class Desktop extends jalview.jbgui.GDesktop
             MessageManager.getString("label.open_local_file"));
     chooser.setToolTipText(MessageManager.getString("action.open"));
 
-    chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
+    chooser.addResponse(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
     {
 
       @Override
@@ -1262,7 +1262,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       }};
     String dialogOption = MessageManager
             .getString("label.input_alignment_from_url");
-    JvOptionPane.newOptionDialog(desktop).response(action)
+    JvOptionPane.newOptionDialog(desktop).addResponse(action)
             .showInternalDialog(panel, dialogOption,
                     JvOptionPane.YES_NO_CANCEL_OPTION,
                     JvOptionPane.PLAIN_MESSAGE, null, options,
@@ -1745,7 +1745,7 @@ public class Desktop extends jalview.jbgui.GDesktop
             "Jalview Project");
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
-    chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
+    chooser.addResponse(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
     {
       @Override
       public void run()
index e150b89..bbb7a20 100644 (file)
@@ -118,7 +118,7 @@ public class EditNameDialog
   {
     Object[] options = new Object[] { MessageManager.getString("action.ok"),
         MessageManager.getString("action.cancel") };
-    JvOptionPane.newOptionDialog(parent).response(action)
+    JvOptionPane.newOptionDialog(parent).addResponse(action)
             .showInternalDialog(panel, title,
                     JvOptionPane.YES_NO_CANCEL_OPTION,
                     JvOptionPane.PLAIN_MESSAGE, null, options,
index ab69f45..d75404a 100644 (file)
@@ -414,10 +414,10 @@ public class FeatureEditor
      * also for Delete if applicable (when amending features)
      */
     JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop)
-            .response(okAction).response(cancelAction);
+            .addResponse(okAction).addResponse(cancelAction);
     if (!forCreate)
     {
-      dialog.response(getDeleteAction());
+      dialog.addResponse(getDeleteAction());
     }
 
     String title = null;
index 76a32bc..36af39a 100644 (file)
@@ -898,7 +898,7 @@ public class FeatureSettings extends JPanel
     chooser.setDialogTitle(
             MessageManager.getString("label.load_feature_colours"));
     chooser.setToolTipText(MessageManager.getString("action.load"));
-    chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION){
+    chooser.addResponse(new RunResponse(JalviewFileChooser.APPROVE_OPTION){
 
                @Override
                public void run() {
index 3a5e0f7..a141e14 100644 (file)
@@ -719,16 +719,14 @@ public class JvOptionPane extends JOptionPane
     {
       switch (messageType)
       {
-      default:
-      case JvOptionPane.INFORMATION_MESSAGE:
-        prefix = "Note: ";
-        break;
       case JvOptionPane.WARNING_MESSAGE:
         prefix = "WARNING! ";
         break;
       case JvOptionPane.ERROR_MESSAGE:
-        prefix = "ERRROR! ";
+        prefix = "ERROR! ";
         break;
+      default:
+        prefix = "Note: ";
       }
     }
     return prefix;
@@ -815,7 +813,6 @@ public class JvOptionPane extends JOptionPane
     {
       parent = parentComponent;
     }
-    ;
     ourOptions = Arrays.asList(options);
     
     int response;
@@ -840,10 +837,10 @@ public class JvOptionPane extends JOptionPane
     
   }
   @Override
-  public JvOptionPane response(RunResponse action)
+  public JvOptionPane addResponse(RunResponse action)
   {
 
-    runner.response(action);
+    runner.addResponse(action);
     return this;
   }
 
index a00d1e9..765a1ac 100644 (file)
@@ -98,7 +98,7 @@ public class LineartOptions extends JPanel
    */
   public void setResponseAction(RunResponse action)
   {
-    dialog.response(action);
+    dialog.addResponse(action);
   }
 
   /**
index 86a51ab..1eba84c 100644 (file)
@@ -158,7 +158,7 @@ public class TextColourChooser
         restoreInitialSettings();
       }
     };
-    JvOptionPane.newOptionDialog(alignPanel).response(action)
+    JvOptionPane.newOptionDialog(alignPanel).addResponse(action)
             .showInternalDialog(bigpanel, title,
                     JvOptionPane.YES_NO_CANCEL_OPTION,
                     JvOptionPane.PLAIN_MESSAGE, null, options,
index 17b2df7..f1ff128 100755 (executable)
@@ -645,7 +645,7 @@ public class UserDefinedColours extends GUserDefinedColours
     chooser.setDialogTitle(
             MessageManager.getString("label.load_colour_scheme"));
     chooser.setToolTipText(MessageManager.getString("action.load"));
-    chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION) {
+    chooser.addResponse(new RunResponse(JalviewFileChooser.APPROVE_OPTION) {
                @Override
                public void run() {
                    File choice = chooser.getSelectedFile();
index a7f8fa6..6838824 100755 (executable)
@@ -538,9 +538,9 @@ public class JalviewFileChooser extends JFileChooser
   }
 
   @Override
-  public JalviewFileChooser response(RunResponse action)
+  public JalviewFileChooser addResponse(RunResponse action)
   {
-    return runner.response(action);
+    return runner.addResponse(action);
   }
 
 }
index fa85ef4..05a63c7 100644 (file)
@@ -70,7 +70,7 @@ public class DialogRunner<T extends DialogRunnerI> implements DialogRunnerI
   }
 
   @Override
-  public T response(RunResponse action)
+  public T addResponse(RunResponse action)
   {
     return addResponse(false, action);
   }
index aaeb304..758d421 100644 (file)
@@ -30,12 +30,14 @@ public interface DialogRunnerI<T extends DialogRunnerI>
 {
 
   /**
-   * define a new response for this dialog. eg. dialog.response(new
-   * RunResponse(OK_PRessed) { run()...}).response(new RunResponse(CANCEL_PRESSED)
-   * { ... });
+   * Adds a new response for this dialog, and returns the dialog (this), to allow chaining, eg.
+   * <pre>
+   * dialog.addResponse(newRunResponse(OK_PRessed) { run()...})
+   *     .addResponse(new RunResponse(CANCEL_PRESSED);
+   * </pre>
    * 
    * @param action
    * @return the dialog
    */
-  T response(RunResponse action);
+  T addResponse(RunResponse action);
 }
index acc53f0..3fd56c4 100644 (file)
@@ -59,11 +59,6 @@ public abstract class RunResponse implements Runnable
     ourTrigger = new Response(trigger);
   }
 
-  public RunResponse(Response trigger)
-  {
-    ourTrigger = trigger;
-  }
-
   public void reset()
   {
     wasRun = false;