From: tcofoegbu Date: Fri, 26 Jun 2015 09:41:32 +0000 (+0100) Subject: JAL-1780 improvement to ensure export settings dialog is not invoked if there's notin... X-Git-Tag: Release_2_10_0~595^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1e0a944431b347efefe067fdecb6f28fe4c187a8;p=jalview.git JAL-1780 improvement to ensure export settings dialog is not invoked if there's noting to configure and clean ups --- diff --git a/src/jalview/api/AlignExportSettingI.java b/src/jalview/api/AlignExportSettingI.java index cf56bf3..9b67cf5 100644 --- a/src/jalview/api/AlignExportSettingI.java +++ b/src/jalview/api/AlignExportSettingI.java @@ -68,10 +68,4 @@ public interface AlignExportSettingI */ public boolean isExportGroups(); - /** - * Checks if settings/export process is cancelled - * - * @return - */ - public boolean isCancelled(); } diff --git a/src/jalview/gui/AlignExportSettings.java b/src/jalview/gui/AlignExportSettings.java index fe7c940..40128af 100644 --- a/src/jalview/gui/AlignExportSettings.java +++ b/src/jalview/gui/AlignExportSettings.java @@ -1,14 +1,14 @@ package jalview.gui; +import jalview.api.AlignExportSettingI; +import jalview.jbgui.GAlignExportSettings; + import java.awt.event.ActionEvent; import javax.swing.JDialog; import javax.swing.JInternalFrame; import javax.swing.JOptionPane; -import jalview.api.AlignExportSettingI; -import jalview.jbgui.GAlignExportSettings; - @SuppressWarnings("serial") public class AlignExportSettings extends GAlignExportSettings implements AlignExportSettingI @@ -17,52 +17,25 @@ public class AlignExportSettings extends GAlignExportSettings implements boolean cancelled = false; - private int width = 450; - - private int height = 200; - JDialog dialog; public AlignExportSettings(boolean hasHiddenSeq, boolean hasHiddenCols, String alignFileFormat) { super(hasHiddenSeq, hasHiddenCols, alignFileFormat); - - // frame = new JInternalFrame(); - // frame.setContentPane(this); - // frame.setLayer(JLayeredPane.PALETTE_LAYER); - // Desktop.addInternalFrame(frame, "Export Settings", width, height); - - JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION, - JOptionPane.DEFAULT_OPTION, null, new Object[] - { this }); - dialog = pane.createDialog(Desktop.desktop, "Export Settings"); - - // dialog = new JDialog(Desktop.instance, true); - // dialog.setTitle("Export Settings"); - - dialog.pack(); - dialog.setVisible(true); - - dialog.setContentPane(this); - dialog.validate(); - + if (isShowDialog()) + { + JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION, + JOptionPane.DEFAULT_OPTION, null, new Object[] + { this }); + dialog = pane.createDialog(Desktop.desktop, "Export Settings"); + dialog.pack(); + dialog.setVisible(true); + dialog.setContentPane(this); + dialog.validate(); + } } - // public static void main(String[] args) - // { - // new AlignExportSettings(false, false, false); - // } - - // public void cancel_actionPerformed(ActionEvent e) - // { - // try - // { - // frame.setClosed(true); - // } catch (Exception ex) - // { - // } - // } public void ok_actionPerformed(ActionEvent e) { @@ -106,7 +79,6 @@ public class AlignExportSettings extends GAlignExportSettings implements return chkExportGrps.isSelected(); } - @Override public boolean isCancelled() { return cancelled; diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 01353d8..764b192 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -28,7 +28,6 @@ import jalview.analysis.CrossRef; import jalview.analysis.Dna; import jalview.analysis.ParseProperties; import jalview.analysis.SequenceIdMatcher; -import jalview.api.AlignExportSettingI; import jalview.api.AlignViewControllerGuiI; import jalview.api.AlignViewControllerI; import jalview.api.AlignViewportI; @@ -1254,7 +1253,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { 0, alignmentToExport.getWidth() - 1 }; boolean hasHiddenSeqs = hiddenSeqs.getSize() > 0; - AlignExportSettingI settings = new AlignExportSettings(hasHiddenSeqs, + AlignExportSettings settings = new AlignExportSettings(hasHiddenSeqs, viewport.hasHiddenColumns(), exportFomat); settings.isExportAnnotations(); @@ -6079,10 +6078,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, private int[] startEnd; - private AlignExportSettingI settings; + private AlignExportSettings settings; public ExportData(AlignmentI align, String[] ommit, int[] startEnd, - AlignExportSettingI settings) + AlignExportSettings settings) { this.alignment = align; this.omitHidden = ommit; @@ -6120,12 +6119,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, this.startEnd = startEnd; } - public AlignExportSettingI getSettings() + public AlignExportSettings getSettings() { return settings; } - public void setSettings(AlignExportSettingI settings) + public void setSettings(AlignExportSettings settings) { this.settings = settings; } diff --git a/src/jalview/jbgui/GAlignExportSettings.java b/src/jalview/jbgui/GAlignExportSettings.java index 2583b6b..15498c6 100644 --- a/src/jalview/jbgui/GAlignExportSettings.java +++ b/src/jalview/jbgui/GAlignExportSettings.java @@ -44,9 +44,8 @@ public abstract class GAlignExportSettings extends JPanel JButton btnCancel = new JButton("Cancel"); - private boolean hasHiddenSeq, hasHiddenCols, isComplexAlignFile; - - boolean isComplexFormat = false; + private boolean hasHiddenSeq, hasHiddenCols, isComplexAlignFile, + showDialog; public GAlignExportSettings(boolean hasHiddenSeq, boolean hasHiddenCols, String alignFileFormat) @@ -64,7 +63,10 @@ public abstract class GAlignExportSettings extends JPanel break; } } - + if (this.hasHiddenCols || this.hasHiddenSeq || this.isComplexAlignFile) + { + this.showDialog = true; + } init(); } @@ -113,7 +115,7 @@ public abstract class GAlignExportSettings extends JPanel optionsPanel.add(hiddenRegionConfPanel); } - if (isComplexAlignFile) + if (this.isComplexAlignFile) { optionsPanel.add(complexExportPanel); } @@ -124,8 +126,6 @@ public abstract class GAlignExportSettings extends JPanel add(actionPanel, BorderLayout.SOUTH); } - - private void checkAllAction() { @@ -140,6 +140,16 @@ public abstract class GAlignExportSettings extends JPanel && chkExportGrps.isEnabled() && isSelected); } + public boolean isShowDialog() + { + return showDialog; + } + + public void setShowDialog(boolean showDialog) + { + this.showDialog = showDialog; + } + public abstract void ok_actionPerformed(ActionEvent e); public abstract void cancel_actionPerformed(ActionEvent e);