import jalview.io.JalviewFileView;
import jalview.io.JnetAnnotationMaker;
import jalview.io.NewickFile;
-import jalview.io.StructureFile;
import jalview.io.TCoffeeScoreFile;
import jalview.jbgui.GAlignFrame;
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.NucleotideColourScheme;
import jalview.schemes.PIDColourScheme;
import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.RNAHelicesColour;
import jalview.schemes.RNAHelicesColourChooser;
+import jalview.schemes.ResidueColourScheme;
import jalview.schemes.ResidueProperties;
import jalview.schemes.StrandColourScheme;
import jalview.schemes.TCoffeeColourScheme;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
conservationMenuItem.setEnabled(!nucleotide);
modifyConservation.setEnabled(!nucleotide);
showGroupConservation.setEnabled(!nucleotide);
+
+ /*
+ * enable / disable colour schemes
+ * - the old, simple way (based on the nucleotide flag), or
+ * - the new, generic way (interrogate the colour scheme)
+ */
+ AlignmentI al = getViewport().getAlignment();
+ clustalColour.setEnabled(!nucleotide);
+ zappoColour.setEnabled(!nucleotide);
+ taylorColour.setEnabled(!nucleotide);
+ hydrophobicityColour.setEnabled(!nucleotide);
+ helixColour.setEnabled(!nucleotide);
+ strandColour.setEnabled(!nucleotide);
+ turnColour.setEnabled(!nucleotide);
+ // buriedColour.setEnabled(!nucleotide);
+ // TODO make isApplicableTo static in ColourSchemeI in Java 8
+ buriedColour.setEnabled(new BuriedColourScheme().isApplicableTo(al));
rnahelicesColour.setEnabled(nucleotide);
- purinePyrimidineColour.setEnabled(nucleotide);
+ nucleotideColour.setEnabled(nucleotide);
+ // purinePyrimidineColour.setEnabled(nucleotide);
+ purinePyrimidineColour.setEnabled(new PurinePyrimidineColourScheme()
+ .isApplicableTo(al));
+ tcoffeeColour
+ .setEnabled(new TCoffeeColourScheme(al).isApplicableTo(al));
+ RNAInteractionColour.setEnabled(nucleotide);
showComplementMenuItem.setText(nucleotide ? MessageManager
.getString("label.protein") : MessageManager
.getString("label.nucleotide"));
- setColourSelected(jalview.bin.Cache.getDefault(
+
+ String selectedColourScheme = Cache.getDefault(
nucleotide ? Preferences.DEFAULT_COLOUR_NUC
- : Preferences.DEFAULT_COLOUR_PROT, "None"));
+ : Preferences.DEFAULT_COLOUR_PROT,
+ ResidueColourScheme.NONE);
+ setColourSelected(selectedColourScheme);
}
/**
autoCalculate.setSelected(av.autoCalculateConsensus);
sortByTree.setSelected(av.sortByTree);
listenToViewSelections.setSelected(av.followSelection);
- rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
+ // rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
+ rnahelicesColour.setEnabled(new RNAHelicesColour(av.getAlignment())
+ .isApplicableTo(av.getAlignment()));
rnahelicesColour
.setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
@Override
public void saveAs_actionPerformed(ActionEvent e)
{
+ String format = currentFileFormat == null ? null : currentFileFormat
+ .toString();
JalviewFileChooser chooser = JalviewFileChooser.forWrite(
- Cache.getProperty("LAST_DIRECTORY"),
- // AppletFormatAdapter.WRITABLE_EXTENSIONS,
- // AppletFormatAdapter.WRITABLE_FNAMES,
- currentFileFormat.toString(), false);
+ Cache.getProperty("LAST_DIRECTORY"), format);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
currentFileFormat = chooser.getSelectedFormat();
while (currentFileFormat == null)
{
- JOptionPane
+ JvOptionPane
.showInternalMessageDialog(
Desktop.desktop,
MessageManager
.getString("label.select_file_format_before_saving"),
MessageManager
.getString("label.file_format_not_specified"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
currentFileFormat = chooser.getSelectedFormat();
value = chooser.showSaveDialog(this);
if (value != JalviewFileChooser.APPROVE_OPTION)
if (!success)
{
- JOptionPane.showInternalMessageDialog(this, MessageManager
+ JvOptionPane.showInternalMessageDialog(this, MessageManager
.formatMessage("label.couldnt_save_file",
new Object[] { fileName }), MessageManager
.getString("label.error_saving_file"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
}
return success;
}
else
{
- JOptionPane.showInternalMessageDialog(this, warning, title,
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.showInternalMessageDialog(this, warning, title,
+ JvOptionPane.WARNING_MESSAGE);
}
return;
}
.getAlignment().getWidth()) ? true : false;
if (isEntireAlignWidth)
{
- int confirm = JOptionPane.showConfirmDialog(this,
+ int confirm = JvOptionPane.showConfirmDialog(this,
MessageManager.getString("warn.delete_all"), // $NON-NLS-1$
MessageManager.getString("label.delete_all"), // $NON-NLS-1$
- JOptionPane.OK_CANCEL_OPTION);
+ JvOptionPane.OK_CANCEL_OPTION);
- if (confirm == JOptionPane.CANCEL_OPTION
- || confirm == JOptionPane.CLOSED_OPTION)
+ if (confirm == JvOptionPane.CANCEL_OPTION
+ || confirm == JvOptionPane.CLOSED_OPTION)
{
return;
}
}
@Override
- public void textColour_actionPerformed(ActionEvent e)
+ public void textColour_actionPerformed()
{
new TextColourChooser().chooseColour(alignPanel, null);
}
* DOCUMENT ME!
*/
@Override
- protected void noColourmenuItem_actionPerformed(ActionEvent e)
+ protected void noColourmenuItem_actionPerformed()
{
changeColour(null);
}
* DOCUMENT ME!
*/
@Override
- public void clustalColour_actionPerformed(ActionEvent e)
+ public void clustalColour_actionPerformed()
{
changeColour(new ClustalxColourScheme(viewport.getAlignment(),
viewport.getHiddenRepSequences()));
* DOCUMENT ME!
*/
@Override
- public void zappoColour_actionPerformed(ActionEvent e)
+ public void zappoColour_actionPerformed()
{
changeColour(new ZappoColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void taylorColour_actionPerformed(ActionEvent e)
+ public void taylorColour_actionPerformed()
{
changeColour(new TaylorColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void hydrophobicityColour_actionPerformed(ActionEvent e)
+ public void hydrophobicityColour_actionPerformed()
{
changeColour(new HydrophobicColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void helixColour_actionPerformed(ActionEvent e)
+ public void helixColour_actionPerformed()
{
changeColour(new HelixColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void strandColour_actionPerformed(ActionEvent e)
+ public void strandColour_actionPerformed()
{
changeColour(new StrandColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void turnColour_actionPerformed(ActionEvent e)
+ public void turnColour_actionPerformed()
{
changeColour(new TurnColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void buriedColour_actionPerformed(ActionEvent e)
+ public void buriedColour_actionPerformed()
{
changeColour(new BuriedColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void nucleotideColour_actionPerformed(ActionEvent e)
+ public void nucleotideColour_actionPerformed()
{
changeColour(new NucleotideColourScheme());
}
@Override
- public void purinePyrimidineColour_actionPerformed(ActionEvent e)
+ public void purinePyrimidineColour_actionPerformed()
{
changeColour(new PurinePyrimidineColourScheme());
}
/*
- * public void covariationColour_actionPerformed(ActionEvent e) {
+ * public void covariationColour_actionPerformed() {
* changeColour(new
* CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
* ()[0])); }
*/
@Override
- public void annotationColour_actionPerformed(ActionEvent e)
+ public void annotationColour_actionPerformed()
{
new AnnotationColourChooser(viewport, alignPanel);
}
}
@Override
- public void rnahelicesColour_actionPerformed(ActionEvent e)
+ public void rnahelicesColour_actionPerformed()
{
new RNAHelicesColourChooser(viewport, alignPanel);
}
/**
* DOCUMENT ME!
*
- * @param e
- * DOCUMENT ME!
*/
@Override
- protected void applyToAllGroups_actionPerformed(ActionEvent e)
+ protected void applyToAllGroups_actionPerformed()
{
viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
}
* DOCUMENT ME!
*/
@Override
- protected void modifyPID_actionPerformed(ActionEvent e)
+ protected void modifyPID_actionPerformed()
{
if (viewport.getAbovePIDThreshold()
&& viewport.getGlobalColourScheme() != null)
* DOCUMENT ME!
*/
@Override
- protected void modifyConservation_actionPerformed(ActionEvent e)
+ protected void modifyConservation_actionPerformed()
{
if (viewport.getConservationSelected()
&& viewport.getGlobalColourScheme() != null)
* DOCUMENT ME!
*/
@Override
- protected void conservationMenuItem_actionPerformed(ActionEvent e)
+ protected void conservationMenuItem_actionPerformed()
{
viewport.setConservationSelected(conservationMenuItem.isSelected());
changeColour(viewport.getGlobalColourScheme());
- modifyConservation_actionPerformed(null);
+ modifyConservation_actionPerformed();
}
/**
* DOCUMENT ME!
*/
@Override
- public void abovePIDThreshold_actionPerformed(ActionEvent e)
+ public void abovePIDThreshold_actionPerformed()
{
viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
changeColour(viewport.getGlobalColourScheme());
- modifyPID_actionPerformed(null);
+ modifyPID_actionPerformed();
}
/**
}
else
{
- UserColourScheme udc = (UserColourScheme) UserDefinedColours
+ UserColourScheme udc = UserDefinedColours
.getUserColourSchemes().get(e.getActionCommand());
changeColour(udc);
}
}
- public void updateUserColourMenu()
- {
-
- Component[] menuItems = colourMenu.getMenuComponents();
- int iSize = menuItems.length;
- for (int i = 0; i < iSize; i++)
- {
- if (menuItems[i].getName() != null
- && menuItems[i].getName().equals("USER_DEFINED"))
- {
- colourMenu.remove(menuItems[i]);
- iSize--;
- }
- }
- if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
- {
- java.util.Enumeration userColours = jalview.gui.UserDefinedColours
- .getUserColourSchemes().keys();
-
- while (userColours.hasMoreElements())
- {
- final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
- userColours.nextElement().toString());
- radioItem.setName("USER_DEFINED");
- radioItem.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mousePressed(MouseEvent evt)
- {
- if (evt.isPopupTrigger()) // Mac
- {
- offerRemoval(radioItem);
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent evt)
- {
- if (evt.isPopupTrigger()) // Windows
- {
- offerRemoval(radioItem);
- }
- }
-
- /**
- * @param radioItem
- */
- void offerRemoval(final JRadioButtonMenuItem radioItem)
- {
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop, MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- colourMenu.remove(radioItem);
- }
- else
- {
- radioItem.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
- }
- });
- }
- }
- });
- radioItem.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
- }
- });
-
- colourMenu.insert(radioItem, 15);
- colours.add(radioItem);
- }
- }
- }
-
/**
* DOCUMENT ME!
*
* DOCUMENT ME!
*/
@Override
- public void PIDColour_actionPerformed(ActionEvent e)
+ public void PIDColour_actionPerformed()
{
changeColour(new PIDColourScheme());
}
* DOCUMENT ME!
*/
@Override
- public void BLOSUM62Colour_actionPerformed(ActionEvent e)
+ public void BLOSUM62Colour_actionPerformed()
{
changeColour(new Blosum62ColourScheme());
}
if ((viewport.getSelectionGroup() == null)
|| (viewport.getSelectionGroup().getSize() < 2))
{
- JOptionPane.showInternalMessageDialog(this, MessageManager
+ JvOptionPane.showInternalMessageDialog(this, MessageManager
.getString("label.you_must_select_least_two_sequences"),
MessageManager.getString("label.invalid_selection"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
}
else
{
.getSelectionGroup().getSize() > 0))
|| (viewport.getAlignment().getHeight() < 4))
{
- JOptionPane
+ JvOptionPane
.showInternalMessageDialog(
this,
MessageManager
.getString("label.principal_component_analysis_must_take_least_four_input_sequences"),
MessageManager
.getString("label.sequence_selection_insufficient"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
return;
}
{
if (viewport.getSelectionGroup().getSize() < 3)
{
- JOptionPane
+ JvOptionPane
.showMessageDialog(
Desktop.desktop,
MessageManager
.getString("label.you_need_more_two_sequences_selected_build_tree"),
MessageManager
.getString("label.not_enough_sequences"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
return;
}
{
if (_s.getLength() < sg.getEndRes())
{
- JOptionPane
+ JvOptionPane
.showMessageDialog(
Desktop.desktop,
MessageManager
.getString("label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
MessageManager
.getString("label.sequences_selection_not_aligned"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
return;
}
// are the visible sequences aligned?
if (!viewport.getAlignment().isAligned(false))
{
- JOptionPane
+ JvOptionPane
.showMessageDialog(
Desktop.desktop,
MessageManager
.getString("label.sequences_must_be_aligned_before_creating_tree"),
MessageManager
.getString("label.sequences_not_aligned"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
return;
}
else if (viewport.getSelectionGroup() != null
&& viewport.getSelectionGroup().getSize() == 1)
{
- int option = JOptionPane.showConfirmDialog(this,
+ int option = JvOptionPane.showConfirmDialog(this,
MessageManager.getString("warn.oneseq_msainput_selection"),
MessageManager.getString("label.invalid_selection"),
- JOptionPane.OK_CANCEL_OPTION);
- if (option == JOptionPane.OK_OPTION)
+ JvOptionPane.OK_CANCEL_OPTION);
+ if (option == JvOptionPane.OK_OPTION)
{
msa = viewport.getAlignmentView(false);
}
viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
} catch (Exception ex)
{
- JOptionPane
+ JvOptionPane
.showMessageDialog(
Desktop.desktop,
ex.getMessage(),
MessageManager
.getString("label.problem_reading_tree_file"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
ex.printStackTrace();
}
if (fin != null && fin.hasWarningMessage())
{
- JOptionPane.showMessageDialog(Desktop.desktop, fin
+ JvOptionPane.showMessageDialog(Desktop.desktop, fin
.getWarningMessage(), MessageManager
.getString("label.possible_problem_with_tree_file"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
}
}
}
@Override
- protected void tcoffeeColorScheme_actionPerformed(ActionEvent e)
+ protected void tcoffeeColorScheme_actionPerformed()
{
changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
}
final String errorTitle = MessageManager
.getString("label.implementation_error")
+ MessageManager.getString("label.translation_failed");
- JOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
- JOptionPane.ERROR_MESSAGE);
+ JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
+ JvOptionPane.ERROR_MESSAGE);
return;
}
if (al == null || al.getHeight() == 0)
.getString("label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
final String errorTitle = MessageManager
.getString("label.translation_failed");
- JOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
+ JvOptionPane.WARNING_MESSAGE);
}
else
{
{
type = null;
}
- if (type != null)
+ if (type != null && type.isStructureFile())
{
- if (FileFormat.PDB.equals(type) || FileFormat.MMCif.equals(type))
- {
- filesmatched.add(new Object[] { file, protocol, mtch });
- continue;
- }
+ filesmatched.add(new Object[] { file, protocol, mtch });
+ continue;
}
}
// File wasn't named like one of the sequences or wasn't a PDB file.
if (filesmatched.size() > 0)
{
if (Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false)
- || JOptionPane
+ || JvOptionPane
.showConfirmDialog(
this,
MessageManager
.toString() }),
MessageManager
.getString("label.automatically_associate_structure_files_by_name"),
- JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
+ JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION)
{
for (Object[] fm : filesmatched)
{
if (assocfiles > 0
&& (Cache.getDefault(
- "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane
+ "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JvOptionPane
.showConfirmDialog(
this,
"<html>"
+ "</html>",
MessageManager
.getString("label.ignore_unmatched_dropped_files"),
- JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION))
+ JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION))
{
return;
}
{
// some problem - if no warning its probable that the ID matching
// process didn't work
- JOptionPane
+ JvOptionPane
.showMessageDialog(
Desktop.desktop,
tcf.getWarningMessage() == null ? MessageManager
: tcf.getWarningMessage(),
MessageManager
.getString("label.problem_reading_tcoffee_score_file"),
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.WARNING_MESSAGE);
}
}
else
if (e.isPopupTrigger())
{
String msg = MessageManager.getString("label.enter_view_name");
- String reply = JOptionPane.showInternalInputDialog(this, msg, msg,
- JOptionPane.QUESTION_MESSAGE);
+ String reply = JvOptionPane.showInternalInputDialog(this, msg, msg,
+ JvOptionPane.QUESTION_MESSAGE);
if (reply != null)
{
}
AlignmentI cdna = new Alignment(cdnaSeqs.toArray(new SequenceI[cdnaSeqs
.size()]));
- AlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
+ GAlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
cdna.alignAs(alignment);
String newtitle = "cDNA " + MessageManager.getString("label.for") + " "
} catch (Exception ex)
{
System.err.println((ex.toString()));
- JOptionPane
+ JvOptionPane
.showInternalMessageDialog(Desktop.desktop, MessageManager
.getString("label.couldnt_run_groovy_script"),
MessageManager
.getString("label.groovy_support_failed"),
- JOptionPane.ERROR_MESSAGE);
+ JvOptionPane.ERROR_MESSAGE);
}
}
else