*/
package jalview.gui;
-import jalview.api.structures.JalviewStructureDisplayI;
-import jalview.datamodel.SequenceGroup;
-import jalview.io.JalviewFileChooser;
-import jalview.jbgui.GUserDefinedColours;
-import jalview.schemes.ColourSchemeI;
-import jalview.schemes.ResidueProperties;
-import jalview.schemes.UserColourScheme;
-import jalview.util.ColorUtils;
-import jalview.util.MessageManager;
-
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.datamodel.SequenceGroup;
+import jalview.io.JalviewFileChooser;
+import jalview.jbgui.GUserDefinedColours;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ResidueProperties;
+import jalview.schemes.UserColourScheme;
+import jalview.util.ColorUtils;
+import jalview.util.MessageManager;
+
/**
* This panel allows the user to assign colours to Amino Acid residue codes, and
* save the colour scheme.
@Override
protected void okButton_actionPerformed(ActionEvent e)
{
- //Check if the user have done any selection
- boolean showWarning = (upperCaseButtons==null) ||
- ((upperCaseButtons!=null) && (upperCaseButtons.size()==0)) ||
- (lowerCaseButtons==null) ||
- ((lowerCaseButtons!=null) && (lowerCaseButtons.size()==0));
- if (showWarning){
- JOptionPane.showMessageDialog(Desktop.desktop,
- MessageManager.getString("label.no_colour_selection_in_scheme"),MessageManager.getString("label.no_colour_selection_warn"),
- JOptionPane.WARNING_MESSAGE);
-
- }else{
- applyButton_actionPerformed(null);
-
- try
- {
- frame.setClosed(true);
- } catch (Exception ex)
- {
- }
- }
+ if (isNoSelectionMade())
+ {
+ JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+ .getString("label.no_colour_selection_in_scheme"),
+ MessageManager.getString("label.no_colour_selection_warn"),
+ JOptionPane.WARNING_MESSAGE);
+ }
+ else
+ {
+ applyButton_actionPerformed(null);
+
+ try
+ {
+ frame.setClosed(true);
+ } catch (Exception ex)
+ {
+ }
+ }
+ }
+
+ /**
+ * Returns true if the user has not made any colour selection (including if
+ * 'case-sensitive' selected and no lower-case colour chosen).
+ *
+ * @return
+ */
+ protected boolean isNoSelectionMade()
+ {
+ final boolean noUpperCaseSelected = upperCaseButtons == null
+ || upperCaseButtons.isEmpty();
+ final boolean noLowerCaseSelected = caseSensitive.isSelected()
+ && (lowerCaseButtons == null || lowerCaseButtons.isEmpty());
+ final boolean noSelectionMade = noUpperCaseSelected || noLowerCaseSelected;
+ return noSelectionMade;
}
/**
@Override
protected void applyButton_actionPerformed(ActionEvent e)
{
- //Check if the user have done any selection
- boolean showWarning = (upperCaseButtons==null) ||
- ((upperCaseButtons!=null) && (upperCaseButtons.size()==0)) ||
- (lowerCaseButtons==null) ||
- ((lowerCaseButtons!=null) && (lowerCaseButtons.size()==0));
- if (showWarning){
+ if (isNoSelectionMade())
+ {
JOptionPane.showMessageDialog(Desktop.desktop,
MessageManager.getString("label.no_colour_selection_in_scheme"),MessageManager.getString("label.no_colour_selection_warn"),
JOptionPane.WARNING_MESSAGE);
name = jucs.getColour(i).getName();
if (ResidueProperties.aa3Hash.containsKey(name))
{
- index = ((Integer) ResidueProperties.aa3Hash.get(name))
+ index = ResidueProperties.aa3Hash.get(name)
.intValue();
}
else