From: gmungoc Date: Thu, 19 Jul 2018 10:42:59 +0000 (+0100) Subject: JAL-3048 revert saveAs action so it works in Javascript too X-Git-Tag: Release_2_11_4_0~45^2~18^2~530 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6365acca3e42b3e1251efad1d86e29a31f99e3d6;p=jalview.git JAL-3048 revert saveAs action so it works in Javascript too --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 7525f47..f8e5e30 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -140,7 +140,6 @@ import java.util.Vector; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JEditorPane; -import javax.swing.JFileChooser; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JLayeredPane; @@ -148,7 +147,6 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTextPane; import javax.swing.SwingUtilities; /** @@ -1154,7 +1152,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (fileName == null || (currentFileFormat == null) || fileName.startsWith("http")) { - saveAs_actionPerformed(null); + saveAs_actionPerformed(); } else { @@ -1163,51 +1161,48 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! + * Saves the alignment to a file with a name chosen by the user, if necessary + * warning if a file would be overwritten */ @Override - public void saveAs_actionPerformed(ActionEvent e) + public void saveAs_actionPerformed() { String format = currentFileFormat == null ? null : currentFileFormat.getName(); - final JalviewFileChooser chooser = JalviewFileChooser + JalviewFileChooser chooser = JalviewFileChooser .forWrite(Cache.getProperty("LAST_DIRECTORY"), format); - final AlignFrame us = this; + chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle( MessageManager.getString("label.save_alignment_to_file")); chooser.setToolTipText(MessageManager.getString("action.save")); - chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION) + int value = chooser.showSaveDialog(this); + + if (value == JalviewFileChooser.APPROVE_OPTION) { - @Override - public void run() + currentFileFormat = chooser.getSelectedFormat(); + while (currentFileFormat == null) { + JvOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager.getString( + "label.select_file_format_before_saving"), + MessageManager.getString("label.file_format_not_specified"), + JvOptionPane.WARNING_MESSAGE); currentFileFormat = chooser.getSelectedFormat(); - while (currentFileFormat == null) + value = chooser.showSaveDialog(this); + if (value != JalviewFileChooser.APPROVE_OPTION) { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString( - "label.select_file_format_before_saving"), - MessageManager - .getString("label.file_format_not_specified"), - JvOptionPane.WARNING_MESSAGE); - currentFileFormat = chooser.getSelectedFormat(); - chooser.showSaveDialog(us); + return; } + } - fileName = chooser.getSelectedFile().getPath(); - - Cache.setProperty("DEFAULT_FILE_FORMAT", - currentFileFormat.getName()); + fileName = chooser.getSelectedFile().getPath(); - Cache.setProperty("LAST_DIRECTORY", fileName); - saveAlignment(fileName, currentFileFormat); - } - }).showSaveDialog(this); + Cache.setProperty("DEFAULT_FILE_FORMAT", currentFileFormat.getName()); + Cache.setProperty("LAST_DIRECTORY", fileName); + saveAlignment(fileName, currentFileFormat); + } } private boolean lastSaveSuccessful = false; diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index a5c2a36..61aa2fc 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -259,7 +259,7 @@ public class GAlignFrame extends JInternalFrame @Override public void actionPerformed(ActionEvent e) { - saveAs_actionPerformed(e); + saveAs_actionPerformed(); } }; @@ -2446,7 +2446,7 @@ public class GAlignFrame extends JInternalFrame { } - protected void saveAs_actionPerformed(ActionEvent e) + protected void saveAs_actionPerformed() { }