import jalview.analysis.AlignmentUtils;
import jalview.analysis.CrossRef;
import jalview.analysis.Dna;
+import jalview.analysis.GeneticCodeI;
import jalview.analysis.ParseProperties;
import jalview.analysis.SequenceIdMatcher;
import jalview.api.AlignExportSettingsI;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
import jalview.io.AlignmentProperties;
import jalview.io.AnnotationFile;
+import jalview.io.BackupFiles;
import jalview.io.BioJsHTMLOutput;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
import jalview.io.TCoffeeScoreFile;
import jalview.io.vcf.VCFLoader;
import jalview.jbgui.GAlignFrame;
+import jalview.project.Jalview2XML;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemes;
import jalview.schemes.ResidueColourScheme;
import java.util.List;
import java.util.Vector;
+import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
Desktop.instance.removeJalviewPropertyChangeListener("services",
thisListener);
closeMenuItem_actionPerformed(true);
- };
+ }
});
// Finally, build the menu once to get current service state
new Thread(new Runnable()
return progressBar.operationInProgress();
}
+ /**
+ * Sets the text of the status bar. Note that setting a null or empty value
+ * will cause the status bar to be hidden, with possibly undesirable flicker
+ * of the screen layout.
+ */
@Override
public void setStatus(String text)
{
- // BH note: If text width and height are 0, then the layout manager
- // will dispense of it and change the frame height.
- // In JavaScript, we use \u00A0 -- unicode "non-breaking space"
- // which is the unicode encoding of
-
statusBar.setText(text == null || text.isEmpty() ? " " : text);
}
*/
public void saveAlignment(String file, FileFormatI format)
{
- lastSaveSuccessful = false;
+ lastSaveSuccessful = true;
lastFilenameSaved = file;
lastFormatSaved = format;
shortName = shortName.substring(
shortName.lastIndexOf(File.separatorChar) + 1);
}
- lastSaveSuccessful = new jalview.project.Jalview2XML().saveAlignment(this, file,
- shortName);
+ lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file, shortName);
statusBar.setText(MessageManager.formatMessage(
"label.successfully_saved_to_file_in_format", new Object[]
}
else
{
+ // create backupfiles object and get new temp filename destination
+ boolean doBackup = BackupFiles.getEnabled();
+ BackupFiles backupfiles = doBackup ? new BackupFiles(file) : null;
try
{
- PrintWriter out = new PrintWriter(new FileWriter(file));
+ String tempFilePath = doBackup ? backupfiles.getTempFilePath() : file;
+ PrintWriter out = new PrintWriter(
+ new FileWriter(tempFilePath));
+
out.print(output);
out.close();
AlignFrame.this.setTitle(file);
- setStatus(MessageManager.formatMessage(
- "label.successfully_saved_to_file_in_format",
- new Object[]
- { fileName, format.getName() }));
+ statusBar.setText(MessageManager.formatMessage(
+ "label.successfully_saved_to_file_in_format", new Object[]
+ { fileName, format.getName() }));
+ lastSaveSuccessful = true;
} catch (Exception ex)
{
lastSaveSuccessful = false;
ex.printStackTrace();
}
+
+ if (doBackup)
+ {
+ backupfiles.setWriteSuccess(lastSaveSuccessful);
+ // do the backup file roll and rename the temp file to actual file
+ lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
+ }
}
}
};
@Override
public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
{
- SequenceGroup sg = new SequenceGroup();
-
- for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
- {
- sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
- }
+ SequenceGroup sg = new SequenceGroup(
+ viewport.getAlignment().getSequences());
sg.setEndRes(viewport.getAlignment().getWidth() - 1);
viewport.setSelectionGroup(sg);
+ viewport.isSelectionGroupChanged(true);
viewport.sendSelection();
// JAL-2034 - should delegate to
// alignPanel to decide if overview needs
newap.av.setRedoList(viewport.getRedoList());
/*
+ * copy any visualisation settings that are not saved in the project
+ */
+ newap.av.setColourAppliesToAllGroups(
+ viewport.getColourAppliesToAllGroups());
+
+ /*
* Views share the same mappings; need to deregister any new mappings
* created by copyAlignPanel, and register the new reference to the shared
* mappings
viewport.setFollowHighlight(state);
if (state)
{
- alignPanel.scrollToPosition(viewport.getSearchResults(), false);
+ alignPanel.scrollToPosition(viewport.getSearchResults());
}
}
viewport.expandColSelection(sg, false);
viewport.hideAllSelectedSeqs();
viewport.hideSelectedColumns();
+ alignPanel.updateLayout();
alignPanel.paintAlignment(true, true);
viewport.sendSelection();
}
public void hideSelColumns_actionPerformed(ActionEvent e)
{
viewport.hideSelectedColumns();
+ alignPanel.updateLayout();
alignPanel.paintAlignment(true, true);
viewport.sendSelection();
}
{
overview.dispose();
alignPanel.setOverviewPanel(null);
- };
+ }
});
if (getKeyListeners().length > 0)
{
* otherwise set the chosen colour scheme (or null for 'None')
*/
ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name,
+ viewport,
viewport.getAlignment(), viewport.getHiddenRepSequences());
changeColour(cs);
}
* frame's DNA sequences to their aligned protein (amino acid) equivalents.
*/
@Override
- public void showTranslation_actionPerformed(ActionEvent e)
+ public void showTranslation_actionPerformed(GeneticCodeI codeTable)
{
AlignmentI al = null;
try
{
Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true));
- al = dna.translateCdna();
+ al = dna.translateCdna(codeTable);
} catch (Exception ex)
{
jalview.bin.Cache.log.error(
af.setFileFormat(this.currentFileFormat);
final String newTitle = MessageManager
.formatMessage("label.translation_of_params", new Object[]
- { this.getTitle() });
+ { this.getTitle(), codeTable.getId() });
af.setTitle(newTitle);
if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
{
trimrs.setSelected(trimrs.isSelected());
Cache.setProperty(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES,
Boolean.valueOf(trimrs.isSelected()).toString());
- };
+ }
});
rfetch.add(trimrs);
JMenuItem fetchr = new JMenuItem(
{
PaintRefresher.Refresh(this, viewport.getSequenceSetId());
alignPanel.updateAnnotation();
- alignPanel.paintAlignment(true, true);
+ alignPanel.paintAlignment(true,
+ viewport.needToUpdateStructureViews());
}
}
colourMenu.add(textColour);
colourMenu.addSeparator();
- ColourMenuHelper.addMenuItems(colourMenu, this, viewport.getAlignment(),
- false);
+ ButtonGroup bg = ColourMenuHelper.addMenuItems(colourMenu, this,
+ viewport.getAlignment(), false);
+ colourMenu.add(annotationColour);
+ bg.add(annotationColour);
colourMenu.addSeparator();
colourMenu.add(conservationMenuItem);
colourMenu.add(modifyConservation);
colourMenu.add(abovePIDThreshold);
colourMenu.add(modifyPID);
- colourMenu.add(annotationColour);
ColourSchemeI colourScheme = viewport.getGlobalColourScheme();
ColourMenuHelper.setColourSelected(colourMenu, colourScheme);
Cache.setProperty("LAST_DIRECTORY", choice);
SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
new VCFLoader(choice).loadVCF(seqs, us);
- };
+ }
});
chooser.showOpenDialog(null);