Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common')
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java529
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java71
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java37
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java59
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java532
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PropertyChangeEventWrapper.java65
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/actions/CComboContributionItem.java164
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java122
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java60
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java598
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java47
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java123
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java626
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java127
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java173
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java208
16 files changed, 0 insertions, 3541 deletions
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java
deleted file mode 100644
index fa3ca270068..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/AbstractPlugin.java
+++ /dev/null
@@ -1,529 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2007 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-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.IActivator;
-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.
- *
- * @author Kelvin Low
- * @author Jinhua Xi
- * @author Phong Nguyen Le
- * @since 1.0
- */
-public abstract class AbstractPlugin extends AbstractUIPlugin implements IActivator {
-
-
- // 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.
- */
- public AbstractPlugin() {
- super();
- }
-
- /**
- * @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.
- */
- public static MsgDialog getMsgDialog(IActivator plugin) {
- MsgDialog msgDialog = (MsgDialog) msgDialogs.get(plugin.getId());
- if (msgDialog == null) {
- msgDialog = new MsgDialog(plugin);
- msgDialogs.put(plugin.getId(), msgDialog);
- }
- return msgDialog;
- }
-
-
- public MsgDialog getMsgDialog() {
- return getMsgDialog(this);
- }
-
- /**
- * Returns the standard display to be used. The method first checks, if the
- * thread calling this method has an associated disaply. If so, this display
- * is returned. Otherwise the method returns the default display.
- */
- public static Display getStandardDisplay() {
- Display display;
- display = Display.getCurrent();
- if (display == null)
- display = Display.getDefault();
- return display;
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java
deleted file mode 100644
index 3681e7d3c58..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/CommonUIPlugin.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial implementation
- *******************************************************************************/
-package org.eclipse.epf.common.ui;
-
-import org.eclipse.epf.common.CommonPlugin;
-import org.eclipse.epf.common.IMessageCallback;
-import org.eclipse.epf.common.ui.util.MsgBox;
-import org.osgi.framework.BundleContext;
-
-public class CommonUIPlugin extends AbstractPlugin {
-
- // The shared plug-in instance.
- private static CommonUIPlugin plugin;
-
- /**
- * Creates a new instance.
- */
- public CommonUIPlugin() {
- super();
- plugin = this;
- }
-
- /**
- * @see org.eclipse.epf.common.ui.AbstractPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
-
-// // set the preference store for the common plugin
- PreferenceStoreWrapper storeWrapper = new PreferenceStoreWrapper(getPreferenceStore());
- CommonPlugin.getDefault().setCommonPreferenceStore(storeWrapper);
-
- // create the message callback context for the non-ui plugins
- // this is the context for message callback
- // for eclipse client, this is the Shell object
- // shell object can't be shared acrooss thread, use a context provider instead
- //CommonPlugin.getDefault().setContext(MsgBox.getDefaultShell());
-
- CommonPlugin.getDefault().setContextProvider(new ContextProvider());
-
- // create the MessageCallback to be accessible to the non-ui plugin
- IMessageCallback msgCallback = new MessageCallback();
- }
-
- /**
- * @see org.eclipse.epf.common.ui.AbstractPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- plugin = null;
- }
-
- /**
- * Gets the shared instance.
- *
- * @return the shared plug-in instance
- */
- public static CommonUIPlugin getDefault() {
- return plugin;
- }
-
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
deleted file mode 100644
index 7530e31cf0d..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial implementation
- *******************************************************************************/
-package org.eclipse.epf.common.ui;
-
-import org.eclipse.epf.common.IContextProvider;
-import org.eclipse.epf.common.ui.util.MsgBox;
-
-/**
- * content provider for non-ui plugins
- *
- * @author Jinhua Xi
- * @since 1.5
- *
- */
-public class ContextProvider implements IContextProvider {
-
- public Object getContext() {
- //TODO: revisit
- Object ctx = null;
- try {
- ctx = CommonUIPlugin.getDefault().getWorkbench().getDisplay().getActiveShell();
- }
- catch(Exception e) {
- //
- }
- return ctx != null ? ctx : MsgBox.getDefaultShell();
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java
deleted file mode 100644
index dfef39b6621..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/MessageCallback.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial implementation
- *******************************************************************************/
-package org.eclipse.epf.common.ui;
-
-import org.eclipse.epf.common.AbstractActivator;
-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) {
- displayWarning(plugin, title, msg, reason, null, null);
- }
-
- public void displayWarning(AbstractActivator plugin, String msg, String reason, Throwable ex) {
- displayWarning(plugin, msg, reason, null, ex);
- }
-
- public void displayWarning(AbstractActivator plugin, String msg, String reason,
- String details, Throwable ex) {
- String title = CommonUIPlugin.getDefault().getWorkbench().getDisplay().getActiveShell().getText();
- displayWarning(plugin, title, msg, reason, details, ex);
- }
-
- public void displayWarning(AbstractActivator plugin, String title, String msg, String reason,
- String details, Throwable ex) {
- MsgDialog dlg = CommonUIPlugin.getDefault().getMsgDialog(plugin);
- dlg.displayWarning(title, msg, reason, details, ex);
- }
-
- public void displayError(AbstractActivator plugin, String title, String msg) {
- displayError(plugin, title, msg, null, null, null);
- }
-
- public void displayError(AbstractActivator plugin, String title, String msg, Throwable ex) {
- displayError(plugin, title, msg, null, null, ex);
- }
- public void displayError(AbstractActivator plugin, String title, String msg, String reason, String details, Throwable ex) {
- MsgDialog dlg = CommonUIPlugin.getDefault().getMsgDialog(plugin);
- dlg.displayError(title, msg, reason, details, ex);
-
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java
deleted file mode 100644
index 534f8af084b..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PreferenceStoreWrapper.java
+++ /dev/null
@@ -1,532 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial implementation
- *******************************************************************************/
-package org.eclipse.epf.common.ui;
-
-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 IPreferenceStore 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
- * is no preference with the given name, or if the current value
- * cannot be treated as a boolean.
- *
- * @param name the name of the preference
- * @return the boolean-valued preference
- */
- public boolean getBoolean(String name) {
- return store.getBoolean(name);
- }
-
- /**
- * Returns the default value for the boolean-valued preference
- * with the given name.
- * Returns the default-default value (<code>false</code>) if there
- * is no default preference with the given name, or if the default
- * value cannot be treated as a boolean.
- *
- * @param name the name of the preference
- * @return the default value of the named preference
- */
- public boolean getDefaultBoolean(String name) {
- return store.getDefaultBoolean(name);
- }
-
- /**
- * Returns the default value for the double-valued preference
- * with the given name.
- * Returns the default-default value (<code>0.0</code>) if there
- * is no default preference with the given name, or if the default
- * value cannot be treated as a double.
- *
- * @param name the name of the preference
- * @return the default value of the named preference
- */
- public double getDefaultDouble(String name) {
- return store.getDefaultDouble(name);
- }
-
- /**
- * Returns the default value for the float-valued preference
- * with the given name.
- * Returns the default-default value (<code>0.0f</code>) if there
- * is no default preference with the given name, or if the default
- * value cannot be treated as a float.
- *
- * @param name the name of the preference
- * @return the default value of the named preference
- */
- public float getDefaultFloat(String name) {
- return store.getDefaultFloat(name);
- }
-
- /**
- * Returns the default value for the integer-valued preference
- * with the given name.
- * Returns the default-default value (<code>0</code>) if there
- * is no default preference with the given name, or if the default
- * value cannot be treated as an integer.
- *
- * @param name the name of the preference
- * @return the default value of the named preference
- */
- public int getDefaultInt(String name) {
- return store.getDefaultInt(name);
- }
-
- /**
- * Returns the default value for the long-valued preference
- * with the given name.
- * Returns the default-default value (<code>0L</code>) if there
- * is no default preference with the given name, or if the default
- * value cannot be treated as a long.
- *
- * @param name the name of the preference
- * @return the default value of the named preference
- */
- public long getDefaultLong(String name) {
- return store.getDefaultLong(name);
- }
-
- /**
- * Returns the default value for the string-valued preference
- * with the given name.
- * Returns the default-default value (the empty string <code>""</code>)
- * is no default preference with the given name, or if the default
- * value cannot be treated as a string.
- *
- * @param name the name of the preference
- * @return the default value of the named preference
- */
- public String getDefaultString(String name) {
- return store.getDefaultString(name);
- }
-
- /**
- * Returns the current value of the double-valued preference with the
- * given name.
- * Returns the default-default value (<code>0.0</code>) if there
- * is no preference with the given name, or if the current value
- * cannot be treated as a double.
- *
- * @param name the name of the preference
- * @return the double-valued preference
- */
- public double getDouble(String name) {
- return store.getDouble(name);
- }
-
- /**
- * Returns the current value of the float-valued preference with the
- * given name.
- * Returns the default-default value (<code>0.0f</code>) if there
- * is no preference with the given name, or if the current value
- * cannot be treated as a float.
- *
- * @param name the name of the preference
- * @return the float-valued preference
- */
- public float getFloat(String name) {
- return store.getFloat(name);
- }
-
- /**
- * Returns the current value of the integer-valued preference with the
- * given name.
- * Returns the default-default value (<code>0</code>) if there
- * is no preference with the given name, or if the current value
- * cannot be treated as an integter.
- *
- * @param name the name of the preference
- * @return the int-valued preference
- */
- public int getInt(String name) {
- return store.getInt(name);
- }
-
- /**
- * Returns the current value of the long-valued preference with the
- * given name.
- * Returns the default-default value (<code>0L</code>) if there
- * is no preference with the given name, or if the current value
- * cannot be treated as a long.
- *
- * @param name the name of the preference
- * @return the long-valued preference
- */
- public long getLong(String name) {
- return store.getLong(name);
- }
-
- /**
- * Returns the current value of the string-valued preference with the
- * given name.
- * Returns the default-default value (the empty string <code>""</code>)
- * if there is no preference with the given name, or if the current value
- * cannot be treated as a string.
- *
- * @param name the name of the preference
- * @return the string-valued preference
- */
- public String getString(String name) {
- return store.getString(name);
- }
-
- /**
- * Returns whether the current value of the preference with the given name
- * has the default value.
- *
- * @param name the name of the preference
- * @return <code>true</code> if the preference has a known default value
- * and its current value is the same, and <code>false</code> otherwise
- * (including the case where the preference is unknown to this store)
- */
- public boolean isDefault(String name) {
- return store.isDefault(name);
- }
-
- /**
- * Returns whether the current values in this property store
- * require saving.
- *
- * @return <code>true</code> if at least one of values of
- * the preferences known to this store has changed and
- * requires saving, and <code>false</code> otherwise.
- */
- public boolean needsSaving() {
- return store.needsSaving();
- }
-
- /**
- * Sets the current value of the preference with the given name to
- * the given string value without sending a property change.
- * <p>
- * This method does not fire a property change event and
- * should only be used for setting internal preferences
- * that are not meant to be processed by listeners.
- * Normal clients should instead call #setValue.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new current value of the preference
- */
- public void putValue(String name, String value) {
- store.putValue(name, value);
- }
-
- /**
- * Sets the default value for the double-valued preference with the
- * given name.
- * <p>
- * Note that the current value of the preference is affected if
- * the preference's current value was its old default value, in which
- * case it changes to the new default value. If the preference's current
- * is different from its old default value, its current value is
- * unaffected. No property change events are reported by changing default
- * values.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new default value for the preference
- */
- public void setDefault(String name, double value) {
- store.setDefault(name, value);
- }
-
- /**
- * Sets the default value for the float-valued preference with the
- * given name.
- * <p>
- * Note that the current value of the preference is affected if
- * the preference's current value was its old default value, in which
- * case it changes to the new default value. If the preference's current
- * is different from its old default value, its current value is
- * unaffected. No property change events are reported by changing default
- * values.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new default value for the preference
- */
- public void setDefault(String name, float value) {
- store.setDefault(name, value);
- }
-
- /**
- * Sets the default value for the integer-valued preference with the
- * given name.
- * <p>
- * Note that the current value of the preference is affected if
- * the preference's current value was its old default value, in which
- * case it changes to the new default value. If the preference's current
- * is different from its old default value, its current value is
- * unaffected. No property change events are reported by changing default
- * values.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new default value for the preference
- */
- public void setDefault(String name, int value) {
- store.setDefault(name, value);
- }
-
- /**
- * Sets the default value for the long-valued preference with the
- * given name.
- * <p>
- * Note that the current value of the preference is affected if
- * the preference's current value was its old default value, in which
- * case it changes to the new default value. If the preference's current
- * is different from its old default value, its current value is
- * unaffected. No property change events are reported by changing default
- * values.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new default value for the preference
- */
- public void setDefault(String name, long value) {
- store.setDefault(name, value);
- }
-
- /**
- * Sets the default value for the string-valued preference with the
- * given name.
- * <p>
- * Note that the current value of the preference is affected if
- * the preference's current value was its old default value, in which
- * case it changes to the new default value. If the preference's current
- * is different from its old default value, its current value is
- * unaffected. No property change events are reported by changing default
- * values.
- * </p>
- *
- * @param name the name of the preference
- * @param defaultObject the new default value for the preference
- */
- public void setDefault(String name, String defaultObject) {
- store.setDefault(name, defaultObject);
- }
-
- /**
- * Sets the default value for the boolean-valued preference with the
- * given name.
- * <p>
- * Note that the current value of the preference is affected if
- * the preference's current value was its old default value, in which
- * case it changes to the new default value. If the preference's current
- * is different from its old default value, its current value is
- * unaffected. No property change events are reported by changing default
- * values.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new default value for the preference
- */
- public void setDefault(String name, boolean value) {
- store.setDefault(name, value);
- }
-
- /**
- * Sets the current value of the preference with the given name back
- * to its default value.
- * <p>
- * Note that the preferred way of re-initializing a preference to the
- * appropriate default value is to call <code>setToDefault</code>.
- * This is implemented by removing the named value from the store,
- * thereby exposing the default value.
- * </p>
- *
- * @param name the name of the preference
- */
- public void setToDefault(String name) {
- store.setToDefault(name);
- }
-
- /**
- * Sets the current value of the double-valued preference with the
- * given name.
- * <p>
- * A property change event is reported if the current value of the
- * preference actually changes from its previous value. In the event
- * object, the property name is the name of the preference, and the
- * old and new values are wrapped as objects.
- * </p>
- * <p>
- * Note that the preferred way of re-initializing a preference to its
- * default value is to call <code>setToDefault</code>.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new current value of the preference
- */
- public void setValue(String name, double value) {
- store.setValue(name, value);
- }
-
- /**
- * Sets the current value of the float-valued preference with the
- * given name.
- * <p>
- * A property change event is reported if the current value of the
- * preference actually changes from its previous value. In the event
- * object, the property name is the name of the preference, and the
- * old and new values are wrapped as objects.
- * </p>
- * <p>
- * Note that the preferred way of re-initializing a preference to its
- * default value is to call <code>setToDefault</code>.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new current value of the preference
- */
- public void setValue(String name, float value) {
- store.setValue(name, value);
- }
-
- /**
- * Sets the current value of the integer-valued preference with the
- * given name.
- * <p>
- * A property change event is reported if the current value of the
- * preference actually changes from its previous value. In the event
- * object, the property name is the name of the preference, and the
- * old and new values are wrapped as objects.
- * </p>
- * <p>
- * Note that the preferred way of re-initializing a preference to its
- * default value is to call <code>setToDefault</code>.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new current value of the preference
- */
- public void setValue(String name, int value) {
- store.setValue(name, value);
- }
-
- /**
- * Sets the current value of the long-valued preference with the
- * given name.
- * <p>
- * A property change event is reported if the current value of the
- * preference actually changes from its previous value. In the event
- * object, the property name is the name of the preference, and the
- * old and new values are wrapped as objects.
- * </p>
- * <p>
- * Note that the preferred way of re-initializing a preference to its
- * default value is to call <code>setToDefault</code>.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new current value of the preference
- */
- public void setValue(String name, long value) {
- store.setValue(name, value);
- }
-
- /**
- * Sets the current value of the string-valued preference with the
- * given name.
- * <p>
- * A property change event is reported if the current value of the
- * preference actually changes from its previous value. In the event
- * object, the property name is the name of the preference, and the
- * old and new values are wrapped as objects.
- * </p>
- * <p>
- * Note that the preferred way of re-initializing a preference to its
- * default value is to call <code>setToDefault</code>.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new current value of the preference
- */
- public void setValue(String name, String value) {
- store.setValue(name, value);
- }
-
- /**
- * Sets the current value of the boolean-valued preference with the
- * given name.
- * <p>
- * A property change event is reported if the current value of the
- * preference actually changes from its previous value. In the event
- * object, the property name is the name of the preference, and the
- * old and new values are wrapped as objects.
- * </p>
- * <p>
- * Note that the preferred way of re-initializing a preference to its
- * default value is to call <code>setToDefault</code>.
- * </p>
- *
- * @param name the name of the preference
- * @param value the new current value of the preference
- */
- public void setValue(String name, boolean value) {
- store.setValue(name, value);
- }
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PropertyChangeEventWrapper.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PropertyChangeEventWrapper.java
deleted file mode 100644
index 2d3a7717757..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/PropertyChangeEventWrapper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial implementation
- *******************************************************************************/
-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/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/actions/CComboContributionItem.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/actions/CComboContributionItem.java
deleted file mode 100644
index 1858e7f8bb6..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/actions/CComboContributionItem.java
+++ /dev/null
@@ -1,164 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2007 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.actions;
-
-import java.util.Collection;
-
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.CoolBar;
-import org.eclipse.swt.widgets.CoolItem;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-/**
- * Wraps a CCombo in a ContributionItem for use in a toolbar
- *
- * Does not use a ComboViewer because of tabbing issues - see bug 78885
- * @author Jeff Hardy
- *
- */
-public class CComboContributionItem extends ContributionItem {
-
- protected CCombo CCombo;
-
- protected ToolItem toolItem;
-
- protected CoolItem coolItem;
-
- protected int style;
-
- protected Collection<String> input;
-
- /**
- * Creates a new instance.
- */
- public CComboContributionItem(int style) {
- super();
- this.style = style;
- }
-
- /*
- * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.ToolBar,
- * int)
- */
- public void fill(ToolBar parent, int index) {
- toolItem = new ToolItem(parent, SWT.SEPARATOR);
- Control box = createControl(parent);
- toolItem.setControl(box);
- Point preferredSize = CCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- toolItem.setWidth(preferredSize.x);
- }
-
- /*
- * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.CoolBar,
- * int)
- */
- public void fill(CoolBar coolBar, int index) {
- Control box = createControl(coolBar);
-
- if (index >= 0) {
- coolItem = new CoolItem(coolBar, SWT.DROP_DOWN, index);
- } else {
- coolItem = new CoolItem(coolBar, SWT.DROP_DOWN);
- }
-
- // Set the back reference.
- coolItem.setData(this);
-
- // Add the toolbar to the CoolItem widget.
- coolItem.setControl(box);
-
- // If the toolbar item exists then adjust the size of the cool item.
- Point toolBarSize = box.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- // Set the preferred size to the size of the toolbar plus trim.
- coolItem.setMinimumSize(toolBarSize);
- coolItem.setPreferredSize(toolBarSize);
- coolItem.setSize(toolBarSize);
- }
-
- /*
- * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Composite)
- */
- public void fill(Composite parent) {
- createControl(parent);
- }
-
- /**
- * Creates the control.
- */
- protected Control createControl(final Composite parent) {
- CCombo = new CCombo(parent, style);
- CCombo.setVisibleItemCount(10);
- CCombo.setEnabled(true);
- CCombo.setItems(input.toArray(new String[0]));
- CCombo.addDisposeListener(
- new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- dispose();
- }
- });
-
- CCombo.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- performSelectionChanged();
- }
- });
-
- return CCombo;
- }
-
- /**
- * Returns the currently selected method configuration
- */
- protected int getSelectionIndex() {
- return CCombo.getSelectionIndex();
- }
-
- protected void setInput(Collection<String> input) {
- this.input = input;
- }
-
-
- protected void performSelectionChanged() {
- }
-
- /*
- * @see org.eclipse.jface.action.ContributionItem#dispose()
- */
- public void dispose() {
- super.dispose();
- }
-
- public CCombo getCCombo() {
- return CCombo;
- }
-
- public ToolItem getToolItem() {
- return toolItem;
- }
-
- public CoolItem getCoolItem() {
- return coolItem;
- }
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java
deleted file mode 100644
index 6fc767b6db4..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ClipboardUtil.java
+++ /dev/null
@@ -1,122 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.epf.common.utils.FileUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.HTMLTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Display;
-import org.osgi.framework.Bundle;
-
-/**
- * Utility class for retrieving data from the clipboard.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class ClipboardUtil {
-
- /**
- * The current clipboard.
- */
- private static Clipboard clipboard;
-
- private static final String SOURCE_URL = "SourceURL:"; //$NON-NLS-1$
-
- private static Transfer htmlTransfer = null;
-
- static {
- if (SWT.getPlatform().equals("win32")) { //$NON-NLS-1$
- try {
- boolean is64bit = (System.getProperty("os.arch").indexOf("64") != -1);
- Bundle bundle = null;
- if (is64bit) {
- bundle = Platform
- .getBundle("org.eclipse.epf.common.win32.win32.x86_64"); //$NON-NLS-1$
- } else {
- bundle = Platform
- .getBundle("org.eclipse.epf.common.win32.win32.x86"); //$NON-NLS-1$
- }
- if (bundle != null) {
- Class<?> c = bundle
- .loadClass("org.eclipse.epf.common.win32.Win32HTMLTransfer"); //$NON-NLS-1$
- if (c != null) {
- htmlTransfer = (Transfer) c.newInstance();
- }
- }
- } catch (Exception e) {
- htmlTransfer = null;
- }
- }
- }
-
- /**
- * Gets the HTML source URL from the current clipboard.
- *
- * @return the HTML source URL or <code>null</code>
- */
- public static String getHTMLSourceURL() {
- if (htmlTransfer == null) {
- return null;
- }
-
- Clipboard clipboard = new Clipboard(Display.getCurrent());
- String sourceURL = null;
- try {
- String htmlContent = (String) clipboard.getContents(htmlTransfer);
- if (htmlContent != null && htmlContent.length() > 0) {
- int index = htmlContent.indexOf(SOURCE_URL);
- if (index > 0) {
- sourceURL = htmlContent.substring(index
- + SOURCE_URL.length());
- sourceURL = sourceURL.substring(0, sourceURL
- .indexOf(FileUtil.LINE_SEP));
- }
- }
- if (sourceURL != null && sourceURL.indexOf("\\") != -1) { //$NON-NLS-1$
- // IE provides sourceURL in form "file://C:\foo\bar.htm"
- // but when the hrefs are resolved, files look like "file:///C:/foo/bar.htm"
- URL url = new URL(sourceURL);
- sourceURL = url.toExternalForm();
- if (sourceURL.startsWith("file://") && !sourceURL.startsWith("file:///")) { //$NON-NLS-1$ //$NON-NLS-2$
- // need to add a third / so rte.js can match the sourceURL to hrefs
- sourceURL = "file:///" + sourceURL.substring(7); //$NON-NLS-1$
- }
- }
- return sourceURL;
- } catch (MalformedURLException urlEx) {
- return sourceURL;
- } finally {
- clipboard.dispose();
- }
- }
-
- /**
- * Copy the string to the clipboard.
- */
- public static void copyTextHTMLToClipboard(String string) {
- if (clipboard != null)
- clipboard.dispose();
- clipboard = new Clipboard(null);
- clipboard.setContents(new Object[] { string, string },
- new Transfer[] { TextTransfer.getInstance(), HTMLTransfer.getInstance() });
- if (clipboard != null)
- clipboard.dispose();
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java
deleted file mode 100644
index d20685d3365..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/CommonPreferences.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial implementation
- *******************************************************************************/
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.epf.common.ui.CommonUIPlugin;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Manages the common preferences.
- *
- * @author Kelvin Low
- * @since 1.2
- */
-public class CommonPreferences {
-
- /**
- * Preference key for storing the preference history size.
- */
- private static final String PREFERENCE_HISTORY_SIZE = "preferenceHistorySize"; //$NON-NLS-1$
-
- // The plug-in specific preference store.
- private static IPreferenceStore prefStore = CommonUIPlugin.getDefault()
- .getPreferenceStore();
-
- static {
- // Initialize the default preference values.
- prefStore.setDefault(PREFERENCE_HISTORY_SIZE,
- getDefaultPreferenceHistorySize());
- }
-
- /**
- * Gets the default preference history size.
- */
- public static int getDefaultPreferenceHistorySize() {
- return 10;
- }
-
- /**
- * Gets the preference history size.
- */
- public static int getPreferenceHistorySize() {
- return prefStore.getInt(PREFERENCE_HISTORY_SIZE);
- }
-
- /**
- * Saves the preference history size.
- */
- public static void setPreferenceHistorySize(int value) {
- prefStore.setValue(PREFERENCE_HISTORY_SIZE, value);
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java
deleted file mode 100644
index 6793260c080..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/ErrorDialogNoReason.java
+++ /dev/null
@@ -1,598 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IconAndMessageDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Displays an error dialog without the Details button.
- *
- * @author Bingxue Xu
- * @since 1.0
- */
-public class ErrorDialogNoReason extends IconAndMessageDialog {
-
- /**
- * Static to prevent opening of error dialogs for automated testing.
- */
- public static final boolean AUTOMATED_MODE = false;
-
- /**
- * Reserve room for this many list items.
- */
- private static final int LIST_ITEM_COUNT = 7;
-
- /**
- * The nesting indent.
- */
- private static final String NESTING_INDENT = " "; //$NON-NLS-1$
-
- /**
- * The Details button.
- */
- protected Button detailsButton;
-
- /**
- * The title of the dialog.
- */
- private String title;
-
- /**
- * The SWT list control that displays the error details.
- */
- private List list;
-
- /**
- * Indicates whether the error details viewer is currently created.
- */
- private boolean listCreated = false;
-
- /**
- * Filter mask for determining which status items to display.
- */
- private int displayMask = 0xFFFF;
-
- /**
- * The main status object.
- */
- private IStatus status;
-
- /**
- * The current clipboard. To be disposed when closing the dialog.
- */
- private Clipboard clipboard;
-
- private boolean shouldIncludeTopLevelErrorInDetails = false;
-
- /**
- * Creates an error dialog. Note that the dialog will have no visual
- * representation (no widgets) until it is told to open.
- * <p>
- * Normally one should use <code>openError</code> to create and open one
- * of these. This constructor is useful only if the error object being
- * displayed contains child items <it>and </it> you need to specify a mask
- * which will be used to filter the displaying of these children.
- * </p>
- *
- * @param parentShell
- * the shell under which to create this dialog
- * @param dialogTitle
- * the title to use for this dialog, or <code>null</code> to
- * indicate that the default title should be used
- * @param message
- * the message to show in this dialog, or <code>null</code> to
- * indicate that the error's message should be shown as the
- * primary message
- * @param status
- * the error to show to the user
- * @param displayMask
- * the mask to use to filter the displaying of child items, as
- * per <code>IStatus.matches</code>
- * @see org.eclipse.core.runtime.IStatus#matches(int)
- */
- public ErrorDialogNoReason(Shell parentShell, String dialogTitle,
- String message, IStatus status, int displayMask) {
- super(parentShell);
- this.title = dialogTitle == null ? JFaceResources
- .getString("Problem_Occurred") : //$NON-NLS-1$
- dialogTitle;
- this.message = message == null ? status.getMessage() : message;
- this.status = status;
- this.displayMask = displayMask;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog. Handles the pressing of the Ok
- * or Details button in this dialog. If the Ok button was pressed then close
- * this dialog. If the Details button was pressed then toggle the displaying
- * of the error details area. Note that the Details button will only be
- * visible if the error being displayed specifies child details.
- */
- protected void buttonPressed(int id) {
- if (id == IDialogConstants.DETAILS_ID) {
- // was the details button pressed?
- toggleDetailsArea();
- } else {
- super.buttonPressed(id);
- }
- }
-
- /*
- * (non-Javadoc) Method declared in Window.
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(title);
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog.
- */
- protected void createButtonsForButtonBar(Composite parent) {
- // create OK and Details buttons
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
- true);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
- if (shouldShowDetailsButton()) {
- detailsButton = createButton(parent, IDialogConstants.DETAILS_ID,
- IDialogConstants.SHOW_DETAILS_LABEL, false);
- }
- }
-
- /**
- * This implementation of the <code>Dialog</code> framework method creates
- * and lays out a composite and calls <code>createMessageArea</code> and
- * <code>createCustomArea</code> to populate it. Subclasses should
- * override <code>createCustomArea</code> to add contents below the
- * message.
- */
- protected Control createDialogArea(Composite parent) {
- createMessageArea(parent);
- // create a composite with standard margins and spacing
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.numColumns = 2;
- composite.setLayout(layout);
- GridData childData = new GridData(GridData.FILL_BOTH);
- childData.horizontalSpan = 2;
- composite.setLayoutData(childData);
- composite.setFont(parent.getFont());
- return composite;
- }
-
- /*
- * @see IconAndMessageDialog#createDialogAndButtonArea(Composite)
- */
- protected void createDialogAndButtonArea(Composite parent) {
- super.createDialogAndButtonArea(parent);
- if (this.dialogArea instanceof Composite) {
- // Create a label if there are no children to force a smaller layout
- Composite dialogComposite = (Composite) dialogArea;
- if (dialogComposite.getChildren().length == 0)
- new Label(dialogComposite, SWT.NULL);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage()
- */
- protected Image getImage() {
- if (status != null) {
- if (status.getSeverity() == IStatus.WARNING)
- return getWarningImage();
- if (status.getSeverity() == IStatus.INFO)
- return getInfoImage();
- }
- // If it was not a warning or an error then return the error image
- return getErrorImage();
- }
-
- /**
- * Create this dialog's drop-down list component.
- *
- * @param parent
- * the parent composite
- * @return the drop-down list component
- */
- protected List createDropDownList(Composite parent) {
- // create the list
- list = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.MULTI);
- // fill the list
- populateList(list);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL
- | GridData.GRAB_VERTICAL);
- data.heightHint = list.getItemHeight() * LIST_ITEM_COUNT;
- data.horizontalSpan = 2;
- list.setLayoutData(data);
- list.setFont(parent.getFont());
- Menu copyMenu = new Menu(list);
- MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
- copyItem.addSelectionListener(new SelectionListener() {
- /*
- * @see SelectionListener.widgetSelected (SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- copyToClipboard();
- }
-
- /*
- * @see SelectionListener.widgetDefaultSelected(SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- copyToClipboard();
- }
- });
- copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
- list.setMenu(copyMenu);
- listCreated = true;
- return list;
- }
-
- /*
- * (non-Javadoc) Method declared on Window.
- */
- /**
- * Extends <code>Window.open()</code>. Opens an error dialog to display
- * the error. If you specified a mask to filter the displaying of these
- * children, the error dialog will only be displayed if there is at least
- * one child status matching the mask.
- */
- public int open() {
- if (!AUTOMATED_MODE && shouldDisplay(status, displayMask)) {
- return super.open();
- }
- setReturnCode(OK);
- return OK;
- }
-
- /**
- * Opens an error dialog to display the given error. Use this method if the
- * error object being displayed does not contain child items, or if you wish
- * to display all such items without filtering.
- *
- * @param parent
- * the parent shell of the dialog, or <code>null</code> if none
- * @param dialogTitle
- * the title to use for this dialog, or <code>null</code> to
- * indicate that the default title should be used
- * @param message
- * the message to show in this dialog, or <code>null</code> to
- * indicate that the error's message should be shown as the
- * primary message
- * @param status
- * the error to show to the user
- * @return the code of the button that was pressed that resulted in this
- * dialog closing. This will be <code>Dialog.OK</code> if the OK
- * button was pressed, or <code>Dialog.CANCEL</code> if this
- * dialog's close window decoration or the ESC key was used.
- */
- public static int openError(Shell parent, String dialogTitle,
- String message, IStatus status) {
- return openError(parent, dialogTitle, message, status, IStatus.OK
- | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
- }
-
- /**
- * Opens an error dialog to display the given error. Use this method if the
- * error object being displayed contains child items <it>and </it> you wish
- * to specify a mask which will be used to filter the displaying of these
- * children. The error dialog will only be displayed if there is at least
- * one child status matching the mask.
- *
- * @param parentShell
- * the parent shell of the dialog, or <code>null</code> if none
- * @param title
- * the title to use for this dialog, or <code>null</code> to
- * indicate that the default title should be used
- * @param message
- * the message to show in this dialog, or <code>null</code> to
- * indicate that the error's message should be shown as the
- * primary message
- * @param status
- * the error to show to the user
- * @param displayMask
- * the mask to use to filter the displaying of child items, as
- * per <code>IStatus.matches</code>
- * @return the code of the button that was pressed that resulted in this
- * dialog closing. This will be <code>Dialog.OK</code> if the OK
- * button was pressed, or <code>Dialog.CANCEL</code> if this
- * dialog's close window decoration or the ESC key was used.
- * @see org.eclipse.core.runtime.IStatus#matches(int)
- */
- public static int openError(Shell parentShell, String title,
- String message, IStatus status, int displayMask) {
- ErrorDialogNoReason dialog = new ErrorDialogNoReason(parentShell,
- title, message, status, displayMask);
- return dialog.open();
- }
-
- /**
- * Populates the list using this error dialog's status object. This walks
- * the child static of the status object and displays them in a list. The
- * format for each entry is status_path : status_message If the status's
- * path was null then it (and the colon) are omitted.
- *
- * @param listToPopulate
- * The list to fill.
- */
- private void populateList(List listToPopulate) {
- populateList(listToPopulate, status, 0,
- shouldIncludeTopLevelErrorInDetails);
- }
-
- /**
- * Populate the list with the messages from the given status. Traverse the
- * children of the status deeply and also traverse CoreExceptions that
- * appear in the status.
- *
- * @param listToPopulate
- * the list to populate
- * @param buildingStatus
- * the status being displayed
- * @param nesting
- * the nesting level (increases one level for each level of
- * children)
- * @param includeStatus
- * whether to include the buildingStatus in the display or just
- * its children
- */
- private void populateList(List listToPopulate, IStatus buildingStatus,
- int nesting, boolean includeStatus) {
-
- if (!buildingStatus.matches(displayMask)) {
- return;
- }
-
- Throwable t = buildingStatus.getException();
- boolean isCoreException = t instanceof CoreException;
- boolean incrementNesting = false;
-
- if (includeStatus) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < nesting; i++) {
- sb.append(NESTING_INDENT);
- }
- String message = buildingStatus.getMessage();
- sb.append(message);
- listToPopulate.add(sb.toString());
- incrementNesting = true;
- }
-
- if (!isCoreException && t != null) {
- // Include low-level exception message
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < nesting; i++) {
- sb.append(NESTING_INDENT);
- }
- String message = t.getLocalizedMessage();
- if (message == null)
- message = t.toString();
-
- sb.append(message);
- listToPopulate.add(sb.toString());
- incrementNesting = true;
- }
-
- if (incrementNesting)
- nesting++;
-
- // Look for a nested core exception
- if (isCoreException) {
- CoreException ce = (CoreException) t;
- IStatus eStatus = ce.getStatus();
- // Only print the exception message if it is not contained in the
- // parent message
- if (message == null || message.indexOf(eStatus.getMessage()) == -1) {
- populateList(listToPopulate, eStatus, nesting, true);
- }
- }
-
- // Look for child status
- IStatus[] children = buildingStatus.getChildren();
- for (int i = 0; i < children.length; i++) {
- populateList(listToPopulate, children[i], nesting, true);
- }
- }
-
- /**
- * Returns whether the given status object should be displayed.
- *
- * @param status
- * a status object
- * @param mask
- * a mask as per <code>IStatus.matches</code>
- * @return <code>true</code> if the given status should be displayed, and
- * <code>false</code> otherwise
- * @see org.eclipse.core.runtime.IStatus#matches(int)
- */
- protected static boolean shouldDisplay(IStatus status, int mask) {
- IStatus[] children = status.getChildren();
- if (children == null || children.length == 0) {
- return status.matches(mask);
- }
- for (int i = 0; i < children.length; i++) {
- if (children[i].matches(mask))
- return true;
- }
- return false;
- }
-
- /**
- * Toggles the unfolding of the details area. This is triggered by the user
- * pressing the details button.
- */
- private void toggleDetailsArea() {
- Point windowSize = getShell().getSize();
- Point oldSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- if (listCreated) {
- list.dispose();
- listCreated = false;
- detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL);
- } else {
- list = createDropDownList((Composite) getContents());
- detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL);
- }
- Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- getShell()
- .setSize(
- new Point(windowSize.x, windowSize.y
- + (newSize.y - oldSize.y)));
- }
-
- /**
- * Put the details of the status of the error onto the stream.
- *
- * @param buildingStatus
- * @param buffer
- * @param nesting
- */
- private void populateCopyBuffer(IStatus buildingStatus,
- StringBuffer buffer, int nesting) {
- if (!buildingStatus.matches(displayMask)) {
- return;
- }
- for (int i = 0; i < nesting; i++) {
- buffer.append(NESTING_INDENT);
- }
- buffer.append(buildingStatus.getMessage());
- buffer.append("\n"); //$NON-NLS-1$
-
- // Look for a nested core exception
- Throwable t = buildingStatus.getException();
- if (t instanceof CoreException) {
- CoreException ce = (CoreException) t;
- populateCopyBuffer(ce.getStatus(), buffer, nesting + 1);
- }
-
- IStatus[] children = buildingStatus.getChildren();
- for (int i = 0; i < children.length; i++) {
- populateCopyBuffer(children[i], buffer, nesting + 1);
- }
- }
-
- /**
- * Copy the contents of the statuses to the clipboard.
- */
- private void copyToClipboard() {
- if (clipboard != null)
- clipboard.dispose();
- StringBuffer statusBuffer = new StringBuffer();
- populateCopyBuffer(status, statusBuffer, 0);
- clipboard = new Clipboard(list.getDisplay());
- clipboard.setContents(new Object[] { statusBuffer.toString() },
- new Transfer[] { TextTransfer.getInstance() });
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#close()
- */
- public boolean close() {
- if (clipboard != null)
- clipboard.dispose();
- return super.close();
- }
-
- /**
- * Show the details portion of the dialog if it is not already visible. This
- * method will only work when it is invoked after the control of the dialog
- * has been set. In other words, after the <code>createContents</code>
- * method has been invoked and has returned the control for the content area
- * of the dialog. Invoking the method before the content area has been set
- * or after the dialog has been disposed will have no effect.
- *
- * @since 3.1
- */
- protected final void showDetailsArea() {
- if (!listCreated) {
- Control control = getContents();
- if (control != null && !control.isDisposed())
- toggleDetailsArea();
- }
- }
-
- /**
- * Return whether the Details button should be included. This method is
- * invoked once when the dialog is built. By default, the Details button is
- * only included if the status used when creating the dialog was a
- * multi-status or if the status contains an exception. Subclasses may
- * override.
- *
- * @return whether the Details button should be included
- * @since 3.1
- */
- protected boolean shouldShowDetailsButton() {
- return status.isMultiStatus() || status.getException() != null;
- }
-
- /**
- * Set the status displayed by this error dialog to the given status. This
- * only affects the status displayed by the Details list. The message, image
- * and title should be updated by the subclass, if desired.
- *
- * @param status
- * the status to be displayed in the details list
- * @since 3.1
- */
- protected final void setStatus(IStatus status) {
- if (this.status != status) {
- this.status = status;
- }
- shouldIncludeTopLevelErrorInDetails = true;
- if (listCreated) {
- repopulateList();
- }
- }
-
- /**
- * Repopulate the supplied list widget.
- */
- private void repopulateList() {
- if (list != null && !list.isDisposed()) {
- list.removeAll();
- populateList(list);
- }
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java
deleted file mode 100644
index 52a828d1e80..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MenuUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.swt.widgets.MenuItem;
-
-/**
- * A helper class for retrieving Eclipse menus.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class MenuUtil {
-
- /**
- * Searches an array of menu items and returns the menu item that matches
- * the given menu text.
- *
- * @param menuItems
- * An array of menu items.
- * @param text
- * The text to look for.
- * @return The menu item if found, <code>null</code> otherwise.
- */
- public static MenuItem getMenuItem(MenuItem[] menuItems, String text) {
- if (menuItems == null || text == null || text.length() == 0) {
- return null;
- }
-
- for (int i = 0; i < menuItems.length; i++) {
- if (menuItems[i].getText().startsWith(text)) {
- return menuItems[i];
- }
- }
-
- return null;
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java
deleted file mode 100644
index 1d97b41167a..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgBox.java
+++ /dev/null
@@ -1,123 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Helper class to display a message box.
- *
- * @author Phong Nguyen Le
- * @author Kelvin Low
- * @since 1.0
- */
-public final class MsgBox {
- /**
- * Use this method to show error message if you don't want long path to be
- * cut off.
- *
- * @param msg
- */
- public static final void nativeShowError(Shell shell, String msg) {
- if (shell == null) {
- shell = getDefaultShell();
- if (shell == null) {
- return;
- }
- }
- MessageBox msgBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
- msgBox.setMessage(msg);
- msgBox.setText(shell.getText());
- msgBox.open();
- }
-
- public static final void showError(String msg) {
- showError(getDefaultShell(), msg);
- }
-
- public static final void showError(Shell shell, String msg) {
- WrappedMessageDialog.openError(shell, shell == null ? null : shell
- .getText(), msg);
- }
-
- public static final void showWarning(String msg) {
- showWarning(getDefaultShell(), msg);
- }
-
- public static final void showWarning(Shell shell, String msg) {
- WrappedMessageDialog.openWarning(shell, shell == null ? null : shell
- .getText(), msg);
- }
-
- public static final Shell getDefaultShell() {
- try {
- Display d = Display.getCurrent();
- if (d == null) {
- d = Display.getDefault();
- }
-
- Shell s = null;
- if (d != null) {
- s = d.getActiveShell();
- }
-
- return s;
- } catch (RuntimeException e) {
- return null;
- }
- }
-
- public static final Display getDisplay() {
- try {
- Display d = Display.getCurrent();
- if (d == null) {
- d = Display.getDefault();
- }
-
- return d;
- } catch (RuntimeException e) {
- return null;
- }
- }
-
- public static final int prompt(String msg) {
- return prompt(getDefaultShell(), msg);
- }
-
- public static final int prompt(Shell shell, String msg) {
- return prompt(shell, null, msg, SWT.YES | SWT.NO | SWT.CANCEL);
- }
-
- public static final int prompt(String msg, int buttons) {
- return prompt(getDefaultShell(), null, msg, buttons);
- }
-
- public static final int prompt(String title, String msg, int buttons) {
- return prompt(getDefaultShell(), title, msg, buttons);
- }
-
- public static final int prompt(Shell shell, String msg, int buttons) {
- return prompt(shell, null, msg, buttons);
- }
-
- public static final int prompt(Shell shell, String title, String msg,
- int buttons) {
- MessageBox msgBox = new MessageBox(shell, buttons | SWT.ICON_QUESTION);
- msgBox.setText(title != null && title.length() > 0 ? title : shell
- .getText());
- msgBox.setMessage(msg);
- return msgBox.open();
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java
deleted file mode 100644
index e681d33a19d..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/MsgDialog.java
+++ /dev/null
@@ -1,626 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.epf.common.IActivator;
-import org.eclipse.epf.common.serviceability.Logger;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * A message dialog used for displaying error, warning, confirmation or
- * informational messages.
- *
- * @author Kelvin Low
- * @author Jinhua Xi
- * @author Phong Nguyen Le
- * @since 1.0
- */
-public class MsgDialog {
-
- // The plug-in ID.
- private String pluginId;
-
- // The plug-in logger.
- private Logger logger;
-
- /**
- * Create a new instance given the plug-in instance.
- *
- * @param plugin
- * The plugin instance.
- */
- public MsgDialog(IActivator plugin) {
- this.pluginId = plugin.getId();
- this.logger = plugin.getLogger();
- }
-
- protected Shell getShell() {
- return PlatformUI.getWorkbench().getDisplay().getActiveShell();
- }
-
- /**
- * Displays the given error message in an error dialog without the error
- * reason and Details button.
- * <p>
- * Note: The error message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- */
- public void displayError(String title, String msg) {
- display(IStatus.ERROR, title, msg, null, null, null);
- }
-
- /**
- * Displays the given error message in an error dialog without the error
- * reason and Details button.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param ex
- * The exception associated with the error.
- */
- public void displayError(String title, String msg, Throwable ex) {
- display(IStatus.ERROR, title, msg, null, null, ex);
- }
-
- /**
- * Displays the given error message in an error dialog without the Details
- * button.
- * <p>
- * Note: The error message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- */
- public void displayError(String title, String msg, String reason) {
- display(IStatus.ERROR, title, msg, reason, null, null);
- }
-
- /**
- * Displays the given error message in an error dialog without the Details
- * button.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param ex
- * The exception associated with the error.
- */
- public void displayError(String title, String msg, String reason,
- Throwable ex) {
- display(IStatus.ERROR, title, msg, reason, null, ex);
- }
-
- /**
- * Displays the given error message in an error dialog. The Details button
- * will be displayed if the <code>details</code> parameter it not null or
- * empty.
- * <p>
- * Note: The error message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param details
- * The error details.
- */
- public void displayError(String title, String msg, String reason,
- String details) {
- display(IStatus.ERROR, title, msg, reason, details, null);
- }
-
- /**
- * Displays the given error message in an error dialog. The Details button
- * will be displayed if the <code>details</code> parameter it not null or
- * empty.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param details
- * The error details.
- * @param ex
- * The exception associated with the error.
- */
- public void displayError(String title, String msg, String reason,
- String details, Throwable ex) {
- display(IStatus.ERROR, title, msg, reason, details, ex);
- }
-
- /**
- * Displays the given error status in an error dialog.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param status
- * The error status.
- */
- public int displayError(String title, IStatus status) {
- return display(title, null, status);
- }
-
- /**
- * Displays the given error status in an error dialog.
- * <p>
- * Note: The error message and the exception stack trace will be written to
- * the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param status
- * The error status.
- */
- public int displayError(String title, String msg, IStatus status) {
- return display(title, msg, status);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The waning message will be written to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- */
- public void displayWarning(String title, String msg) {
- display(IStatus.WARNING, title, msg, null, null, null);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- * @param ex
- * The exception associated with the warning.
- */
- public void displayWarning(String title, String msg, Throwable ex) {
- display(IStatus.WARNING, title, msg, null, null, ex);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The waning message will be written to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- */
- public void displayWarning(String title, String msg, String reason) {
- display(IStatus.WARNING, title, msg, reason, null, null);
- }
-
- /**
- * Displays the given warning message in a warning dialog without the
- * warning reason and Details button.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the warning dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- * @param ex
- * The exception associated with the warning.
- */
- public void displayWarning(String title, String msg, String reason,
- Throwable ex) {
- display(IStatus.WARNING, title, msg, reason, null, ex);
- }
-
- /**
- * Displays the given warning message in a warning dialog. The Details
- * button will be displayed if the <code>details</code> parameter it not
- * null or empty.
- * <p>
- * Note: The waning message will be written to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- * @param details
- * The warning details.
- */
- public void displayWarning(String title, String msg, String reason,
- String details) {
- display(IStatus.WARNING, title, msg, reason, details, null);
- }
-
- /**
- * Displays the given warning message in a warning dialog. The Details
- * button will be displayed if the <code>details</code> parameter it not
- * null or empty.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The warning message.
- * @param reason
- * The reason for the warning.
- * @param details
- * The warning details.
- * @param ex
- * The exception associated with the warning.
- */
- public void displayWarning(String title, String msg, String reason,
- String details, Throwable ex) {
- display(IStatus.WARNING, title, msg, reason, details, ex);
- }
-
- /**
- * Displays the given warning status in an error dialog.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param status
- * The error status.
- */
- public void displayWarning(String title, IStatus status) {
- display(title, null, status);
- }
-
- /**
- * Displays the given warning status in an error dialog.
- * <p>
- * Note: The warning message and the exception stack trace will be written
- * to the log file.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param status
- * The error status.
- */
- public void displayWarning(String title, String msg, IStatus status) {
- display(title, msg, status);
- }
-
- /**
- * Displays the given error or warning message in an error or warning
- * dialog. The Details button will be displayed if the <code>details</code>
- * parameter it not null or empty.
- *
- * @param severity
- * The severity, either IStatus.ERROR or IStatus.WARNING.
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param reason
- * The reason for the error.
- * @param details
- * The error details.
- * @param ex
- * The exception associated with the error.
- */
- public synchronized void display(int severity, String title, String msg,
- String reason, String details, Throwable ex) {
- if (msg == null && ex != null) {
- msg = ex.getMessage();
- }
-
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- if (severity == IStatus.ERROR || severity == IStatus.WARNING) {
- logger.logMsg(severity, msg, ex);
- } else {
- throw new IllegalArgumentException(
- "severity argument must be IStatus.ERROR or IStatus.WARNING"); //$NON-NLS-1$
- }
-
- Image oldImage = org.eclipse.jface.dialogs.ErrorDialog
- .getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- if (details != null && details.length() > 0) {
- MultiStatus mStatus = new MultiStatus(pluginId, IStatus.OK, reason,
- ex);
- Status status = new Status(severity, pluginId, IStatus.OK, details,
- ex);
- mStatus.add(status);
- org.eclipse.jface.dialogs.ErrorDialog.openError(shell, title, msg,
- mStatus);
- } else if (reason != null && reason.length() > 0) {
- Status status = new Status(severity, pluginId, IStatus.OK, reason,
- ex);
- org.eclipse.jface.dialogs.ErrorDialog.openError(shell, title, msg,
- status);
- } else {
- if (severity == IStatus.ERROR) {
- WrappedMessageDialog.openError(shell, title, msg);
- } else if (severity == IStatus.WARNING) {
- WrappedMessageDialog.openWarning(shell, title, msg);
- }
- }
-
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(oldImage);
- }
- }
-
- /**
- * Displays the given error or warning message in an error or warning
- * dialog. The Details button will be displayed if the <code>details</code>
- * parameter it not null or empty.
- *
- * @param title
- * The title for the error dialog.
- * @param status
- * The error status.
- */
- public synchronized int display(String title, IStatus status) {
- return display(title, null, status);
- }
-
- /**
- * Displays the given error or warning message in an error or warning
- * dialog. The Details button will be displayed if the <code>details</code>
- * parameter it not null or empty.
- *
- * @param title
- * The title for the error dialog.
- * @param msg
- * The error message.
- * @param status
- * The error status.
- */
- public synchronized int display(String title, String msg, IStatus status) {
- if (status == null) {
- throw new IllegalArgumentException("status argument cannot be null"); //$NON-NLS-1$
- }
-
- if (msg == null) {
- msg = status.getMessage();
- }
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- int severity = status.getSeverity();
- if (severity == IStatus.ERROR || severity == IStatus.WARNING) {
- logger.logMsg(severity, msg, status.getException());
- }
-
- Image oldImage = org.eclipse.jface.dialogs.ErrorDialog
- .getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- int rc = org.eclipse.jface.dialogs.ErrorDialog.openError(shell, title,
- msg, status);
-
- if (shellImage != null) {
- ErrorDialog.setDefaultImage(oldImage);
- }
-
- return rc;
- }
-
- /**
- * Displays the given message in a informational dialog with an "OK" button.
- *
- * @param title
- * The title for the information dialog.
- * @param msg
- * The message to display.
- */
- public void displayInfo(String title, String msg) {
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image oldImage = WrappedMessageDialog.getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
- WrappedMessageDialog.openInformation(shell, title, msg);
-
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(oldImage);
- }
- }
-
- /**
- * Displays the given message in a question dialog with a "Yes" and "No"
- * button.
- *
- * @param title
- * The title for the information dialog.
- * @param msg
- * The message to display.
- */
- public boolean displayPrompt(String title, String msg) {
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image oldImage = WrappedMessageDialog.getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
- boolean result = WrappedMessageDialog.openQuestion(shell, title, msg);
-
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(oldImage);
- }
-
- return result;
- }
-
- /**
- * Displays the given message in a confirmation dialog with a "Yes" and
- * "Cancel" button.
- *
- * @param title
- * The title for the information dialog.
- * @param msg
- * The message to display.
- */
- public boolean displayConfirmation(String title, String msg) {
- return displayConfirmationWithCheckBox(title, msg, null) > 0;
- }
-
- //return: 0 = cancel, 1 = ok with check-box checked, 2 = ok with check box unchecked
- public int displayConfirmationWithCheckBox(String title, String msg, String checkBoxLabel) {
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image oldImage = WrappedMessageDialog.getDefaultImage();
- Image shellImage = getShellImage();
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- if (shellImage != null) {
- WrappedMessageDialog.setDefaultImage(oldImage);
- }
-
- if (checkBoxLabel == null) {
- boolean b = WrappedMessageDialog.openConfirm(shell, title, msg);
- return b ? 1 : 0;
- }
-
- return WrappedMessageDialog.openConfirmWithCheckBox(shell, title, msg, checkBoxLabel);
- }
-
- public int displayConfirmation(String title, String msg, IStatus status) {
- if (status == null) {
- throw new IllegalArgumentException("status argument cannot be null"); //$NON-NLS-1$
- }
-
- if (msg == null) {
- msg = status.getMessage();
- }
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Image shellImage = getShellImage();
- if (shellImage != null) {
- ErrorDialogNoReason.setDefaultImage(shellImage);
- }
-
- Shell shell = getShell();
-
- int rc = ErrorDialogNoReason.openError(shell, title, msg, status);
-
- return rc;
-
- }
-
- /**
- * Returns the image for the current shell.
- *
- * @return The current shell image.
- */
- private Image getShellImage() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow workbenchWindow = workbench
- .getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- Shell shell = workbenchWindow.getShell();
- if (shell != null) {
- return shell.getImage();
- }
- }
- }
- return null;
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java
deleted file mode 100644
index a928ec798c8..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PerspectiveUtil.java
+++ /dev/null
@@ -1,127 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveRegistry;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-
-/**
- * Utility class for accessing perspectives.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class PerspectiveUtil {
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private PerspectiveUtil() {
- }
-
- /**
- * Returns the ID of the active perspective.
- *
- * @return The active perspective ID.
- */
- public static String getActivePerspectiveId() {
- if (PlatformUI.getWorkbench() == null || PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow() == null) {
- return null;
- }
-
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- IPerspectiveDescriptor activePerspective = activePage
- .getPerspective();
- return activePerspective.getId();
- }
- return null;
- }
-
- /**
- * Opens a perspective.
- *
- * @param perspectiveId
- * The perspective ID.
- * @return The previously active perspective.
- */
- public static IPerspectiveDescriptor openPerspective(String perspectiveId) {
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- IPerspectiveRegistry registry = PlatformUI.getWorkbench()
- .getPerspectiveRegistry();
- IPerspectiveDescriptor oldPerspective = activePage.getPerspective();
- if (!oldPerspective.getId().equals(perspectiveId)) {
- IPerspectiveDescriptor perspective = registry
- .findPerspectiveWithId(perspectiveId);
- activePage.setPerspective(perspective);
- }
- return oldPerspective;
- } else {
- IWorkbenchWindow activeWindow = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- try {
- PlatformUI.getWorkbench().showPerspective(
- perspectiveId, activeWindow);
- } catch (WorkbenchException e) {
- }
- }
- return null;
- }
-
- /**
- * Returns true if the given perspective is already active.
- *
- * @param perspectiveId
- * The perspective ID.
- * @return
- */
- public static boolean isActivePerspective(String perspectiveId) {
- String activePerspectiveId = PerspectiveUtil.getActivePerspectiveId();
- if (perspectiveId == null || activePerspectiveId == null) {
- return false;
- }
- return activePerspectiveId.equalsIgnoreCase(perspectiveId);
- }
-
- /**
- * Returns the view part with the given view ID.
- *
- * @param viewId
- * The view ID.
- * @return The view part.
- */
- public static IViewPart getView(String viewId) {
- try {
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- IViewPart view = activePage.findView(viewId);
- if (view == null) {
- view = activePage.showView(viewId);
- }
- return view;
- }
- } catch (Exception e) {
- }
- return null;
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java
deleted file mode 100644
index 158d7d882ec..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/PreferenceUtil.java
+++ /dev/null
@@ -1,173 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2007 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import com.ibm.icu.util.StringTokenizer;
-
-/**
- * Utility class for accessing preferences.
- *
- * @author Kelvin Low
- * @since 1.2
- */
-public class PreferenceUtil {
-
- // The multi-string preference delimiter.
- private static final String PREFERENCE_DELIMITER = ";"; //$NON-NLS-1$
-
- /**
- * Gets a list containing string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @return a list of string values
- */
- public static List<String> getList(IPreferenceStore prefStore, String name) {
- List<String> values = new ArrayList<String>();
- if (prefStore != null && name != null) {
- String value = prefStore.getString(name);
- StringTokenizer tokenizer = new StringTokenizer(value,
- PREFERENCE_DELIMITER);
- int tokenCount = tokenizer.countTokens();
- for (int i = 0; i < tokenCount; i++) {
- values.add(tokenizer.nextToken());
- }
- }
- return values;
- }
-
- /**
- * Gets the string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @return a list of string preference values
- */
- public static String[] getStringValues(IPreferenceStore prefStore,
- String name) {
- List<String> list = getList(prefStore, name);
- String[] values = new String[list.size()];
- list.toArray(values);
- return values;
- }
-
- /**
- * Saves a list containing string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param values
- * a list of string values
- */
- public static void setList(IPreferenceStore prefStore, String name,
- List values) {
- if (prefStore != null && name != null && values != null) {
- StringBuffer buffer = new StringBuffer();
- for (Iterator it = values.iterator(); it.hasNext();) {
- String value = (String) it.next();
- buffer.append(value);
- buffer.append(PREFERENCE_DELIMITER);
- }
- prefStore.setValue(name, buffer.toString());
- }
- }
-
- /**
- * Adds a string value to a list containing string values associated with a
- * named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param value
- * a string value
- * @param defaultValue
- * a default string value that will be added to the end of the
- * list
- */
- public static void addToList(IPreferenceStore prefStore, String name,
- String value, String defaultValue) {
- if (prefStore != null && name != null && value != null) {
- List<String> list = getList(prefStore, name);
- list.remove(value);
- list.add(0, value);
-
- //adjust the list according to the history size
- int preferenceHistorySize = CommonPreferences.getPreferenceHistorySize();
- if (list.size() > preferenceHistorySize) {
- list = list.subList(0, preferenceHistorySize - 1);
- }
- if (defaultValue != null && defaultValue.length() > 0) {
- if (!list.contains(defaultValue)) {
- if (list.size() == preferenceHistorySize) {
- list.add(list.size() - 1, defaultValue);
- } else {
- list.add(defaultValue);
- }
- }
- }
-
- setList(prefStore, name, list);
- }
- }
-
- /**
- * Adds a string value to a list containing string values associated with a
- * named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param value
- * a string value
- */
- public static void addToList(IPreferenceStore prefStore, String name,
- String value) {
- addToList(prefStore, name, value, null);
- }
-
- /**
- * Saves an array of string values associated with a named preference.
- *
- * @param prefStore
- * a preference store
- * @param name
- * the preference name
- * @param values
- * an array of string values
- */
- public static void setStringValues(IPreferenceStore prefStore, String name,
- String[] values) {
- if (prefStore != null && name != null && values != null) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < values.length; i++) {
- buffer.append(values[i]);
- buffer.append(PREFERENCE_DELIMITER);
- }
- prefStore.setValue(name, buffer.toString());
- }
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java b/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java
deleted file mode 100644
index 926cc5ad791..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/util/WrappedMessageDialog.java
+++ /dev/null
@@ -1,208 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 IBM Corporation and others.
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// Contributors:
-// IBM Corporation - initial implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.common.ui.util;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Displays a message dialog that displays wrapped text.
- *
- * @author Bingxue Xu
- * @since 1.0
- */
-public class WrappedMessageDialog extends MessageDialog {
-
- public WrappedMessageDialog(Shell parentShell, String dialogTitle,
- Image dialogTitleImage, String dialogMessage, int dialogImageType,
- String[] dialogButtonLabels, int defaultIndex) {
- super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
- dialogImageType, dialogButtonLabels, defaultIndex);
- }
-
- protected Control createMessageArea(Composite composite) {
-
- Control rComposite = super.createMessageArea(composite);
-
- int minWidth = IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH;// + 300;
- // TO-DO: need to revist the # of dialog display units and margin
- // when in other languages
- int charsPerLine = minWidth / 4 - 15;
- GridData gd = (GridData) messageLabel.getLayoutData();
- gd.minimumWidth = minWidth;
- messageLabel.setText(addLineBreaks(message, charsPerLine));
-
- return rComposite;
- }
-
- String addLineBreaks(String msg, int maxChars) {
- // System.out.println("$$$ DEBUG: original message = " + msg);
-
- if (msg == null)
- return null;
-
- StringBuffer strBuf = new StringBuffer();
- int count = 0;
- for (int i = 0; i < msg.length(); i++) {
- strBuf.append(msg.charAt(i));
- if (Character.isWhitespace(msg.charAt(i)))
- count = 0;
- else
- count++;
-
- if (count >= maxChars) {
- if (!Character.isWhitespace(msg.charAt(i))) {
- strBuf.append("\n"); //$NON-NLS-1$
- }
- count = 0;
- }
- }
-
- // System.out.println("$$$ DEBUG: broken message = " +
- // strBuf.toString());
- return strBuf.toString();
- }
-
- public static boolean openConfirm(Shell parent, String title, String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, QUESTION, new String[] { IDialogConstants.OK_LABEL,
- IDialogConstants.CANCEL_LABEL }, 0); // OK is the
- // default
- return dialog.open() == 0;
- }
-
- static class ConfirmWithCheckBoxDialog extends WrappedMessageDialog {
- private String checkBoxLabel;
- private Button checkBox;
- private boolean checkBoxChecked = false;
-
- public ConfirmWithCheckBoxDialog(Shell parentShell, String dialogTitle,
- Image dialogTitleImage, String dialogMessage, int dialogImageType,
- String[] dialogButtonLabels, int defaultIndex, String checkBoxLabel) {
- super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
- dialogImageType, dialogButtonLabels, defaultIndex);
- this.checkBoxLabel = checkBoxLabel;
- }
-
- @Override
- protected Control createMessageArea(Composite composite) {
- Control rComposite = super.createMessageArea(composite);
-
- checkBox = new Button(composite, SWT.CHECK);
- checkBox.setText(checkBoxLabel);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- checkBox.setLayoutData(gd);
-
- return rComposite;
- }
-
- protected void buttonPressed(int buttonId) {
- checkBoxChecked = checkBox.getSelection();
- super.buttonPressed(buttonId);
- }
-
- public boolean isCheckBoxChecked() {
- return checkBoxChecked;
- }
-
- }
-
- //return: 0 = cancel, 1 = ok with check-box checked, 2 = ok with check box unchecked
- public static int openConfirmWithCheckBox(Shell parent, String title, String message, String checkBoxLabel) {
- ConfirmWithCheckBoxDialog dialog = new ConfirmWithCheckBoxDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, QUESTION, new String[] { IDialogConstants.OK_LABEL,
- IDialogConstants.CANCEL_LABEL }, 0, checkBoxLabel); // OK is the default
-
- int ix = dialog.open() ;
- if (ix != 0) {
- return 0;
- }
-
- return dialog.isCheckBoxChecked() ? 1 : 2;
- }
-
- public static void openError(Shell parent, String title, String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); // ok
- // is
- // the
- // default
- dialog.open();
- return;
- }
-
- public static void openInformation(Shell parent, String title,
- String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, INFORMATION,
- new String[] { IDialogConstants.OK_LABEL }, 0);
- // ok is the default
- dialog.open();
- return;
- }
-
- public static boolean openQuestion(Shell parent, String title,
- String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, QUESTION, new String[] { IDialogConstants.YES_LABEL,
- IDialogConstants.NO_LABEL }, 0); // yes is the
- // default
- return dialog.open() == 0;
- }
-
- public static void openWarning(Shell parent, String title, String message) {
- WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title,
- null, // accept
- // the
- // default
- // window
- // icon
- message, WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); // ok
- // is
- // the
- // default
- dialog.open();
- return;
- }
-}

Back to the top