From: hansonr Date: Fri, 17 May 2019 12:22:49 +0000 (-0500) Subject: Jalview-JS/JAL-3253-applet additional static final preferences X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2b08c849bd54a0799ddf251f602a421d4696005e;p=jalview.git Jalview-JS/JAL-3253-applet additional static final preferences Consolidates UserDefinedColours.USER_DEFINED_COLOURS and Preferences.USER_DEFINED_COLOURS --- diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index c95b507..2d33478 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -22,7 +22,7 @@ package jalview.bin; import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; import jalview.datamodel.PDBEntry; -import jalview.gui.UserDefinedColours; +import jalview.gui.Preferences; import jalview.schemes.ColourSchemeLoader; import jalview.schemes.ColourSchemes; import jalview.schemes.UserColourScheme; @@ -598,7 +598,7 @@ public class Cache implements ApplicationSingletonI setProperty("VERSION", codeVersion); // LOAD USERDEFINED COLOURS - initUserColourSchemes(getProperty("USER_DEFINED_COLOURS")); + initUserColourSchemes(getProperty(Preferences.USER_DEFINED_COLOURS)); } private void deleteBuildProperties() @@ -1137,13 +1137,13 @@ public class Cache implements ApplicationSingletonI { if (coloursFound.toString().length() > 1) { - setProperty(UserDefinedColours.USER_DEFINED_COLOURS, + setProperty(Preferences.USER_DEFINED_COLOURS, coloursFound.toString()); } else { getInstance().applicationProperties - .remove(UserDefinedColours.USER_DEFINED_COLOURS); + .remove(Preferences.USER_DEFINED_COLOURS); } } } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index d716c25..07fd4d6 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -481,7 +481,7 @@ public class Jalview implements ApplicationSingletonI } else { - if (Cache.getProperty("NOQUESTIONNAIRES") == null) + if (Cache.getProperty(Preferences.NOQUESTIONNAIRES) == null) { // Start the desktop questionnaire prompter with the specified // questionnaire diff --git a/src/jalview/gui/ColourMenuHelper.java b/src/jalview/gui/ColourMenuHelper.java index e38b55b..5528e75 100644 --- a/src/jalview/gui/ColourMenuHelper.java +++ b/src/jalview/gui/ColourMenuHelper.java @@ -281,7 +281,7 @@ public class ColourMenuHelper static void updatePreferences() { StringBuilder coloursFound = new StringBuilder(); - String[] files = Cache.getProperty("USER_DEFINED_COLOURS").split("\\|"); + String[] files = Cache.getProperty(Preferences.USER_DEFINED_COLOURS).split("\\|"); /* * the property does not include the scheme name, it is in the file; @@ -310,11 +310,11 @@ public class ColourMenuHelper if (coloursFound.toString().length() > 1) { - Cache.setProperty("USER_DEFINED_COLOURS", coloursFound.toString()); + Cache.setProperty(Preferences.USER_DEFINED_COLOURS, coloursFound.toString()); } else { - Cache.removePropertyNoSave("USER_DEFINED_COLOURS"); + Cache.removePropertyNoSave(Preferences.USER_DEFINED_COLOURS); } } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 62c1239..e80b28b 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -84,6 +84,11 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager; @SuppressWarnings("serial") public class Preferences extends GPreferences { + + public static final String NOQUESTIONNAIRES = "NOQUESTIONNAIRES"; + + public static final String QUESTIONNAIRE = "QUESTIONNAIRE"; + public static final String ANNOTATIONCOLOUR_MAX = "ANNOTATIONCOLOUR_MAX"; public static final String ANNOTATIONCOLOUR_MIN = "ANNOTATIONCOLOUR_MIN"; @@ -148,6 +153,8 @@ public class Preferences extends GPreferences public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START"; + public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS"; + public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP"; public static final String GAP_COLOUR = "GAP_COLOUR"; @@ -176,6 +183,7 @@ public class Preferences extends GPreferences public static final List groupURLLinks; // not implemented + static { // get links selected to be in the menu (SEQUENCE_LINKS) @@ -541,7 +549,7 @@ public class Preferences extends GPreferences usagestats.setSelected(Cache.getDefault("USAGESTATS", false)); // note antisense here: default is true questionnaire - .setSelected(Cache.getProperty("NOQUESTIONNAIRES") == null); + .setSelected(Cache.getProperty(NOQUESTIONNAIRES) == null); versioncheck.setSelected(Cache.getDefault("VERSION_CHECK", true)); /* @@ -824,13 +832,13 @@ public class Preferences extends GPreferences } if (!questionnaire.isSelected()) { - Cache.setProperty("NOQUESTIONNAIRES", "true"); + Cache.setProperty(NOQUESTIONNAIRES, "true"); } else { // special - made easy to edit a property file to disable questionnaires // by just adding the given line - Cache.removeProperty("NOQUESTIONNAIRES"); + Cache.removeProperty(NOQUESTIONNAIRES); } /* diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 2f18f43..6e3a68b 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -69,8 +69,6 @@ public class UserDefinedColours extends GUserDefinedColours 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 = 440; @@ -694,7 +692,7 @@ public class UserDefinedColours extends GUserDefinedColours /** * Loads the user-defined colour scheme from the first file listed in property - * "USER_DEFINED_COLOURS". If this fails, returns an all-white colour scheme. + * Preferences.USER_DEFINED_COLOURS. If this fails, returns an all-white colour scheme. * * @return */ @@ -702,7 +700,7 @@ public class UserDefinedColours extends GUserDefinedColours { UserColourScheme ret = null; - String colours = Cache.getProperty(USER_DEFINED_COLOURS); + String colours = Cache.getProperty(Preferences.USER_DEFINED_COLOURS); if (colours != null) { if (colours.indexOf("|") > -1) @@ -814,7 +812,8 @@ public class UserDefinedColours extends GUserDefinedColours * update the delimited list of user defined colour files in * Jalview property USER_DEFINED_COLOURS */ - String defaultColours = Cache.getDefault(USER_DEFINED_COLOURS, + String defaultColours = Cache.getDefault( + Preferences.USER_DEFINED_COLOURS, filePath); if (defaultColours.indexOf(filePath) == -1) { @@ -824,7 +823,7 @@ public class UserDefinedColours extends GUserDefinedColours } defaultColours = defaultColours.concat(filePath); } - Cache.setProperty(USER_DEFINED_COLOURS, defaultColours); + Cache.setProperty(Preferences.USER_DEFINED_COLOURS, defaultColours); /* * construct and register the colour scheme diff --git a/src/jalview/gui/UserQuestionnaireCheck.java b/src/jalview/gui/UserQuestionnaireCheck.java index 156f072..df64db0 100644 --- a/src/jalview/gui/UserQuestionnaireCheck.java +++ b/src/jalview/gui/UserQuestionnaireCheck.java @@ -101,7 +101,7 @@ public class UserQuestionnaireCheck implements Runnable try { // First - check to see if wee have an old questionnaire/response id pair. - String lastq = jalview.bin.Cache.getProperty("QUESTIONNAIRE"); + String lastq = jalview.bin.Cache.getProperty(Preferences.QUESTIONNAIRE); if (lastq == null) { prompt = checkresponse(new URL(url @@ -133,7 +133,7 @@ public class UserQuestionnaireCheck implements Runnable if (qid != null && rid != null) { // Update our local property cache with latest qid and rid - jalview.bin.Cache.setProperty("QUESTIONNAIRE", qid + ":" + rid); + jalview.bin.Cache.setProperty(Preferences.QUESTIONNAIRE, qid + ":" + rid); } if (prompt) { diff --git a/src/jalview/gui/WsParamSetManager.java b/src/jalview/gui/WsParamSetManager.java index 0f315eb..0bfbb43 100644 --- a/src/jalview/gui/WsParamSetManager.java +++ b/src/jalview/gui/WsParamSetManager.java @@ -274,7 +274,7 @@ public class WsParamSetManager implements ParamManager * 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 + * Preferences.USER_DEFINED_COLOURS, choice.getPath()); if * (defaultColours.indexOf(choice.getPath()) == -1) { defaultColours = * defaultColours.concat("|") .concat(choice.getPath()); } (non-Javadoc) *