From: gmungoc Date: Tue, 18 Dec 2018 17:11:33 +0000 (+0000) Subject: JAL-3048 DialogRunnerI reduced to minimal implementation X-Git-Tag: Release_2_11_4_0~45^2~18^2~343^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2afa9987e7d3276b4525abb28767617732e6e7cf;p=jalview.git JAL-3048 DialogRunnerI reduced to minimal implementation --- diff --git a/src/jalview/gui/AlignExportOptions.java b/src/jalview/gui/AlignExportOptions.java index db78bee..70601c9 100644 --- a/src/jalview/gui/AlignExportOptions.java +++ b/src/jalview/gui/AlignExportOptions.java @@ -24,7 +24,6 @@ import jalview.api.AlignExportSettingsI; import jalview.api.AlignViewportI; import jalview.io.FileFormatI; import jalview.util.MessageManager; -import jalview.util.dialogrunner.RunResponse; import java.awt.BorderLayout; import java.awt.FlowLayout; @@ -120,9 +119,9 @@ public class AlignExportOptions extends JPanel * * @param action */ - public void setResponseAction(Object response, RunResponse action) + public void setResponseAction(Object response, Runnable action) { - dialog.addResponse(response, action); + dialog.setResponseHandler(response, action); } /** diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index a1d97e7..7183f7f 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -89,7 +89,6 @@ import jalview.schemes.ResidueColourScheme; import jalview.schemes.TCoffeeColourScheme; import jalview.util.ImageMaker.TYPE; import jalview.util.MessageManager; -import jalview.util.dialogrunner.RunResponse; import jalview.viewmodel.AlignmentViewport; import jalview.viewmodel.ViewportRanges; import jalview.ws.DBRefFetcher; @@ -1246,7 +1245,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } AlignExportSettingsI options = new AlignExportSettingsAdapter(false); - RunResponse cancelAction = new RunResponse(JvOptionPane.CANCEL_OPTION) + Runnable cancelAction = new Runnable() { @Override public void run() @@ -1254,7 +1253,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, lastSaveSuccessful = false; } }; - RunResponse outputAction = new RunResponse(JvOptionPane.OK_OPTION) + Runnable outputAction = new Runnable() { @Override public void run() @@ -1322,7 +1321,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, FileFormatI fileFormat = FileFormats.getInstance() .forName(fileFormatName); AlignExportSettingsI options = new AlignExportSettingsAdapter(false); - RunResponse outputAction = new RunResponse(JvOptionPane.OK_OPTION) + Runnable outputAction = new Runnable() { @Override public void run() @@ -1472,7 +1471,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, MessageManager.getString("label.load_jalview_annotations")); chooser.setToolTipText( MessageManager.getString("label.load_jalview_annotations")); - chooser.addResponse(0, new RunResponse(JalviewFileChooser.APPROVE_OPTION) + chooser.setResponseHandler(0, new Runnable() { @Override public void run() @@ -3964,7 +3963,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, chooser.setToolTipText( MessageManager.getString("label.load_tree_file")); - chooser.addResponse(0,new RunResponse(JalviewFileChooser.APPROVE_OPTION) + chooser.setResponseHandler(0,new Runnable() { @Override public void run() @@ -5695,7 +5694,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.addResponse(0, new RunResponse(JalviewFileChooser.APPROVE_OPTION) + chooser.setResponseHandler(0, new Runnable() { @Override public void run() diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 7b8c6c9..62a3698 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -48,7 +48,6 @@ import jalview.structure.SelectionSource; import jalview.structure.StructureSelectionManager; import jalview.structure.VamsasSource; import jalview.util.MessageManager; -import jalview.util.dialogrunner.RunResponse; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.AutoCalcSetting; @@ -771,21 +770,21 @@ public class AlignViewport extends AlignmentViewport * in reverse order) */ JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop) - .addResponse(0, new RunResponse(0) + .setResponseHandler(0, new Runnable() { @Override public void run() { addDataToAlignment(al); } - }).addResponse(1, new RunResponse(1) + }).setResponseHandler(1, new Runnable() { @Override public void run() { us.openLinkedAlignmentAs(al, title, true); } - }).addResponse(2, new RunResponse(2) + }).setResponseHandler(2, new Runnable() { @Override public void run() diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 294b8db..6ea4c57 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -34,7 +34,6 @@ import jalview.io.FormatAdapter; import jalview.util.Comparison; import jalview.util.MessageManager; import jalview.util.Platform; -import jalview.util.dialogrunner.RunResponse; import java.awt.Color; import java.awt.Cursor; @@ -292,7 +291,7 @@ public class AnnotationLabels extends JPanel annotation.description, name, description); dialog.showDialog(ap.alignFrame, title, - new RunResponse(JvOptionPane.OK_OPTION) + new Runnable() { @Override public void run() diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 1e258b8..a927741 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -46,7 +46,6 @@ import jalview.util.ImageMaker.TYPE; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.util.UrlConstants; -import jalview.util.dialogrunner.RunResponse; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.ParamManager; import jalview.ws.utils.UrlDownloadClient; @@ -89,7 +88,6 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.ListIterator; -import java.util.StringTokenizer; import java.util.Vector; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -1125,7 +1123,7 @@ public class Desktop extends jalview.jbgui.GDesktop MessageManager.getString("label.open_local_file")); chooser.setToolTipText(MessageManager.getString("action.open")); - chooser.addResponse(0, new RunResponse(JalviewFileChooser.APPROVE_OPTION) + chooser.setResponseHandler(0, new Runnable() { @Override public void run() @@ -1206,7 +1204,7 @@ public class Desktop extends jalview.jbgui.GDesktop Object[] options = new Object[] { MessageManager.getString("action.ok"), MessageManager.getString("action.cancel") }; - RunResponse action = new RunResponse(JvOptionPane.OK_OPTION) { + Runnable action = new Runnable() { @Override public void run() { @@ -1262,7 +1260,7 @@ public class Desktop extends jalview.jbgui.GDesktop }}; String dialogOption = MessageManager .getString("label.input_alignment_from_url"); - JvOptionPane.newOptionDialog(desktop).addResponse(0, action) + JvOptionPane.newOptionDialog(desktop).setResponseHandler(0, action) .showInternalDialog(panel, dialogOption, JvOptionPane.YES_NO_CANCEL_OPTION, JvOptionPane.PLAIN_MESSAGE, null, options, @@ -1745,7 +1743,7 @@ public class Desktop extends jalview.jbgui.GDesktop "Jalview Project"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager.getString("label.restore_state")); - chooser.addResponse(0, new RunResponse(JalviewFileChooser.APPROVE_OPTION) + chooser.setResponseHandler(0, new Runnable() { @Override public void run() diff --git a/src/jalview/gui/EditNameDialog.java b/src/jalview/gui/EditNameDialog.java index c976545..8aaebc8 100644 --- a/src/jalview/gui/EditNameDialog.java +++ b/src/jalview/gui/EditNameDialog.java @@ -21,7 +21,6 @@ package jalview.gui; import jalview.util.MessageManager; -import jalview.util.dialogrunner.RunResponse; import java.awt.FlowLayout; import java.awt.Font; @@ -112,11 +111,11 @@ public class EditNameDialog * @param action */ public void showDialog(JComponent parent, String title, - RunResponse action) + Runnable action) { Object[] options = new Object[] { MessageManager.getString("action.ok"), MessageManager.getString("action.cancel") }; - JvOptionPane.newOptionDialog(parent).addResponse(0, action) + JvOptionPane.newOptionDialog(parent).setResponseHandler(0, 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 b829ec7..d547c58 100644 --- a/src/jalview/gui/FeatureEditor.java +++ b/src/jalview/gui/FeatureEditor.java @@ -10,7 +10,6 @@ import jalview.io.FeaturesFile; import jalview.schemes.FeatureColour; import jalview.util.ColorUtils; import jalview.util.MessageManager; -import jalview.util.dialogrunner.RunResponse; import java.awt.BorderLayout; import java.awt.Color; @@ -406,18 +405,18 @@ public class FeatureEditor */ public void showDialog() { - RunResponse okAction = forCreate ? getCreateAction() : getAmendAction(); - RunResponse cancelAction = getCancelAction(); + Runnable okAction = forCreate ? getCreateAction() : getAmendAction(); + Runnable cancelAction = getCancelAction(); /* * set dialog action handlers for OK (create/Amend) and Cancel options * also for Delete if applicable (when amending features) */ JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop) - .addResponse(0, okAction).addResponse(2, cancelAction); + .setResponseHandler(0, okAction).setResponseHandler(2, cancelAction); if (!forCreate) { - dialog.addResponse(1, getDeleteAction()); + dialog.setResponseHandler(1, getDeleteAction()); } String title = null; @@ -453,9 +452,9 @@ public class FeatureEditor * * @return */ - protected RunResponse getCancelAction() + protected Runnable getCancelAction() { - RunResponse okAction = new RunResponse(JvOptionPane.CANCEL_OPTION) + Runnable okAction = new Runnable() { @Override public void run() @@ -477,9 +476,9 @@ public class FeatureEditor * * @return */ - protected RunResponse getCreateAction() + protected Runnable getCreateAction() { - RunResponse okAction = new RunResponse(JvOptionPane.OK_OPTION) + Runnable okAction = new Runnable() { boolean useLastDefaults = features.get(0).getType() == null; @@ -535,9 +534,9 @@ public class FeatureEditor * * @return */ - protected RunResponse getDeleteAction() + protected Runnable getDeleteAction() { - RunResponse deleteAction = new RunResponse(JvOptionPane.NO_OPTION) + Runnable deleteAction = new Runnable() { public void run() { @@ -637,9 +636,9 @@ public class FeatureEditor * * @return */ - protected RunResponse getAmendAction() + protected Runnable getAmendAction() { - RunResponse okAction = new RunResponse(JvOptionPane.OK_OPTION) + Runnable okAction = new Runnable() { boolean useLastDefaults = features.get(0).getType() == null; diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index f29655b..23bdecb 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -36,7 +36,6 @@ import jalview.io.JalviewFileView; import jalview.schemes.FeatureColour; import jalview.util.MessageManager; import jalview.util.Platform; -import jalview.util.dialogrunner.RunResponse; import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean; import jalview.xml.binding.jalview.JalviewUserColours; import jalview.xml.binding.jalview.JalviewUserColours.Colour; @@ -902,7 +901,7 @@ public class FeatureSettings extends JPanel chooser.setDialogTitle( MessageManager.getString("label.load_feature_colours")); chooser.setToolTipText(MessageManager.getString("action.load")); - chooser.addResponse(0, new RunResponse(JalviewFileChooser.APPROVE_OPTION) + chooser.setResponseHandler(0, new Runnable() { @Override public void run() diff --git a/src/jalview/gui/ImageExporter.java b/src/jalview/gui/ImageExporter.java index 90b212f..a43eef0 100644 --- a/src/jalview/gui/ImageExporter.java +++ b/src/jalview/gui/ImageExporter.java @@ -7,15 +7,12 @@ import jalview.io.JalviewFileView; import jalview.util.ImageMaker; import jalview.util.ImageMaker.TYPE; import jalview.util.MessageManager; -import jalview.util.dialogrunner.RunResponse; import java.awt.Component; import java.awt.Graphics; import java.io.File; import java.util.concurrent.atomic.AtomicBoolean; -import javax.swing.JOptionPane; - /** * A class that marshals steps in exporting a view in image graphics format *