re-factoring to seperate preferenceStore dependency from non-ui plugins, use a wrapper of the common.ui preference store instead.
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/AuthoringUIService.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/AuthoringUIService.java
index 0c90493..e400ba8 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/AuthoringUIService.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/AuthoringUIService.java
@@ -17,6 +17,7 @@
import org.eclipse.epf.authoring.ui.editors.EditorChooser;
import org.eclipse.epf.authoring.ui.providers.MethodEditorPageProvider;
import org.eclipse.epf.authoring.ui.providers.ProcessEditorPageProvider;
+import org.eclipse.epf.common.ui.PreferenceStoreWrapper;
import org.eclipse.epf.diagram.model.util.GraphicalDataManager;
import org.eclipse.epf.library.ILibraryServiceListener;
import org.eclipse.epf.library.LibraryPlugin;
@@ -132,7 +133,8 @@
Providers.setPreferenceStore(LibraryPlugin.getDefault()
.getPreferenceStore());
- Providers.setAuthoringPlugin(AuthoringUIPlugin.getDefault());
+ PreferenceStoreWrapper store = new PreferenceStoreWrapper(AuthoringUIPlugin.getDefault().getPreferenceStore());
+ Providers.setAuthoringPluginPreferenceStore(store);
List<ICommandListener> cmdListeners = GraphicalDataManager.getInstance()
.getCommandListeners();
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditor.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditor.java
index 662930f..35f6ace 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditor.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditor.java
@@ -60,6 +60,9 @@
import org.eclipse.epf.authoring.ui.properties.EPFPropertySheetPage;
import org.eclipse.epf.authoring.ui.providers.ProcessEditorPageProvider;
import org.eclipse.epf.authoring.ui.views.ProcessViewer;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeEventWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeListenerWrapper;
import org.eclipse.epf.diagram.core.part.AbstractDiagramEditor;
import org.eclipse.epf.diagram.core.part.DiagramEditorInput;
import org.eclipse.epf.diagram.core.part.DiagramEditorInputProxy;
@@ -109,9 +112,6 @@
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -576,7 +576,7 @@
}
};
- protected IPropertyChangeListener prefStoreListener;
+ protected IPropertyChangeListenerWrapper prefStoreListener;
// private ProcessConfigurator configurator;
@@ -869,9 +869,9 @@
// listen to the change of column list in preference store
//
if (prefStoreListener == null) {
- prefStoreListener = new IPropertyChangeListener() {
+ prefStoreListener = new IPropertyChangeListenerWrapper() {
- public void propertyChange(PropertyChangeEvent event) {
+ public void propertyChange(IPropertyChangeEventWrapper event) {
ProcessBreakdownStructureFormPage page = null;
if (event.getProperty().equals(
ApplicationPreferenceConstants.PREF_WBS_COLUMNS)) {
@@ -1082,7 +1082,7 @@
// IPreferenceStore store = AuthoringUIPlugin.getDefault()
// .getPreferenceStore();
PreferenceUtil.validatePreferences();
- IPreferenceStore store = getPreferenceStore();
+ IPreferenceStoreWrapper store = getPreferenceStore();
List pages = new ArrayList();
@@ -2378,13 +2378,13 @@
return false;
}
- protected IPreferenceStore getPreferenceStore() {
+ protected IPreferenceStoreWrapper getPreferenceStore() {
// preference is managed by library plugin,
// since this preferences is also used for browsing and publishing
// Jinhua Xi 08/21/2006
// IPreferenceStore store = AuthoringUIPlugin.getDefault()
// .getPreferenceStore();
- IPreferenceStore store = LibraryPlugin.getDefault()
+ IPreferenceStoreWrapper store = LibraryPlugin.getDefault()
.getPreferenceStore();
return store;
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/BreakdownElementPrefPage.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/BreakdownElementPrefPage.java
index 05202b5..82a6432 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/BreakdownElementPrefPage.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/BreakdownElementPrefPage.java
@@ -240,7 +240,7 @@
* @see org.eclipse.epf.authoring.ui.preferences.CommonPrefPage#doGetPreferenceStore()
*/
protected IPreferenceStore doGetPreferenceStore() {
- return LibraryPlugin.getDefault().getPreferenceStore();
+ return (IPreferenceStore)LibraryPlugin.getDefault().getPreferenceStore().getStore();
}
}
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/CommonPrefPage.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/CommonPrefPage.java
index 040846b..6f8ddf9 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/CommonPrefPage.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/CommonPrefPage.java
@@ -122,7 +122,7 @@
*/
protected IPreferenceStore doGetPreferenceStore() {
- return LibraryPlugin.getDefault().getPreferenceStore();
+ return (IPreferenceStore)LibraryPlugin.getDefault().getPreferenceStore().getStore();
// return PlatformUI.getWorkbench().getPreferenceStore();
}
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryLocationData.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryLocationData.java
index 57b7400..21fa5a7 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryLocationData.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryLocationData.java
@@ -144,8 +144,8 @@
*
*/
public void loadFromPreferenceStore() {
- IPreferenceStore store = LibraryPlugin.getDefault()
- .getPreferenceStore();
+ IPreferenceStore store = (IPreferenceStore)LibraryPlugin.getDefault()
+ .getPreferenceStore().getStore();
String lastDir = store
.getString(LibraryPreferenceConstants.PREF_LAST_LIBRARY_PARENT_DIRECTORY);
@@ -167,8 +167,8 @@
*
*/
public void saveToPreferenceStore() {
- IPreferenceStore store = LibraryPlugin.getDefault()
- .getPreferenceStore();
+ IPreferenceStore store = (IPreferenceStore)LibraryPlugin.getDefault()
+ .getPreferenceStore().getStore();
File file = new File(this.getParentFolder());
LibraryUIPreferences.setSavedLibraryPath(file.getAbsolutePath());
store.setValue(
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryPreferenceInitializer.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryPreferenceInitializer.java
index bf676ad..ecf9c14 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryPreferenceInitializer.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/LibraryPreferenceInitializer.java
@@ -29,8 +29,8 @@
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
- IPreferenceStore store = LibraryPlugin.getDefault()
- .getPreferenceStore();
+ IPreferenceStore store = (IPreferenceStore)LibraryPlugin.getDefault()
+ .getPreferenceStore().getStore();
store.setDefault(LibraryPreferenceConstants.PREF_RADIO_SAVE_CHOICE, 1);
store.setDefault(ApplicationPreferenceConstants.PREF_WBS_COLUMNS,
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/ProcessEditorPreferencePage.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/ProcessEditorPreferencePage.java
index d5246fe..6eada20 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/ProcessEditorPreferencePage.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/ProcessEditorPreferencePage.java
@@ -231,7 +231,7 @@
* @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
*/
protected IPreferenceStore doGetPreferenceStore() {
- return LibraryPlugin.getDefault().getPreferenceStore();
+ return (IPreferenceStore)LibraryPlugin.getDefault().getPreferenceStore().getStore();
}
/**
@@ -676,6 +676,6 @@
// we need to share the preference in Library browsing and publishing
// Jinhua Xi 08/19/2006
// changed to use CommonUIPlugin store
- return LibraryPlugin.getDefault().getPreferenceStore();
+ return (IPreferenceStore)LibraryPlugin.getDefault().getPreferenceStore().getStore();
}
}
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/RootPrefPage.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/RootPrefPage.java
index cf4ba2b..1ca8409 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/RootPrefPage.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/preferences/RootPrefPage.java
@@ -90,7 +90,7 @@
* @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
*/
protected IPreferenceStore doGetPreferenceStore() {
- return LibraryPlugin.getDefault().getPreferenceStore();
+ return (IPreferenceStore)LibraryPlugin.getDefault().getPreferenceStore().getStore();
}
/**
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/properties/ActivityRollupSection.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/properties/ActivityRollupSection.java
index af5a7d3..9344536 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/properties/ActivityRollupSection.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/properties/ActivityRollupSection.java
@@ -83,7 +83,7 @@
toolkit = getWidgetFactory();
// get preference store
- store = LibraryPlugin.getDefault().getPreferenceStore();
+ store = (IPreferenceStore)LibraryPlugin.getDefault().getPreferenceStore().getStore();
}
/**
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java
index f50e91f..09ea8e9 100644
--- a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java
+++ b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java
@@ -10,12 +10,37 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.common.ui;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import org.eclipse.core.internal.runtime.InternalPlatform;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.epf.common.AbstractActivator;
+import org.eclipse.epf.common.serviceability.Logger;
import org.eclipse.epf.common.ui.util.MsgDialog;
+import org.eclipse.epf.common.utils.FileUtil;
+import org.eclipse.epf.common.utils.I18nUtil;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
/**
* The abstract base class for all EPF plug-ins.
@@ -24,11 +49,39 @@
* @author Jinhua Xi
* @since 1.0
*/
-public abstract class AbstractPlugin extends AbstractActivator {
+public abstract class AbstractPlugin extends AbstractUIPlugin {
+
+
+ // The relative path to the icons.
+ private static final String ICON_PATH = "icons/"; //$NON-NLS-1$;
+
+ // The logger hash map.
+ private static Map<String, Logger> loggers = new HashMap<String, Logger>();
// The message dialog hash map.
private static Map<String, MsgDialog> msgDialogs = new HashMap<String, MsgDialog>();
+ // The shared image hash map.
+ private static Map<String, Image> sharedImages = new HashMap<String, Image>();
+
+ // The resource bundle for this plug-in.
+ private ResourceBundle resourceBundle;
+
+ // This plug-in ID.
+ private String pluginId;
+
+ // The plug-in install URL.
+ private URL installURL;
+
+ // The plug-in install path.
+ private String installPath;
+
+ // The plug-in icon URL.
+ private URL iconURL;
+
+ // The profiling flag.
+ private boolean profiling;
+
/**
* Default constructor.
*/
@@ -37,6 +90,410 @@
}
/**
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ init(context);
+
+ // set the
+ if (isDebugging()) {
+ getLogger().logInfo("Started " + pluginId); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ // Free the shared images.
+ for (Iterator images = sharedImages.values().iterator(); images
+ .hasNext();) {
+ Image image = (Image) images.next();
+ if (image != null && !image.isDisposed()) {
+ image.dispose();
+ }
+ }
+
+ super.stop(context);
+
+ if (isDebugging()) {
+ getLogger().logInfo("Stopped " + pluginId); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Initializes this plug-in.
+ *
+ * @param context
+ * The bundle context.
+ */
+ protected void init(BundleContext context) throws Exception {
+ // Get the bundle for this plug-in.
+ Bundle bundle = getBundle();
+
+ // Get the resouce bundle for this plug-in.
+ resourceBundle = Platform.getResourceBundle(bundle);
+
+ // Get the ID for this plug-in.
+ pluginId = bundle.getSymbolicName();
+
+ if (isDebugging()) {
+ getLogger().logInfo("Initializing " + pluginId); //$NON-NLS-1$
+ }
+
+ // Get the install path of this plug-in.
+ installURL = bundle.getEntry("/"); //$NON-NLS-1$
+
+ try {
+ installPath = FileLocator.resolve(installURL).getPath();
+ } catch (IOException e) {
+ installPath = Platform.getInstallLocation().getURL().getPath();
+ }
+
+ try {
+ iconURL = new URL(installURL, ICON_PATH);
+ } catch (IOException e) {
+ }
+
+ String symbolicName = bundle.getSymbolicName();
+ if (symbolicName != null) {
+ String key = symbolicName + "/profiling"; //$NON-NLS-1$
+ String value = InternalPlatform.getDefault().getOption(key);
+ profiling = value == null ? false : value.equalsIgnoreCase("true"); //$NON-NLS-1$
+ }
+
+ if (isDebugging()) {
+ getLogger().logInfo(
+ "Initialized " + pluginId + ", installPath=" + installPath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Returns the ID of this plug-in.
+ *
+ * @return The ID of this plug-in.
+ */
+ public String getId() {
+ return pluginId;
+ }
+
+ /**
+ * Returns the install URL of this plug-in.
+ *
+ * @param The
+ * install URL of this plug-in.
+ */
+ public URL getInstallURL() {
+ return installURL;
+ }
+
+ /**
+ * Returns the install path of this plug-in.
+ *
+ * @param The
+ * install path of this plug-in.
+ */
+ public String getInstallPath() {
+ return installPath;
+ }
+
+ /**
+ * Loads and returns the localized properties of a Java properties file.
+ * <p>
+ *
+ * @param path
+ * The properties file path relative to the plug-in root.
+ * @return A <code>Properties</code> object.
+ */
+ public Properties getProperties(String path) throws IOException {
+ Properties props = new Properties();
+ if (path == null) {
+ return props;
+ }
+
+ String filePath = getLocalizedFile(path, true);
+ if (filePath != null) {
+ props.load(new FileInputStream(filePath));
+ }
+
+ return props;
+ }
+
+ /**
+ * get the locale specific absolute file path name of the given file in the
+ * plugin.
+ *
+ * @param path
+ * The properties file path relative to the plug-in root.
+ * @return String the locale specific absolute file path name of the given
+ * file.
+ * @throws IOException
+ */
+ public String getLocalizedFile(String path, boolean useDefault)
+ throws IOException {
+ String filePath = null;
+ String fileName = FileUtil.getFileName(path);
+ int index = path.lastIndexOf(fileName);
+ String pathName = path.substring(0, index);
+
+ Locale locale = Locale.getDefault();
+
+ Bundle bundle = getBundle();
+ Bundle[] bundles = Platform.getFragments(bundle);
+ if (bundles != null) {
+ for (int i = 0; i < bundles.length; i++) {
+ URL entry = bundles[i].getEntry(pathName);
+ if (entry != null) {
+ URL url = FileLocator.resolve(entry);
+ filePath = I18nUtil.getLocalizedFile(url.getPath()
+ + fileName, locale);
+ if (filePath != null) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (filePath == null) {
+ URL entry = bundle.getEntry(path);
+ if (entry != null) {
+ URL url = FileLocator.resolve(entry);
+ filePath = I18nUtil.getLocalizedFile(url.getPath(), locale);
+ if (filePath == null && useDefault) {
+ filePath = url.getPath();
+ }
+ }
+ }
+
+ return filePath;
+ }
+
+ /**
+ * for the given path in the plugin, find the localized files form the nl
+ * fragemenets and copy the localized files to the destination folder
+ *
+ * @param path
+ * String a relative path to the plugin root. The files in this
+ * folder will be iterated and their localized files will be
+ * copied over
+ * @param toDir
+ * FIle the destination folder
+ * @param recursive
+ * boolean recurively looking for files int the specified folder
+ * @param useLocaleFileName
+ * boolean if true the locale specific file names will be used in
+ * the copied destination, otherwise, the locale specific file
+ * name will be renamed to the default one in the destination
+ * folder
+ * @throws IOException
+ */
+ public void copyLocalizedFiles(String path, File toDir, boolean recursive,
+ boolean useLocaleFileName) throws IOException {
+ String pluginPath = getInstallPath();
+ URI pluginUri = new File(pluginPath).toURI();
+ URI pathUri = new File(pluginPath, path).toURI();
+
+ List<File> files = new ArrayList<File>();
+ File f = new File(pluginPath, path);
+ FileUtil.getAllFiles(f, files, recursive);
+
+ // for each file found in the specified folder, get the localized file
+ for (Iterator it = files.iterator(); it.hasNext();) {
+ URI srcUri = ((File) it.next()).toURI();
+
+ // get the relative path of the file to the plugin root, then find
+ // the localized file
+ String relPath = pluginUri.relativize(srcUri).getPath();
+
+ // only get the locale specific file, don't include the default one
+ String localizedFile = getLocalizedFile(relPath, false);
+ if (localizedFile == null) {
+ continue;
+ }
+
+ // need to change the target file path to relative to the path
+ // instead of the plugin root
+ relPath = pathUri.relativize(srcUri).getPath();
+ File srcFile = new File(localizedFile);
+ File targetFile = new File(toDir, relPath);
+ File targetParent = targetFile.getParentFile();
+
+ // copy the file to the desitination
+ // if useLocaleFileName is true, the destination file name should
+ // also use the locale specific file name
+ if (useLocaleFileName) {
+ String fileName = srcFile.getName();
+ targetFile = new File(targetParent, fileName);
+ }
+
+ if (isDebugging()) {
+ System.out.println("Copying localized file: "); //$NON-NLS-1$
+ System.out.println("Source: " + srcFile); //$NON-NLS-1$
+ System.out.println("Target: " + targetFile); //$NON-NLS-1$
+ System.out.println(""); //$NON-NLS-1$
+ }
+
+ try {
+ if (!targetParent.exists()) {
+ targetParent.mkdirs();
+ }
+
+ if (!targetFile.exists()) {
+ targetFile.createNewFile();
+ }
+
+ FileUtil.copyFile(srcFile, targetFile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ /**
+ * Returns the localized resource.
+ *
+ * @param key
+ * The resource key.
+ * @return The localized resource.
+ */
+ public String getString(String key) {
+ if (resourceBundle != null) {
+ try {
+ return resourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ }
+ }
+ return '[' + key + ']';
+ }
+
+ /**
+ * Returns the formatted localized message given the resource key and the
+ * message argument.
+ *
+ * @param key
+ * The resource key.
+ * @param argument
+ * The message argument.
+ * @return The formatted localized message.
+ */
+ public String formatMessage(String key, Object argument) {
+ if (resourceBundle != null) {
+ try {
+ String msg = resourceBundle.getString(key);
+ Object[] arguments = { argument };
+ return MessageFormat.format(msg, arguments);
+ } catch (MissingResourceException e) {
+ }
+ }
+ return '[' + key + ']';
+ }
+
+ /**
+ * Returns the image URL given the relative path.
+ *
+ * @param relativePath
+ * The image's path relative to the plug-in's root.
+ * @return The image URL.
+ */
+ public URL getImageURL(String relativePath) {
+ try {
+ URL url = new URL(iconURL, relativePath);
+ return FileLocator.resolve(url);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the image descriptor given the relative path.
+ *
+ * @param relativePath
+ * The image's path relative to the plug-in's root.
+ * @return The image descriptor.
+ */
+ public ImageDescriptor getImageDescriptor(String relativePath) {
+ try {
+ URL url = new URL(iconURL, relativePath);
+ return ImageDescriptor.createFromURL(url);
+ } catch (MalformedURLException e) {
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+ }
+
+ /**
+ * Returns the image given the relative path.
+ * <p>
+ * Note: The returned image need to be freed by the caller.
+ *
+ * @param relativePath
+ * The image's path relative to the plug-in's root.
+ * @return The image.
+ */
+ public Image getImage(String relativePath) {
+ Image image = null;
+
+ ImageDescriptor imageDescriptor = getImageDescriptor(relativePath);
+ if (imageDescriptor != null) {
+ image = imageDescriptor.createImage(false);
+ }
+
+ return image;
+ }
+
+ /**
+ * Returns the shared image given the relative path.
+ * <p>
+ * Note: The returned image will be automatically freed when the plug-in
+ * shuts down.
+ *
+ * @param relativePath
+ * The image's path relative to the plug-in's root.
+ * @return The image.
+ */
+ public Image getSharedImage(String relativePath) {
+ Image image = (Image) sharedImages.get(relativePath);
+ if (image != null) {
+ return image;
+ }
+
+ ImageDescriptor imageDescriptor = getImageDescriptor(relativePath);
+ if (imageDescriptor != null) {
+ image = imageDescriptor.createImage(false);
+ if (image != null) {
+ sharedImages.put(relativePath, image);
+ }
+ }
+
+ return image;
+ }
+
+ /**
+ * Returns the profiling flag.
+ *
+ * @return <code>true</code> if profiling is enabled for this plu-in
+ */
+ public boolean isProfiling() {
+ return profiling;
+ }
+
+ /**
+ * Returns the logger given the plug-in ID.
+ *
+ * @return The new or cached logger.
+ */
+ public Logger getLogger() {
+ Logger logger = (Logger) loggers.get(pluginId);
+ if (logger == null) {
+ logger = new Logger(this);
+ loggers.put(pluginId, logger);
+ }
+ return logger;
+ }
+
+ /**
* Returns the message dialog given the plug-in ID.
*
* @return The new or cached message dialog.
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java
index 3dc8518..b28084c 100644
--- a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java
+++ b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java
@@ -25,8 +25,8 @@
super.start(context);
// // set the preference store for the common plugin
-// PreferenceStoreWrapper storeWrapper = new PreferenceStoreWrapper(getPreferenceStore());
-// CommonPlugin.getDefault().setPreferenceStore(storeWrapper);
+ PreferenceStoreWrapper storeWrapper = new PreferenceStoreWrapper(getPreferenceStore());
+ CommonPlugin.getDefault().setPreferenceStore(storeWrapper);
// create the message callback context for the non-ui plugins
// this is the context for message callback
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
index 63b018b..82f1f51 100644
--- a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
+++ b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
@@ -2,6 +2,13 @@
import org.eclipse.epf.common.IContextProvider;
+/**
+ * content provider for non-ui plugins
+ *
+ * @author Jinhua Xi
+ * @since 1.5
+ *
+ */
public class ContextProvider implements IContextProvider {
public Object getContext() {
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java
index fb9a5d3..b08351d 100644
--- a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java
+++ b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java
@@ -4,6 +4,13 @@
import org.eclipse.epf.common.IMessageCallback;
import org.eclipse.epf.common.ui.util.MsgDialog;
+/**
+ * message callback implementation
+ *
+ * @author Jinhua Xi
+ * @since 1.5
+ *
+ */
public class MessageCallback implements IMessageCallback {
public void displayWarning(AbstractActivator plugin, String title, String msg, String reason) {
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java
index 912c84f..0d62ccc 100644
--- a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java
+++ b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java
@@ -1,15 +1,60 @@
package org.eclipse.epf.common.ui;
-import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
-import org.eclipse.jface.preference.IPreferenceStore;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeListenerWrapper;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * wrapper class for preference store
+ *
+ * @author Jinhua Xi
+ * @since 1.5
+ *
+ */
public class PreferenceStoreWrapper implements IPreferenceStoreWrapper {
private IPreferenceStore store;
public PreferenceStoreWrapper(IPreferenceStore store) {
this.store = store;
}
- /**
+ Map<IPropertyChangeListenerWrapper, IPropertyChangeListener> listenerMap = new HashMap<IPropertyChangeListenerWrapper, IPropertyChangeListener>();
+
+ public Object getStore() {
+ return store;
+ }
+
+ public void addPropertyChangeListener(final IPropertyChangeListenerWrapper listener) {
+ // create a PropertyChangeListener and add to the store
+ IPropertyChangeListener pcl = new IPropertyChangeListener(){
+
+ public void propertyChange(PropertyChangeEvent event) {
+ PropertyChangeEventWrapper wrapper = new PropertyChangeEventWrapper(event);
+ listener.propertyChange(wrapper);
+
+ }};
+
+ listenerMap.put(listener, pcl);
+ store.addPropertyChangeListener(pcl);
+ }
+
+ public void firePropertyChangeEvent(String name, Object oldValue,
+ Object newValue) {
+ store.firePropertyChangeEvent(name, oldValue, newValue);
+ }
+
+ public void removePropertyChangeListener(IPropertyChangeListenerWrapper listener) {
+ IPropertyChangeListener pcl = listenerMap.remove(listener);
+ if ( pcl != null ) {
+ store.removePropertyChangeListener(pcl);
+ }
+ }
+
+ /**
* Returns the current value of the boolean-valued preference with the
* given name.
* Returns the default-default value (<code>false</code>) if there
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PropertyChangeEventWrapper.java b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PropertyChangeEventWrapper.java
new file mode 100644
index 0000000..b6698e0
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PropertyChangeEventWrapper.java
@@ -0,0 +1,55 @@
+package org.eclipse.epf.common.ui;
+
+import org.eclipse.epf.common.preferences.IPropertyChangeEventWrapper;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * wrapper class for property change event
+ *
+ * @author Jinhua Xi
+ * @since 1.5
+ *
+ */
+public class PropertyChangeEventWrapper implements IPropertyChangeEventWrapper {
+
+ private PropertyChangeEvent event;
+ public PropertyChangeEventWrapper(PropertyChangeEvent event) {
+ this.event = event;
+ }
+
+ /**
+ * Returns the new value of the property.
+ *
+ * @return the new value, or <code>null</code> if not known
+ * or not relevant (for instance if the property was removed).
+ */
+ public Object getNewValue() {
+ return this.event.getNewValue();
+ }
+
+ /**
+ * Returns the old value of the property.
+ *
+ * @return the old value, or <code>null</code> if not known
+ * or not relevant (for instance if the property was just
+ * added and there was no old value).
+ */
+ public Object getOldValue() {
+ return this.event.getOldValue();
+ }
+
+ /**
+ * Returns the name of the property that changed.
+ * <p>
+ * Warning: there is no guarantee that the property name returned
+ * is a constant string. Callers must compare property names using
+ * equals, not ==.
+ * </p>
+ *
+ * @return the name of the property that changed
+ */
+ public String getProperty() {
+ return this.event.getProperty();
+ }
+
+}
diff --git a/2.0/plugins/org.eclipse.epf.common/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.common/META-INF/MANIFEST.MF
index 1072ac5..a86e03b 100644
--- a/2.0/plugins/org.eclipse.epf.common/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.common/META-INF/MANIFEST.MF
@@ -10,8 +10,7 @@
Require-Bundle: com.ibm.icu;visibility:=reexport,
org.eclipse.core.resources;visibility:=reexport,
org.eclipse.core.runtime;visibility:=reexport,
- org.apache.ant,
- org.eclipse.ui
+ org.apache.ant
Eclipse-LazyStart: true
Export-Package: org.eclipse.epf.common,
org.eclipse.epf.common.html,
@@ -21,4 +20,6 @@
org.eclipse.epf.common.utils,
org.eclipse.epf.common.xml
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.eclipse.jface.resource,
+ org.eclipse.swt.graphics
diff --git a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
index 89150fe..87a072e 100644
--- a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
+++ b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
@@ -30,12 +30,13 @@
import org.eclipse.core.internal.runtime.InternalPlatform;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
import org.eclipse.epf.common.serviceability.Logger;
import org.eclipse.epf.common.utils.FileUtil;
import org.eclipse.epf.common.utils.I18nUtil;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -46,7 +47,7 @@
* @author Jinhua Xi
* @since 1.0
*/
-public abstract class AbstractActivator extends AbstractUIPlugin {
+public abstract class AbstractActivator extends Plugin {
// The relative path to the icons.
private static final String ICON_PATH = "icons/"; //$NON-NLS-1$;
@@ -500,6 +501,11 @@
}
}
+ public IPreferenceStoreWrapper getPreferenceStore() {
+ return CommonPlugin.getDefault().storeWrapper;
+ }
+
+
public Object getContext() {
if ( CommonPlugin.getDefault().contextProvider != null ) {
return CommonPlugin.getDefault().contextProvider.getContext();
diff --git a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java
index 0340696..9040d82 100644
--- a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java
+++ b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java
@@ -57,10 +57,10 @@
// * set the store wrapper before it's being used.
// * @param storeWrapper
// */
-// IPreferenceStoreWrapper storeWrapper = null;
-// public void setPreferenceStore(IPreferenceStoreWrapper storeWrapper) {
-// this.storeWrapper = storeWrapper;
-// }
+ IPreferenceStoreWrapper storeWrapper = null;
+ public void setPreferenceStore(IPreferenceStoreWrapper storeWrapper) {
+ this.storeWrapper = storeWrapper;
+ }
// this is the context for message callback
// for eclipse client, this is the Shell object
diff --git a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java
index 8b2ece2..183433f 100644
--- a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java
+++ b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java
@@ -1,9 +1,21 @@
package org.eclipse.epf.common.preferences;
-
+/**
+ * wrapper interface for preference store
+ *
+ * @author Jinhua Xi
+ * @since 1.5
+ *
+ */
public interface IPreferenceStoreWrapper {
+ public Object getStore();
+
+ public void addPropertyChangeListener(IPropertyChangeListenerWrapper listener);
+ public void firePropertyChangeEvent(String name, Object oldValue,
+ Object newValue);
+ public void removePropertyChangeListener(IPropertyChangeListenerWrapper listener);
/**
* Returns the current value of the boolean-valued preference with the
diff --git a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeEventWrapper.java b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeEventWrapper.java
new file mode 100644
index 0000000..99624fb
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeEventWrapper.java
@@ -0,0 +1,40 @@
+package org.eclipse.epf.common.preferences;
+
+/**
+ * wrapper interface for property change event
+ *
+ * @author Jinhua Xi
+ * @since 1.5
+ *
+ */
+public interface IPropertyChangeEventWrapper {
+
+ /**
+ * Returns the new value of the property.
+ *
+ * @return the new value, or <code>null</code> if not known
+ * or not relevant (for instance if the property was removed).
+ */
+ public Object getNewValue();
+
+ /**
+ * Returns the old value of the property.
+ *
+ * @return the old value, or <code>null</code> if not known
+ * or not relevant (for instance if the property was just
+ * added and there was no old value).
+ */
+ public Object getOldValue();
+
+ /**
+ * Returns the name of the property that changed.
+ * <p>
+ * Warning: there is no guarantee that the property name returned
+ * is a constant string. Callers must compare property names using
+ * equals, not ==.
+ * </p>
+ *
+ * @return the name of the property that changed
+ */
+ public String getProperty();
+}
diff --git a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java
index a11d503..2f7bf66 100644
--- a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java
+++ b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java
@@ -1,5 +1,13 @@
package org.eclipse.epf.common.preferences;
+/**
+ * wrapper interface for property change listener
+ *
+ * @author Jinhua Xi
+ * @since 1.5
+ *
+ */
public interface IPropertyChangeListenerWrapper {
+ public void propertyChange(IPropertyChangeEventWrapper event);
}
diff --git a/2.0/plugins/org.eclipse.epf.diagram.model/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.diagram.model/META-INF/MANIFEST.MF
index e19fba2..d9d79c0 100644
--- a/2.0/plugins/org.eclipse.epf.diagram.model/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.diagram.model/META-INF/MANIFEST.MF
@@ -9,8 +9,7 @@
org.eclipse.core.runtime,
org.eclipse.draw2d,
org.eclipse.emf.transaction,
- org.eclipse.emf.workspace,
- org.eclipse.ui
+ org.eclipse.emf.workspace
Eclipse-LazyStart: true
Export-Package: org.eclipse.epf.diagram.model,
org.eclipse.epf.diagram.model.impl,
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java
index ff9f370..b752e74 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.epf.common.AbstractActivator;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
import org.eclipse.jface.preference.IPreferenceStore;
import org.osgi.framework.Bundle;
@@ -35,9 +36,9 @@
private static IConfigurationApplicator configurationApplicator;
- private static IPreferenceStore preferenceStore;
+ private static IPreferenceStoreWrapper preferenceStore;
- private static AbstractActivator authoringPlugin;
+ private static IPreferenceStoreWrapper authoringPluginPreferenceStore;
private static Map commandTypeToListenersMap = new HashMap();
@@ -63,20 +64,20 @@
Providers.configurationApplicator = configurationApplicator;
}
- public static IPreferenceStore getPreferenceStore() {
+ public static IPreferenceStoreWrapper getPreferenceStore() {
return preferenceStore;
}
- public static void setPreferenceStore(IPreferenceStore preferenceStore) {
+ public static void setPreferenceStore(IPreferenceStoreWrapper preferenceStore) {
Providers.preferenceStore = preferenceStore;
}
- public static AbstractActivator getAuthoringPlugin() {
- return authoringPlugin;
+ public static IPreferenceStoreWrapper getAuthoringPluginPreferenceStore() {
+ return authoringPluginPreferenceStore;
}
- public static void setAuthoringPlugin(AbstractActivator plugin) {
- authoringPlugin = plugin;
+ public static void setAuthoringPluginPreferenceStore(IPreferenceStoreWrapper store) {
+ authoringPluginPreferenceStore = store;
}
public static void registerCommandListener(ICommandListener listener) {
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java
index eb8c8cc..b55f848 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java
@@ -37,8 +37,7 @@
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
-import org.eclipse.epf.common.AbstractActivator;
-import org.eclipse.epf.common.ui.AbstractPlugin;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
import org.eclipse.epf.library.edit.IConfigurable;
import org.eclipse.epf.library.edit.IConfigurator;
import org.eclipse.epf.library.edit.IFilter;
@@ -703,9 +702,8 @@
*/
public ComposedAdapterFactory createProcessComposedAdapterFactory() {
org.eclipse.epf.library.edit.process.consolidated.ItemProviderAdapterFactory adapterFactory = new org.eclipse.epf.library.edit.process.consolidated.ItemProviderAdapterFactory();
- AbstractActivator authoringPlugin = Providers.getAuthoringPlugin();
- if (authoringPlugin != null) {
- IPreferenceStore prefStore = authoringPlugin.getPreferenceStore();
+ IPreferenceStoreWrapper prefStore = Providers.getAuthoringPluginPreferenceStore();
+ if (prefStore != null) {
adapterFactory.setColumnIndexToNameMap(ProcessUtil
.toColumnIndexToNameMap(prefStore
.getString(LibraryEditConstants.PREF_WBS_COLUMNS)));
@@ -795,7 +793,7 @@
synchronized (this) {
if (procAdapterFactory == null) {
org.eclipse.epf.library.edit.process.consolidated.ItemProviderAdapterFactory adapterFactory = new org.eclipse.epf.library.edit.process.consolidated.ItemProviderAdapterFactory();
- final IPreferenceStore prefStore = Providers.getPreferenceStore();
+ final IPreferenceStore prefStore = (IPreferenceStore)Providers.getPreferenceStore();
if (prefStore != null) {
adapterFactory
.setColumnIndexToNameMap(ProcessUtil
@@ -884,10 +882,9 @@
// remove adapter factory as property change listener from
// preference store
//
- AbstractActivator authoringPlugin = Providers.getAuthoringPlugin();
- if (authoringPlugin != null) {
- IPreferenceStore prefStore = authoringPlugin
- .getPreferenceStore();
+ IPreferenceStore prefStore =
+ (IPreferenceStore)Providers.getAuthoringPluginPreferenceStore().getStore();
+ if (prefStore != null) {
for (int i = 0; i < procAdapterFactories.length; i++) {
Object adapterFactory = procAdapterFactories[i];
if (adapterFactory instanceof IPropertyChangeListener) {
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java
index fb197e1..59a5f41 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java
@@ -23,6 +23,8 @@
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeListenerWrapper;
import org.eclipse.epf.library.edit.IGroupContainer;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.Providers;
@@ -51,7 +53,7 @@
protected static final boolean processContributionEnabled = false;
- private IPropertyChangeListener prefStoreListener;
+ private IPropertyChangeListenerWrapper prefStoreListener;
/**
* @param adapterFactory
@@ -94,7 +96,7 @@
* @see org.eclipse.emf.edit.provider.ItemProviderAdapter#dispose()
*/
public void dispose() {
- IPreferenceStore prefStore = Providers.getPreferenceStore();
+ IPreferenceStoreWrapper prefStore = Providers.getPreferenceStore();
if (prefStore != null && prefStoreListener != null) {
prefStore.removePropertyChangeListener(prefStoreListener);
}
diff --git a/2.0/plugins/org.eclipse.epf.library.persistence/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.library.persistence/META-INF/MANIFEST.MF
index e7e3318..bdcb8dd 100644
--- a/2.0/plugins/org.eclipse.epf.library.persistence/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.library.persistence/META-INF/MANIFEST.MF
@@ -31,4 +31,3 @@
org.eclipse.epf.resourcemanager.util
Bundle-Activator: org.eclipse.epf.persistence.PersistencePlugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.eclipse.ui
diff --git a/2.0/plugins/org.eclipse.epf.library.xmi/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.library.xmi/META-INF/MANIFEST.MF
index 604f2bd..ebf9125 100644
--- a/2.0/plugins/org.eclipse.epf.library.xmi/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.library.xmi/META-INF/MANIFEST.MF
@@ -13,5 +13,3 @@
Export-Package: org.eclipse.epf.library.xmi,
org.eclipse.epf.library.xmi.preferences
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.eclipse.jface.preference,
- org.eclipse.ui
diff --git a/2.0/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/preferences/XMILibraryPreferences.java b/2.0/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/preferences/XMILibraryPreferences.java
index 705712a..a731e5f 100644
--- a/2.0/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/preferences/XMILibraryPreferences.java
+++ b/2.0/plugins/org.eclipse.epf.library.xmi/src/org/eclipse/epf/library/xmi/preferences/XMILibraryPreferences.java
@@ -10,6 +10,7 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.library.xmi.preferences;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
import org.eclipse.epf.common.utils.FileUtil;
import org.eclipse.epf.library.xmi.XMILibraryPlugin;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -29,7 +30,7 @@
static {
// Initialize the default preference values.
- IPreferenceStore store = XMILibraryPlugin.getDefault()
+ IPreferenceStoreWrapper store = XMILibraryPlugin.getDefault()
.getPreferenceStore();
String defaultLibraryPath = System.getProperty("user.home") //$NON-NLS-1$
// FIXME! Avoid using hard coded constant
diff --git a/2.0/plugins/org.eclipse.epf.library/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.library/META-INF/MANIFEST.MF
index 382bd9e..7e2d7c3 100644
--- a/2.0/plugins/org.eclipse.epf.library/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.library/META-INF/MANIFEST.MF
@@ -28,6 +28,5 @@
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.emf.ecore.xmi;visibility:=reexport,
- org.eclipse.ui,
org.eclipse.emf.edit.ui
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/AbstractLibraryManager.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/AbstractLibraryManager.java
index 1b4758e..c79b199 100644
--- a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/AbstractLibraryManager.java
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/AbstractLibraryManager.java
@@ -45,6 +45,8 @@
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.epf.common.preferences.IPropertyChangeEventWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeListenerWrapper;
import org.eclipse.epf.common.serviceability.DebugTrace;
import org.eclipse.epf.library.edit.TngAdapterFactory;
import org.eclipse.epf.library.edit.command.IActionManager;
@@ -74,8 +76,6 @@
import org.eclipse.epf.uma.UmaPackage;
import org.eclipse.epf.uma.ecore.impl.MultiResourceEObject;
import org.eclipse.epf.uma.util.AssociationHelper;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IPropertyListener;
/**
@@ -331,8 +331,8 @@
};
// Listen to preference store changes.
- private IPropertyChangeListener preferenceStoreChangeListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
+ private IPropertyChangeListenerWrapper preferenceStoreChangeListener = new IPropertyChangeListenerWrapper() {
+ public void propertyChange(IPropertyChangeEventWrapper event) {
if (event.getProperty().equals(
LibraryPreferences.DISCARD_UNRESOLVED_REFERENCES)) {
saveOptions.put(
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/preferences/LibraryPreferences.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/preferences/LibraryPreferences.java
index 7c94bed..a03d889 100644
--- a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/preferences/LibraryPreferences.java
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/preferences/LibraryPreferences.java
@@ -10,6 +10,7 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.library.preferences;
+import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
import org.eclipse.epf.library.LibraryPlugin;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -72,7 +73,7 @@
private static final int DEFAULT_ROLE_DIAGRAM_MAX_TEXT_LINES = 3;
// The plug-in specific preference store.
- private static IPreferenceStore prefStore = LibraryPlugin.getDefault()
+ private static IPreferenceStoreWrapper prefStore = LibraryPlugin.getDefault()
.getPreferenceStore();
static {
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/prefs/PreferenceUtil.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/prefs/PreferenceUtil.java
index 23af3a9..e91e154 100644
--- a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/prefs/PreferenceUtil.java
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/prefs/PreferenceUtil.java
@@ -132,7 +132,7 @@
private static List getPreferenceItems(String key) {
- IPreferenceStore store = LibraryPlugin.getDefault().getPreferenceStore();
+ IPreferenceStoreWrapper store = LibraryPlugin.getDefault().getPreferenceStore();
String str = store.getString(key);
if (str == null) {
str = store.getDefaultString(key);
@@ -207,7 +207,7 @@
}
public static void saveSelectedConfigIntoPersistence(String configName) {
- IPreferenceStore store = LibraryPlugin.getDefault()
+ IPreferenceStoreWrapper store = LibraryPlugin.getDefault()
.getPreferenceStore();
store
.setValue(
@@ -217,7 +217,7 @@
}
public static String getSavedLastConfig() {
- IPreferenceStore store = LibraryPlugin.getDefault()
+ IPreferenceStoreWrapper store = LibraryPlugin.getDefault()
.getPreferenceStore();
return store
.getString(LibraryPreferenceConstants.PREF_SELECTED_CONFIG_IN_LAST_SESSION);
diff --git a/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/preferences/PublishingPreferencePage.java b/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/preferences/PublishingPreferencePage.java
index 29199d0..ea59cea 100644
--- a/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/preferences/PublishingPreferencePage.java
+++ b/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/preferences/PublishingPreferencePage.java
@@ -14,7 +14,6 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.epf.authoring.ui.AuthoringUIText;
import org.eclipse.epf.common.utils.StrUtil;
-import org.eclipse.epf.publishing.PublishingPlugin;
import org.eclipse.epf.publishing.ui.PublishingUIPlugin;
import org.eclipse.epf.publishing.ui.PublishingUIResources;
import org.eclipse.epf.ui.preferences.BasePreferencePage;
@@ -180,7 +179,7 @@
* @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
*/
protected IPreferenceStore doGetPreferenceStore() {
- return PublishingPlugin.getDefault().getPreferenceStore();
+ return PublishingUIPlugin.getDefault().getPreferenceStore();
}
/**
diff --git a/2.0/plugins/org.eclipse.epf.search/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.search/META-INF/MANIFEST.MF
index 8a6b4a4..1e1c8b4 100644
--- a/2.0/plugins/org.eclipse.epf.search/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.search/META-INF/MANIFEST.MF
@@ -11,7 +11,6 @@
org.eclipse.epf.library;visibility:=reexport,
org.apache.lucene;visibility:=reexport,
org.eclipse.search,
- org.eclipse.ui,
org.eclipse.help.base
Eclipse-LazyStart: true
Export-Package: org.eclipse.epf.search,