From: gmungoc Date: Thu, 26 Jan 2017 11:34:04 +0000 (+0000) Subject: Merge branch 'develop' into features/JAL-2360colourSchemeApplicability X-Git-Tag: Release_2_10_3b1~357^2~10^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=89911f9bb8cd7c981cbeefb0445af265fc2b0d0b;p=jalview.git Merge branch 'develop' into features/JAL-2360colourSchemeApplicability Conflicts: src/jalview/gui/UserDefinedColours.java --- 89911f9bb8cd7c981cbeefb0445af265fc2b0d0b diff --cc src/jalview/gui/UserDefinedColours.java index 012edb6,6b4bd10..5314c5c --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@@ -64,12 -60,6 +64,13 @@@ import javax.swing.event.ChangeListener public class UserDefinedColours extends GUserDefinedColours implements ChangeListener { - private static final Font VERDANA_BOLD_10 = new Font("Verdana", Font.BOLD, 10); ++ private static final Font VERDANA_BOLD_10 = new Font("Verdana", ++ Font.BOLD, 10); + + public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS"; + + private static final String LAST_DIRECTORY = "LAST_DIRECTORY"; + private static final int MY_FRAME_HEIGHT = 420; private static final int MY_FRAME_WIDTH = 810; @@@ -150,7 -142,7 +151,8 @@@ if (oldColourScheme instanceof UserColourScheme) { - schemeName.setText(((UserColourScheme) oldColourScheme).getSchemeName()); - schemeName.setText(((UserColourScheme) oldColourScheme).getName()); ++ schemeName.setText(((UserColourScheme) oldColourScheme) ++ .getSchemeName()); } resetButtonPanel(false); @@@ -389,22 -383,15 +391,22 @@@ } /** - * DOCUMENT ME! + * A helper method to update or make a colour button, whose background colour + * is the associated colour, and text colour a darker shade of the same. If + * the button is already in the list, then its text and margins are updated, + * if not then it is created and added. This method supports toggling between + * case-sensitive and case-insensitive button panels. The case-sensitive + * version has abbreviated button text in order to fit in more buttons. * * @param label - * DOCUMENT ME! - * @param aa - * DOCUMENT ME! + * @param residue + * @param the + * list of buttons + * @param buttonIndex + * the button's position in the list */ - JButton makeButton(String label, String residue, - List buttons, int buttonIndex) - JButton makeButton(String label, String aa, - ArrayList caseSensitiveButtons, int buttonIndex) ++ JButton makeButton(String label, String residue, List buttons, ++ int buttonIndex) { final JButton button; Color col; @@@ -614,42 -605,50 +616,43 @@@ int value = chooser.showOpenDialog(this); - if (value == JalviewFileChooser.APPROVE_OPTION) + if (value != JalviewFileChooser.APPROVE_OPTION) { - File choice = chooser.getSelectedFile(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); - String defaultColours = jalview.bin.Cache.getDefault( - "USER_DEFINED_COLOURS", choice.getPath()); - if (defaultColours.indexOf(choice.getPath()) == -1) - { - defaultColours = defaultColours.concat("|") - .concat(choice.getPath()); - } - - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours); - - UserColourScheme ucs = loadColours(choice.getAbsolutePath()); - Color[] colors = ucs.getColours(); - schemeName.setText(ucs.getName()); + return; + } + File choice = chooser.getSelectedFile(); + Cache.setProperty(LAST_DIRECTORY, choice.getParent()); - UserColourScheme ucs = ColourSchemes.loadColourScheme(choice.getAbsolutePath()); - if (ucs.getLowerCaseColours() != null) - { - caseSensitive.setSelected(true); - lcaseColour.setEnabled(true); - resetButtonPanel(true); - for (int i = 0; i < lowerCaseButtons.size(); i++) - { - JButton button = lowerCaseButtons.get(i); - button.setBackground(ucs.getLowerCaseColours()[i]); - } ++ UserColourScheme ucs = ColourSchemes.loadColourScheme(choice ++ .getAbsolutePath()); + Color[] colors = ucs.getColours(); + schemeName.setText(ucs.getSchemeName()); - } - else + if (ucs.getLowerCaseColours() != null) + { + caseSensitive.setSelected(true); + lcaseColour.setEnabled(true); + resetButtonPanel(true); + for (int i = 0; i < lowerCaseButtons.size(); i++) { - caseSensitive.setSelected(false); - lcaseColour.setEnabled(false); - resetButtonPanel(false); - } - - for (int i = 0; i < upperCaseButtons.size(); i++) - { - JButton button = upperCaseButtons.get(i); - button.setBackground(colors[i]); + JButton button = lowerCaseButtons.get(i); + button.setBackground(ucs.getLowerCaseColours()[i]); } + } + else + { + caseSensitive.setSelected(false); + lcaseColour.setEnabled(false); + resetButtonPanel(false); + } + for (int i = 0; i < upperCaseButtons.size(); i++) + { + JButton button = upperCaseButtons.get(i); + button.setBackground(colors[i]); } + + addNewColourScheme(choice.getPath()); } /** @@@ -711,14 -827,13 +714,13 @@@ { return; } - - userColourSchemes.remove(schemeName.getText()); + ColourSchemes.getInstance().removeColourScheme(name); } - JalviewFileChooser chooser = new JalviewFileChooser( - Cache.getProperty(LAST_DIRECTORY), "jc", + JalviewFileChooser chooser = new JalviewFileChooser("jc", "Jalview User Colours"); - chooser.setFileView(new JalviewFileView()); + JalviewFileView fileView = new JalviewFileView(); + chooser.setFileView(fileView); chooser.setDialogTitle(MessageManager .getString("label.save_colour_scheme")); chooser.setToolTipText(MessageManager.getString("action.save"));