From: darolmar Date: Fri, 10 Oct 2014 06:35:44 +0000 (+0200) Subject: JAL-1420 X-Git-Tag: Release_2_8_2b1^2~40 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9f9ebe83d2906c9bcb553f86dad16a6cf1be4da8;p=jalview.git JAL-1420 --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 47755f3..0a7a0d7 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1130,4 +1130,6 @@ label.show_group_logo = Show Group Logo label.normalise_group_logo = Normalise Group Logo label.show_histogram = Show Histogram label.show_logo = Show Logo -label.normalise_logo = Normalise Logo \ No newline at end of file +label.normalise_logo = Normalise Logo +label.no_colour_selection_in_scheme = Please, make a colour selection before to apply colour scheme +label.no_colour_selection_warn = Error saving colour scheme \ No newline at end of file diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 7bf2e6c..37824fe 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -454,14 +454,26 @@ public class UserDefinedColours extends GUserDefinedColours implements @Override protected void okButton_actionPerformed(ActionEvent e) { - applyButton_actionPerformed(null); - - try - { - frame.setClosed(true); - } catch (Exception ex) - { - } + //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) + { + } + } } /** @@ -473,7 +485,18 @@ public class UserDefinedColours extends GUserDefinedColours implements @Override protected void applyButton_actionPerformed(ActionEvent e) { - UserColourScheme ucs = getSchemeFromButtons(); + //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); + + } + UserColourScheme ucs = getSchemeFromButtons(); ucs.setName(schemeName.getText()); if (seqGroup != null) @@ -496,10 +519,18 @@ public class UserDefinedColours extends GUserDefinedColours implements Color[] newColours = new Color[24]; - for (int i = 0; i < 24; i++) - { - JButton button = upperCaseButtons.get(i); - newColours[i] = button.getBackground(); + int length = upperCaseButtons.size(); + if (length<24){ + int i = 0; + for (JButton btn:upperCaseButtons){ + newColours[i] = btn.getBackground(); + i++; + } + }else{ + for (int i = 0; i < 24; i++){ + JButton button = (JButton) upperCaseButtons.get(i); + newColours[i] = button.getBackground(); + } } UserColourScheme ucs = new UserColourScheme(newColours); @@ -507,10 +538,18 @@ public class UserDefinedColours extends GUserDefinedColours implements if (caseSensitive.isSelected()) { newColours = new Color[23]; - for (int i = 0; i < 23; i++) - { - JButton button = lowerCaseButtons.get(i); - newColours[i] = button.getBackground(); + length = lowerCaseButtons.size(); + if (length<23){ + int i = 0; + for (JButton btn:lowerCaseButtons){ + newColours[i] = btn.getBackground(); + i++; + } + }else{ + for (int i = 0; i < 23; i++){ + JButton button = (JButton) lowerCaseButtons.get(i); + newColours[i] = button.getBackground(); + } } ucs.setLowerCaseColours(newColours); }