From 2e02b14ba33c2cf4618f65c831a506f81e621589 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 6 Dec 2018 15:02:15 +0000 Subject: [PATCH] JAL-3048 response() renamed addResponse(); checkstyle warning fixes --- src/jalview/gui/AlignExportOptions.java | 2 +- src/jalview/gui/AlignFrame.java | 6 +++--- src/jalview/gui/AlignViewport.java | 6 +++--- src/jalview/gui/Desktop.java | 6 +++--- src/jalview/gui/EditNameDialog.java | 2 +- src/jalview/gui/FeatureEditor.java | 4 ++-- src/jalview/gui/FeatureSettings.java | 2 +- src/jalview/gui/JvOptionPane.java | 13 +++++-------- src/jalview/gui/LineartOptions.java | 2 +- src/jalview/gui/TextColourChooser.java | 2 +- src/jalview/gui/UserDefinedColours.java | 2 +- src/jalview/io/JalviewFileChooser.java | 4 ++-- src/jalview/util/dialogrunner/DialogRunner.java | 2 +- src/jalview/util/dialogrunner/DialogRunnerI.java | 10 ++++++---- src/jalview/util/dialogrunner/RunResponse.java | 5 ----- 15 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/jalview/gui/AlignExportOptions.java b/src/jalview/gui/AlignExportOptions.java index 5667744..ecf89cc 100644 --- a/src/jalview/gui/AlignExportOptions.java +++ b/src/jalview/gui/AlignExportOptions.java @@ -122,7 +122,7 @@ public class AlignExportOptions extends JPanel */ public void setResponseAction(RunResponse action) { - dialog.response(action); + dialog.addResponse(action); } /** diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index f9f5cfd..f2ff1d4 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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() diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 53ab6fc..ee61308 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -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() diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 701d778..320ebc2 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -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() diff --git a/src/jalview/gui/EditNameDialog.java b/src/jalview/gui/EditNameDialog.java index e150b89..bbb7a20 100644 --- a/src/jalview/gui/EditNameDialog.java +++ b/src/jalview/gui/EditNameDialog.java @@ -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, diff --git a/src/jalview/gui/FeatureEditor.java b/src/jalview/gui/FeatureEditor.java index ab69f45..d75404a 100644 --- a/src/jalview/gui/FeatureEditor.java +++ b/src/jalview/gui/FeatureEditor.java @@ -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; diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 76a32bc..36af39a 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -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() { diff --git a/src/jalview/gui/JvOptionPane.java b/src/jalview/gui/JvOptionPane.java index 3a5e0f7..a141e14 100644 --- a/src/jalview/gui/JvOptionPane.java +++ b/src/jalview/gui/JvOptionPane.java @@ -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; } diff --git a/src/jalview/gui/LineartOptions.java b/src/jalview/gui/LineartOptions.java index a00d1e9..765a1ac 100644 --- a/src/jalview/gui/LineartOptions.java +++ b/src/jalview/gui/LineartOptions.java @@ -98,7 +98,7 @@ public class LineartOptions extends JPanel */ public void setResponseAction(RunResponse action) { - dialog.response(action); + dialog.addResponse(action); } /** diff --git a/src/jalview/gui/TextColourChooser.java b/src/jalview/gui/TextColourChooser.java index 86a51ab..1eba84c 100644 --- a/src/jalview/gui/TextColourChooser.java +++ b/src/jalview/gui/TextColourChooser.java @@ -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, diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 17b2df7..f1ff128 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -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(); diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index a7f8fa6..6838824 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -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); } } diff --git a/src/jalview/util/dialogrunner/DialogRunner.java b/src/jalview/util/dialogrunner/DialogRunner.java index fa85ef4..05a63c7 100644 --- a/src/jalview/util/dialogrunner/DialogRunner.java +++ b/src/jalview/util/dialogrunner/DialogRunner.java @@ -70,7 +70,7 @@ public class DialogRunner implements DialogRunnerI } @Override - public T response(RunResponse action) + public T addResponse(RunResponse action) { return addResponse(false, action); } diff --git a/src/jalview/util/dialogrunner/DialogRunnerI.java b/src/jalview/util/dialogrunner/DialogRunnerI.java index aaeb304..758d421 100644 --- a/src/jalview/util/dialogrunner/DialogRunnerI.java +++ b/src/jalview/util/dialogrunner/DialogRunnerI.java @@ -30,12 +30,14 @@ public interface 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. + *
+   * dialog.addResponse(newRunResponse(OK_PRessed) { run()...})
+   *     .addResponse(new RunResponse(CANCEL_PRESSED);
+   * 
* * @param action * @return the dialog */ - T response(RunResponse action); + T addResponse(RunResponse action); } diff --git a/src/jalview/util/dialogrunner/RunResponse.java b/src/jalview/util/dialogrunner/RunResponse.java index acc53f0..3fd56c4 100644 --- a/src/jalview/util/dialogrunner/RunResponse.java +++ b/src/jalview/util/dialogrunner/RunResponse.java @@ -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; -- 1.7.10.2