+ if (doBackup)
+ {
+ backupfiles.setWriteSuccess(lastSaveSuccessful);
+ Console.debug("ALIGNFRAME writing temp file was "
+ + (lastSaveSuccessful ? "" : "NOT ") + "successful");
+ // do the backup file roll and rename the temp file to actual file
+ Console.trace("ALIGNFRAME about to rollBackupsAndRenameTempFile");
+ lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
+ Console.debug("ALIGNFRAME performed rollBackupsAndRenameTempFile "
+ + (lastSaveSuccessful ? "" : "un") + "successfully");
+ }
+
+ Console.debug("lastSaveSuccessful=" + lastSaveSuccessful);
+ if (lastSaveSuccessful)
+ {
+ AlignFrame.this.getViewport().setSavedUpToDate(true);
+ }
+ }
+ };
+
+ /*
+ * show dialog with export options if applicable; else just do it
+ */
+ if (AlignExportOptions.isNeeded(viewport, format))
+ {
+ AlignExportOptions choices = new AlignExportOptions(
+ alignPanel.getAlignViewport(), format, options);
+ choices.setResponseAction(0, outputAction);
+ choices.setResponseAction(1, cancelAction);
+ choices.showDialog();
+ }
+ else
+ {
+ try
+ {
+ outputAction.run();
+ } catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Outputs the alignment to textbox in the requested format, if necessary
+ * first prompting the user for whether to include hidden regions or
+ * non-sequence data
+ *
+ * @param fileFormatName
+ */
+ @Override
+ protected void outputText_actionPerformed(String fileFormatName)
+ {
+ FileFormatI fileFormat = FileFormats.getInstance()
+ .forName(fileFormatName);
+ AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
+ Runnable outputAction = () -> {
+ // todo defer this to inside formatSequences (or later)
+ AlignmentExportData exportData = viewport.getAlignExportData(options);
+ CutAndPasteTransfer cap = new CutAndPasteTransfer();
+ cap.setForInput(null);
+ try
+ {
+ FileFormatI format = fileFormat;
+ cap.setText(new FormatAdapter(alignPanel, options).formatSequences(
+ format, exportData.getAlignment(),
+ exportData.getOmitHidden(),
+ exportData.getStartEndPostions(),
+ viewport.getAlignment().getHiddenColumns()));
+ Desktop.addInternalFrame(cap, MessageManager.formatMessage(
+ "label.alignment_output_command", new Object[]
+ { fileFormat.getName() }), 600, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("Outputting alignment as " + fileFormat.getName(),
+ oom);
+ cap.dispose();
+ }
+ };
+
+ /*
+ * show dialog with export options if applicable; else just do it
+ */
+ if (AlignExportOptions.isNeeded(viewport, fileFormat))
+ {
+ AlignExportOptions choices = new AlignExportOptions(
+ alignPanel.getAlignViewport(), fileFormat, options);
+ choices.setResponseAction(0, outputAction);
+ choices.showDialog();
+ }
+ else
+ {
+ try
+ {
+ outputAction.run();
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }