From f509321134ee9a709fc0bbdfc9dcf845d10cdca6 Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Thu, 27 Feb 2014 16:12:21 -0600 Subject: [PATCH] Issue #2861 Rewrote HierarchicalPreferenceStore to be more efficient and thread safe when reading values. Amend: Added comments and cleaned up preference store Change-Id: Iac708c0988fc1b8f552d3bccf76b1706d6324b8d Former-commit-id: a01a6d68d07c2a7a834127da518f16bf56fe8326 [formerly a01a6d68d07c2a7a834127da518f16bf56fe8326 [formerly cc34e3dbebe13ec4f63b7529f5053391135837ef]] Former-commit-id: cbf8b9249c0bcd9d6eac42e862ff975fee7f9ac7 Former-commit-id: 654da3c0a28f4e8cf2d3f9139cfcd5862d2191fa --- .../raytheon/uf/viz/alertviz/Activator.java | 33 +- .../uf/viz/collaboration/ui/Activator.java | 46 +- .../META-INF/MANIFEST.MF | 2 +- .../com/raytheon/uf/viz/core/Activator.java | 22 +- .../localization/CAVELocalizationAdapter.java | 2 +- .../HierarchicalPreferenceStore.java | 1390 ++++++++--------- .../com/raytheon/uf/viz/d2d/ui/Activator.java | 34 +- .../viz/gisdatastore/directory/Activator.java | 23 +- .../uf/viz/gisdatastore/Activator.java | 23 +- .../uf/viz/monitor/scan/Activator.java | 31 +- .../raytheon/uf/viz/monitor/Activator.java | 33 +- .../uf/viz/radarapps/activator/Activator.java | 20 +- .../raytheon/uf/viz/thinclient/Activator.java | 18 +- .../src/com/raytheon/uf/viz/xy/Activator.java | 35 +- .../viz/aviation/activator/Activator.java | 18 +- .../com/raytheon/viz/avnconfig/Activator.java | 33 +- .../com/raytheon/viz/core/gl/Activator.java | 30 +- .../src/com/raytheon/viz/core/CorePlugin.java | 21 +- .../src/com/raytheon/viz/radar/Activator.java | 31 +- .../src/com/raytheon/viz/ui/UiPlugin.java | 19 +- .../com/raytheon/viz/warngen/Activator.java | 18 +- .../raytheon/monitor/activator/Activator.java | 31 +- .../nws/ncep/viz/rsc/ncradar/Activator.java | 31 +- 23 files changed, 872 insertions(+), 1072 deletions(-) diff --git a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Activator.java b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Activator.java index 7b3ae8070c..98910de897 100644 --- a/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Activator.java +++ b/cave/com.raytheon.uf.viz.alertviz/src/com/raytheon/uf/viz/alertviz/Activator.java @@ -22,24 +22,36 @@ package com.raytheon.uf.viz.alertviz; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { - private HierarchicalPreferenceStore prefs; - // The plug-in ID public static final String PLUGIN_ID = "com.raytheon.uf.viz.alertviz"; // The shared instance private static Activator plugin; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); + /** * The constructor */ @@ -86,17 +98,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java index e5e6039f46..bad07eb095 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java @@ -25,10 +25,8 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.jivesoftware.smack.packet.Presence.Mode; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; @@ -109,36 +107,26 @@ public class Activator extends AbstractUIPlugin { @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - prefs.setDefault(CollabPrefConstants.P_SERVER, ""); - prefs.setDefault(CollabPrefConstants.AUTO_JOIN, true); + if (prefs == null) { + prefs = new HierarchicalPreferenceStore(this); + prefs.setDefault(CollabPrefConstants.P_SERVER, ""); + prefs.setDefault(CollabPrefConstants.AUTO_JOIN, true); - // TODO better default? - prefs.setDefault(CollabPrefConstants.P_USERNAME, - System.getProperty("user.name")); + // TODO better default? + prefs.setDefault(CollabPrefConstants.P_USERNAME, + System.getProperty("user.name")); - prefs.setDefault(CollabPrefConstants.P_STATUS, - Mode.available.toString()); - prefs.setDefault(CollabPrefConstants.P_MESSAGE, ""); - prefs.setDefault(CollabPrefConstants.AWAY_ON_IDLE, true); - prefs.setDefault(CollabPrefConstants.AWAY_TIMEOUT, - CollabPrefConstants.AWAY_TIMEOUT_DEFAULT); - prefs.setDefault(CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE, - false); - prefs.setDefault(CollabPrefConstants.DEFAULT_HANDLE, - CollabPrefConstants.HandleOption.USERNAME.name()); - prefs.setDefault(CollabPrefConstants.CUSTOM_HANDLE, ""); - } - - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); + prefs.setDefault(CollabPrefConstants.P_STATUS, + Mode.available.toString()); + prefs.setDefault(CollabPrefConstants.P_MESSAGE, ""); + prefs.setDefault(CollabPrefConstants.AWAY_ON_IDLE, true); + prefs.setDefault(CollabPrefConstants.AWAY_TIMEOUT, + CollabPrefConstants.AWAY_TIMEOUT_DEFAULT); + prefs.setDefault(CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE, false); + prefs.setDefault(CollabPrefConstants.DEFAULT_HANDLE, + CollabPrefConstants.HandleOption.USERNAME.name()); + prefs.setDefault(CollabPrefConstants.CUSTOM_HANDLE, ""); } - return prefs; } diff --git a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF index d5ef0fca12..ad13b27526 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Viz Core Plug-in Bundle-SymbolicName: com.raytheon.uf.viz.core;singleton:=true -Bundle-Version: 1.14.1.qualifier +Bundle-Version: 1.14.2.qualifier Bundle-Activator: com.raytheon.uf.viz.core.Activator Bundle-Vendor: Raytheon Require-Bundle: org.eclipse.ui, diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/Activator.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/Activator.java index 4660af7d0f..a9d471b54e 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/Activator.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/Activator.java @@ -26,9 +26,6 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.services.IDisposable; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -38,8 +35,9 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * chammack Initial Creation. - * Mar 5, 2013 1753 njensen Added printout to stop() + * chammack Initial Creation. + * Mar 5, 2013 1753 njensen Added printout to stop() + * Mar 3, 2014 2861 mschenke Create preference store immediately * * * @@ -54,7 +52,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private HierarchicalPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); private BundleContext ctx; @@ -116,17 +115,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/CAVELocalizationAdapter.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/CAVELocalizationAdapter.java index 16dbfe73ad..4739a98450 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/CAVELocalizationAdapter.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/CAVELocalizationAdapter.java @@ -141,7 +141,7 @@ public class CAVELocalizationAdapter implements ILocalizationAdapter { if (file.exists()) { return file; } else { - File bundleFile = null; + File bundleFile = file; // Default to base location boolean containsKey = false; synchronized (caveStaticBaseFiles) { containsKey = caveStaticBaseFiles.containsKey(fileName); diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/HierarchicalPreferenceStore.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/HierarchicalPreferenceStore.java index f3d06b4e11..66eaef9509 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/HierarchicalPreferenceStore.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/HierarchicalPreferenceStore.java @@ -20,58 +20,51 @@ package com.raytheon.uf.viz.core.localization; -import java.io.File; import java.io.IOException; -import java.io.PrintWriter; +import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; -import java.util.NoSuchElementException; +import java.util.Map; +import java.util.Set; -import org.apache.commons.configuration.CombinedConfiguration; -import org.apache.commons.configuration.ConversionException; +import javax.measure.converter.ConversionException; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.MapConfiguration; import org.apache.commons.configuration.XMLConfiguration; -import org.apache.commons.configuration.tree.OverrideCombiner; +import org.eclipse.core.runtime.Plugin; import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import com.raytheon.uf.common.localization.FileLocker; -import com.raytheon.uf.common.localization.FileLocker.Type; import com.raytheon.uf.common.localization.FileUpdatedMessage; import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.LocalizationFileOutputStream; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.viz.core.exception.VizException; /** * Defines a hierarchical preference store, backed by Apache Commons - * configurator. - * - *
- *

- * Three scopes are defined, in order of increasing precedence: - *

- * - *
- *
- * + * configurator. A config.xml file is expected in the CAVE_STATIC hierarchy for + * the bundleId the store is created with. The config.xml file must conform to + * the Apache {@link XMLConfiguration} format. This preference store is + * hierarchical in that it will search for preferences based on the localization + * search hierarchy * *
  * SOFTWARE HISTORY
@@ -80,6 +73,8 @@ import com.raytheon.uf.viz.core.exception.VizException;
  * Apr 16, 2007            chammack    Initial Creation.
  * Feb 5, 2008             chammack    Add API to support set/remove at any tier 
  *                                     and support for listeners
+ * Feb 27, 2014 2861       mschenke    Rewrote to add thread safety and handle
+ *                                     all LocalizationLevels
  * 
  * 
* @@ -90,25 +85,99 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(HierarchicalPreferenceStore.class, "CAVE"); - public static enum Level { - USER, SITE, BASE, COMBINED - }; + private static class LocalizationConfiguration { - private CombinedConfiguration combinedConfiguration; + private final LocalizationFile file; - private CombinedConfiguration localConfiguration; + private XMLConfiguration config; - private LocalizationFile userFile; + private boolean loaded = false; - private XMLConfiguration userConfiguration; + private boolean dirty = false; - private XMLConfiguration baseConfiguration; + public LocalizationConfiguration(LocalizationFile file) { + this.file = file; + this.config = new XMLConfiguration(); + } - private XMLConfiguration siteConfiguration; + public XMLConfiguration accessConfiguration() { + if (loaded == false) { + // Loaded flag is used for first access + loaded = true; + try { + reload(); + } catch (LocalizationException e) { + statusHandler.handle(Priority.PROBLEM, + e.getLocalizedMessage(), e); + } + } + return config; + } - private final List propertyChangeListeners; + public void markDirty() { + dirty = true; + } - private boolean isDirty; + public boolean isDirty() { + return dirty; + } + + public LocalizationFile getFile() { + return file; + } + + public void save() throws LocalizationException { + if (isDirty()) { + LocalizationFileOutputStream out = file.openOutputStream(); + try { + try { + config.save(out); + out.closeAndSave(); + dirty = false; + } catch (ConfigurationException e) { + out.close(); + throw new LocalizationException( + "Error saving config.xml into localization", e); + } + } catch (IOException e) { + // Ignore close exception + } + } + } + + public void reload() throws LocalizationException { + if (file.exists()) { + InputStream in = file.openInputStream(); + try { + XMLConfiguration newConfig = new XMLConfiguration(); + newConfig.load(in); + this.config = newConfig; + } catch (ConfigurationException e) { + throw new LocalizationException( + "Error loading localization file into config", e); + } finally { + try { + in.close(); + } catch (IOException e) { + // Ignore close exception + } + } + } + } + + } + + private static final LocalizationLevel COMBINED = null; + + private final String configFilePath; + + private final LocalizationLevel defaultPersistLevel; + + private final Map configMap = new HashMap(); + + private MapConfiguration defaults; + + private final Set propertyChangeListeners = new LinkedHashSet(); public static String EMPTY_CONFIGURATION = "\n" + "\n" + "\n"; @@ -117,166 +186,158 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * Constructor * * @param activator - * @throws VizException */ - public HierarchicalPreferenceStore(AbstractUIPlugin activator) - throws LocalizationException { - this.propertyChangeListeners = new ArrayList(); - initialize(activator.getBundle().getSymbolicName(), false); - } - - private void initialize(final String context, boolean reload) - throws LocalizationException { - LocalizationFile baseLocFile = null, siteLocFile = null; - CombinedConfiguration oldCombConfiguration = this.combinedConfiguration; - - try { - IPathManager pm = PathManagerFactory.getPathManager(); - - LocalizationContext userCtx = pm.getContext( - LocalizationType.CAVE_CONFIG, LocalizationLevel.USER); - LocalizationContext siteCtx = pm.getContext( - LocalizationType.CAVE_CONFIG, LocalizationLevel.SITE); - LocalizationContext baseCtx = pm.getContext( - LocalizationType.CAVE_CONFIG, LocalizationLevel.BASE); - - // Get the base file - baseLocFile = pm.getLocalizationFile(baseCtx, context - + File.separator + "config.xml"); - File baseFile = baseLocFile.getFile(); - - siteLocFile = pm.getLocalizationFile(siteCtx, context - + File.separator + "config.xml"); - if (!reload) { - siteLocFile - .addFileUpdatedObserver(new ILocalizationFileObserver() { - @Override - public void fileUpdated(FileUpdatedMessage message) { - try { - initialize(context, true); - } catch (LocalizationException e) { - statusHandler.handle(Priority.PROBLEM, - "Error reloading plugin configuration: " - + e.getLocalizedMessage(), - e); - } - } - }); - } - File siteFile = siteLocFile.getFile(); - - if (!reload) { - this.userFile = pm.getLocalizationFile(userCtx, context - + File.separator + "config.xml"); - this.userFile - .addFileUpdatedObserver(new ILocalizationFileObserver() { - @Override - public void fileUpdated(FileUpdatedMessage message) { - try { - initialize(context, true); - } catch (LocalizationException e) { - statusHandler.handle(Priority.PROBLEM, - "Error reloading plugin configuration: " - + e.getLocalizedMessage(), - e); - } - } - }); - } - File userFile = this.userFile.getFile(); - - FileLocker.lock(this, baseLocFile, Type.READ); - FileLocker.lock(this, siteLocFile, Type.READ); - FileLocker.lock(this, this.userFile, Type.READ); - - XMLConfiguration baseConfiguration = new XMLConfiguration(baseFile); - XMLConfiguration siteConfiguration = null, userConfiguration = null; - // Create empty files if necessary - if (siteFile != null) { - setupEmptyFile(siteFile); - // Load the individual configuration for site - siteConfiguration = new XMLConfiguration(siteFile); - } else { - siteConfiguration = new XMLConfiguration(); - } - - // Create empty files if necessary - if (userFile != null) { - setupEmptyFile(userFile); - // Load the individual configuration for user - userConfiguration = new XMLConfiguration(userFile); - } else { - userConfiguration = new XMLConfiguration(); - } - - // Create and initialize the node combiner - OverrideCombiner combiner = new OverrideCombiner(); - - // Construct the combined configuration - CombinedConfiguration combinedConfiguration = new CombinedConfiguration( - combiner); - combinedConfiguration.setForceReloadCheck(true); - - combinedConfiguration.addConfiguration(userConfiguration); - combinedConfiguration.addConfiguration(siteConfiguration); - combinedConfiguration.addConfiguration(baseConfiguration); - - this.baseConfiguration = baseConfiguration; - this.siteConfiguration = siteConfiguration; - this.userConfiguration = userConfiguration; - this.combinedConfiguration = combinedConfiguration; - - // Construct the combined configuration (minus the users settings, - // use this as the default settings) - localConfiguration = new CombinedConfiguration(combiner); - localConfiguration.setForceReloadCheck(true); - localConfiguration.addConfiguration(siteConfiguration, "site"); - localConfiguration.addConfiguration(baseConfiguration, "base"); - } catch (Exception e) { - throw new LocalizationException(e); - } finally { - // Always unlock files - FileLocker.unlock(this, baseLocFile, siteLocFile, userFile); - } - - if (reload && oldCombConfiguration != null - && combinedConfiguration != null) { - // We are reloading, loop through properties from new - // configuration and notify of changes. We wait to do this until - // we've already unlocked the files we read in to avoid any dead - // locks - Iterator keyIter = combinedConfiguration.getKeys(); - while (keyIter.hasNext()) { - String key = String.valueOf(keyIter.next()); - Object newValue = combinedConfiguration.getProperty(key); - Object oldValue = oldCombConfiguration.getProperty(key); - firePropertyChangeEvent(key, oldValue, newValue); - } - } + public HierarchicalPreferenceStore(Plugin activator) { + this(activator.getBundle().getSymbolicName()); } /** - * Set up an empty configuration file if one does not exist * - * @param siteStr + * @param bundleId */ - private void setupEmptyFile(File file) { - if (!file.exists()) { - File parent = file.getParentFile(); - if (!parent.exists()) { - parent.mkdirs(); + public HierarchicalPreferenceStore(String bundleId) { + this(bundleId, LocalizationLevel.USER); + } + + /** + * + * @param activator + * @param defaultLevel + */ + public HierarchicalPreferenceStore(Plugin activator, + LocalizationLevel defaultLevel) { + this(activator.getBundle().getSymbolicName(), defaultLevel); + } + + /** + * + * @param bundleId + * @param defaultLevel + */ + public HierarchicalPreferenceStore(String bundleId, + LocalizationLevel defaultLevel) { + this.configFilePath = bundleId + IPathManager.SEPARATOR + "config.xml"; + this.defaultPersistLevel = defaultLevel; + } + + private MapConfiguration getDefaultConfig() { + if (defaults == null) { + defaults = new MapConfiguration(new HashMap()); + // Populate defaults with base first, setDefault* method will + // override what was in BASE + LocalizationConfiguration baseConfig = createConfigurationForLevel(LocalizationLevel.BASE); + defaults.append(baseConfig.accessConfiguration()); + } + return defaults; + } + + /** + * @return The configuration search hierarchy + */ + private Collection getSearchHierarchy() { + LocalizationLevel[] levels = PathManagerFactory.getPathManager() + .getAvailableLevels(); + List configs = new ArrayList( + levels.length); + for (int i = levels.length - 1; i >= 0; i--) { + LocalizationLevel level = levels[i]; + // Skip BASE as it is loaded in defaults + if (level != LocalizationLevel.BASE) { + configs.add(getConfigurationForLevel(level)); + } + } + return configs; + } + + /** + * @param name + * @return The highest {@link LocalizationConfiguration} in the search + * hierarchy that contains the key name or null if none + */ + private LocalizationConfiguration getConfigurationForLevel( + LocalizationLevel level, String name) { + if (level == COMBINED) { + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return config; + } + } + } else { + return getConfigurationForLevel(level); + } + return null; + } + + /** + * @param localizationLevel + * @return {@link LocalizationConfiguration} for the specified level + */ + private LocalizationConfiguration getConfigurationForLevel( + LocalizationLevel localizationLevel) { + LocalizationConfiguration config; + synchronized (configMap) { + config = configMap.get(localizationLevel); + if (config == null) { + config = createConfigurationForLevel(localizationLevel); + configMap.put(localizationLevel, config); + } + } + return config; + } + + /** + * Creates a new {@link LocalizationConfiguration} for the specified level + * + * @param level + * @return + */ + private LocalizationConfiguration createConfigurationForLevel( + LocalizationLevel level) { + IPathManager mgr = PathManagerFactory.getPathManager(); + final LocalizationFile configFile = mgr.getLocalizationFile( + mgr.getContext(LocalizationType.CAVE_CONFIG, level), + configFilePath); + configFile.addFileUpdatedObserver(new ILocalizationFileObserver() { + @Override + public void fileUpdated(FileUpdatedMessage message) { + if (configFile.getName().equals(message.getFileName()) + && configFile.getContext().equals(message.getContext())) { + reloadConfig(configFile.getContext().getLocalizationLevel()); + } + } + }); + return new LocalizationConfiguration(configFile); + } + + private void reloadConfig(LocalizationLevel level) { + LocalizationConfiguration config; + synchronized (configMap) { + config = configMap.get(level); + } + if (config != null && config.loaded) { + // Capture old properties + Map oldPropertyMapping = new HashMap(); + for (String key : getKeys()) { + oldPropertyMapping.put(key, getProperty(key)); } - PrintWriter pw = null; try { - pw = new PrintWriter(file); - pw.write(EMPTY_CONFIGURATION); + config.reload(); + } catch (LocalizationException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); + } - } catch (IOException e) { - // ignore - } finally { - if (pw != null) { - pw.close(); + // Update changed properties + for (String key : getKeys()) { + Object newProperty = getProperty(key); + Object oldProperty = oldPropertyMapping.get(key); + if ((oldProperty != null && newProperty == null) + || (oldProperty == null && newProperty != null) + || (oldProperty != null && oldProperty + .equals(newProperty) == false)) { + firePropertyChangeEvent(key, oldProperty, newProperty); } } } @@ -290,21 +351,35 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * (org.eclipse.jface.util.IPropertyChangeListener) */ - public void addPropertyChangeListener( - org.eclipse.jface.util.IPropertyChangeListener listener) { + public void addPropertyChangeListener(IPropertyChangeListener listener) { this.propertyChangeListeners.add(listener); } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener + * (org.eclipse.jface.util.IPropertyChangeListener) + */ + public void removePropertyChangeListener(IPropertyChangeListener listener) { + this.propertyChangeListeners.remove(listener); + } + /* * (non-Javadoc) * * @see * org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String) */ - + @Override public boolean contains(String name) { - return this.combinedConfiguration.containsKey(name); - + for (LocalizationConfiguration config : getSearchHierarchy()) { + if (config.accessConfiguration().containsKey(name)) { + return true; + } + } + return getDefaultConfig().containsKey(name); } /* @@ -314,7 +389,7 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent * (java.lang.String, java.lang.Object, java.lang.Object) */ - + @Override public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { // The following criteria meets the Eclipse contract @@ -335,48 +410,6 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String - * ) - */ - public boolean getBoolean(String name) { - return getBoolean(Level.COMBINED, name); - } - - /** - * Return a boolean value given a specific level - * - * @param level - * the hierarchical level - * @param name - * the parameter name - * @return the value - */ - public boolean getBoolean(Level level, String name) { - try { - switch (level) { - case BASE: - return this.baseConfiguration.getBoolean(name); - case SITE: - return this.siteConfiguration.getBoolean(name); - case USER: - return this.userConfiguration.getBoolean(name); - case COMBINED: - return this.combinedConfiguration.getBoolean(name); - default: - throw new IllegalArgumentException("Unsupported level: " - + level); - } - } catch (NoSuchElementException e) { - return IPreferenceStore.BOOLEAN_DEFAULT_DEFAULT; - } catch (ConversionException cfe) { - return IPreferenceStore.BOOLEAN_DEFAULT_DEFAULT; - } - } - /* * (non-Javadoc) * @@ -386,11 +419,8 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { */ public boolean getDefaultBoolean(String name) { - try { - return localConfiguration.getBoolean(name); - } catch (NoSuchElementException e) { - return IPreferenceStore.BOOLEAN_DEFAULT_DEFAULT; - } + return getDefaultConfig().getBoolean(name, + IPreferenceStore.BOOLEAN_DEFAULT_DEFAULT); } /* @@ -402,11 +432,8 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { */ public double getDefaultDouble(String name) { - try { - return localConfiguration.getDouble(name); - } catch (NoSuchElementException e) { - return IPreferenceStore.DOUBLE_DEFAULT_DEFAULT; - } + return getDefaultConfig().getDouble(name, + IPreferenceStore.DOUBLE_DEFAULT_DEFAULT); } /* @@ -418,11 +445,8 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { */ public float getDefaultFloat(String name) { - try { - return localConfiguration.getFloat(name); - } catch (NoSuchElementException e) { - return IPreferenceStore.FLOAT_DEFAULT_DEFAULT; - } + return getDefaultConfig().getFloat(name, + IPreferenceStore.FLOAT_DEFAULT_DEFAULT); } /* @@ -434,11 +458,8 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { */ public int getDefaultInt(String name) { - try { - return localConfiguration.getInt(name); - } catch (NoSuchElementException e) { - return IPreferenceStore.INT_DEFAULT_DEFAULT; - } + return getDefaultConfig().getInt(name, + IPreferenceStore.INT_DEFAULT_DEFAULT); } /* @@ -450,11 +471,8 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { */ public long getDefaultLong(String name) { - try { - return localConfiguration.getLong(name); - } catch (NoSuchElementException e) { - return IPreferenceStore.LONG_DEFAULT_DEFAULT; - } + return getDefaultConfig().getLong(name, + IPreferenceStore.LONG_DEFAULT_DEFAULT); } /* @@ -466,18 +484,47 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { */ public String getDefaultString(String name) { - try { - String val = localConfiguration.getString(name); - if (val == null) { - return IPreferenceStore.STRING_DEFAULT_DEFAULT; - } + return getDefaultConfig().getString(name, + IPreferenceStore.STRING_DEFAULT_DEFAULT); + } - return val; - } catch (NoSuchElementException e) { - return IPreferenceStore.STRING_DEFAULT_DEFAULT; + /** + * Return a boolean value given a specific level + * + * @param level + * the hierarchical level + * @param name + * the parameter name + * @return the value + */ + public boolean getBoolean(LocalizationLevel level, String name) { + try { + LocalizationConfiguration config = getConfigurationForLevel(level, + name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getBoolean(name); + } + } + return getDefaultBoolean(name); + } catch (ConversionException e) { + return IPreferenceStore.BOOLEAN_DEFAULT_DEFAULT; } } + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String + * ) + */ + @Override + public boolean getBoolean(String name) { + return getBoolean(COMBINED, name); + } + /** * Return a double value given a specific level * @@ -487,24 +534,18 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the parameter name * @return the value */ - public double getDouble(Level level, String name) { + public double getDouble(LocalizationLevel level, String name) { try { - switch (level) { - case BASE: - return this.baseConfiguration.getDouble(name); - case SITE: - return this.siteConfiguration.getDouble(name); - case USER: - return this.userConfiguration.getDouble(name); - case COMBINED: - return this.combinedConfiguration.getDouble(name); - default: - throw new IllegalArgumentException("Unsupported level: " - + level); + LocalizationConfiguration config = getConfigurationForLevel(level, + name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getDouble(name); + } } - } catch (NoSuchElementException e) { - return IPreferenceStore.DOUBLE_DEFAULT_DEFAULT; - } catch (ConversionException cfe) { + return getDefaultDouble(name); + } catch (ConversionException e) { return IPreferenceStore.DOUBLE_DEFAULT_DEFAULT; } } @@ -515,8 +556,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * @see * org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String) */ + @Override public double getDouble(String name) { - return getDouble(Level.COMBINED, name); + return getDouble(COMBINED, name); } /** @@ -528,24 +570,18 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the parameter name * @return the value */ - public float getFloat(Level level, String name) { + public float getFloat(LocalizationLevel level, String name) { try { - switch (level) { - case BASE: - return this.baseConfiguration.getFloat(name); - case SITE: - return this.siteConfiguration.getFloat(name); - case USER: - return this.userConfiguration.getFloat(name); - case COMBINED: - return this.combinedConfiguration.getFloat(name); - default: - throw new IllegalArgumentException("Unsupported level: " - + level); + LocalizationConfiguration config = getConfigurationForLevel(level, + name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getFloat(name); + } } - } catch (NoSuchElementException e) { - return IPreferenceStore.FLOAT_DEFAULT_DEFAULT; - } catch (ConversionException cfe) { + return getDefaultFloat(name); + } catch (ConversionException e) { return IPreferenceStore.FLOAT_DEFAULT_DEFAULT; } } @@ -556,11 +592,12 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * @see * org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String) */ + @Override public float getFloat(String name) { - return getFloat(Level.COMBINED, name); + return getFloat(COMBINED, name); } - public float[] getFloatArray(Level level, String name) { + public float[] getFloatArray(LocalizationLevel level, String name) { String[] s = getStringArray(level, name); float[] ret = new float[s.length]; @@ -576,7 +613,7 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { } public float[] getFloatArray(String name) { - return getFloatArray(Level.COMBINED, name); + return getFloatArray(COMBINED, name); } /** @@ -588,24 +625,18 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the parameter name * @return the value */ - public int getInt(Level level, String name) { + public int getInt(LocalizationLevel level, String name) { try { - switch (level) { - case BASE: - return this.baseConfiguration.getInt(name); - case SITE: - return this.siteConfiguration.getInt(name); - case USER: - return this.userConfiguration.getInt(name); - case COMBINED: - return this.combinedConfiguration.getInt(name); - default: - throw new IllegalArgumentException("Unsupported level: " - + level); + LocalizationConfiguration config = getConfigurationForLevel(level, + name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getInt(name); + } } - } catch (NoSuchElementException e) { - return IPreferenceStore.INT_DEFAULT_DEFAULT; - } catch (ConversionException cfe) { + return getDefaultInt(name); + } catch (ConversionException e) { return IPreferenceStore.INT_DEFAULT_DEFAULT; } } @@ -616,8 +647,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * @see * org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String) */ + @Override public int getInt(String name) { - return getInt(Level.COMBINED, name); + return getInt(COMBINED, name); } /** @@ -629,24 +661,18 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the parameter name * @return the value */ - public long getLong(Level level, String name) { + public long getLong(LocalizationLevel level, String name) { try { - switch (level) { - case BASE: - return this.baseConfiguration.getLong(name); - case SITE: - return this.siteConfiguration.getLong(name); - case USER: - return this.userConfiguration.getLong(name); - case COMBINED: - return this.combinedConfiguration.getLong(name); - default: - throw new IllegalArgumentException("Unsupported level: " - + level); + LocalizationConfiguration config = getConfigurationForLevel(level, + name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getLong(name); + } } - } catch (NoSuchElementException e) { - return IPreferenceStore.LONG_DEFAULT_DEFAULT; - } catch (ConversionException cfe) { + return getDefaultLong(name); + } catch (ConversionException e) { return IPreferenceStore.LONG_DEFAULT_DEFAULT; } } @@ -658,7 +684,7 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String) */ public long getLong(String name) { - return getLong(Level.COMBINED, name); + return getLong(COMBINED, name); } /** @@ -670,40 +696,24 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the parameter name * @return the value */ - public String getString(Level level, String name) { + public String getString(LocalizationLevel level, String name) { try { - String v; - switch (level) { - case BASE: - v = this.baseConfiguration.getString(name); - break; - case SITE: - v = this.siteConfiguration.getString(name); - break; - case USER: - v = this.userConfiguration.getString(name); - break; - case COMBINED: - v = this.combinedConfiguration.getString(name); - break; - default: - throw new IllegalArgumentException("Unsupported level: " - + level); + LocalizationConfiguration config = getConfigurationForLevel(level, + name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getString(name); + } } - if (v == null) { - return IPreferenceStore.STRING_DEFAULT_DEFAULT; - } else { - return v; - } - } catch (NoSuchElementException e) { - return IPreferenceStore.STRING_DEFAULT_DEFAULT; - } catch (ConversionException cfe) { + return getDefaultString(name); + } catch (ConversionException e) { return IPreferenceStore.STRING_DEFAULT_DEFAULT; } } public String[] getStringArray(String name) { - return getStringArray(Level.COMBINED, name); + return getStringArray(COMBINED, name); } /** @@ -715,35 +725,19 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the parameter name * @return the value */ - public String[] getStringArray(Level level, String name) { + public String[] getStringArray(LocalizationLevel level, String name) { try { - String[] v; - switch (level) { - case BASE: - v = this.baseConfiguration.getStringArray(name); - break; - case SITE: - v = this.siteConfiguration.getStringArray(name); - break; - case USER: - v = this.userConfiguration.getStringArray(name); - break; - case COMBINED: - v = this.combinedConfiguration.getStringArray(name); - break; - default: - throw new IllegalArgumentException("Unsupported level: " - + level); + LocalizationConfiguration config = getConfigurationForLevel(level, + name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getStringArray(name); + } } - if (v == null) { - return null; - } else { - return v; - } - } catch (NoSuchElementException e) { - return null; - } catch (ConversionException cfe) { - return null; + return getDefaultConfig().getStringArray(name); + } catch (ConversionException e) { + return new String[0]; } } @@ -753,8 +747,57 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * @see * org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String) */ + @Override public String getString(String name) { - return getString(Level.COMBINED, name); + return getString(COMBINED, name); + } + + /** + * Gets the property Object for the key name at the level specified + * + * @param level + * @param name + * @return + */ + public Object getProperty(LocalizationLevel level, String name) { + LocalizationConfiguration config = getConfigurationForLevel(level, name); + if (config != null) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + return xmlConfig.getProperty(name); + } + } + return getDefaultConfig().getProperty(name); + } + + /** + * Gets the hierarchical property Object for the key name + * + * @param name + * @return + */ + public Object getProperty(String name) { + return getProperty(COMBINED, name); + } + + /** + * Checks if the property value for the level is the same as the default + * value + * + * @param level + * @param name + * @return + */ + public boolean isDefault(LocalizationLevel level, String name) { + LocalizationConfiguration config = getConfigurationForLevel(level, name); + if (config != null) { + Object object = config.accessConfiguration().getProperty(name); + Object defaultObject = getDefaultConfig().getProperty(name); + return (object == defaultObject) + || (object != null && defaultObject != null && object + .equals(defaultObject)); + } + return true; } /* @@ -763,17 +806,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * @see * org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String) */ - + @Override public boolean isDefault(String name) { - - try { - return (this.baseConfiguration.getProperty(name) - .equals(this.combinedConfiguration.getProperty(name))); - } catch (NoSuchElementException e) { - return false; - } catch (NullPointerException e) { - return false; - } + return isDefault(COMBINED, name); } /* @@ -781,9 +816,14 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving() */ - + @Override public boolean needsSaving() { - return isDirty; + for (LocalizationConfiguration config : getSearchHierarchy()) { + if (config.isDirty()) { + return true; + } + } + return false; } /* @@ -793,21 +833,12 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, * java.lang.String) */ + @Override public void putValue(String name, String value) { - userConfiguration.setProperty(name, value); - isDirty = true; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener - * (org.eclipse.jface.util.IPropertyChangeListener) - */ - public void removePropertyChangeListener( - org.eclipse.jface.util.IPropertyChangeListener listener) { - this.propertyChangeListeners.remove(listener); + LocalizationConfiguration config = getConfigurationForLevel(defaultPersistLevel); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } /* @@ -817,8 +848,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String * , boolean) */ + @Override public void setDefault(String name, boolean value) { - this.baseConfiguration.setProperty(name, value); + getDefaultConfig().setProperty(name, value); } /* @@ -828,8 +860,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String * , double) */ + @Override public void setDefault(String name, double value) { - this.baseConfiguration.setProperty(name, value); + getDefaultConfig().setProperty(name, value); } /* @@ -839,9 +872,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String * , float) */ + @Override public void setDefault(String name, float value) { - this.baseConfiguration.setProperty(name, value); - + getDefaultConfig().setProperty(name, value); } /* @@ -851,8 +884,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String * , int) */ + @Override public void setDefault(String name, int value) { - this.baseConfiguration.setProperty(name, value); + getDefaultConfig().setProperty(name, value); } /* @@ -862,9 +896,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String * , long) */ + @Override public void setDefault(String name, long value) { - this.baseConfiguration.setProperty(name, value); - + getDefaultConfig().setProperty(name, value); } /* @@ -874,9 +908,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String * , java.lang.String) */ + @Override public void setDefault(String name, String defaultObject) { - this.baseConfiguration.setProperty(name, defaultObject); - + getDefaultConfig().setProperty(name, defaultObject); } /* @@ -886,45 +920,31 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang. * String) */ + @Override public void setToDefault(String name) { - userConfiguration.clear(); + removeFromLevel(defaultPersistLevel, name); } - public void setValue(Level level, String name, boolean value) { - boolean oldValue = false; - try { - oldValue = this.combinedConfiguration.getBoolean(name); - } catch (RuntimeException e1) { - // ignore - } - - switch (level) { - case USER: - try { - if (value == this.combinedConfiguration.getBoolean(name)) { - return; - } - } catch (NoSuchElementException e) { + public void setValue(LocalizationLevel level, String name, boolean value) { + boolean oldValue; + if (level == COMBINED) { + oldValue = getBoolean(name); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - this.userConfiguration.setProperty(name, value); - isDirty = true; - break; - case SITE: - try { - if (value == this.baseConfiguration.getBoolean(name)) { - return; - } - } catch (NoSuchElementException e) { - } - this.siteConfiguration.setProperty(name, value); - isDirty = true; - break; - case BASE: - this.baseConfiguration.setProperty(name, value); - isDirty = true; - break; + } else { + oldValue = getBoolean(level, name); + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); + } + if (oldValue != value) { + firePropertyChangeEvent(name, new Boolean(oldValue), new Boolean( + value)); } - firePropertyChangeEvent(name, new Boolean(oldValue), new Boolean(value)); } /* @@ -934,48 +954,31 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, * boolean) */ + @Override public void setValue(String name, boolean value) { - setValue(Level.USER, name, value); + setValue(defaultPersistLevel, name, value); } - public void setValue(Level level, String name, double value) { - - double oldValue = IPreferenceStore.DOUBLE_DEFAULT_DEFAULT; - - try { - oldValue = this.combinedConfiguration.getDouble(name); - } catch (RuntimeException e1) { - // ignore - } - - switch (level) { - case USER: - try { - if (value == this.combinedConfiguration.getDouble(name)) { - return; - } - } catch (NoSuchElementException e) { + public void setValue(LocalizationLevel level, String name, double value) { + double oldValue; + if (level == COMBINED) { + oldValue = getDouble(name); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - this.userConfiguration.setProperty(name, value); - isDirty = true; - break; - case SITE: - try { - if (value == this.baseConfiguration.getDouble(name)) { - return; - } - } catch (NoSuchElementException e) { - } - this.siteConfiguration.setProperty(name, value); - isDirty = true; - break; - case BASE: - this.baseConfiguration.setProperty(name, value); - isDirty = true; - break; + } else { + oldValue = getDouble(level, name); + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); + } + if (oldValue != value) { + firePropertyChangeEvent(name, new Double(oldValue), new Double( + value)); } - - firePropertyChangeEvent(name, new Double(oldValue), new Double(value)); } /* @@ -985,48 +988,30 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, * double) */ + @Override public void setValue(String name, double value) { - setValue(Level.USER, name, value); + setValue(defaultPersistLevel, name, value); } - public void setValue(Level level, String name, float value) { - - double oldValue = IPreferenceStore.FLOAT_DEFAULT_DEFAULT; - - try { - oldValue = this.combinedConfiguration.getDouble(name); - } catch (RuntimeException e1) { - // ignore - } - - switch (level) { - case USER: - try { - if (value == this.combinedConfiguration.getFloat(name)) { - return; - } - } catch (NoSuchElementException e) { + public void setValue(LocalizationLevel level, String name, float value) { + float oldValue; + if (level == COMBINED) { + oldValue = getFloat(name); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - this.userConfiguration.setProperty(name, value); - isDirty = true; - break; - case SITE: - try { - if (value == this.baseConfiguration.getFloat(name)) { - return; - } - } catch (NoSuchElementException e) { - } - this.siteConfiguration.setProperty(name, value); - isDirty = true; - break; - case BASE: - this.baseConfiguration.setProperty(name, value); - isDirty = true; - break; + } else { + oldValue = getFloat(level, name); + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); + } + if (oldValue != value) { + firePropertyChangeEvent(name, new Float(oldValue), new Float(value)); } - - firePropertyChangeEvent(name, new Float(oldValue), new Float(value)); } /* @@ -1036,47 +1021,31 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, * float) */ + @Override public void setValue(String name, float value) { - setValue(Level.USER, name, value); + setValue(defaultPersistLevel, name, value); } - public void setValue(Level level, String name, int value) { - int oldValue = IPreferenceStore.INT_DEFAULT_DEFAULT; - - try { - oldValue = this.combinedConfiguration.getInt(name); - } catch (RuntimeException e1) { - // ignore - } - - switch (level) { - case USER: - try { - if (value == this.combinedConfiguration.getInt(name)) { - return; - } - } catch (NoSuchElementException e) { + public void setValue(LocalizationLevel level, String name, int value) { + int oldValue; + if (level == COMBINED) { + oldValue = getInt(name); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - this.userConfiguration.setProperty(name, value); - isDirty = true; - break; - case SITE: - try { - if (value == this.baseConfiguration.getInt(name)) { - return; - } - } catch (NoSuchElementException e) { - } - this.siteConfiguration.setProperty(name, value); - isDirty = true; - break; - case BASE: - this.baseConfiguration.setProperty(name, value); - isDirty = true; - break; + } else { + oldValue = getInt(level, name); + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); + } + if (oldValue != value) { + firePropertyChangeEvent(name, new Integer(oldValue), new Integer( + value)); } - - firePropertyChangeEvent(name, new Integer(oldValue), new Integer(value)); } /* @@ -1086,48 +1055,31 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, * int) */ + @Override public void setValue(String name, int value) { - setValue(Level.USER, name, value); + setValue(defaultPersistLevel, name, value); } - public void setValue(Level level, String name, long value) { - - long oldValue = IPreferenceStore.LONG_DEFAULT_DEFAULT; - - try { - oldValue = this.combinedConfiguration.getLong(name); - } catch (RuntimeException e1) { - // ignore + public void setValue(LocalizationLevel level, String name, long value) { + long oldValue; + if (level == COMBINED) { + oldValue = getLong(name); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); + } + } else { + oldValue = getLong(level, name); + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - switch (level) { - case USER: - try { - if (value == this.combinedConfiguration.getLong(name)) { - return; - } - } catch (NoSuchElementException e) { - } - this.userConfiguration.setProperty(name, value); - isDirty = true; - break; - case SITE: - try { - if (value == this.baseConfiguration.getLong(name)) { - return; - } - } catch (NoSuchElementException e) { - } - this.siteConfiguration.setProperty(name, value); - isDirty = true; - break; - case BASE: - this.baseConfiguration.setProperty(name, value); - isDirty = true; - break; + if (oldValue != value) { + firePropertyChangeEvent(name, new Long(oldValue), new Long(value)); } - - firePropertyChangeEvent(name, new Long(oldValue), new Long(value)); } /* @@ -1138,101 +1090,78 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * long) */ public void setValue(String name, long value) { - setValue(Level.USER, name, value); + setValue(defaultPersistLevel, name, value); } - public void setValue(Level level, String name, String value) { - - String oldValue = IPreferenceStore.STRING_DEFAULT_DEFAULT; - - try { - oldValue = this.combinedConfiguration.getString(name); - } catch (RuntimeException e1) { - // ignore - } - - if (oldValue == null) { - oldValue = IPreferenceStore.STRING_DEFAULT_DEFAULT; - } - - switch (level) { - case USER: - try { - if (value.equals(this.combinedConfiguration.getString(name))) { - return; - } - } catch (NoSuchElementException e) { + public void setValue(LocalizationLevel level, String name, String value) { + String oldValue; + if (level == COMBINED) { + oldValue = getString(name); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - this.userConfiguration.setProperty(name, value); - isDirty = true; - break; - case SITE: - try { - if (value.equals(this.baseConfiguration.getString(name))) { - return; - } - } catch (NoSuchElementException e) { - } - this.siteConfiguration.setProperty(name, value); - isDirty = true; - break; - case BASE: - this.baseConfiguration.setProperty(name, value); - isDirty = true; - break; + } else { + oldValue = getString(level, name); + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - if (value != null) { + + if ((oldValue == null && value != null) + || (oldValue != null && value == null) + || (oldValue != null && oldValue.equals(value) == false)) { firePropertyChangeEvent(name, oldValue, value); } } - public void setValue(Level level, String name, String[] value) { - - String[] oldValue = null; - - try { - oldValue = this.combinedConfiguration.getStringArray(name); - } catch (RuntimeException e1) { - // ignore + public void setValue(LocalizationLevel level, String name, String[] value) { + String[] oldValue; + if (level == COMBINED) { + oldValue = getStringArray(name); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); + } + } else { + oldValue = getStringArray(level, name); + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.setProperty(name, value); + config.markDirty(); } - switch (level) { - case USER: - try { - if (value.equals(this.combinedConfiguration - .getStringArray(name))) { - return; - } - } catch (NoSuchElementException e) { - } - this.userConfiguration.setProperty(name, value); - isDirty = true; - break; - case SITE: - try { - if (value.equals(this.baseConfiguration.getStringArray(name))) { - return; - } - } catch (NoSuchElementException e) { - } - this.siteConfiguration.setProperty(name, value); - isDirty = true; - break; - case BASE: - this.baseConfiguration.setProperty(name, value); - isDirty = true; - break; - } - if (value != null) { + if ((oldValue == null && value != null) + || (oldValue != null && value == null) + || Arrays.equals(oldValue, value) == false) { firePropertyChangeEvent(name, oldValue, value); } } + public String[] getKeys() { + Set keys = new LinkedHashSet(); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + Iterator configKeys = xmlConfig.getKeys(); + while (configKeys.hasNext()) { + keys.add((String) configKeys.next()); + } + } + + return keys.toArray(new String[keys.size()]); + } + public String[] getKeys(String prefix) { - Iterator iterator = this.combinedConfiguration.getKeys(prefix); - List keys = new ArrayList(); - while (iterator.hasNext()) { - keys.add((String) iterator.next()); + Set keys = new LinkedHashSet(); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + Iterator configKeys = xmlConfig.getKeys(prefix); + while (configKeys.hasNext()) { + keys.add((String) configKeys.next()); + } } return keys.toArray(new String[keys.size()]); @@ -1245,12 +1174,13 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, * java.lang.String) */ + @Override public void setValue(String name, String value) { - setValue(Level.USER, name, value); + setValue(defaultPersistLevel, name, value); } public void setValue(String name, String[] value) { - setValue(Level.USER, name, value); + setValue(defaultPersistLevel, name, value); } /* @@ -1258,19 +1188,16 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * * @see org.eclipse.jface.preference.IPersistentPreferenceStore#save() */ + @Override public void save() throws IOException { - try { - if (this.userFile != null) { - FileLocker.lock(this, userFile, Type.WRITE); - userConfiguration.save(); - userFile.save(); + for (LocalizationConfiguration config : getSearchHierarchy()) { + try { + config.save(); + } catch (LocalizationException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); } - } catch (Exception e) { - throw new IOException("Error saving configuration file", e); - } finally { - FileLocker.unlock(this, userFile); } - isDirty = false; } /** @@ -1282,24 +1209,9 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the key to check * @return if a value is defined for the key at a particular level */ - public boolean isAvailableAtLevel(Level level, String name) { - try { - switch (level) { - case BASE: - return this.baseConfiguration.containsKey(name); - case SITE: - return this.siteConfiguration.containsKey(name); - case USER: - return this.userConfiguration.containsKey(name); - case COMBINED: - return this.combinedConfiguration.containsKey(name); - default: - throw new IllegalArgumentException("Unsupported level: " - + level); - } - } catch (RuntimeException e) { - return false; - } + public boolean isAvailableAtLevel(LocalizationLevel level, String name) { + LocalizationConfiguration config = getConfigurationForLevel(level); + return config.accessConfiguration().containsKey(name); } /** @@ -1310,24 +1222,12 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * @param name * the key */ - public void removeFromLevel(Level level, String name) { - try { - switch (level) { - case BASE: - this.baseConfiguration.clearProperty(name); - break; - case SITE: - this.siteConfiguration.clearProperty(name); - break; - case USER: - this.userConfiguration.clearProperty(name); - break; - default: - throw new IllegalArgumentException("Unsupported level: " - + level); - } - } catch (RuntimeException e) { - return; + public void removeFromLevel(LocalizationLevel level, String name) { + LocalizationConfiguration config = getConfigurationForLevel(level); + XMLConfiguration xmlConfig = config.accessConfiguration(); + if (xmlConfig.containsKey(name)) { + xmlConfig.clearProperty(name); + config.markDirty(); } } @@ -1338,7 +1238,15 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * the key to clear overrides */ public void clearUserOverrides(String key) { - this.userConfiguration.clearTree(key); + LocalizationConfiguration config = getConfigurationForLevel(LocalizationLevel.USER); + XMLConfiguration xmlConfig = config.accessConfiguration(); + Iterator keys = xmlConfig.getKeys(key); + if (keys.hasNext()) { + config.markDirty(); + } + while (keys.hasNext()) { + xmlConfig.clearProperty((String) keys.next()); + } } /** @@ -1347,11 +1255,11 @@ public class HierarchicalPreferenceStore implements IPersistentPreferenceStore { * USE THIS METHOD WITH CAUTION. THIS IS PRIMARILY INTENDED TO AIDE TESTING. */ public void clear() { - this.baseConfiguration.clear(); - this.siteConfiguration.clear(); - this.userConfiguration.clear(); - this.combinedConfiguration.clear(); - this.localConfiguration.clear(); + for (LocalizationConfiguration config : getSearchHierarchy()) { + XMLConfiguration xmlConfig = config.accessConfiguration(); + xmlConfig.clear(); + config.markDirty(); + } } } diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/Activator.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/Activator.java index c2c28f3b44..30a2f0de44 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/Activator.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/Activator.java @@ -22,18 +22,26 @@ package com.raytheon.uf.viz.d2d.ui; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(Activator.class); // The plug-in ID public static final String PLUGIN_ID = "com.raytheon.uf.viz.d2d.ui"; @@ -42,7 +50,8 @@ public class Activator extends AbstractUIPlugin { private static Activator plugin; // pref store - private HierarchicalPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -88,17 +97,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - statusHandler.handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/Activator.java b/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/Activator.java index 5deb1993a0..42a71a20d9 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/Activator.java +++ b/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/Activator.java @@ -23,10 +23,8 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -38,7 +36,8 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Nov 12, 2012 #1326 randerso Initial creation + * Nov 12, 2012 #1326 randerso Initial creation + * Mar 3, 2014 #2861 mschenke Create preference store immediately * * * @@ -49,15 +48,16 @@ public class Activator extends AbstractUIPlugin { public static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(Activator.class); - // pref store - private HierarchicalPreferenceStore prefs; - // The plug-in ID public static final String PLUGIN_ID = "com.raytheon.uf.viz.gisdatastore.directory"; //$NON-NLS-1$ // The shared instance private static Activator plugin; + // pref store + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); + /** * The constructor */ @@ -106,17 +106,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - statusHandler.handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/Activator.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/Activator.java index def8d10277..f634de55f9 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/Activator.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/Activator.java @@ -23,10 +23,8 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -38,7 +36,8 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Nov 12, 2012 #1326 randerso Initial creation + * Nov 12, 2012 #1326 randerso Initial creation + * Mar 3, 2014 #2861 mschenke Create preference store immediately * * * @@ -49,15 +48,16 @@ public class Activator extends AbstractUIPlugin { public static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(Activator.class); - // pref store - private HierarchicalPreferenceStore prefs; - // The plug-in ID public static final String PLUGIN_ID = "com.raytheon.uf.viz.gisdatastore"; //$NON-NLS-1$ // The shared instance private static Activator plugin; + // pref store + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); + /** * The constructor */ @@ -106,17 +106,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - statusHandler.handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/Activator.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/Activator.java index 37d475d24f..9b951c6f9d 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/Activator.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/Activator.java @@ -22,13 +22,24 @@ package com.raytheon.uf.viz.monitor.scan; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { @@ -38,7 +49,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private HierarchicalPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -88,17 +100,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/Activator.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/Activator.java index d6e56f8d8d..de6f5052b7 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/Activator.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/Activator.java @@ -23,24 +23,36 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { - private HierarchicalPreferenceStore prefs; - // The plug-in ID public static final String PLUGIN_ID = "com.raytheon.uf.viz.monitor"; // The shared instance private static Activator plugin; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); + /** * The constructor */ @@ -101,17 +113,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/activator/Activator.java b/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/activator/Activator.java index 741724171d..02f019d311 100644 --- a/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/activator/Activator.java +++ b/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/activator/Activator.java @@ -23,9 +23,6 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -37,7 +34,8 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 21, 2009 mfegan Initial creation + * Apr 21, 2009 mfegan Initial creation + * Mar 3, 2014 2861 mschenke Create preference store immediately * * * @@ -52,7 +50,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private IPersistentPreferenceStore prefs; + private IPersistentPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * Constructor. @@ -95,17 +94,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/Activator.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/Activator.java index 6e5e8fd46b..2be4438732 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/Activator.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/Activator.java @@ -25,9 +25,6 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.preferences.ScopedPreferenceStore; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -39,7 +36,9 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Oct 20, 2011 mschenke Initial creation + * Oct 20, 2011 mschenke Initial creation + * Mar 3, 2014 2861 mschenke Create preference store immediately + * * * * @@ -58,7 +57,8 @@ public class Activator extends AbstractUIPlugin { private BundleContext ctx; // General preference store - private IPersistentPreferenceStore prefs; + private IPersistentPreferenceStore prefs = new HierarchicalPreferenceStore( + this); // Preferences for UI private HierarchicalPreferenceStore uiPrefs; @@ -134,14 +134,6 @@ public class Activator extends AbstractUIPlugin { * @return */ public HierarchicalPreferenceStore getUiPreferenceStore() { - if (uiPrefs == null) { - try { - uiPrefs = new HierarchicalPreferenceStore(this); - } catch (LocalizationException e) { - UFStatus.getHandler(Activator.class).handle(Priority.PROBLEM, - "Error constructing hierarchical preferences", e); - } - } return uiPrefs; } diff --git a/cave/com.raytheon.uf.viz.xy/src/com/raytheon/uf/viz/xy/Activator.java b/cave/com.raytheon.uf.viz.xy/src/com/raytheon/uf/viz/xy/Activator.java index c8eee4c574..d3496e7453 100644 --- a/cave/com.raytheon.uf.viz.xy/src/com/raytheon/uf/viz/xy/Activator.java +++ b/cave/com.raytheon.uf.viz.xy/src/com/raytheon/uf/viz/xy/Activator.java @@ -23,27 +23,39 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { public static final String MAP_DISPLAY_DENSITY = "mapDisplayDensity"; - + public static final String MAP_DISPLAY_WIDTH = "mapDisplayWidth"; - + // The plug-in ID public static final String PLUGIN_ID = "com.raytheon.uf.viz.xy"; // The shared instance private static Activator plugin; - private IPersistentPreferenceStore prefs = null; + private IPersistentPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -91,17 +103,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/activator/Activator.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/activator/Activator.java index 7fbe581a54..caa15f1536 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/activator/Activator.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/activator/Activator.java @@ -23,9 +23,6 @@ package com.raytheon.viz.aviation.activator; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -38,6 +35,7 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 1/21/2008 817 grichard Initial creation. + * Mar 3, 2014 2861 mschenke Create preference store immediately * * * @@ -54,7 +52,8 @@ public class Activator extends AbstractUIPlugin { private static Activator plugin; /** preference store to read in the config XML */ - private HierarchicalPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -102,17 +101,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } diff --git a/cave/com.raytheon.viz.avnconfig/src/com/raytheon/viz/avnconfig/Activator.java b/cave/com.raytheon.viz.avnconfig/src/com/raytheon/viz/avnconfig/Activator.java index aea20f3d81..322f588c5b 100644 --- a/cave/com.raytheon.viz.avnconfig/src/com/raytheon/viz/avnconfig/Activator.java +++ b/cave/com.raytheon.viz.avnconfig/src/com/raytheon/viz/avnconfig/Activator.java @@ -22,24 +22,36 @@ package com.raytheon.viz.avnconfig; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { - private HierarchicalPreferenceStore prefs; - // The plug-in ID public static final String PLUGIN_ID = "com.raytheon.viz.avnconfig"; // The shared instance private static Activator plugin; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); + /** * The constructor */ @@ -88,17 +100,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/Activator.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/Activator.java index 42a74c7483..580bc64f3c 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/Activator.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/Activator.java @@ -23,14 +23,26 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { @@ -44,7 +56,8 @@ public class Activator extends AbstractUIPlugin { private static Activator plugin; // The preference store - private IPersistentPreferenceStore prefs; + private IPersistentPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -92,17 +105,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - statusHandler.handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } diff --git a/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/CorePlugin.java b/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/CorePlugin.java index 5de652baeb..2111aefac1 100644 --- a/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/CorePlugin.java +++ b/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/CorePlugin.java @@ -22,13 +22,9 @@ package com.raytheon.viz.core; import javax.media.jai.ParameterBlockJAI; -import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -41,6 +37,7 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 7/1/06 chammack Initial Creation. + * Mar 3, 2014 2861 mschenke Create preference store immediately * * * @@ -54,7 +51,8 @@ public class CorePlugin extends AbstractUIPlugin { // The shared instance. private static CorePlugin plugin; - private IPersistentPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); private BundleContext ctx; @@ -109,18 +107,7 @@ public class CorePlugin extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - - return (HierarchicalPreferenceStore) prefs; + return prefs; } } diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/Activator.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/Activator.java index 8657f03726..72b05db8c6 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/Activator.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/Activator.java @@ -22,13 +22,24 @@ package com.raytheon.viz.radar; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { @@ -38,7 +49,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private HierarchicalPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -86,17 +98,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java index 7c7819213b..ebf3b70633 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/UiPlugin.java @@ -25,9 +25,6 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; import com.raytheon.viz.ui.jobs.MemoryMonitorJob; import com.raytheon.viz.ui.panes.DrawCoordinatorJob; @@ -44,7 +41,7 @@ import com.raytheon.viz.ui.panes.DrawCoordinatorJob; * Oct 24, 2012 2491 bsteffen Do not start DrawCoordinatorJob during * activation to allow activation before * localization is set. - * + * Mar 3, 2014 2861 mschenke Create preference store immediately * * * @@ -58,7 +55,8 @@ public class UiPlugin extends AbstractUIPlugin { // The shared instance. private static UiPlugin plugin; - private HierarchicalPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); private final Job memoryWatchJob = new MemoryMonitorJob(); @@ -116,17 +114,6 @@ public class UiPlugin extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/Activator.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/Activator.java index a650cf85b9..771ec7f2d6 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/Activator.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/Activator.java @@ -23,9 +23,6 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** @@ -36,6 +33,7 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 26, 2007 chammack Initial Creation. + * Mar 3, 2014 2861 mschenke Create preference store immediately * * * @@ -50,7 +48,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private IPersistentPreferenceStore prefs; + private IPersistentPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -98,17 +97,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } diff --git a/cave/ohd.hseb.monitor/src/com/raytheon/monitor/activator/Activator.java b/cave/ohd.hseb.monitor/src/com/raytheon/monitor/activator/Activator.java index 357e0b860c..7a2f34e2e2 100755 --- a/cave/ohd.hseb.monitor/src/com/raytheon/monitor/activator/Activator.java +++ b/cave/ohd.hseb.monitor/src/com/raytheon/monitor/activator/Activator.java @@ -4,13 +4,24 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { @@ -20,7 +31,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private IPersistentPreferenceStore prefs; + private IPersistentPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -70,17 +82,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public IPersistentPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; } } diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/src/gov/noaa/nws/ncep/viz/rsc/ncradar/Activator.java b/ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/src/gov/noaa/nws/ncep/viz/rsc/ncradar/Activator.java index f3ee9eca21..1935205c19 100644 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/src/gov/noaa/nws/ncep/viz/rsc/ncradar/Activator.java +++ b/ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/src/gov/noaa/nws/ncep/viz/rsc/ncradar/Activator.java @@ -3,13 +3,24 @@ package gov.noaa.nws.ncep.viz.rsc.ncradar; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.raytheon.uf.common.localization.exception.LocalizationException; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; /** + * * The activator class controls the plug-in life cycle + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 3, 2014  2861       mschenke    Create preference store immediately
+ * 
+ * 
+ * + * @author unknown + * @version 1.0 */ public class Activator extends AbstractUIPlugin { @@ -19,7 +30,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - private HierarchicalPreferenceStore prefs; + private HierarchicalPreferenceStore prefs = new HierarchicalPreferenceStore( + this); /** * The constructor @@ -67,17 +79,6 @@ public class Activator extends AbstractUIPlugin { */ @Override public HierarchicalPreferenceStore getPreferenceStore() { - try { - if (prefs == null) { - prefs = new HierarchicalPreferenceStore(this); - } - } catch (LocalizationException e) { - UFStatus.getHandler().handle( - Priority.PROBLEM, - "Error reading preference store: " - + e.getLocalizedMessage(), e); - } - return prefs; }