Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/epf-richtext/org.eclipse.epf.common/src')
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java518
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java82
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IActivator.java23
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IContextProvider.java15
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLFormatter.java39
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLParser.java25
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IMessageCallback.java26
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/package.html5
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java440
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeEventWrapper.java50
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java23
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/DebugTrace.java104
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/Logger.java134
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/package.html5
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ExtensionHelper.java216
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/FileUtil.java1285
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/I18nUtil.java219
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IMarkerAttributeContributer.java25
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IObjectFactory.java23
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ImageUtil.java179
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/MathUtil.java25
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/NetUtil.java400
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ProfilingUtil.java60
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/RestartableJob.java123
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java676
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StringMatcher.java458
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ThreadUtil.java41
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/Timer.java49
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/WarUtil.java57
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/XMLUtil.java666
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ZipUtil.java106
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/package.html5
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/AbstractSAXParser.java216
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/XSLTProcessor.java449
-rw-r--r--extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/package.html5
35 files changed, 0 insertions, 6772 deletions
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
deleted file mode 100644
index b7593501458..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
+++ /dev/null
@@ -1,518 +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;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-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.core.runtime.Plugin;
-import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
-import org.eclipse.epf.common.serviceability.Logger;
-import org.eclipse.epf.common.utils.FileUtil;
-import org.eclipse.epf.common.utils.I18nUtil;
-import org.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 AbstractActivator extends Plugin 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.
- protected URL iconURL;
-
- // The profiling flag.
- private boolean profiling;
-
- /**
- * Default constructor.
- */
- public AbstractActivator() {
- 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;
- }
-
- /**
- * Logs the given object or message.
- */
- public void log(Object logEntry) {
- if (logEntry instanceof Throwable) {
- ((Throwable) logEntry).printStackTrace(System.err);
- } else {
- System.err.println(logEntry);
- }
- }
-
- public IPreferenceStoreWrapper getPreferenceStore() {
- return CommonPlugin.getDefault().getCommonPreferenceStore();
- }
-
-
- public Object getContext() {
- if ( CommonPlugin.getDefault().contextProvider != null ) {
- return CommonPlugin.getDefault().contextProvider.getContext();
- }
-
- return null;
- }
-
- public IMessageCallback getMsgCallback() {
- return CommonPlugin.getDefault().msgCallback;
- }
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java
deleted file mode 100644
index aa7c0c0d6ce..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/CommonPlugin.java
+++ /dev/null
@@ -1,82 +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;
-
-import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
-import org.osgi.framework.BundleContext;
-
-/**
- * The Common plug-in activator.
- */
-public final class CommonPlugin extends AbstractActivator {
-
- // The shared plug-in instance.
- private static CommonPlugin plugin;
-
- /**
- * Creates a new instance.
- */
- public CommonPlugin() {
- 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);
- }
-
- /**
- * @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 CommonPlugin getDefault() {
- return plugin;
- }
-
-// /**
-// * set the store wrapper before it's being used.
-// * @param storeWrapper
-// */
- private IPreferenceStoreWrapper storeWrapper = null;
-
- public void setCommonPreferenceStore(IPreferenceStoreWrapper storeWrapper) {
- this.storeWrapper = storeWrapper;
- }
-
- public IPreferenceStoreWrapper getCommonPreferenceStore() {
- return storeWrapper;
- }
-
- // this is the context for message callback
- // for eclipse client, this is the Shell object
- IContextProvider contextProvider = null;
-
- public void setContextProvider(IContextProvider contextProvider) {
- this.contextProvider = contextProvider;
- }
-
- IMessageCallback msgCallback = null;
- public void setMsgCallback(IMessageCallback msgCallback) {
- this.msgCallback = msgCallback;
- }
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IActivator.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IActivator.java
deleted file mode 100644
index 4ddeed449fb..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IActivator.java
+++ /dev/null
@@ -1,23 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2008 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;
-
-import org.eclipse.epf.common.serviceability.Logger;
-
-/**
- * @author Phong Nguyen Le
- * @since 1.5
- *
- */
-public interface IActivator {
- String getId();
- Logger getLogger();
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IContextProvider.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IContextProvider.java
deleted file mode 100644
index b361fcb8f17..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IContextProvider.java
+++ /dev/null
@@ -1,15 +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;
-
-public interface IContextProvider {
- public Object getContext();
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLFormatter.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLFormatter.java
deleted file mode 100644
index b9db6ff70d8..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLFormatter.java
+++ /dev/null
@@ -1,39 +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;
-
-import java.io.UnsupportedEncodingException;
-import java.util.regex.Pattern;
-
-public interface IHTMLFormatter {
-
- /*
- * String location = m.group(1);
- * String lineStr = m.group(2);
- * String columnStr = m.group(3);
- * String errorMsg = m.group(4);
- */
- public static final Pattern jTidyErrorParser = Pattern
- .compile(
- "(line\\s+(\\d+)\\s+column\\s+(\\d+))\\s+-\\s+(.+)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
-
- public static final String DIAGNOSTIC_SOURCE = "org.eclipse.epf.common.IHTMLFormatter"; //$NON-NLS-1$
-
- public static final Pattern p_whitespace = Pattern.compile("^\\s+", Pattern.MULTILINE); //$NON-NLS-1$
-
- public String formatHTML(String html, boolean returnBodyOnly, boolean forceOutput, boolean makeBare, boolean word2000) throws UnsupportedEncodingException;
-
- public String formatHTML(String text) throws UnsupportedEncodingException;
-
- public String getLastErrorStr();
-
- public String removeLeadingWhitespace(String input);
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLParser.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLParser.java
deleted file mode 100644
index dac8b72e6c3..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IHTMLParser.java
+++ /dev/null
@@ -1,25 +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;
-
-import java.io.File;
-import java.util.Properties;
-
-public interface IHTMLParser {
-
- public String getText();
-
- public String getSummary();
-
- public Properties getMetaTags();
-
- public void parse(File file) throws Exception;
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IMessageCallback.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IMessageCallback.java
deleted file mode 100644
index 362f33b983e..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/IMessageCallback.java
+++ /dev/null
@@ -1,26 +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;
-
-
-public interface IMessageCallback {
-
- public void displayWarning(AbstractActivator plugin, String title, String msg, String reason);
- public void displayWarning(AbstractActivator plugin, String msg, String reason, Throwable ex);
- public void displayWarning(AbstractActivator plugin, String msg, String reason, String details, Throwable ex);
- public void displayWarning(AbstractActivator plugin, String title, String msg, String reason, String details, Throwable ex);
-
- public void displayError(AbstractActivator plugin, String title, String msg);
- public void displayError(AbstractActivator plugin, String title, String msg, Throwable ex);
- public void displayError(AbstractActivator plugin, String title, String msg, String reason, String details, Throwable ex);
-
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/package.html b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/package.html
deleted file mode 100644
index dba34bd4a8f..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-Provides the activator for managing the Common plug-in's life cycle.
-</body>
-</html> \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java
deleted file mode 100644
index 938f1fc7820..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPreferenceStoreWrapper.java
+++ /dev/null
@@ -1,440 +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.preferences;
-
-
-/**
- * wrapper interface for preference store
- *
- * @author Jinhua Xi
- * @since 1.5
- *
- */
-public interface IPreferenceStoreWrapper {
-
- //public Object getStore();
-
- public void addPropertyChangeListener(IPropertyChangeListenerWrapper listener);
- public void firePropertyChangeEvent(String name, Object oldValue,
- Object newValue);
- public void removePropertyChangeListener(IPropertyChangeListenerWrapper listener);
-
- /**
- * Returns the current value of the boolean-valued preference with the
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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();
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
- /**
- * 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);
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeEventWrapper.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeEventWrapper.java
deleted file mode 100644
index e1b305c88a5..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeEventWrapper.java
+++ /dev/null
@@ -1,50 +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.preferences;
-
-/**
- * wrapper interface for property change event
- *
- * @author Jinhua Xi
- * @since 1.5
- *
- */
-public interface IPropertyChangeEventWrapper {
-
- /**
- * Returns the new value of the property.
- *
- * @return the new value, or <code>null</code> if not known
- * or not relevant (for instance if the property was removed).
- */
- public Object getNewValue();
-
- /**
- * Returns the old value of the property.
- *
- * @return the old value, or <code>null</code> if not known
- * or not relevant (for instance if the property was just
- * added and there was no old value).
- */
- public Object getOldValue();
-
- /**
- * Returns the name of the property that changed.
- * <p>
- * Warning: there is no guarantee that the property name returned
- * is a constant string. Callers must compare property names using
- * equals, not ==.
- * </p>
- *
- * @return the name of the property that changed
- */
- public String getProperty();
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java
deleted file mode 100644
index 9e4f195a868..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/preferences/IPropertyChangeListenerWrapper.java
+++ /dev/null
@@ -1,23 +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.preferences;
-
-/**
- * wrapper interface for property change listener
- *
- * @author Jinhua Xi
- * @since 1.5
- *
- */
-public interface IPropertyChangeListenerWrapper {
-
- public void propertyChange(IPropertyChangeEventWrapper event);
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/DebugTrace.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/DebugTrace.java
deleted file mode 100644
index 0e004d48034..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/DebugTrace.java
+++ /dev/null
@@ -1,104 +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.serviceability;
-
-/**
- * Helper utility for printing debug traces to the console.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class DebugTrace {
-
- /**
- * Prints a debug trace to the console.
- *
- * @param instance
- * a class instance
- * @param method
- * a method name
- * @param msg
- * a debug message
- * @param th
- * a <code>Throwable</code> object
- */
- public static void print(Object instance, String method, String msg,
- Throwable th) {
- StringBuffer debugMsg = new StringBuffer();
- if (instance != null) {
- debugMsg.append(instance.getClass().getName());
- if (method != null) {
- debugMsg.append('.').append(method);
- }
- debugMsg.append(": "); //$NON-NLS-1$
- }
- if (msg != null && msg.length() > 0) {
- debugMsg.append(msg);
- }
- System.out.println(debugMsg);
- if (th != null) {
- th.printStackTrace();
- }
- }
-
- /**
- * Prints a debug trace to the console.
- *
- * @param instance
- * a class instance
- * @param method
- * a method name
- * @param th
- * a <code>Throwable</code> object
- */
- public static void print(Object instance, String method, Throwable th) {
- print(instance, method, null, th);
- }
-
- /**
- * Prints a debug trace to the console.
- *
- * @param instance
- * a class instance
- * @param method
- * a method name
- * @param msg
- * a debug message
- */
- public static void print(Object instance, String method, String msg) {
- print(instance, method, msg, null);
- }
-
- /**
- * Prints a debug trace to the console.
- *
- * @param instance
- * a class instance
- * @param method
- * a method name
- */
- public static void print(Object instance, String method) {
- print(instance, method, null, null);
- }
-
- /**
- * Prints a debug trace to the console.
- *
- * @param th
- * a <code>Throwable</code> object
- */
- public static void print(Throwable th) {
- if (th != null) {
- th.printStackTrace();
- }
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/Logger.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/Logger.java
deleted file mode 100644
index d8e12460230..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/Logger.java
+++ /dev/null
@@ -1,134 +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.serviceability;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Generic logger used for logging status messages, warning messages, error
- * messages, and exception stack traces.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class Logger {
-
- public static String SeeLogFileForMoreDetails;
-
- // The plug-in instance.
- private Plugin plugin;
-
- // The plug-in ID.
- private String pluginId;
-
- /**
- * Create a new <code>Logger</code> given the plug-in instance.
- *
- * @param plugin
- * The plugin instance.
- */
- public Logger(Plugin plugin) {
- this.plugin = plugin;
- this.pluginId = plugin.getBundle().getSymbolicName(); //plugin.getId();
- }
-
- /**
- * Logs the given error message.
- *
- * @param msg
- * The error message.
- */
- public void logError(String msg) {
- logMsg(IStatus.ERROR, msg, null);
- }
-
- /**
- * Logs the given exception.
- *
- * @param ex
- * The exception.
- */
- public void logError(Throwable ex) {
- logMsg(IStatus.ERROR, null, ex);
- }
-
- /**
- * Logs the given error message and exception.
- *
- * @param msg
- * The error message.
- * @param ex
- * The exception.
- */
- public void logError(String msg, Throwable ex) {
- logMsg(IStatus.ERROR, msg, ex);
- }
-
- /**
- * Logs the given warning message.
- *
- * @param msg
- * The warning message.
- */
- public void logWarning(String msg) {
- logMsg(IStatus.WARNING, msg, null);
- }
-
- /**
- * Logs the given warning message and exception.
- *
- * @param msg
- * The warning message.
- * @param ex
- * The exception.
- */
- public void logWarning(String msg, Throwable ex) {
- logMsg(IStatus.WARNING, msg, ex);
- }
-
- /**
- * Logs the given status message and exception.
- *
- * @param msg
- * The status message.
- */
- public void logInfo(String msg) {
- logMsg(IStatus.INFO, msg, null);
- }
-
- /**
- * Logs the given message and exception.
- *
- * @param severity
- * The severity.
- * @param msg
- * The message.
- * @param ex
- * The exception.
- */
- public synchronized void logMsg(int severity, String msg, Throwable ex) {
- if (msg == null && ex != null) {
- msg = ex.getMessage();
- }
-
- if (msg == null) {
- msg = ""; //$NON-NLS-1$
- }
-
- Status status = new Status(severity, pluginId, IStatus.OK, msg, ex);
-
- // Call the Eclipse Logger.
- plugin.getLog().log(status);
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/package.html b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/package.html
deleted file mode 100644
index 7aed6dede63..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/serviceability/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-Provides common error handling, logging and versioning services.
-</body>
-</html> \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ExtensionHelper.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ExtensionHelper.java
deleted file mode 100644
index 2745046f8c6..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ExtensionHelper.java
+++ /dev/null
@@ -1,216 +0,0 @@
-//------------------------------------------------------------------------------
-//Copyright (c) 2005, 2008 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.utils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.epf.common.CommonPlugin;
-import org.eclipse.epf.common.IHTMLFormatter;
-import org.eclipse.epf.common.IHTMLParser;
-import org.osgi.framework.Bundle;
-
-/**
-* Helper class with methods to retrieve extensions
-* Moved part of org.eclipse.epf.library.edit.util.ExtensionManager, to allow
-* access by classes that have no dependency on org.eclipse.epf.library.edit
-*
-* @author Phong Nguyen Le
-* @author Weiping Lu
-* @since 1.5
-*/
-public class ExtensionHelper {
- private static Map IDToExtensionMap = new HashMap();
-
- public static Object createExtension(String namespace, String extensionPointName) {
- // Process the contributors.
- //
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(namespace, extensionPointName);
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- Object ext = null;
- ext_walk:
- for (int i = 0; i < extensions.length; i++) {
- IExtension extension = extensions[i];
- String pluginId = extension.getNamespaceIdentifier();
- Bundle bundle = Platform.getBundle(pluginId);
- IConfigurationElement[] configElements = extension
- .getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
- IConfigurationElement configElement = configElements[j];
- try {
- String className = configElement.getAttribute("class"); //$NON-NLS-1$
- if(className != null) {
- ext = bundle.loadClass(className).newInstance();
- break ext_walk;
- }
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- }
- }
- return ext;
- }
- return null;
- }
-
- public static Object getExtension(String namespace, String extensionPointName) {
- String ID = namespace + '.' + extensionPointName;
- Object ext = IDToExtensionMap.get(ID);
- if(ext == null) {
- synchronized (IDToExtensionMap) {
- ext = IDToExtensionMap.get(ID);
- if(ext == null) {
- ext = createExtension(namespace, extensionPointName);
- if(ext != null) {
- IDToExtensionMap.put(ID, ext);
- }
- }
- }
-
- }
- return ext;
- }
-
- /**
- * This is a special method to handle JTidy extensions
- *
- */
- public static Object createExtensionForJTidy(String namespace, String extensionPointName) {
- List<IHTMLFormatter> formaters = new ArrayList<IHTMLFormatter>();
- List<IHTMLParser> parsers = new ArrayList<IHTMLParser>();
-
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(namespace, extensionPointName);
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IExtension extension = extensions[i];
- String pluginId = extension.getNamespaceIdentifier();
- Bundle bundle = Platform.getBundle(pluginId);
- IConfigurationElement[] configElements = extension.getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
- IConfigurationElement configElement = configElements[j];
- try {
- String className = configElement.getAttribute("class"); //$NON-NLS-1$
- if(className != null) {
- Object obj = bundle.loadClass(className).newInstance();
- if (extensionPointName.equals("htmlFormatter")) { //$NON-NLS-1$
- formaters.add((IHTMLFormatter)obj);
- } else if (extensionPointName.equals("htmlParser")) { //$NON-NLS-1$
- parsers.add((IHTMLParser)obj);
- }
- }
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- }
- }
-
- if (formaters.size() > 0) {
- if (formaters.size() == 1) {
- return formaters.get(0);
- }
- return selectExtension(formaters);
- } else if (parsers.size() > 0) {
- if (parsers.size() == 1) {
- return parsers.get(0);
- }
- return selectExtension(parsers);
- }
- }
-
- return null;
- }
-
- private static Object selectExtension(List objs) {
- for (Object obj : objs) {
- String name = obj.getClass().getName();
- if (!(name.equals("org.eclipse.epf.common.html.DefaultHTMLFormatter") //$NON-NLS-1$
- || name.equals("org.eclipse.epf.common.html.DefaultHTMLParser"))) { //$NON-NLS-1$
- return obj;
- }
- }
-
- return null;
- }
-
- public static IMarkerAttributeContributer getMarkerAttributeContributer() {
- IMarkerAttributeContributer ret = (IMarkerAttributeContributer) getExtension(
- CommonPlugin.getDefault().getId(), "markerAttributeContributer");//$NON-NLS-1$
- return ret;
- }
-
- /**
- * Create object based on type and context through extension
- * @param type
- * @param context
- * @return created object or null if no extension is found
- */
- public static Object create(Class type, Object context) {
- IObjectFactory ret = (IObjectFactory) getExtension(
- CommonPlugin.getDefault().getId(), "objectFactory");//$NON-NLS-1$
- if (ret == null) {
- return null;
- }
- return ret.create(type, context);
- }
-
- public static <T>List<T> getExtensions(String namespace, String extensionPointName, Class<T> type) {
- List<T> list = new ArrayList<T>();
- try {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(namespace, extensionPointName);
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IExtension extension = extensions[i];
- String pluginId = extension.getNamespaceIdentifier();
- Bundle bundle = Platform.getBundle(pluginId);
- IConfigurationElement[] configElements = extension
- .getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
- IConfigurationElement configElement = configElements[j];
- try {
- String className = configElement.getAttribute("class"); //$NON-NLS-1$
- if(className != null) {
- Object ext = bundle.loadClass(className).newInstance();
- if(type.isInstance(ext)) {
- list.add((T)ext);
- }
- }
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- }
- }
- }
- }
- catch(Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- if(list.isEmpty()) {
- return Collections.<T>emptyList();
- }
- return list;
- }
-
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/FileUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/FileUtil.java
deleted file mode 100644
index bf8c51b2e74..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/FileUtil.java
+++ /dev/null
@@ -1,1285 +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.utils;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.nio.CharBuffer;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import java.nio.channels.OverlappingFileLockException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CodingErrorAction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.epf.common.CommonPlugin;
-import org.osgi.framework.Bundle;
-
-/**
- * Utility class for managing directories and files.
- *
- * @author Kelvin Low
- * @author Jinhua Xi
- * @since 1.0
- */
-public class FileUtil {
-
- /**
- * Platform-specific line separator.
- */
- public static final String LINE_SEP = System.getProperty("line.separator"); //$NON-NLS-1$
-
- /**
- * Platform-specific file separator.
- */
- public static final String FILE_SEP = System.getProperty("file.separator"); //$NON-NLS-1$
-
- /**
- * Platform-specific line separator length.
- */
- public static final int LINE_SEP_LENGTH = LINE_SEP.length();
-
- /**
- * UNC path prefix.
- */
- public static final String UNC_PATH_PREFIX = "\\\\"; //$NON-NLS-1$
-
- /**
- * UNC path prefix length.
- */
- public static final int UNC_PATH_PREFIX_LENGTH = UNC_PATH_PREFIX.length();
-
- /**
- * ISO-8859-1 encoding.
- */
- public static final String ENCODING_ISO_8859_1 = "ISO-8859-1"; //$NON-NLS-1$
-
- /**
- * UTF-8 encoding.
- */
- public static final String ENCODING_UTF_8 = "UTF-8";//$NON-NLS-1$
-
- private static Map<File, File> copiedFileMap;
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private FileUtil() {
- }
-
- /**
- * Returns the absolute path for a file or directory.
- *
- * @param file
- * a file or directory
- * @return the absolute path to the file or directory
- */
- public static String getAbsolutePath(File file) {
- return file.getAbsolutePath().replace('\\', '/');
- }
-
- /**
- * Returns the absolute path for a file or directory.
- *
- * @param path
- * a path to a file or directory
- * @return an absolute path to the file or directory
- */
- public static String getAbsolutePath(String path) {
- return getAbsolutePath(new File(path));
- }
-
- /**
- * Returns the absolute path for a URL.
- *
- * @param url
- * a URL
- * @return the absolute path of the URL
- */
- public static String getAbsolutePath(URL url) {
- String pathName = url.getFile().substring(1);
- String result = NetUtil.decodeUrl(pathName, null);
- return result;
- }
-
- /**
- * Returns the parent directory of a path.
- *
- * @param path
- * a path name
- * @return the name of the parent directory
- */
- public static String getParentDirectory(String path) {
- return (new File(path)).getParent();
- }
-
- /**
- * Returns the file name and extension from a path.
- *
- * @param path
- * a path name
- * @return the file name including the file extension
- */
- public static String getFileName(String path) {
- return getFileName(path, true);
- }
-
- /**
- * Returns the file name from a path, with or without the file extension.
- *
- * @param path
- * a path name
- * @param withExtension
- * if <code>true</code>, include the file extension in the
- * result
- * @return the file name with or without the file extension
- */
- public static String getFileName(String path, boolean withExtension) {
- String normalizedPath = path.replace('\\', '/');
-
- int prefixLength = 0;
- if (normalizedPath.startsWith(NetUtil.FILE_URI_PREFIX)) {
- prefixLength = NetUtil.FILE_URI_PREFIX_LENGTH;
- } else if (normalizedPath.startsWith(NetUtil.HTTP_URI_PREFIX)) {
- prefixLength = NetUtil.HTTP_URI_PREFIX_LENGTH;
- }
-
- String fileName;
- int index = normalizedPath.lastIndexOf("/"); //$NON-NLS-1$
- if (index < prefixLength) {
- fileName = normalizedPath.substring(prefixLength);
- } else {
- fileName = path.substring(index + 1);
- }
-
- if (withExtension) {
- return fileName;
- }
-
- index = fileName.indexOf("."); //$NON-NLS-1$
- return (index > 0) ? fileName.substring(0, index) : fileName;
- }
-
- /**
- * Returns the relative path of a path from a base path.
- *
- * @param path
- * a path
- * @param basePath
- * the base path
- * @return a relative path
- */
- public static String getRelativePathToBase(File path, File basePath) {
- try {
- String dir = path.toURL().toExternalForm();
- String baseDir = basePath.toURL().toExternalForm();
- StringBuffer result = new StringBuffer();
- if (dir.indexOf(baseDir) == 0) {
- String delta = dir.substring(baseDir.length());
- for (int i = 0; i < delta.length(); i++) {
- if (delta.charAt(i) == '/') {
- result.append("../"); //$NON-NLS-1$
- }
- }
- }
- return result.toString();
- } catch (Exception e) {
- return ""; //$NON-NLS-1$
- }
- }
-
- public static String getRelativePath(File path, File basePath) {
- try {
- String dir = path.toURL().toExternalForm();
- String baseDir = appendSeparator(basePath.toURL().toExternalForm(),
- "/"); //$NON-NLS-1$
- StringBuffer result = new StringBuffer();
- while (dir.indexOf(baseDir) == -1) {
- basePath = basePath.getParentFile();
- baseDir = appendSeparator(basePath.toURL().toExternalForm(),
- "/"); //$NON-NLS-1$
- result.append("../"); //$NON-NLS-1$
- }
- if (dir.indexOf(baseDir) == 0) {
- String delta = dir.substring(baseDir.length());
- result.append(delta);
- }
- return result.toString();
- } catch (Exception e) {
- return ""; //$NON-NLS-1$
- }
- }
-
- /**
- * Appends the platform specific path separator to the end of a path.
- *
- * @param path
- * a path name
- * @return the path name appended with the platform specific path separator
- */
- public static String appendSeparator(String path) {
- return appendSeparator(path, File.separator);
- }
-
- /**
- * Appends the given path separator to the end of a path
- *
- * @param path
- * a path name
- * @param separator
- * a path separator
- * @return the path name appended with the given separator
- */
- public static String appendSeparator(String path, String separator) {
- return path.endsWith(separator) ? path : path + separator;
- }
-
- /**
- * Removes the ending path separator from a path.
- *
- * @param path
- * a path name
- * @return the path name minus the platform specific path separator
- */
- public static String removeSeparator(String path) {
- return path.endsWith(File.separator) ? path.substring(0,
- path.length() - 1) : path;
- }
-
- /**
- * Removes the ending path separator from a path.
- *
- * @param path
- * a path name
- * @return the path name minus the path separator "\\" or "/"
- */
- public static String removeAllSeparator(String path) {
- return path.endsWith("/") || path.endsWith("\\") ? path.substring(0, path.length() - 1) : path; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Removes the ending path separator from a path.
- *
- * @param path
- * a path name
- * @param separator
- * a path separator
- * @return the path name minus the separator
- */
- public static String removeSeparator(String path, String separator) {
- return path.endsWith(separator) ? path.substring(0, path.length() - 1)
- : path;
- }
-
- /**
- * Replaces the file name with another in a path.
- *
- * @param path
- * a path name
- * @param oldFileName
- * the old file name
- * @param newFileName
- * the new file name
- * @return the new path name with the new file name
- */
- public static String replaceFileName(String path, String oldFileName,
- String newFileName) {
- int index = path.lastIndexOf(oldFileName);
- return path.substring(0, index) + newFileName;
- }
-
- /**
- * Replaces the file extension with another in a path.
- *
- * @param path
- * a path name
- * @param oldFileExt
- * rhe old file extension
- * @param newFileExt
- * the new file extension
- * @return the new path with the new file extension
- */
- public static String replaceExtension(String path, String oldExt,
- String newExt) {
- int index = path.lastIndexOf(oldExt);
- return path.substring(0, index) + newExt;
- }
-
- /**
- * Returns the locale-specific path of a base path.
- *
- * @param path
- * a base path name
- * @param localeStr
- * a locale string
- * @return the locale-specific path
- */
- public static String getLocalePath(String path, String localeStr) {
- if (StrUtil.isBlank(localeStr)) {
- return path;
- }
- String fileName = getFileName(path);
- return replaceFileName(path, fileName, localeStr + "/" + fileName); //$NON-NLS-1$
- }
-
- /**
- * Returns the locale-specific path of a base path.
- *
- * @param path
- * a base path name
- * @param locale
- * a locale object
- * @return the locale-specific path
- */
- public static String getLocalePath(String path, Locale locale) {
- return locale == null ? path : getLocalePath(path, locale.toString());
- }
-
- /**
- * Writes the given text to a text file.
- *
- * @param fileName
- * the target file name
- * @param text
- * the text to write
- * @return <code>true</code> if the given text is written successfully to
- * file
- */
- public static boolean writeFile(String filename, String text) {
- FileWriter writer = null;
- try {
- writer = new FileWriter(filename);
- writer.write(text);
- writer.flush();
- } catch (IOException e) {
- } finally {
- if (writer != null) {
- try {
- writer.close();
- return true;
- } catch (Exception e) {
- }
- }
- }
- return false;
- }
-
- /**
- * Write the given text to a file with UTF-8 encoding.
- *
- * @param fileName
- * the target file name
- * @param text
- * the text to write
- * @param append
- * if <code>true</code>, append the text to the end of the
- * file, if <code>false</code>, override the file
- * @return <code>true</code> if the given text is written successfully to
- * file
- */
- public static boolean writeUTF8File(String filename, String text) {
- return writeUTF8File(filename, text, false);
- }
-
- /**
- * Write the given text to a file with UTF-8 encoding.
- *
- * @param fileName
- * the target file name
- * @param text
- * the text to write
- * @param append
- * if <code>true</code>, append the text to the end of the
- * file, if <code>false</code>, override the file
- * @return <code>true</code> if the given text is written successfully to
- * file
- */
- public static boolean writeUTF8File(String filename, String text,
- boolean append) {
- OutputStreamWriter writer = null;
- FileOutputStream fileOut = null;
- try {
- fileOut = new FileOutputStream(filename, append);
- writer = new OutputStreamWriter(fileOut, ENCODING_UTF_8);
- writer.write(text);
- writer.flush();
- fileOut.flush();
- } catch (IOException e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- } finally {
- if (writer != null) {
- try {
- writer.close();
- return true;
- } catch (Exception e) {
- }
- }
- if (fileOut != null) {
- try {
- fileOut.close();
- return true;
- } catch (Exception e) {
- }
- }
- }
- return false;
- }
-
- /**
- * Write the content of the given URI to an output stream.
- *
- * @param uri
- * the source URI
- * @param output
- * the output stream
- */
- public static void writeFile(String uri, OutputStream output)
- throws IOException {
- if (uri == null) {
- return;
- }
-
- InputStream input = null;
- try {
- input = NetUtil.getInputStream(uri);
- int bytesRead;
- byte[] buf = new byte[4096];
- while ((bytesRead = input.read(buf, 0, 4096)) > 0) {
- output.write(buf, 0, bytesRead);
- }
- output.flush();
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (Exception e) {
- }
- }
- }
- }
-
- /**
- * Write the content of the given URI to a <code>PrintWriter</code>.
- *
- * @param uri
- * the source URI
- * @param writer
- * the <code>PrintWriter</code> object
- */
- public static void writeFile(String uri, PrintWriter pw) throws IOException {
- if (uri == null) {
- return;
- }
-
- InputStreamReader input = null;
- try {
- input = new InputStreamReader(NetUtil.getInputStream(uri));
- int charsRead;
- char[] buf = new char[4096];
- while ((charsRead = input.read(buf, 0, 4096)) > 0) {
- pw.write(buf, 0, charsRead);
- }
- pw.flush();
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (Exception e) {
- }
- }
- }
- }
-
- /**
- * Recursively delete all sub-directories and files in a directory except
- * for the directory itself.
- *
- * @param dir
- * the directory containing the sub-directories and files
- * @return <code>true</code> if the delete operation is successful
- */
- public static boolean deleteAllFiles(String dir) {
- boolean ret = true;
- File targetDir = new File(dir);
- File[] files = targetDir.listFiles();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- ret = ret && deleteAllFiles(files[i].getAbsolutePath());
- }
- ret = ret && files[i].delete();
- }
- }
-
- return ret;
- }
-
- public static boolean deleteTree(File file) {
- boolean ret = true;
-
- if (file.isDirectory()) {
- File[] files = file.listFiles();
- if (files != null) {
- for (File f : files) {
- if (!deleteTree(f)) {
- ret = false;
- }
- }
- }
- }
-
- if (!file.delete()) {
- ret = false;
- }
-
- return ret;
- }
-
- /**
- * Recursively delete all sub-directories and files in a directory except
- * for the directory itself and the specified file.
- *
- * @param dir
- * the directory containing the sub-directories and files
- * @param filesNotToDelete
- * a list of files and/or directories that should not be deleted
- * @return <code>true</code> if delete operation is successful
- */
- public static boolean deleteAllFiles(String dir, List<File> filesNotToDelete) {
- boolean ret = true;
- File targetDir = new File(dir);
- File[] files = targetDir.listFiles();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (!filesNotToDelete.contains(files[i])) {
- if (files[i].isDirectory()) {
- ret = ret
- && deleteAllFiles(files[i].getAbsolutePath(),
- filesNotToDelete);
- }
- ret = ret && files[i].delete();
- }
- }
- }
-
- return ret;
- }
-
- /**
- * Copies the content of the source file to the target file. Will overwrite
- * an existing file if it has write permission
- *
- * @param srcFile
- * the source file or path
- * @param tgtFile
- * the target file or path
- */
- public static boolean copyFile(File srcFile, File tgtFile) {
- Map<File, File> map = getCopiedFileMap();
- File keyFile = null;
- File valFile = null;
- if (map != null) {
- try {
- keyFile = tgtFile.getCanonicalFile();
- valFile = srcFile.getCanonicalFile();
- if (valFile.equals(map.get(keyFile))) {
- return true;
- }
- } catch (Exception e) {
- keyFile = valFile = null;
- }
- }
-
- try {
- boolean ret = copyfile(srcFile, tgtFile);
- if (map != null && keyFile != null && valFile != null) {
- map.put(keyFile, valFile);
- }
- return ret;
- } catch (IOException ex) {
- CommonPlugin.getDefault().getLogger().logError(ex);
- return false;
- }
- }
-
- /**
- * Copies the content of the source file to the target file.
- *
- * @param srcFileName
- * the source file name
- * @param tgtFileName
- * the target file name
- */
- public static boolean copyFile(String srcFileName, String tgtFileName) {
- return copyFile(new File(srcFileName), new File(tgtFileName));
- }
-
- /**
- * Copies one file to another.
- * <p>
- * If both source and destination are directories, delegates to
- * copydirectory().
- * <p>
- * source must exist and be readable
- * <p>
- * cannot copy a directory to a file
- * <p>
- * will not copy if timestamps and filesize match, will overwrite otherwise
- *
- * @param source
- * the source file
- * @param dest
- * the destination file
- * @throws IOException
- * if an error occurs during the copy operation
- */
- private static boolean copyfile(File source, File dest) throws IOException {
- if (source.equals(dest))
- // do not copy equal files
- return false;
-
- if (!source.exists() || !source.canRead()) {
- // source does not exist or can't read
- return false;
- }
-
- if (dest.exists() && !dest.canWrite()) {
- // dest exists and cannot be written
- return false;
- }
-
- if (source.isDirectory()) {
- if (dest.isFile()) {
- // can't copy a directory to a file
- return false;
- } else {
- // delegate to copydirectory
- return copydirectory(source, dest);
- }
- } else {
- // source is a file
- if (dest.isDirectory()) {
- String sourceFileName = source.getName();
- return copyfile(source, new File(dest, sourceFileName));
- }
- // both source and dest are files
- boolean needCopy = true;
- if (dest.exists()) {
- needCopy = (dest.lastModified() != source.lastModified())
- || (dest.length() != source.length());
- }
-
- if (needCopy) {
- FileInputStream input = null;
- FileOutputStream output = null;
-
- try {
- input = new FileInputStream(source);
- FileChannel in = input.getChannel();
- if (!dest.exists()) {
- dest.getParentFile().mkdirs();
- }
- output = new FileOutputStream(dest);
- FileChannel out = output.getChannel();
- out.transferFrom(in, 0, source.length());
- dest.setLastModified(source.lastModified());
- return true;
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- }
- }
- if (output != null) {
- try {
- output.close();
- } catch (IOException e) {
- }
- }
- }
- } else {
- // did not copy
- // return true because dest file is same as source
- return true;
- }
- }
- }
-
- /**
- * Copies the content of a directory to another directory.
- *
- * @param srcDirName
- * the source directory name
- * @param tgtDirName
- * the target directory name
- */
- public static boolean copyDir(File srcDir, File tgtDir) {
- try {
- return copydirectory(srcDir, tgtDir);
- } catch (IOException ex) {
- CommonPlugin.getDefault().getLogger().logError(ex);
- return false;
- }
- }
-
- /**
- * Copies the content of a directory to another directory.
- *
- * @param srcDirName
- * the source directory name
- * @param tgtDirName
- * the target directory name
- */
- public static boolean copyDir(String srcDirName, String tgtDirName) {
- return copyDir(new File(srcDirName), new File(tgtDirName));
- }
-
- /**
- * Copies one directory to another - operates ONLY on directories.
- * <p>
- * Both source and dest must exist.
- */
- private static boolean copydirectory(File sourceDir, File destDir)
- throws IOException {
- if (!sourceDir.exists() || !destDir.exists()) {
- return false;
- }
-
- if (!sourceDir.isDirectory() || !destDir.isDirectory()) {
- return false;
- }
-
- File[] files = sourceDir.listFiles();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- // calc destination name
- String destName = destDir
- + File.separator
- + files[i].getAbsolutePath().substring(
- sourceDir.getAbsolutePath().length() + 1);
- if (files[i].isFile()) {
- // copy the file
- copyfile(files[i], new File(destName));
- } else if (files[i].isDirectory()) {
- // copy directory recursively
- File destFile = new File(destName);
- destFile.mkdirs();
- copydirectory(files[i], destFile);
- }
- }
- }
- return true;
- }
-
- // for some reason, this guy locks the file, if you try to update the file,
- // got the following exception
- // java.io.FileNotFoundException:
- // (The requested operation cannot be performed on a file with a user-mapped
- // section open)
- // need to handle later
- public static CharBuffer readFile(File file) throws IOException {
- FileInputStream input = null;
- CharBuffer charBuffer = null;
- try {
- input = new FileInputStream(file);
- FileChannel inChannel = input.getChannel();
- int length = (int) inChannel.size();
- MappedByteBuffer byteBuffer = inChannel.map(
- FileChannel.MapMode.READ_ONLY, 0, length);
- Charset charset = Charset.forName(ENCODING_ISO_8859_1);
- CharsetDecoder decoder = charset.newDecoder();
- charBuffer = decoder.decode(byteBuffer);
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- }
- }
- }
- return charBuffer;
- }
-
- public static String readInputStream(InputStream input) throws IOException {
- String result = ""; //$NON-NLS-1$
- byte[] readData = new byte[8 * 1024];
- try {
- int bytesRead = 0;
- while ( (bytesRead = input.read(readData)) > 0) {
- result += new String(readData, 0, bytesRead);
- }
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- }
- }
- }
- return result;
- }
-
- public static StringBuffer readFile(File file, String encoding)
- throws IOException {
-
- StringBuffer result = new StringBuffer();
- FileInputStream fis = null;
- InputStreamReader reader = null;
- int size;
- try {
- Charset cs = Charset.forName(encoding);
- CharsetDecoder csd = cs.newDecoder();
- csd.onMalformedInput(CodingErrorAction.REPLACE);
- char[] buffer = new char[1024];
- fis = new FileInputStream(file);
- reader = new InputStreamReader(fis, csd);
- while ((size = reader.read(buffer, 0, 1024)) > 0) {
- result.append(buffer, 0, size);
- }
- } catch (Exception e) {
- // System.out.println(encoding);
- e.printStackTrace();
- } finally {
- if (fis != null) {
- fis.close();
- }
-
- if (reader != null) {
- reader.close();
- }
- }
-
- return result;
- }
-
- public static long getSize(File file) {
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(file);
- return fis.getChannel().size();
- }
- catch (IOException e) {
- //
- }
- finally {
- try {
- fis.close();
- }
- catch(Exception e) {
- //
- }
- }
- return -1;
- }
-
- /**
- * Uses Java 1.4's FileLock class to test for a file lock
- *
- * @param file
- * @return
- */
- public static boolean isFileLocked(File file) {
- boolean isLocked = false;
- FileOutputStream input = null;
- FileLock lock = null;
-
- if (!file.exists()) {
- return false;
- }
- try {
- input = new FileOutputStream(file);
- FileChannel fileChannel = input.getChannel();
-
- lock = fileChannel.tryLock();
-
- if (lock == null)
- isLocked = true;
- else
- lock.release();
- } catch (Exception e) {
- if (e instanceof SecurityException)
- // Can't write to file.
- isLocked = true;
- else if (e instanceof FileNotFoundException)
- isLocked = false;
- else if (e instanceof IOException)
- isLocked = true;
- // OverlappingFileLockException means that this JVM has it locked
- // therefore it is not locked to us
- else if (e instanceof OverlappingFileLockException)
- isLocked = false;
- // Could not get a lock for some other reason.
- else
- isLocked = true;
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (Exception ex) {
- }
- }
- }
- return isLocked;
- }
-
- /**
- * Locks a file for the current JVM. Will create the file if it does not
- * exist
- *
- * @param file
- * @return a FileLock object, or null if file could not be locked
- */
- public static FileLock lockFile(File file) {
- FileOutputStream input = null;
- FileLock lock = null;
- try {
- input = new FileOutputStream(file);
- FileChannel fileChannel = input.getChannel();
- lock = fileChannel.tryLock();
-
- if (lock.isValid())
- return lock;
- } catch (Exception e) {
- // Could not get a lock for some reason.
- return null;
- } finally {
- try {
- if (input != null && (lock == null || !lock.isValid())) {
- input.close();
- }
- } catch (Exception ex) {
- }
- }
- return null;
- }
-
- /**
- * Gets all files in a specified path.
- *
- * @param path
- * absolute path of a folder
- * @param fileList
- * a list to collect the files
- * @param recursive
- * if <code>true</code>, find the files in sub folders as well
- */
- public static void getAllFiles(File path, List<File> fileList,
- boolean recursive) {
- if (path.isDirectory()) {
- File[] files = path.listFiles();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].isFile()) {
- fileList.add(files[i]);
- } else if (recursive) {
- getAllFiles(files[i], fileList, recursive);
- }
- }
- }
- }
- }
-
- /**
- * Given a directory and extension, returns all files (recursively) whose
- * extension starts with a given extension.
- *
- * @param file
- * a directory
- * @param extension
- * a file extension
- * @return a colleciton of <code>File</code> with the given extension
- */
- public static List<File> fileList(File f, String extension) {
- extension = extension.toUpperCase();
- List<File> returnList = new ArrayList<File>();
- try {
- if (f.isDirectory()) {
- String[] flist = f.list();
- for (int i = 0; i < flist.length; ++i) {
- File fc = new File(f.getPath(), flist[i]);
- returnList.addAll(fileList(fc, extension));
- }
- } else {
- if (extension != null) {
- String name = f.getName().toUpperCase();
- if (name.lastIndexOf(".") != -1) //$NON-NLS-1$
- if (name
- .substring(name.lastIndexOf(".") + 1).startsWith(extension)) { //$NON-NLS-1$
- returnList.add(f);
- }
- } else
- returnList.add(f);
- }
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- return returnList;
- }
-
- /**
- * Given a directory and extension, returns all files (recursively) whose
- * extension does not starts with a given extension.
- *
- * @param file
- * a directory
- * @param extension
- * a file extension
- * @return a colleciton of <code>File</code> without the given extension
- */
- public static List<File> fileListExcludeExt(File f, String extension) {
- List<File> returnList = new ArrayList<File>();
- try {
- if (f.isDirectory()) {
- String[] flist = f.list();
- for (int i = 0; i < flist.length; ++i) {
- File fc = new File(f.getPath(), flist[i]);
- returnList.addAll(fileListExcludeExt(fc, extension));
- }
- } else {
- if (extension != null) {
- String name = f.getName();
- if (name.lastIndexOf(".") != -1) //$NON-NLS-1$
- if (!(name.substring(name.lastIndexOf(".") + 1).startsWith(extension))) { //$NON-NLS-1$
- returnList.add(f);
- }
- } else
- returnList.add(f);
- }
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- return returnList;
- }
-
- /**
- * Gets all file paths in the specified path.
- *
- * @param path,
- * absolute path of a folder
- * @param recursive
- * if <code>true</code>, find the files in sub folders as well
- */
- public static ArrayList<String> getAllFileAbsolutePaths(File path,
- boolean recursive) {
- ArrayList<File> files = new ArrayList<File>();
- getAllFiles(path, files, recursive);
- ArrayList<String> paths = new ArrayList<String>();
- for (int i = 0; i < files.size(); i++) {
- String absPath = ((File) files.get(i)).getAbsolutePath();
- paths.add(absPath);
- }
- return paths;
- }
-
- /**
- * Moves a file from a directory to another.
- * <p>
- * Attempts to rename the file first. If that fails, will copy the
- * sourceFile to destFile and delete the sourceFile.
- *
- * @param sourceFile
- * the source file
- * @param destFile
- * the destination file
- * @return
- */
- public static boolean moveFile(File sourceFile, File destFile) {
- try {
- doMoveFile(sourceFile, destFile);
- return true;
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- return false;
- }
- }
-
- public static void doMoveFile(File sourceFile, File destFile) throws IOException {
- // Try to rename the source file to the destination file.
- if (!sourceFile.renameTo(destFile)) {
- // Try to copy the source file to the destination file and
- // delete
- // the source file.
- copyfile(sourceFile, destFile);
- sourceFile.delete();
- }
- }
-
- private static Map<File, File> getCopiedFileMap() {
- return copiedFileMap;
- }
-
- public static void setCopiedFileMap(Map<File, File> copiedFileMap) {
- FileUtil.copiedFileMap = copiedFileMap;
- }
-
-
- /**
- * Unzips the contents of a zip file to a directory
- *
- * @param zipfile
- * source zip file
- * @param tgtDir
- * target directory
- */
- public static boolean unzip(File srcZipFile, File tgtDir) {
- if (! srcZipFile.exists() || ! tgtDir.exists()) {
- return false;
- }
-
- if (! tgtDir.isDirectory()) {
- return false;
- }
-
- try {
- ZipFile zipFile = new ZipFile(srcZipFile);
- Enumeration entries = zipFile.entries();
-
- while (entries.hasMoreElements()) {
- ZipEntry entry = (ZipEntry) entries.nextElement();
-
- File tgtFile = new File(tgtDir, entry.getName());
-
- if (entry.isDirectory() && ! tgtFile.exists()) {
- tgtFile.mkdirs();
-
- } else {
- File parentFolder = tgtFile.getParentFile();
- if (! parentFolder.exists()) {
- parentFolder.mkdirs();
- }
-
- copyInputStream(zipFile.getInputStream(entry),
- new BufferedOutputStream(new FileOutputStream(
- new File(tgtDir, entry.getName()))));
- }
- }
-
- zipFile.close();
- } catch (IOException ioe) {
- return false;
- }
- return false;
- }
-
- private static final void copyInputStream(InputStream in, OutputStream out)
- throws IOException {
- byte[] buffer = new byte[1024];
- int len;
-
- while ((len = in.read(buffer)) >= 0)
- out.write(buffer, 0, len);
-
- in.close();
- out.close();
- }
-
- public static class FileChecker {
- public IStatus syncExecCheckModify(List<String> modifiedFiles) {
- return Status.OK_STATUS;
- }
- }
-
- private static FileChecker fileChecker;
- private static void loadDeafultFileChecker() {
- if (fileChecker != null) {
- return;
- }
- Bundle bundle = Platform.getBundle("org.eclipse.epf.import");
- try {
- bundle.start();
- } catch (Exception e) {
- }
- }
- public static void setFileChecker(FileChecker fileChecker) {
- FileUtil.fileChecker = fileChecker;
- }
-
- public static IStatus syncExecCheckModify(List<String> modifiedFiles) {
- loadDeafultFileChecker();
- if (fileChecker != null) {
- return fileChecker.syncExecCheckModify(modifiedFiles);
- }
- return Status.OK_STATUS;
- }
-
- public static boolean binaryEqual(File f1, File f2) {
- BufferedInputStream is1 = null;
- BufferedInputStream is2 = null;
-
- int bufSz = 1024;
- byte buff1[] = new byte[bufSz];
- byte buff2[] = new byte[bufSz];
-
- try {
- is1 = new BufferedInputStream(new FileInputStream(f1));
- is2 = new BufferedInputStream(new FileInputStream(f2));
-
- int read1 = -1;
- int read2 = -1;
-
- do {
- int offset1 = 0;
- while (offset1 < bufSz
- && (read1 = is1.read(buff1, offset1, bufSz - offset1)) >= 0) {
- offset1 += read1;
- }
-
- int offset2 = 0;
- while (offset2 < bufSz
- && (read2 = is2.read(buff2, offset2, bufSz - offset2)) >= 0) {
- offset2 += read2;
- }
- if (offset1 != offset2)
- return false;
- if (offset1 != bufSz) {
- Arrays.fill(buff1, offset1, bufSz, (byte) 0);
- Arrays.fill(buff2, offset2, bufSz, (byte) 0);
- }
- if (!Arrays.equals(buff1, buff2))
- return false;
- } while (read1 >= 0 && read2 >= 0);
- if (read1 < 0 && read2 < 0)
- return true;
- return false;
-
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- return false;
- }
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/I18nUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/I18nUtil.java
deleted file mode 100644
index 9758975d8e3..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/I18nUtil.java
+++ /dev/null
@@ -1,219 +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.utils;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Helper utiltiies for handling internationalization.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class I18nUtil {
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private I18nUtil() {
- }
-
- /**
- * Returns the localized string associated with a resource key.
- *
- * @param resourceBundle
- * A resource bundle.
- * @param key
- * A resource key.
- * @return A localized string.
- */
- public static String getString(ResourceBundle resourceBundle, String key) {
- if (resourceBundle != null) {
- try {
- return resourceBundle.getString(key);
- } catch (MissingResourceException e) {
- }
- }
- return '[' + key + ']';
- }
-
- /**
- * Returns the localized string associated with a resource key and formatted
- * with a given string.
- *
- * @param resourceBundle
- * A resource bundle.
- * @param key
- * A resource key.
- * @param data
- * An object.
- * @return A formatted localized string.
- */
- public static String formatString(ResourceBundle resourceBundle,
- String key, Object data) {
- if (resourceBundle != null) {
- try {
- String localizedStr = resourceBundle.getString(key);
- return MessageFormat
- .format(localizedStr, new Object[] { data });
- } catch (MissingResourceException e) {
- }
- }
- return '[' + key + ']';
- }
-
- /**
- * Returns the localized string associated with a resource key and formatted
- * with two given string.
- *
- * @param resourceBundle
- * A resource bundle.
- * @param key
- * A resource key.
- * @param data1
- * An object.
- * @param data2
- * An object.
- * @return A formatted localized string.
- */
- public static String formatString(ResourceBundle resourceBundle,
- String key, Object data1, Object data2) {
- if (resourceBundle != null) {
- try {
- String localizedStr = resourceBundle.getString(key);
- return MessageFormat.format(localizedStr, new Object[] { data1,
- data2 });
- } catch (MissingResourceException e) {
- }
- }
- return '[' + key + ']';
- }
-
- /**
- * Returns the localized string associated with a resource key and formatted
- * with a given string.
- *
- * @param resourceBundle
- * A resource bundle.
- * @param key
- * A resource key.
- * @param data
- * An array of objects.
- * @return A formatted localized string.
- */
- public static String formatString(ResourceBundle resourceBundle,
- String key, Object[] data) {
- if (resourceBundle != null) {
- try {
- String localizedStr = resourceBundle.getString(key);
- return MessageFormat.format(localizedStr, data);
- } catch (MissingResourceException e) {
- }
- }
- return '[' + key + ']';
- }
-
- /**
- * Returns the localized integer value associated with a resource key.
- *
- * @param resourceBundle
- * A resource bundle.
- * @param key
- * A resource key.
- * @param defaultValue
- * The default value to return if the resource key cannot be
- * located.
- * @return A localized interger value.
- */
- public static int getInt(String intString,
- int defaultValue) {
- try {
- if (intString != null) {
- return Integer.parseInt(intString);
- }
- } catch (Exception e) {
- }
- return defaultValue;
- }
-
- /**
- * Returns the localized version of a US English resource file.
- *
- * @param path
- * The absolute path to a resource file.
- * @param locale
- * A locale.
- * @return The localized resource file. If none exists, return null.
- */
- public static String getLocalizedFile(String path, Locale locale) {
- if (locale.equals(Locale.US) || path == null) {
- return null;
- }
-
- // Build the locale string array. This is used to construct the
- // localized file names.
- String language = locale.getLanguage();
- String country = locale.getCountry();
- String variant = locale.getVariant();
-
- String[] localeStrs = new String[3];
- if (variant != null && variant.length() > 0) {
- localeStrs[0] = locale.toString();
- }
- if (country != null && country.length() > 0) {
- localeStrs[1] = language + "_" + country; //$NON-NLS-1$
- }
- if (language != null) {
- localeStrs[2] = language;
- }
-
- String dir = path.replace('\\', '/');
- String fileName;
-
- int pathIndex = dir.lastIndexOf("/"); //$NON-NLS-1$
- if (pathIndex > 0) {
- dir = path.substring(0, pathIndex + 1);
- fileName = path.substring(pathIndex + 1);
- } else {
- fileName = dir;
- dir = ""; //$NON-NLS-1$
- }
-
- String fileExt = ""; //$NON-NLS-1$
- int extIndex = fileName.lastIndexOf("."); //$NON-NLS-1$
- if (extIndex > 0) {
- fileExt = fileName.substring(extIndex);
- fileName = fileName.substring(0, extIndex);
- }
-
- fileName = dir + fileName + "_"; //$NON-NLS-1$
-
- // Look for the localized file.
- for (int i = 0; i < 3; i++) {
- if (localeStrs[i] != null) {
- // Gets the localized path name.
- String fname = fileName + localeStrs[i] + fileExt;
- File file = new File(fname);
- if (file.exists()) {
- return fname;
- }
- }
- }
-
- return null;
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IMarkerAttributeContributer.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IMarkerAttributeContributer.java
deleted file mode 100644
index ceba9ebd156..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IMarkerAttributeContributer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-//------------------------------------------------------------------------------
-//Copyright (c) 2005, 2008 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.utils;
-
-import org.eclipse.core.resources.IMarker;
-
-/**
-* Interface for adding additional attributes to markers
-*
-* @author Weiping Lu
-* @since 1.5
-*/
-public interface IMarkerAttributeContributer {
-
- void addAddtionalAttributes(IMarker marker, Object context);
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IObjectFactory.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IObjectFactory.java
deleted file mode 100644
index 21d93d3e722..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/IObjectFactory.java
+++ /dev/null
@@ -1,23 +0,0 @@
-//------------------------------------------------------------------------------
-//Copyright (c) 2005, 2008 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.utils;
-
-/**
-* Interface to create object based on type and context
-*
-* @author Weiping Lu
-* @since 1.5
-*/
-public interface IObjectFactory {
-
- Object create(Class type, Object context);
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ImageUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ImageUtil.java
deleted file mode 100644
index 9af9c4fb740..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ImageUtil.java
+++ /dev/null
@@ -1,179 +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.utils;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.Image;
-import java.awt.MediaTracker;
-import java.awt.font.FontRenderContext;
-import java.awt.font.LineBreakMeasurer;
-import java.awt.font.TextAttribute;
-import java.awt.font.TextLayout;
-import java.awt.geom.Point2D;
-import java.awt.image.BufferedImage;
-import java.text.AttributedCharacterIterator;
-import java.text.AttributedString;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Utility class for creating image files.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class ImageUtil {
-
- // The BufferedImage cache.
- private static HashMap<String, BufferedImage> imageCache = new HashMap<String, BufferedImage>();
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private ImageUtil() {
- }
-
- /**
- * Creates a <code>BufferedImage</code> from the given image file.
- *
- * @param imageFile
- * an image file
- * @param c
- * an AWT component
- */
- public static BufferedImage getBufferedImage(String imageFile, Component c) {
- if (imageFile == null || c == null) {
- return null;
- }
-
- BufferedImage bufferedImage = (BufferedImage) imageCache.get(imageFile);
- if (bufferedImage != null) {
- return bufferedImage;
- }
-
- Image image = c.getToolkit().getImage(imageFile);
- MediaTracker tracker = new MediaTracker(c);
- tracker.addImage(image, 0);
- try {
- tracker.waitForAll();
- } catch (InterruptedException e) {
- }
-
- bufferedImage = new BufferedImage(image.getWidth(c),
- image.getHeight(c), BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D g2d = bufferedImage.createGraphics();
- g2d.drawImage(image, 0, 0, c);
- imageCache.put(imageFile, bufferedImage);
-
- return bufferedImage;
- }
-
- /**
- * Returns <code>true</code> if the given image is loaded successfully.
- *
- * @param image
- * an AWT image
- * @param c
- * an AWT component
- */
- public static boolean waitForImage(Image image, Component c) {
- MediaTracker tracker = new MediaTracker(c);
- tracker.addImage(image, 0);
- try {
- tracker.waitForAll();
- } catch (InterruptedException ie) {
- }
- return (!tracker.isErrorAny());
- }
-
- /**
- * Draws the given text.
- *
- * @param g2d
- * the <code>Graphics2D</code> context
- * @param text
- * the text to be rendered
- * @param font
- * the font used for rendering the text
- * @param color
- * the color used for rendering the text
- * @param x
- * the horizontal coordinate used for rendering the text
- * @param y
- * the verticalcoordinate used for rendering the text
- */
- public static void drawText(Graphics2D g2d, String text, Font font,
- Color color, int x, int y) {
- if (text == null || text.length() == 0) {
- return;
- }
- g2d.setColor(color);
- FontRenderContext frc = g2d.getFontRenderContext();
- TextLayout textlayout = new TextLayout(text, font, frc);
- textlayout.draw(g2d, x, y);
- }
-
- /**
- * Draws the given text and wraps it based on the given width.
- *
- * @param g2d
- * the <code>Graphics2D</code> context
- * @param text
- * the text to be rendered
- * @param font
- * the font used for rendering the text
- * @param color
- * the color used for rendering the text
- * @param x
- * the horizontal coordinate used for rendering the text
- * @param y
- * the verticalcoordinate used for rendering the text
- * @param width
- * the maximum width used for wrapping the text
- * @param maxLine
- * the maximum number of line of wrapped text
- */
- public static void drawText(Graphics2D g2d, String text, Font font,
- Color color, int x, int y, float width, int maxLine) {
- if (text == null || text.length() == 0) {
- return;
- }
- float maxWrapWidth = width - 10;
- g2d.setColor(color);
- Point2D.Float pen = new Point2D.Float(x, y);
- Map<TextAttribute, Font> attributes = new HashMap<TextAttribute, Font>();
- attributes.put(TextAttribute.FONT, font);
- AttributedCharacterIterator textIterator = new AttributedString(text,
- attributes).getIterator();
- FontRenderContext frc = g2d.getFontRenderContext();
- LineBreakMeasurer measurer = new LineBreakMeasurer(textIterator, frc);
- int line = 1;
- while (line <= maxLine) {
- TextLayout layout = measurer.nextLayout(maxWrapWidth);
- if (layout == null)
- break;
- pen.y += layout.getAscent();
- float dx = 0;
- if (layout.isLeftToRight()) {
- dx = (width - layout.getAdvance());
- }
- layout.draw(g2d, pen.x + dx / 2, pen.y);
- pen.y += layout.getDescent() + layout.getLeading() - 1;
- line++;
- }
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/MathUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/MathUtil.java
deleted file mode 100644
index 0ad88f943e2..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/MathUtil.java
+++ /dev/null
@@ -1,25 +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.utils;
-
-/**
- * Utility class for performing math operations.
- *
- * @author Phong Nguyen Le
- * @since 1.0
- */
-public class MathUtil {
-
- public static final long ceil1000(long l) {
- return (l - (l & 7));
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/NetUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/NetUtil.java
deleted file mode 100644
index b12f20edf37..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/NetUtil.java
+++ /dev/null
@@ -1,400 +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.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-
-/**
- * Implements a utility class for managing URLs and URIs.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class NetUtil {
-
- /**
- * FILE scheme.
- */
- public final static String FILE_SCHEME = "file"; //$NON-NLS-1$
-
- /**
- * File URI prefix.
- */
- public final static String FILE_URI_PREFIX = FILE_SCHEME + ":/"; //$NON-NLS-1$
-
- /**
- * File URI prefix size.
- */
- public final static int FILE_URI_PREFIX_LENGTH = FILE_URI_PREFIX.length();
-
- /**
- * HTTP scheme.
- */
- public final static String HTTP_SCHEME = "http"; //$NON-NLS-1$
-
- /**
- * HTTP URI prefix.
- */
- public final static String HTTP_URI_PREFIX = HTTP_SCHEME + "://"; //$NON-NLS-1$
-
- /**
- * HTTP URI prefix size.
- */
- public final static int HTTP_URI_PREFIX_LENGTH = HTTP_URI_PREFIX.length();
-
- public static final String FILE_PREFIX_2 = "file://"; //$NON-NLS-1$
-
- public static final String FILE_PREFIX_3 = "file:///"; //$NON-NLS-1$
-
- /**
- * A table of hex values.
- */
- private final static String[] HEX_VALUES = {
- "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%28", "%29", "%2A", "%2B", "%2C", "%2D", "%2E", "%2F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%38", "%39", "%3A", "%3B", "%3C", "%3D", "%3E", "%3F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%48", "%49", "%4A", "%4B", "%4C", "%4D", "%4E", "%4F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%58", "%59", "%5A", "%5B", "%5C", "%5D", "%5E", "%5F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%68", "%69", "%6A", "%6B", "%6C", "%6D", "%6E", "%6F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%78", "%79", "%7A", "%7B", "%7C", "%7D", "%7E", "%7F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- };
-
- public static final String RAW_URL_RAW = "raw_URL_raw"; //$NON-NLS-1$
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private NetUtil() {
- }
-
- /**
- * Returns the URI for the given file.
- *
- * @param file
- * The input file.
- * @return The URI for the given file.
- * @throws MalformedURLException
- * if an error occur while constructing the URI for the given
- * file.
- */
- public static String getUri(File file) throws MalformedURLException {
- String url = file.toURL().toExternalForm();
- StringBuffer strBuf = new StringBuffer();
- int urlLength = url.length();
- for (int i = 0; i < urlLength; i++) {
- char ch = url.charAt(i);
- switch (ch) {
- case ' ':
- strBuf.append("%20"); //$NON-NLS-1$
- break;
- default:
- strBuf.append(ch);
- break;
- }
- }
- return strBuf.toString();
- }
-
- /**
- * Resolves the given URI using the given the base URI.
- *
- * @param uri
- * The URI to resolve.
- * @param baseUri
- * The base URI.
- * @return A fully formed URI.
- */
- public static String resolveUri(String uri, String baseUri) {
- if (uri == null) {
- return null;
- }
-
- if (uri.startsWith("../")) { //$NON-NLS-1$
- if (baseUri.endsWith("/")) { //$NON-NLS-1$
- baseUri = baseUri.substring(0, baseUri.length() - 1);
- }
- while (uri.startsWith("../")) { //$NON-NLS-1$
- uri = uri.substring(3);
- int index = baseUri.lastIndexOf('/');
- if (index > 0) {
- baseUri = baseUri.substring(0, index);
- }
- }
- uri = "/" + uri; //$NON-NLS-1$
- }
-
- if (uri.startsWith("/")) { //$NON-NLS-1$
- return baseUri.endsWith("/") //$NON-NLS-1$
- ? baseUri + uri.substring(1) : baseUri + uri;
- }
-
- if (uri.startsWith(FILE_URI_PREFIX) || uri.startsWith(HTTP_URI_PREFIX)) {
- return uri;
- }
-
- return baseUri.endsWith("/") ? baseUri + uri : baseUri + '/' + uri; //$NON-NLS-1$
- }
-
- /**
- * Returns the input stream for the given URI.
- *
- * @param uri
- * The source URI.
- * @return The input stream for the given URI.
- * @throw MalformedURLException if a given XML document URI is invalid.
- * @throw IOException if an I/O error occur while accessing the URI.
- */
- public static InputStream getInputStream(String uri)
- throws MalformedURLException, IOException {
- if (uri == null) {
- return null;
- }
-
- if (uri.startsWith(HTTP_URI_PREFIX)) {
- URL url = new URL(uri);
- return url.openStream();
- } else if (uri.startsWith(FILE_URI_PREFIX)) {
- uri = uri.substring(FILE_URI_PREFIX_LENGTH);
- }
-
- return new FileInputStream(NetUtil.decodeUrl(uri, null));
- }
-
- /**
- * Returns the Java string represention (encoded in UTF-16) of the given URL
- * (encoded in the given encoding and ASCII-escaped).
- *
- * @param url
- * The URL to decode.
- * @param encoding
- * The encoding of the URL.
- * @return The Java UTF-16 string respresentation.
- * @throws IllegalArgumentException
- * if the given URL contain improperly escaped characters.
- */
- public static String decodeUrl(String url, String encoding) {
- if (url == null) {
- return url;
- }
-
- int len = url.length();
- if (len == 0) {
- return url;
- }
-
- // Unescape the url.
- StringBuffer strBuf = new StringBuffer();
- for (int i = 0; i < len; i++) {
- char ch = url.charAt(i);
- switch (ch) {
- case '+':
- strBuf.append(' ');
- break;
- case '%':
- try {
- strBuf.append((char) Integer.parseInt(url.substring(i + 1,
- i + 3), 16));
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException();
- }
- i += 2;
- break;
- default:
- strBuf.append(ch);
- break;
- }
- }
-
- // Convert the un-escaped byte values to Java UTF-16 string.
- String result = strBuf.toString();
- if (encoding != null) {
- try {
- byte[] bytes = result.getBytes("8859_1"); //$NON-NLS-1$
- result = new String(bytes, encoding);
- } catch (UnsupportedEncodingException e) {
- }
- }
-
- return result;
- }
-
- /**
- * Returns the ASCII-escaped representation (encoded in the specified
- * encoding) of the given URL (encoded in UTF-16).
- *
- * @param url
- * The URL to encode.
- * @param encoding
- * The encoding of the URL.
- * @return the ASCII-escaped respresentation.
- * @throws IllegalArgumentException
- * if the given URL contain improperly escaped characters.
- * @throws UnsupportedEncodingException
- * if the given coding is unsupport.
- */
- public static String encodeUrl(String url, String encoding)
- throws UnsupportedEncodingException {
- if (url == null) {
- return url;
- }
- int len = url.length();
- if (len == 0) {
- return url;
- }
-
- StringBuffer result = new StringBuffer();
-
- byte[] bytes = url.getBytes(encoding);
- for (int i = 0; i < bytes.length; i++) {
- char ch = (char) bytes[i];
-
- if (ch >= 'a' && ch <= 'z') {
- result.append(ch);
- } else if (ch >= 'A' && ch <= 'Z') {
- result.append(ch);
- } else if (ch >= '0' && ch <= '9') {
- result.append(ch);
- } else {
- switch (ch) {
- case '-':
- case '_':
- case '.':
- case '!':
- case '~':
- case '*':
- case '\'':
- case '(':
- case ')':
- result.append(ch);
- break;
- default:
- result.append(HEX_VALUES[ch & 0xFF]);
- break;
- }
- }
- }
-
- return result.toString();
- }
-
- /**
- * Returns the ASCII-escaped representation of the given file URL.
- *
- * @param fileURL
- * The file URL to encode.
- * @return the ASCII-escaped respresentation.
- */
- public static String encodeFileURL(String fileURL) {
- String url = fileURL;
- StringBuffer strBuf = new StringBuffer();
- int urlLength = url.length();
- for (int i = 0; i < urlLength; i++) {
- char ch = url.charAt(i);
- switch (ch) {
- case ' ':
- strBuf.append("+"); //$NON-NLS-1$
- break;
- default:
- strBuf.append(ch);
- break;
- }
- }
- return strBuf.toString();
- }
-
- /**
- * Returns the ASCII-escaped representation of the given file URL.
- *
- * @param fileURL
- * The file URL to encode.
- * @return the ASCII-escaped respresentation.
- */
- public static String decodedFileUrl(String fileURL) {
- if (isRawUrl(fileURL)) {
- return fileURL;
- }
-
- String url = fileURL;
- StringBuffer strBuf = new StringBuffer();
- int urlLength = url.length();
- for (int i = 0; i < urlLength; i++) {
- char ch = url.charAt(i);
- switch (ch) {
- case '+':
- strBuf.append(' ');
- break;
- case '%':
- try {
- strBuf.append((char) Integer.parseInt(url.substring(i + 1,
- i + 3), 16));
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException();
- }
- i += 2;
- break;
- default:
- strBuf.append(ch);
- break;
- }
- }
- return strBuf.toString();
- }
-
- public static String decodeURL (String url) throws UnsupportedEncodingException {
-// url = url.replaceAll("\\+", "%2B"); //$NON-NLS-1$
- url = URLDecoder.decode(url, "UTF-8"); //$NON-NLS-1$
- return url;
- }
-
- public static boolean isRawUrl(String url) {
- boolean result = false;
-
- if (url.endsWith(RAW_URL_RAW)) {
- result = true;
- }
-
- return result;
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ProfilingUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ProfilingUtil.java
deleted file mode 100644
index db94b48b4b1..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ProfilingUtil.java
+++ /dev/null
@@ -1,60 +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.utils;
-
-import java.io.PrintStream;
-
-
-/**
- * Utility class for profiling
- *
- * @author Weiping Lu
- * @since 1.0
- */
-
-public class ProfilingUtil {
-
- public static boolean traceFootprint = false;
-
- private static PrintStream output = System.out;
-
- public static void setOutput(PrintStream ps) {
- output = ps;
- }
-
- public static void fullGC() {
- Runtime rt = Runtime.getRuntime();
- long isFree = rt.freeMemory();
- long wasFree;
- do {
- wasFree = isFree;
- rt.runFinalization();
- rt.gc();
- isFree = rt.freeMemory();
- } while (isFree > wasFree);
- }
-
- public static long traceUsedMemory(String location) {
- Runtime rt = Runtime.getRuntime();
- long usedMem = rt.totalMemory() - rt.freeMemory();
- output.println("Footprint> " + location + ": " + usedMem/1000 + " K"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- return usedMem;
- }
-
- public static long traceUsedMemoryDiff(String locationInfo, long currUsed, long PrevUsed) {
- long diff = currUsed - PrevUsed;
- output.println("Footprint> Diff, " + locationInfo + ": " + diff/1000 + " K\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- return diff;
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/RestartableJob.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/RestartableJob.java
deleted file mode 100644
index c60e94cc1c6..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/RestartableJob.java
+++ /dev/null
@@ -1,123 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2008 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.utils;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-
-/**
- * Job class that is re-startable
- *
- * @author Weiping Lu
- * @since 1.5
- */
-
-public abstract class RestartableJob extends Job {
-
- protected static boolean localDebug = false;
-
- private boolean toRestart = true;
- private boolean schedulingLocked = false;
- private boolean enabled = true;
-
- public RestartableJob(String name) {
- super(name);
- }
-
- public final void guardedSchedule(long delay) {
- guardedSchedule(delay, false);
- }
-
- private void guardedSchedule(long delay, boolean inRunCall) {
- if ( ! isEnabled()) {
- return;
- }
- if (!inRunCall && getState() != Job.NONE) {
- return;
- }
- if (isSchedulingLocked()) {
- return;
- }
- if (localDebug) {
- System.out.println("LD> guardedSchedule completed"); //$NON-NLS-1$
- }
- setSchedulingLocked(true);
- schedule(delay);
- }
-
- protected final IStatus run(IProgressMonitor monitor) {
- if (localDebug) {
- System.out.println("LD> RestartableJob.run"); //$NON-NLS-1$
- }
- setSchedulingLocked(false);
- setToRestart(false);
- IStatus status = Status.OK_STATUS;
- try {
- status = restartableRun(monitor);
- } catch (RestartInterruptException e) {
- guardedSchedule(e.getDelay(), true);
- }
-
- return Status.OK_STATUS;
- }
-
- protected abstract IStatus restartableRun(IProgressMonitor monitor) throws RestartInterruptException;
- protected abstract void resetToRestart();
-
- private synchronized boolean isSchedulingLocked() {
- return schedulingLocked;
- }
-
- private synchronized void setSchedulingLocked(boolean schedulingLocked) {
- this.schedulingLocked = schedulingLocked;
- }
-
- private synchronized boolean isToRestart() {
- return toRestart;
- }
-
- private synchronized void setToRestart(boolean toRestart) {
- this.toRestart = toRestart;
- }
-
- public void enableToRestart() {
- setToRestart(true);
- }
-
- public void checkRestartInterruptException(long delay) throws RestartInterruptException {
- if (isToRestart()) {
- resetToRestart();
- throw new RestartInterruptException(delay);
- }
- }
-
- public static class RestartInterruptException extends Exception {
- private long delay = 0;
- public RestartInterruptException(long delay) {
- this.delay = delay;
- }
-
- public long getDelay() {
- return delay;
- }
- }
-
- public synchronized boolean isEnabled() {
- return enabled;
- }
-
- public synchronized void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java
deleted file mode 100644
index b4fd0c17f65..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StrUtil.java
+++ /dev/null
@@ -1,676 +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.utils;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.epf.common.CommonPlugin;
-
-import com.ibm.icu.lang.UCharacter;
-import com.ibm.icu.util.StringTokenizer;
-
-/**
- * A helper class for manuipulating strings.
- *
- * @author Kelvin Low
- * @author Jinhua Xi
- * @since 1.0
- */
-public class StrUtil {
- public static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- public static final String TAB = "\t"; //$NON-NLS-1$
-
- private static final String REGEXP_ANY_SPECIAL_CHARS = "(`|~|!|@|#|\\$|%|\\^|&|\\*|\\(|\\)|\\+|=|\\[|\\]|\\||\\:|\"|<|>|\\?|/|'|\\s|\\\\)+"; //$NON-NLS-1$
-
- private static final String REGEXP_INVALID_PUBLISHED_PATH_CHARS = "(\\[|#|\\*|\\?|\"|<|>|\\||!|%|/|\\])+"; //$NON-NLS-1$
-
- private static final String REGEXP_INVALID_PUBLISHED_PATH_CHARS_LINUX = "(\\[|#|\\*|\\?|\"|<|>|\\||!|%|\\])+"; //$NON-NLS-1$
-
- private static final String REGEXP_INVALID_FILENAME_CHARS = "(\\[|#|/|\\\\|\\:|\\*|\\?|\"|<|>|\\||\\]|\\s)+"; //$NON-NLS-1$
-
- private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5',
- '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
-
- public static final String LINE_FEED = System.getProperty("line.separator"); //$NON-NLS-1$
-
- public static final String ESCAPED_LF = "&#xA;"; //$NON-NLS-1$
-
- public static final String ESCAPED_CR = "&#xD;"; //$NON-NLS-1$
-
- public static final String ESCAPED_LINE_FEED = LINE_FEED.replace(
- "\n", ESCAPED_LF).replace("\r", ESCAPED_CR); //$NON-NLS-1$ //$NON-NLS-2$
-
- public static final String LINE_FEED_REGEX = LINE_FEED.replaceAll(
- "\\\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
-
- public static final String ESCAPED_LINE_FEED_REGEX = ESCAPED_LINE_FEED;
-
- public static final String HTML_BREAK = "<br/>";//$NON-NLS-1$
-
- public static final String HTML_COPY = "&copy;";//$NON-NLS-1$
-
- public static final String HTML_EURO = "&euro;";//$NON-NLS-1$
-
- public static final String HTML_REG = "&reg;";//$NON-NLS-1$
-
- public static final String HTML_TRADEMARK = "&trade;";//$NON-NLS-1$
-
- public static boolean during_migration = false;
-
- private static StrUtilOptions options;
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private StrUtil() {
- }
-
- /**
- * Tests for null string.
- * <p>
- * A null string is defined as one that has an empty reference or has zero
- * length.
- *
- * @param str
- * a string
- * @return <code>true</code> if the given string is a null string
- */
- public static boolean isNull(String str) {
- return str == null || str.length() == 0;
- }
-
- /**
- * Tests for blank string.
- * <p>
- * A blank string is defined as one that has an empty reference or has zero
- * length after the leading and trailing space characters are trimmed.
- *
- * @param str
- * a string
- * @return <code>true</code> if the given string is a blank string
- */
- public static boolean isBlank(String str) {
- return str == null || str.trim().length() == 0;
- }
-
- /**
- * Removes the leading and trailing space characters from a string.
- *
- * @param str
- * a string
- * @return a string with no leading and trailing space characters
- */
- public static String trim(String str) {
- return str == null ? null : str.trim();
- }
-
- /**
- * Removes whitespace characters (TAB, CR, LF and SPACE) from a string.
- *
- * @param str
- * a string
- * @return a string with whitespace characters removed
- */
- public static String removeWhiteSpaceChars(String str) {
- int len = (str == null) ? 0 : str.length();
- for (int i = 0; i < len; i++) {
- switch (str.charAt(i)) {
- case '\t':
- case '\r':
- case '\n':
- case ' ':
- break;
- default:
- return str;
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Removes CR, LF from a string.
- *
- * @param str
- * a string
- * @return a string with CR, LF removed
- */
- public static String removeNewlines(String str) {
- StringBuffer sb = new StringBuffer();
- int len = (str == null) ? 0 : str.length();
- for (int i = 0; i < len; i++) {
- char c = str.charAt(i);
- switch (c) {
- case '\r':
- case '\n':
- break;
- default:
- sb.append(c);
- }
- }
- return sb.toString();
- }
-
- /**
- * Splits a string into an array of string tokens.
- *
- * @param str
- * a string
- * @param sep
- * a string containing the string separators
- * @param count
- * the desired number of string tokens
- * @return an array of string tokens
- */
- public static String[] split(String str, String sep, int count) {
- if (str == null || count == 0 || count < -1) {
- return null;
- }
-
- StringTokenizer tokenizer = new StringTokenizer(str, sep,
- count == -1 ? false : true);
-
- if (count == -1) {
- count = tokenizer.countTokens();
- }
-
- String[] result = new String[count];
- int i = 0;
- while (tokenizer.hasMoreTokens()) {
- String t = tokenizer.nextToken();
- if (i < count) {
- if ((t.length() == 1) && (sep.indexOf(t) != -1)) {
- continue;
- }
- result[i++] = t;
- } else {
- result[count - 1] += t;
- }
- }
- return result;
- }
-
- /**
- * Splits a string into an array of string tokens.
- *
- * @param str
- * a string
- * @param sep
- * a string containing the string separators
- * @return an array of string tokens
- */
- public static String[] split(String str, String sep) {
- return split(str, sep, -1);
- }
-
- /**
- * Replaces a substring within a string with another substring.
- * <p>
- * Note: Only the first occurrence of the substring will be replaced.
- *
- * @param str
- * a string
- * @param src
- * the substring to replace
- * @param tgt
- * the substring to use for the replacement
- * @return a string with the first substring replaced
- *
- * TODO: Review implementation. Call String.replaceFirst() instead?
- */
- public static String replace(String str, String src, String tgt) {
- if ((str == null || str.length() == 0)
- || (src == null || src.length() == 0)) {
- return str;
- }
-
- String tmpStr = str;
- int index;
- while ((index = tmpStr.indexOf(src)) != -1) {
- tmpStr = tmpStr.substring(0, index) + tgt
- + tmpStr.substring(index + src.length());
- }
- return tmpStr;
- }
-
- /**
- * Returns the integer value of a string.
- *
- * @param str
- * a string
- * @param defaultValue
- * a default integer value for the string
- * @return the integer value of the given string
- */
- public static int getIntValue(String str, int defaultValue) {
- if (StrUtil.isBlank(str)) {
- return defaultValue;
- }
-
- try {
- return Integer.parseInt(str);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- /**
- * Returns an array of bytes representing the UTF-8 encoding of a string.
- *
- * @param str
- * a string
- * @return a byte array containing the UTF-8 encoding of the given string
- */
- public static byte[] getUTF8Bytes(String str) {
- char[] c = str.toCharArray();
- int len = c.length;
- int count = 0;
- for (int i = 0; i < len; i++) {
- int ch = c[i];
- if (ch <= 0x7f) {
- count++;
- } else if (ch <= 0x7ff) {
- count += 2;
- } else {
- count += 3;
- }
- }
-
- byte[] b = new byte[count];
- int off = 0;
- for (int i = 0; i < len; i++) {
- int ch = c[i];
- if (ch <= 0x7f) {
- b[off++] = (byte) ch;
- } else if (ch <= 0x7ff) {
- b[off++] = (byte) ((ch >> 6) | 0xc0);
- b[off++] = (byte) ((ch & 0x3f) | 0x80);
- } else {
- b[off++] = (byte) ((ch >> 12) | 0xe0);
- b[off++] = (byte) (((ch >> 6) & 0x3f) | 0x80);
- b[off++] = (byte) ((ch & 0x3f) | 0x80);
- }
- }
- return b;
- }
-
- /**
- * Returns the hexidecimal character representation for an integer.
- *
- * @param value
- * an integer
- * @return the hexidecimal representation
- */
- private static char toHex(int value) {
- return HEX_DIGITS[(value & 0xF)];
- }
-
- /**
- * Returns the escaped Unicode representation of a string.
- *
- * @param str
- * a string
- * @param skipASCII
- * if <code>true</code>, avoid escaping the ASCII characters
- * @return the escaped Unicode representation of the given string
- */
- public static String toEscapedUnicode(String str, boolean skipASCII) {
- int len = str.length();
- StringBuffer result = new StringBuffer(len * 2);
-
- for (int i = 0; i < len; i++) {
- char ch = str.charAt(i);
-
- if (skipASCII && ch < 0x007E) {
- result.append(ch);
- } else {
- result.append("\\u"); //$NON-NLS-1$
- result.append(toHex((ch >> 12) & 0xF));
- result.append(toHex((ch >> 8) & 0xF));
- result.append(toHex((ch >> 4) & 0xF));
- result.append(toHex(ch & 0xF));
- }
- }
-
- return result.toString();
- }
-
- /**
- * Returns the escaped HTML representation of a string.
- *
- * @param html
- * a HTML string
- * @return the escaped Unicode representation of the given HTML string
- */
- public static String getEscapedHTML(String html) {
- if (html == null || html.length() == 0) {
- return ""; //$NON-NLS-1$
- }
-
- StrUtilOptions options = getOptions();
- StringBuffer result = new StringBuffer();
- int length = html.length();
- for (int i = 0; i < length; i++) {
- char ch = html.charAt(i);
- switch (ch) {
- case '%':
- if (i + 4 < length) {
- String hexStr = html.substring(i + 1, i + 5);
- boolean validHextStr = true;
-
- for (int j = 0; j < hexStr.length(); j++) {
- char c = hexStr.charAt(j);
- if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
- validHextStr = false;
- break;
- }
- }
-
- if (options == null) {
- //code below will treat "%20de" as " de"
- //this may lose some double bytes character(e.g. Chinese), which start with %20, but keep all url links
- //so far open this convertion not only during library migration to support file like "my design.gif"
- if (/*during_migration && */validHextStr) {
- if (hexStr.startsWith("20")) { //$NON-NLS-1$
- result.append("%20"); //$NON-NLS-1$
- i += 2;
- break;
- }
- }
- } else {
- int ix = options.getRteUrlDecodingOption();
- if (ix == 1) {
- validHextStr = false;
- } else if (ix == 2) {
- String key = getHexStr("%" + hexStr);
- if (key != null && options.getRteUrlDecodingHexMap().containsKey(key)) {
- validHextStr = false;
- }
- }
- }
-
- if (validHextStr) {
- try {
- int codePoint = Integer.parseInt(hexStr, 16);
- char[] c = UCharacter.toChars(codePoint);
- result.append(c);
- i += 4;
- break;
- } catch (NumberFormatException e) {
- // wasn't a valid hex string..
- // fall through to the result.append(ch)
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- }
- }
- result.append(ch);
- break;
- case '\u00a9':
- result.append(HTML_COPY);
- break;
- case '\u00ae':
- result.append(HTML_REG);
- break;
- case '\u20ac':
- result.append(HTML_EURO);
- break;
- case '\u2122':
- result.append(HTML_TRADEMARK);
- break;
- default:
- result.append(ch);
- break;
- }
- }
- return result.toString();
- }
-
- /**
- * Returns the plain text from HTML text.
- * <p>
- * Note: All HTML tags will be stripped.
- *
- * @param html
- * the HTML text.
- * @return the plain text representation of the given HTML text
- */
- public static String getPlainText(String html) {
- if (html == null) {
- return ""; //$NON-NLS-1$
- }
-
- final Pattern p_plaintext_filter = Pattern.compile(
- "<[^>]*?>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
- final Pattern p_plaintext_filter2 = Pattern.compile(
- "&.{1,5}[^;];", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
- final Pattern p_plaintext_filter3 = Pattern.compile(
- "\\s+", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
-
- String result = html.replaceAll(p_plaintext_filter.pattern(), " ") //$NON-NLS-1$
- .replaceAll(p_plaintext_filter2.pattern(), " ") //$NON-NLS-1$
- .replaceAll(p_plaintext_filter3.pattern(), " "); //$NON-NLS-1$
- return result;
- }
-
- /**
- * Converts a string into a valid file name.
- *
- * @param str
- * a string
- * @return a valid file name derived from the given string
- */
- public static String makeValidFileName(String str) {
- if (str == null) {
- return ""; //$NON-NLS-1$
- }
- return getPlainText(str)
- .replaceAll(REGEXP_INVALID_FILENAME_CHARS, " ").trim(); //$NON-NLS-1$
- }
-
- public static String removeSpecialCharacters(String str) {
- if (str == null) {
- return ""; //$NON-NLS-1$
- }
- return getPlainText(str)
- .replaceAll(REGEXP_ANY_SPECIAL_CHARS, " ").trim(); //$NON-NLS-1$
- }
-
- /**
- * Returns true if the path does not contain any invalid filename
- * characters.
- *
- * @param path
- * the file path
- * @return <code>true</code> if the given path contains only valid
- * filename characters
- */
- public static boolean isValidPublishPath(String path) {
- // return path.replaceAll(invalidPublishPathCharsRegExp,
- // "").equals(path);
-
- if (Platform.getOS().equals(Platform.WS_WIN32)) {
- return path
- .replaceAll(REGEXP_INVALID_PUBLISHED_PATH_CHARS, "").equals(path); //$NON-NLS-1$
- }
-
- // else default to Linux
- return path
- .replaceAll(REGEXP_INVALID_PUBLISHED_PATH_CHARS_LINUX, "").equals(path); //$NON-NLS-1$
- }
-
- /**
- * Returns the lower-case of str unless the current locale is German
- *
- * @param str
- * @return
- */
- public static String toLower(String str) {
- if (Platform.getNL().startsWith("de")) { //$NON-NLS-1$
- return str;
- }
- return str.toLowerCase();
- }
-
- /**
- * escape the " and '
- *
- * @param str
- * @return
- */
- public static String escape(String str) {
- return str.replaceAll("'", "\\\\\'").replaceAll("\"", "\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- /**
- * Converts a <code>List</code> to an String array.
- *
- * @param list
- * a <code>List</code>
- * @return a String array
- */
- public static String[] convertListToStrArray(List list) {
- if (list != null) {
- int cnt = list.size();
- String[] strArray = new String[cnt];
-
- for (int i = 0; i < cnt; i++) {
- String str = (String) list.get(i);
- strArray[i] = new String(str);
- }
- return strArray;
- } else {
- return null;
- }
- }
-
- public static boolean isValidName(String name) {
- return name.replaceAll(REGEXP_ANY_SPECIAL_CHARS, "").equals(name); //$NON-NLS-1$
- }
-
- /**
- * added some test code
- *
- * @param args
- */
- public static void main(String[] args) {
-
- String text = "A&% `&# $~!@#$%^&*()_-+={}[\"]:|\\:;\"'<,>.?/ \t\r\nZ"; //$NON-NLS-1$
-
- System.out.println("[" + text + "] <== text"); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("[" + text.replaceAll(REGEXP_ANY_SPECIAL_CHARS, " ") //$NON-NLS-1$ //$NON-NLS-2$
- + "] <== All"); //$NON-NLS-1$
- System.out.println("[" //$NON-NLS-1$
- + text.replaceAll(REGEXP_INVALID_FILENAME_CHARS, " ") //$NON-NLS-1$
- + "] <== File Name"); //$NON-NLS-1$
- System.out.println("[" //$NON-NLS-1$
- + text.replaceAll(REGEXP_INVALID_PUBLISHED_PATH_CHARS, " ") //$NON-NLS-1$
- + "] <== path"); //$NON-NLS-1$
- System.out.println("[" //$NON-NLS-1$
- + text.replaceAll(REGEXP_INVALID_PUBLISHED_PATH_CHARS_LINUX,
- " ") + "] <== path, Linux"); //$NON-NLS-1$ //$NON-NLS-2$
-
- System.out.println(""); //$NON-NLS-1$
- }
-
- /**
- * Converts the platform line-separator (\n or \n\r or \r) to &lt;br/&gt;
- *
- * @param text
- * @return
- */
- public static String convertNewlinesToHTML(String text) {
- if (text != null) {
- text = text.replaceAll(LINE_FEED_REGEX, HTML_BREAK + LINE_FEED);
- text = text.replaceAll(ESCAPED_LINE_FEED_REGEX, HTML_BREAK
- + ESCAPED_LINE_FEED);
- }
- return text;
- }
-
- public static URI toURI(String pathStr) {
- if (pathStr != null && pathStr.length() > 0) {
- IPath path = Path.fromOSString(pathStr);
- try {
- return path.toFile().toURI();
- } catch (Exception e) {
- CommonPlugin.getDefault().getLogger().logError(e);
- }
- }
- return null;
- }
-
- public static String escapeChar(String text, char c) {
- int i=text.indexOf(c);
- if ( i < 0 ) {
- return text;
- }
-
- int start = 0;
- StringBuffer buffer = new StringBuffer();
- while ( i > start ) {
- buffer.append(text.substring(start, i)).append("\\"); //$NON-NLS-1$
- start = i;
- i=text.indexOf(c, start+1);
- }
-
- buffer.append(text.substring(start));
-
- return buffer.toString();
- }
-
- public static String getHexStr(String str) {
- if (str.length() < 3) {
- return null;
- }
- if (str.charAt(0) != '%') {
- return null;
- }
- StringBuffer b = new StringBuffer();
- b.append('%');
- for (int i = 1 ; i <= 2; i++) {
- char c = str.charAt(i);
- if (c >= 'a' && c <= 'z') {
- c -= 'a';
- c += 'A';
- }
- boolean valid = (c >= '0' && c <= '9') ||
- (c >= 'A' && c <= 'F');
- if (!valid) {
- return null;
- }
- b.append(c);
- }
-
- return b.toString();
- }
-
- public interface StrUtilOptions {
- int getRteUrlDecodingOption();
- Map<String, String> getRteUrlDecodingHexMap();
- }
-
- public static StrUtilOptions getOptions() {
- return options;
- }
-
- public static void setOptions(StrUtilOptions options) {
- StrUtil.options = options;
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StringMatcher.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StringMatcher.java
deleted file mode 100644
index 4a0b4b443aa..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/StringMatcher.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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 API and implementation
- *******************************************************************************/
-package org.eclipse.epf.common.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-/**
- * A string pattern matcher. Supports '*' and '?' wildcards.
- */
-public class StringMatcher {
- protected String fPattern;
- protected int fLength; // pattern length
- protected boolean fIgnoreWildCards;
- protected boolean fIgnoreCase;
- protected boolean fHasLeadingStar;
- protected boolean fHasTrailingStar;
- protected String fSegments[]; //the given pattern is split into * separated segments
-
- /* boundary value beyond which we don't need to search in the text */
- protected int fBound= 0;
-
-
- protected static final char fSingleWildCard= '\u0000';
-
- public static class Position {
- int start; //inclusive
- int end; //exclusive
- public Position(int start, int end) {
- this.start= start;
- this.end= end;
- }
- public int getStart() {
- return start;
- }
- public int getEnd() {
- return end;
- }
- }
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern. The pattern may contain '*' for 0 and many characters and
- * '?' for exactly one character.
- *
- * Literal '*' and '?' characters must be escaped in the pattern
- * e.g., "\*" means literal "*", etc.
- *
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern.
- * e.g., "\a" means "a" and "\\" means "\"
- *
- * If invoking the StringMatcher with string literals in Java, don't forget
- * escape characters are represented by "\\".
- *
- * @param pattern the pattern to match text against
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
- */
- public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
- if (pattern == null)
- throw new IllegalArgumentException();
- fIgnoreCase= ignoreCase;
- fIgnoreWildCards= ignoreWildCards;
- fPattern= pattern;
- fLength= pattern.length();
-
- if (fIgnoreWildCards) {
- parseNoWildCards();
- } else {
- parseWildCards();
- }
- }
- /**
- * Find the first occurrence of the pattern between <code>start</code)(inclusive)
- * and <code>end</code>(exclusive).
- * @param text the String object to search in
- * @param start the starting index of the search range, inclusive
- * @param end the ending index of the search range, exclusive
- * @return an <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
- */
- public StringMatcher.Position find(String text, int start, int end) {
- if (text == null)
- throw new IllegalArgumentException();
-
- int tlen= text.length();
- if (start < 0)
- start= 0;
- if (end > tlen)
- end= tlen;
- if (end < 0 ||start >= end )
- return null;
- if (fLength == 0)
- return new Position(start, start);
- if (fIgnoreWildCards) {
- int x= posIn(text, start, end);
- if (x < 0)
- return null;
- return new Position(x, x+fLength);
- }
-
- int segCount= fSegments.length;
- if (segCount == 0)//pattern contains only '*'(s)
- return new Position (start, end);
-
- int curPos= start;
- int matchStart= -1;
- int i;
- for (i= 0; i < segCount && curPos < end; ++i) {
- String current= fSegments[i];
- int nextMatch= regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0 )
- return null;
- if(i == 0)
- matchStart= nextMatch;
- curPos= nextMatch + current.length();
- }
- if (i < segCount)
- return null;
- return new Position(matchStart, curPos);
- }
- /**
- * match the given <code>text</code> with the pattern
- * @return true if matched eitherwise false
- * @param text a String object
- */
- public boolean match(String text) {
- return match(text, 0, text.length());
- }
- /**
- * Given the starting (inclusive) and the ending (exclusive) positions in the
- * <code>text</code>, determine if the given substring matches with aPattern
- * @return true if the specified portion of the text matches the pattern
- * @param text a String object that contains the substring to match
- * @param start marks the starting position (inclusive) of the substring
- * @param end marks the ending index (exclusive) of the substring
- */
- public boolean match(String text, int start, int end) {
- if (null == text)
- throw new IllegalArgumentException();
-
- if (start > end)
- return false;
-
- if (fIgnoreWildCards)
- return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
- int segCount= fSegments.length;
- if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s)
- return true;
- if (start == end)
- return fLength == 0;
- if (fLength == 0)
- return start == end;
-
- int tlen= text.length();
- if (start < 0)
- start= 0;
- if (end > tlen)
- end= tlen;
-
- int tCurPos= start;
- int bound= end - fBound;
- if ( bound < 0)
- return false;
- int i=0;
- String current= fSegments[i];
- int segLength= current.length();
-
- /* process first segment */
- if (!fHasLeadingStar){
- if(!regExpRegionMatches(text, start, current, 0, segLength)) {
- return false;
- } else {
- ++i;
- tCurPos= tCurPos + segLength;
- }
- }
- if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
- // only one segment to match, no wildcards specified
- return tCurPos == end;
- }
- /* process middle segments */
- while (i < segCount) {
- current= fSegments[i];
- int currentMatch;
- int k= current.indexOf(fSingleWildCard);
- if (k < 0) {
- currentMatch= textPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- } else {
- currentMatch= regExpPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- }
- tCurPos= currentMatch + current.length();
- i++;
- }
-
- /* process final segment */
- if (!fHasTrailingStar && tCurPos != end) {
- int clen= current.length();
- return regExpRegionMatches(text, end - clen, current, 0, clen);
- }
- return i == segCount ;
- }
-
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
- */
- private void parseNoWildCards() {
- fSegments= new String[1];
- fSegments[0]= fPattern;
- fBound= fLength;
- }
- /**
- * Parses the given pattern into segments seperated by wildcard '*' characters.
- */
- private void parseWildCards() {
- if(fPattern.startsWith("*"))//$NON-NLS-1$
- fHasLeadingStar= true;
- if(fPattern.endsWith("*")) {//$NON-NLS-1$
- /* make sure it's not an escaped wildcard */
- if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar= true;
- }
- }
-
- Vector<String> temp= new Vector<String>();
-
- int pos= 0;
- StringBuffer buf= new StringBuffer();
- while (pos < fLength) {
- char c= fPattern.charAt(pos++);
- switch (c) {
- case '\\':
- if (pos >= fLength) {
- buf.append(c);
- } else {
- char next= fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
- }
- break;
- case '*':
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
- break;
- case '?':
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default:
- buf.append(c);
- }
- }
-
- /* add last buffer to segment list */
- if (buf.length() > 0) {
- temp.addElement(buf.toString());
- fBound += buf.length();
- }
-
- fSegments= new String[temp.size()];
- temp.copyInto(fSegments);
- }
- /**
- * @param text a string which contains no wildcard
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int posIn(String text, int start, int end) {//no wild card in pattern
- int max= end - fLength;
-
- if (!fIgnoreCase) {
- int i= text.indexOf(fPattern, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i= start; i <= max; ++i) {
- if (text.regionMatches(true, i, fPattern, 0, fLength))
- return i;
- }
-
- return -1;
- }
- /**
- * @param text a simple regular expression that may only contain '?'(s)
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a simple regular expression that may contains '?'
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int regExpPosIn(String text, int start, int end, String p) {
- int plen= p.length();
-
- int max= end - plen;
- for (int i= start; i <= max; ++i) {
- if (regExpRegionMatches(text, i, p, 0, plen))
- return i;
- }
- return -1;
- }
-
-
- protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
- while (plen-- > 0) {
- char tchar= text.charAt(tStart++);
- char pchar= p.charAt(pStart++);
-
- /* process wild cards */
- if (!fIgnoreWildCards) {
- /* skip single wild cards */
- if (pchar == fSingleWildCard) {
- continue;
- }
- }
- if (pchar == tchar)
- continue;
- if (fIgnoreCase) {
- if (Character.toUpperCase(tchar) == Character.toUpperCase(pchar))
- continue;
- // comparing after converting to upper case doesn't handle all cases;
- // also compare after converting to lower case
- if (Character.toLowerCase(tchar) == Character.toLowerCase(pchar))
- continue;
- }
- return false;
- }
- return true;
- }
- /**
- * @param text the string to match
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a string that has no wildcard
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen= p.length();
- int max= end - plen;
-
- if (!fIgnoreCase) {
- int i= text.indexOf(p, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i= start; i <= max; ++i) {
- if (text.regionMatches(true, i, p, 0, plen))
- return i;
- }
-
- return -1;
- }
-
- public static String[] convertFromString(String patterns, String separator) {
- StringTokenizer tokenizer= new StringTokenizer(patterns, separator, true);
- int tokenCount= tokenizer.countTokens();
- List<String> result= new ArrayList<String>(tokenCount);
- boolean escape= false;
- boolean append= false;
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
- if (separator.equals(token)) {
- if (!escape)
- escape= true;
- else {
- addPattern(result, separator);
- append= true;
- }
- } else {
- if (!append)
- result.add(token);
- else
- addPattern(result, token);
- append= false;
- escape= false;
- }
- }
- return (String[])result.toArray(new String[result.size()]);
- }
-
- private static void addPattern(List<String> list, String pattern) {
- if (list.isEmpty())
- list.add(pattern);
- else {
- int index= list.size() - 1;
- list.set(index, ((String)list.get(index)) + pattern);
- }
- }
-
- public static String convertToString(String[] patterns, String separator) {
- int length= patterns.length;
- StringBuffer strBuf= new StringBuffer();
- if (length > 0)
- strBuf.append(escapeSeparator(patterns[0], separator));
- else
- return ""; //$NON-NLS-1$
- int i= 1;
- while (i < length) {
- strBuf.append(separator);
- strBuf.append(" "); //$NON-NLS-1$
- strBuf.append(escapeSeparator(patterns[i++], separator));
- }
- return strBuf.toString();
- }
-
- private static String escapeSeparator(String pattern, String separator) {
- int length= pattern.length();
- StringBuffer buf= new StringBuffer(length);
- for (int i= 0; i < length; i++) {
- char ch= pattern.charAt(i);
- if (separator.equals(String.valueOf(ch)))
- buf.append(ch);
- buf.append(ch);
- }
- return buf.toString();
-
- }
-
- public static String[] convertFromString(String patterns) {
- return convertFromString(patterns, SEPARATOR);
- }
-
- private static final String SEPARATOR= ","; //$NON-NLS-1$
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ThreadUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ThreadUtil.java
deleted file mode 100644
index 4faf4ee29d7..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ThreadUtil.java
+++ /dev/null
@@ -1,41 +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.utils;
-
-/**
- * Utility class for handling threads.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class ThreadUtil {
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private ThreadUtil() {
- }
-
- /**
- * Puts the current thread to sleep for a given duration.
- *
- * @param time
- * The duration in milliseconds.
- */
- public static void pause(long time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- }
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/Timer.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/Timer.java
deleted file mode 100644
index c0dc6361254..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/Timer.java
+++ /dev/null
@@ -1,49 +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.utils;
-import com.ibm.icu.util.Calendar;
-
-/**
- * A simple timer for tracking time.
- *
- * @author Jinhua Xi
- * @since 1.0
- */
-public class Timer {
-
- private long initTime;
-
- private long startTime;
-
- private long endTime;
-
- public Timer() {
- start();
- initTime = startTime;
- }
-
- public void start() {
- startTime = Calendar.getInstance().getTimeInMillis();
- }
-
- public void stop() {
- endTime = Calendar.getInstance().getTimeInMillis();
- }
-
- public int getTime() {
- return (int) (endTime - startTime);
- }
-
- public int getTotalTime() {
- return (int) (endTime - initTime);
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/WarUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/WarUtil.java
deleted file mode 100644
index ccd8a0a2c20..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/WarUtil.java
+++ /dev/null
@@ -1,57 +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.utils;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.War;
-import org.apache.tools.ant.types.FileSet;
-
-
-public class WarUtil {
-
- /**
- * Creates a war file.
- *
- * @param outputWarFile
- * an absolute path to the target war file
- * @param webAppDirectory
- * an absolute path to a directory containing the files and sub
- * directories to be wared
- * @param monitor
- * a progress monitor
- * @throws IOException
- * if an error occurs while creating the zip file
- */
- public static void buildWarFile(String outputWarFile, String webAppDirectory,
- IProgressMonitor monitor) throws IOException {
-
- try {
- Project antProject = new Project();
- antProject.init();
- War warTask = new War();
- warTask.setProject(antProject);
- warTask.setDestFile(new File(outputWarFile));
- warTask.setWebxml(new File(webAppDirectory + File.separator + "WEB-INF" //$NON-NLS-1$
- + File.separator + "web.xml")); //$NON-NLS-1$
- FileSet webFiles = new FileSet();
- webFiles.setDir(new File(webAppDirectory));
- warTask.addFileset(webFiles);
- warTask.execute();
- } catch (Exception e) {
- throw new IOException(e.getMessage());
- }
- }
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/XMLUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/XMLUtil.java
deleted file mode 100644
index 100ed59ca33..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/XMLUtil.java
+++ /dev/null
@@ -1,666 +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.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXParseException;
-
-/**
- * Utility class for processing XML documents.
- *
- * @author Kelvin Low
- * @author Jinhua Xi
- * @author Phong Nguyen Le
- * @since 1.0
- */
-public class XMLUtil {
-
- /**
- * XML declaration.
- */
- public final static String XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //$NON-NLS-1$
-
- /**
- * XML Escape characters.
- */
- public final static String XML_AMP = "&amp;"; //$NON-NLS-1$
-
- public final static String XML_BACKSLASH = "&#92;"; //$NON-NLS-1$
-
- public final static String XML_APOS = "&apos;"; //$NON-NLS-1$
-
- public final static String XML_CR = "&#13;"; //$NON-NLS-1$
-
- public final static String XML_GT = "&gt;"; //$NON-NLS-1$
-
- public final static String XML_LT = "&lt;"; //$NON-NLS-1$
-
- public final static String XML_LF = "&#10;"; //$NON-NLS-1$
-
- public final static String XML_QUOT = "&quot;"; //$NON-NLS-1$
-
- public final static String XML_TAB = "&#9;"; //$NON-NLS-1$
-
- private static final String CRLF = "\r\n"; //$NON-NLS-1$
-
- private static final byte[] CRLF_BYTES = CRLF.getBytes();
-
- /**
- * Private constructor to prevent this class from being instantiated. All
- * methods in this class should be static.
- */
- private XMLUtil() {
- }
-
- /**
- * Clones the given DOM node into the given DOM document.
- *
- * @param node
- * The DOM node to clone.
- * @param doc
- * The target DOM document.
- * @return The cloned node in the target DOM document.
- */
- public static Node cloneNode(Node node, Document doc) {
- Node clone = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- clone = doc.createElement(node.getNodeName());
- NamedNodeMap attrs = node.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attrNode = attrs.item(i);
- Attr attrClone = doc.createAttribute(attrNode.getNodeName());
- attrClone.setNodeValue(attrNode.getNodeValue());
- ((Element) clone).setAttributeNode(attrClone);
- }
-
- // Iterate through each child nodes.
- NodeList childNodes = node.getChildNodes();
- if (childNodes != null) {
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node childNode = childNodes.item(i);
- Node childClone = cloneNode(childNode, doc);
- clone.appendChild(childClone);
- }
- }
- break;
-
- case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
- clone = doc.createTextNode(node.getNodeName());
- clone.setNodeValue(node.getNodeValue());
- break;
- }
- return clone;
- }
-
- /**
- * Escapes a XML attribute to make it XML parser friendly.
- *
- * @param str
- * The XML attribute string.
- * @return The escaped string.
- */
- public static String escapeAttr(String str) {
- if (str == null || str.length() == 0)
- return ""; //$NON-NLS-1$
- StringBuffer sb = new StringBuffer();
- int len = str.length();
- for (int i = 0; i < len; i++) {
- char ch = str.charAt(i);
- switch (ch) {
- case '<':
- sb.append(XML_LT);
- break;
- case '&':
- sb.append(XML_AMP);
- break;
- case '"':
- sb.append(XML_QUOT);
- break;
- default:
- sb.append(ch);
- break;
- }
- }
- return sb.toString();
- }
-
- /**
- * Escapes the given string to make it XML parser friendly.
- *
- * @param str
- * The source string.
- * @return The escaped string.
- */
- public static String escape(String str) {
- if (str == null || str.length() == 0)
- return ""; //$NON-NLS-1$
- StringBuffer sb = new StringBuffer();
- int len = str.length();
- for (int i = 0; i < len; i++) {
- char ch = str.charAt(i);
- switch (ch) {
- case '<':
- sb.append(XML_LT);
- break;
- case '>':
- sb.append(XML_GT);
- break;
- case '&':
- sb.append(XML_AMP);
- break;
- case '"':
- sb.append(XML_QUOT);
- break;
- case '\'':
- sb.append(XML_APOS);
- break;
- case '\r':
- sb.append(XML_CR);
- break;
- case '\n':
- sb.append(XML_LF);
- break;
- case '\\':
- sb.append(XML_BACKSLASH);
- break;
- default:
- sb.append(ch);
- break;
- }
- }
- return sb.toString();
- }
-
- /**
- * Escapes the given string to make it XML parser friendly.
- *
- * @param str
- * The source string.
- * @param ignoreCRLF
- * If true, do not escape the CR and LF characters.
- * @return The escaped string.
- */
- public static String escape(String str, boolean ignoreCRLF) {
- if (str == null || str.length() == 0)
- return ""; //$NON-NLS-1$
- StringBuffer sb = new StringBuffer();
- int len = str.length();
- for (int i = 0; i < len; i++) {
- char ch = str.charAt(i);
- switch (ch) {
- case '<':
- sb.append(XML_LT);
- break;
- case '>':
- sb.append(XML_GT);
- break;
- case '&':
- // This is to avoid the double escaping (see Bugzilla 179921)
- if (!str.startsWith(XML_LT+"p/", i) && !str.startsWith(XML_APOS, i) //$NON-NLS-1$
- && !str.startsWith(XML_AMP, i))
- sb.append(XML_AMP);
- else
- sb.append(ch);
- break;
- case '"':
- sb.append(XML_QUOT);
- break;
- case '\'':
- sb.append(XML_APOS);
- break;
- case '\r':
- if (ignoreCRLF)
- sb.append(ch);
- else
- sb.append(XML_CR);
- break;
- case '\n':
- if (ignoreCRLF)
- sb.append(ch);
- else
- sb.append(XML_LF);
- break;
- default:
- sb.append(ch);
- break;
- }
- }
- return sb.toString();
- }
-
- /**
- * Unescapes the given XML string.
- *
- * @param str
- * The source string.
- * @return The escaped string.
- */
- public static String unescape(String str) {
- if (str == null || str.length() == 0)
- return ""; //$NON-NLS-1$
- StringBuffer sb = new StringBuffer();
- int len = str.length();
- for (int i = 0; i < len; i++) {
- char ch = str.charAt(i);
- switch (ch) {
- case '&':
- if (str.startsWith(XML_LT, i)) {
- sb.append('<');
- i += 3;
- } else if (str.startsWith(XML_GT, i)) {
- sb.append('>');
- i += 3;
- } else if (str.startsWith(XML_AMP, i)) {
- sb.append('&');
- i += 4;
- } else if (str.startsWith(XML_QUOT, i)) {
- sb.append('"');
- i += 5;
- } else if (str.startsWith(XML_APOS, i)) {
- sb.append("\'"); //$NON-NLS-1$
- i += 5;
- } else if (str.startsWith(XML_CR, i)) {
- sb.append('\r');
- i += 4;
- } else if (str.startsWith(XML_LF, i)) {
- sb.append('\n');
- i += 4;
- } else {
- sb.append(ch);
- }
- break;
- default:
- sb.append(ch);
- break;
- }
- }
- return sb.toString();
- }
-
- /**
- * Writes the content of the given DOM document to the output stream.
- *
- * @param xmlDoc
- * The DOM document.
- * @param output
- * The output stream.
- * @throws IOException
- * if an I/O error occur while accessing the output stream.
- */
- public static void writeDocument(Document xmlDoc, OutputStream output)
- throws IOException {
- DataOutputStream out = new DataOutputStream(output);
- writeNode(xmlDoc, "", out); //$NON-NLS-1$
- out.flush();
- }
-
- /**
- * Writes the content of the given DOM document to the PrintWriter.
- *
- * @param xmlDoc
- * The DOM document.
- * @param pw
- * The PrintWriter object.
- * @throws IOException
- * if an I/O error occur while accessing the output stream.
- */
- public static void writeDocument(Document xmlDoc, PrintWriter pw)
- throws IOException {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(os);
- writeNode(xmlDoc, "", out); //$NON-NLS-1$
- out.flush();
- // FIXME! Need to specify encoding?
- String s = os.toString();
- pw.write(s);
- pw.flush();
- }
-
- /**
- * Saves the content of the given DOM document to file.
- *
- * @param xmlDoc
- * The DOM document.
- * @param xmlFile
- * The XML file.
- * @throws IOException
- * if an I/O error occur while accessing the output stream.
- */
- public static void saveDocument(Document xmlDoc, String xmlFile)
- throws IOException {
- DataOutputStream out = new DataOutputStream(new FileOutputStream(
- xmlFile));
- writeNode(xmlDoc, "", out); //$NON-NLS-1$
- out.flush();
- out.close();
- }
-
- /**
- * Saves the given XML string to the given file.
- *
- * @param xmlStr
- * The XML string.
- * @param xmlFile
- * The XML file.
- * @throws IOException
- * if an I/O error occur while accessing the output stream.
- */
- public static void saveDocument(String xmlStr, String xmlFile)
- throws IOException {
- DataOutputStream out = new DataOutputStream(new FileOutputStream(
- xmlFile));
- out.write(xmlStr.getBytes());
- out.flush();
- out.close();
- }
-
- /**
- * Writes the given DOM tree node to the given output stream.
- *
- * @param node
- * The DOM node.
- * @param indent
- * The string indentation (containing space characters).
- * @param out
- * The output stream.
- * @throws IOException
- * if an I/O error occur while accessing the output stream.
- */
- private static void writeNode(Node node, String indent, DataOutputStream out)
- throws IOException {
- String text;
-
- switch (node.getNodeType()) {
- case Node.DOCUMENT_NODE:
- // Write the XML file signature.
- out.write(StrUtil.getUTF8Bytes(XML_DECLARATION));
- out.write(CRLF_BYTES);
-
- // Iterate through each child nodes.
- NodeList nodes = node.getChildNodes();
- if (nodes != null) {
- for (int i = 0; i < nodes.getLength(); i++) {
- writeNode(nodes.item(i), "", out); //$NON-NLS-1$
- }
- }
- break;
-
- case Node.ELEMENT_NODE:
- String name = node.getNodeName();
- out.write(StrUtil.getUTF8Bytes(indent + "<" + name)); //$NON-NLS-1$
- NamedNodeMap attrs = node.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attrNode = attrs.item(i);
- out.write(StrUtil.getUTF8Bytes(" " + attrNode.getNodeName() //$NON-NLS-1$
- + "=\"" + escape(attrNode.getNodeValue()) + "\"")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- out.write(StrUtil.getUTF8Bytes(">")); //$NON-NLS-1$
- out.write(CRLF_BYTES);
-
- // Iterate through each child nodes.
- NodeList childNodes = node.getChildNodes();
- if (childNodes != null) {
- for (int i = 0; i < childNodes.getLength(); i++) {
- writeNode(childNodes.item(i), indent, out);
- }
- }
- out.write(StrUtil.getUTF8Bytes(indent + "</" + name + ">")); //$NON-NLS-1$ //$NON-NLS-2$
- out.write(CRLF_BYTES);
-
- break;
-
- case Node.TEXT_NODE:
- text = StrUtil.removeWhiteSpaceChars(node.getNodeValue());
- if (text.length() > 0) {
- out.write(StrUtil.getUTF8Bytes(escape(text)));
- }
- break;
-
- case Node.CDATA_SECTION_NODE:
- text = StrUtil.removeWhiteSpaceChars(node.getNodeValue());
- if (text.length() > 0) {
- out.write(StrUtil.getUTF8Bytes("<![CDATA[")); //$NON-NLS-1$
- out.write(StrUtil.getUTF8Bytes(text));
- out.write(StrUtil.getUTF8Bytes("]]>")); //$NON-NLS-1$
- out.write(CRLF_BYTES);
- }
- break;
-
- case Node.PROCESSING_INSTRUCTION_NODE:
- out.write(StrUtil.getUTF8Bytes("<?" + node.getNodeName() //$NON-NLS-1$
- + " " + node.getNodeValue() + "?>")); //$NON-NLS-1$ //$NON-NLS-2$
- out.write(CRLF_BYTES);
- break;
-
- case Node.ENTITY_REFERENCE_NODE:
- out.write(StrUtil.getUTF8Bytes("&" + node.getNodeName() + ";")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
-
- /**
- * Returns the file location where the given SAX exception occurred.
- *
- * @param e
- * The SAX parse exception.
- * @return A string containing the file location where the exception
- * occurred.
- */
- public static String getLocationOfException(SAXParseException e) {
- StringBuffer sb = new StringBuffer();
- sb.append("row "); //$NON-NLS-1$
- sb.append(e.getLineNumber());
- sb.append(", col "); //$NON-NLS-1$
- sb.append(e.getColumnNumber());
-
- String systemId = e.getSystemId();
- if (systemId != null) {
- int index = systemId.lastIndexOf('/');
- if (index != -1) {
- systemId = systemId.substring(index + 1);
- }
- sb.append(" of XML document "); //$NON-NLS-1$
- sb.append(systemId);
- }
-
- return sb.toString();
- }
-
- public static Document loadXml(File file) throws Exception {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder builder = builderFactory.newDocumentBuilder();
-
- return builder.parse(file);
- }
-
- public static Document createDocument() throws Exception {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder builder = builderFactory.newDocumentBuilder();
- return builder.newDocument();
- }
-
- /**
- * text of a leaf node, without child element
- *
- * @param tag
- * @return String
- */
- public static String getNodeText(Element tag) {
- String text = tag.toString();
- int i = text.indexOf(">"); //$NON-NLS-1$
- int j = text.lastIndexOf("</"); //$NON-NLS-1$
- if (i < 0 || j < 0 || j < i) {
- return ""; //$NON-NLS-1$
- }
-
- return text.substring(i + 1, j);
- }
-
- public static String getChildText(Element tag, String childTagName) {
- Element child = getFirstChild(tag, childTagName);
- if (child != null) {
- return getNodeText(child);
- }
-
- return ""; //$NON-NLS-1$
- }
-
- public static Element getFirstChild(Element tag, String childTagName) {
- NodeList nodes = tag.getElementsByTagName(childTagName);
- if (nodes == null || nodes.getLength() == 0) {
- return null;
- }
-
- return (Element) nodes.item(0);
- }
-
- /**
- * iterator of all the children of the element
- *
- * @param tag
- * @return Iterator
- */
- public static Iterator childIterator(Element tag) {
- NodeList nodes = tag.getChildNodes();
-
- // NodeList contains no Element nodes such as text nodes, ignore those
- List<Node> elements = new ArrayList<Node>();
- if (nodes != null) {
- int size = nodes.getLength();
- for (int i = 0; i < size; i++) {
- Node node = nodes.item(i);
- if (node instanceof Element) {
- elements.add(node);
- }
- }
- }
-
- return elements.iterator();
- }
-
- private static class NodeIterator implements Iterator {
- int currentIndex = -1;
-
- int size = 0;
-
- NodeList nodes = null;
-
- public NodeIterator(NodeList nodes) {
- this.nodes = nodes;
- if (nodes != null)
- size = nodes.getLength();
- }
-
- public void remove() {
- // Do nothing, this is a readonly iterator.
- }
-
- public boolean hasNext() {
- return currentIndex + 1 < size;
- }
-
- public Object next() {
- if (hasNext()) {
- return nodes.item(++currentIndex);
- }
-
- return null;
- }
- }
-
- /**
- * iterator of all the children of the element
- *
- * @param tag
- * @return Iterator
- */
- public static Iterator childIterator(Element tag, String childTagName) {
- NodeList nodes = tag.getElementsByTagName(childTagName);
- return new NodeIterator(nodes);
- }
-
- /**
- * Gets the list of immediate child elements with the given tag name.
- *
- * @param element
- * @param tagName
- * @return list of {@link Element} objects
- */
- public static List<Element> getChildElementsByTagName(Element element, String tagName) {
- List<Element> elements = new ArrayList<Element>();
- NodeList list = element.getChildNodes();
- int size = list.getLength();
- if(size > 0) {
- for (int i = 0; i < size; i++) {
- Node node = list.item(i);
- if(node instanceof Element) {
- Element e = (Element) node;
- if(e.getTagName().equals(tagName)) {
- elements.add(e);
- }
- }
- }
- }
- return elements;
- }
-
- /**
- * Gets the first element with the given tag name in the immediate child elements.
- *
- * @param element
- * @param tagName
- * @return
- */
- public static Element getFirstChildElementByTagName(Node element, String tagName) {
- NodeList list = element.getChildNodes();
- int size = list.getLength();
- if(size > 0) {
- for (int i = 0; i < size; i++) {
- Node node = list.item(i);
- if(node instanceof Element) {
- Element e = (Element) node;
- if(e.getTagName().equals(tagName)) {
- return e;
- }
- }
- }
- }
- return null;
- }
-
- public static String removeBOM(String xml) {
- return xml.trim().replaceFirst("^([\\W]+)<", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ZipUtil.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ZipUtil.java
deleted file mode 100644
index 5396843191e..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/ZipUtil.java
+++ /dev/null
@@ -1,106 +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.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Utility class for reading and writing zip files.
- *
- * @author Kelvin Low
- * @since 1.2
- */
-public class ZipUtil {
-
- /**
- * Creates a zip file.
- *
- * @param zipFilePath
- * an absolute path to the target zip file
- * @param contentPath
- * an absolute path to a directory containing the files and sub
- * directories to be zipped
- * @param monitor
- * a progress monitor
- * @throws IOException
- * if an error occurs while creating the zip file
- */
- public static void createZipFile(String zipFilePath, String contentPath,
- IProgressMonitor monitor) throws IOException {
- ZipOutputStream out = null;
- try {
- out = new ZipOutputStream(new FileOutputStream(
- zipFilePath));
- File contentDir = new File(contentPath);
- populateZipFile(out, contentDir.getAbsolutePath(), contentDir,
- monitor);
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e.getMessage());
- }
- finally {
- if (out != null) {
- try {
- out.close();
- }
- catch (Exception e) {
- }
- }
- }
- }
-
- /**
- * Populates a zip file with directories and files.
- *
- * @param out
- * a zip file output stream
- * @param rootPath
- * a root path that is used to compute the relative paths of the
- * zip content
- * @param file
- * a file or directory
- * @param monitor
- * a progress monitor
- */
- public static void populateZipFile(ZipOutputStream out, String rootPath,
- File file, IProgressMonitor monitor) throws IOException {
- File[] files = file.listFiles();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- populateZipFile(out, rootPath, files[i], monitor);
- } else {
- String filePath = files[i].getAbsolutePath();
- FileInputStream in = new FileInputStream(filePath);
- String relativePath = filePath
- .substring(rootPath.length() + 1);
- out.putNextEntry(new ZipEntry(relativePath));
- byte[] buffer = new byte[1024];
- int len;
- while ((len = in.read(buffer)) > 0) {
- out.write(buffer, 0, len);
- }
- out.closeEntry();
- in.close();
- }
- }
- }
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/package.html b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/package.html
deleted file mode 100644
index 164d717abc6..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/utils/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-Provides common clipboard, file, I18N, image, networking, string manipulation and threading services.
-</body>
-</html> \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/AbstractSAXParser.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/AbstractSAXParser.java
deleted file mode 100644
index 13218b004d5..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/AbstractSAXParser.java
+++ /dev/null
@@ -1,216 +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.xml;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.epf.common.serviceability.Logger;
-import org.eclipse.epf.common.utils.NetUtil;
-import org.eclipse.epf.common.utils.StrUtil;
-import org.eclipse.epf.common.utils.XMLUtil;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * An abstract SAX parser that can be used to parse a single XML file or a
- * directory of XML files.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public abstract class AbstractSAXParser extends DefaultHandler {
-
- /**
- * The logger used for logging warnings, errors and exceptions.
- */
- protected Logger logger;
-
- /**
- * The name of the current XML file being parsed.
- */
- protected String xmlFile;
-
- /**
- * The String buffer for accumulating text.
- */
- protected StringBuffer strBuf;
-
- /**
- * The XML validating flag.
- */
- private boolean validating;
-
- /**
- * Creates a new <code>AbstractSaxParser</code> given the validating flag.
- *
- * @param logger
- * The logger for logging warnings and errors.
- * @param validating
- * If true, validate the XML document.
- */
- public AbstractSAXParser(Logger logger, boolean validating) {
- this.logger = logger;
- this.validating = validating;
- }
-
- /**
- * Parses the given XML directory or file.
- *
- * @param xmlPath
- * The XML directory or file.
- */
- public void parse(String xmlPath) {
- String pathName = StrUtil.replace(xmlPath, "%20", " "); //$NON-NLS-1$ //$NON-NLS-2$
- File path = new File(pathName);
- File[] files = path.isFile() ? new File[] { path } : path.listFiles();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (!files[i].isDirectory()) {
- try {
- parseFile(files[i].getAbsoluteFile());
- } catch (Exception e) {
- if (logger != null) {
- logger
- .logError(
- "Failed to parse \"" + files[i].getAbsolutePath() + '"', e); //$NON-NLS-1$
- }
- }
- }
- }
- }
- }
-
- /**
- * Parses the given XML file.
- *
- * @param xmlFile
- * The XML file.
- */
- protected void parseFile(File xmlFile) throws ParserConfigurationException,
- IOException, SAXException {
- // Create the SAX parser factory.
- SAXParserFactory spf = SAXParserFactory.newInstance();
-
- // Set the XML validating flag.
- spf.setValidating(validating);
-
- // Create the SAX parser.
- SAXParser saxParser = spf.newSAXParser();
-
- // Get the SAX XML reader.
- XMLReader xmlReader = saxParser.getXMLReader();
-
- // Set the SAX parser handlers to this class.
- xmlReader.setContentHandler(this);
- xmlReader.setErrorHandler(this);
-
- // Instruct the SAX parser to parse the given XML file.
- this.xmlFile = xmlFile.getAbsolutePath();
- xmlReader.parse(NetUtil.getUri(xmlFile));
- }
-
- /**
- * Called when the XML parser starts to parse the document.
- */
- public void startDocument() {
- strBuf = new StringBuffer();
- }
-
- /**
- * Called when the the XML parser encounters the chararacter data within a
- * text element.
- */
- public void characters(char[] buffer, int start, int length) {
- strBuf.append(buffer, start, length);
- }
-
- /**
- * Called when the parser starts to parse each new element.
- */
- public abstract void startElement(String namespaceURL, String localName,
- String qname, Attributes attributes);
-
- /**
- * Called when the XML parser reaches the end of the an element.
- */
- public abstract void endElement(String namespaceURL, String localName,
- String qname);
-
- /**
- * Called when the XML parser reaches the end of the document.
- */
- public void endDocument() {
- }
-
- /**
- * Logs the SAX parsing warning.
- *
- * @param e
- * The SAX parse exception.
- */
- public void warning(SAXParseException e) {
- if (logger != null) {
- logger
- .logWarning("SAX parsing warning encountered at " //$NON-NLS-1$
- + XMLUtil.getLocationOfException(e)
- + ": " + e.getMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * Logs the SAX parsing error.
- *
- * @param e
- * The SAX parse exception.
- */
- public void error(SAXParseException e) {
- if (logger != null) {
- logger
- .logError("SAX parsing error encountered at " //$NON-NLS-1$
- + XMLUtil.getLocationOfException(e)
- + ": " + e.getMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * Logs the SAX non-recoverable error and exits.
- *
- * @param e
- * The SAX parse exception.
- */
- public void fatalError(SAXParseException e) throws SAXException {
- if (logger != null) {
- logger
- .logError("SAX parsing fatal error encountered at " //$NON-NLS-1$
- + XMLUtil.getLocationOfException(e)
- + ": " + e.getMessage()); //$NON-NLS-1$
- logger.logError(e);
- }
- }
-
- /**
- * Returns the current XML file that is being parsed.
- *
- * @return The name of the XML file.
- */
- public String getXMLFile() {
- return xmlFile;
- }
-
-} \ No newline at end of file
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/XSLTProcessor.java b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/XSLTProcessor.java
deleted file mode 100644
index a595850fbec..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/XSLTProcessor.java
+++ /dev/null
@@ -1,449 +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.xml;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.eclipse.epf.common.CommonPlugin;
-
-/**
- * A wrapper over the XSLT processor bundled with the JRE.
- *
- * @author Kelvin Low
- * @since 1.0
- */
-public class XSLTProcessor {
-
- // If true, cache the compiled the XSL transformer with the compiled XSL
- // templates.
- private static boolean cacheXSL;
-
- // Caches the XSL transformers.
- private static Map<String, CachedTransformer> transformerCache;
-
- static {
- String cacheXSLProperty = CommonPlugin.getDefault().getString(
- "cacheXSL"); //$NON-NLS-1$
- if (cacheXSLProperty != null && !cacheXSLProperty.startsWith("[")) { //$NON-NLS-1$
- cacheXSL = Boolean.getBoolean(cacheXSLProperty);
- } else {
- cacheXSL = true;
- }
- if (cacheXSL) {
- transformerCache = new HashMap<String, CachedTransformer>();
- }
-
- // Increase the entity expansion line limit to handle a larger number of
- // XML entities.
- System.setProperty("entityExpansionLimit", "1000000"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Default private constructor to prevent this class from being
- * instantiated.
- */
- private XSLTProcessor() {
- }
-
- /**
- * Executes the XSL transformation given the XSL source, XML source, target
- * output and encoding.
- *
- * @param xslSource
- * The XSL source.
- * @param xmlSource
- * The XML source.
- * @param output
- * The output target.
- * @param params
- * The parameters for the XSL transformation.
- * @param encoding
- * The target encoding.
- */
- public static void transform(Source xslSource, Source xmlSource,
- Writer output, Properties params, String encoding) throws Exception {
- if (xslSource != null && xmlSource != null) {
- Transformer transformer = null;
- String xslFile = xslSource.getSystemId();
- if (cacheXSL && xslFile != null) {
- CachedTransformer cachedTransformer = null;
- synchronized (transformerCache) {
- cachedTransformer = transformerCache.get(xslFile);
- if (cachedTransformer == null) {
- TransformerFactory factory = TransformerFactory
- .newInstance();
- transformer = factory.newTransformer(xslSource);
- transformerCache.put(xslFile, new CachedTransformer(
- transformer, params));
- } else {
- cachedTransformer.setParams(params);
- transformer = cachedTransformer.getTransformer();
- }
- }
- } else {
- TransformerFactory factory = TransformerFactory.newInstance();
- transformer = factory.newTransformer(xslSource);
-
- if (params != null && params.size() > 0) {
- for (Iterator<Object> i = params.keySet().iterator(); i
- .hasNext();) {
- String paramName = (String) i.next();
- String paramValue = params.getProperty(paramName);
- transformer.setParameter(paramName, paramValue);
- }
- }
- }
-
- if (encoding != null && encoding.length() > 0) {
- transformer.setOutputProperty("encoding", encoding); //$NON-NLS-1$
- } else {
- transformer.setOutputProperty("encoding", "utf-8"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- transformer.transform(xmlSource, new StreamResult(output));
- }
- }
-
- /**
- * Executes the XSL transformation given the XSL source, XML source, target
- * output and encoding.
- *
- * @param xslSource
- * The XSL source.
- * @param xmlSource
- * The XML source.
- * @param output
- * The output target.
- * @param encoding
- * The target encoding.
- */
- public static void transform(Source xslSource, Source xmlSource,
- Writer output, String encoding) throws Exception {
- transform(xslSource, xmlSource, output, null, encoding);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML source,
- * target output and encoding.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML source.
- * @param output
- * The output target.
- * @param params
- * The parameters for the XSL transformation.
- * @param encoding
- * The target encoding.
- */
- public static void transform(String xslUri, Source xmlSource,
- Writer output, Properties params, String encoding) throws Exception {
- InputStream xslInput = getXslInputStream(xslUri);
- if (xslInput != null) {
- StreamSource xslSource = new StreamSource(xslInput);
- xslSource.setSystemId(new File(xslUri));
- transform(xslSource, xmlSource, output, params, encoding);
- try {
- xslInput.close();
- } catch (Exception e) {
- }
- }
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML source,
- * target output and encoding.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML source.
- * @param output
- * The output target.
- * @param encoding
- * The target encoding.
- */
- public static void transform(String xslUri, Source xmlSource,
- Writer output, String encoding) throws Exception {
- transform(xslUri, xmlSource, output, null, encoding);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string,
- * target output and encoding.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param output
- * The output target.
- * @param params
- * The parameters for the XSL transformation.
- * @param encoding
- * The target encoding.
- */
- public static void transform(String xslUri, String xmlStr, Writer output,
- Properties params, String encoding) throws Exception {
- InputStream xslInput = getXslInputStream(xslUri);
- if (xslInput != null) {
- StreamSource xslSource = new StreamSource(xslInput);
- xslSource.setSystemId(new File(xslUri));
-
- byte[] xml = xmlStr.getBytes("utf-8"); //$NON-NLS-1$
- ByteArrayInputStream xmlInput = new ByteArrayInputStream(xml);
- StreamSource xmlSource = new StreamSource(xmlInput);
-
- transform(xslSource, xmlSource, output, params, encoding);
-
- try {
- xslInput.close();
- xmlInput.close();
- } catch (Exception e) {
- }
- }
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string,
- * target output and encoding.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param output
- * The output target.
- * @param encoding
- * The target encoding.
- */
- public static void transform(String xslUri, String xmlStr, Writer output,
- String encoding) throws Exception {
- transform(xslUri, xmlStr, output, null, encoding);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string,
- * target output and encoding.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param file
- * The output file.
- * @param params
- * The parameters for the XSL transformation.
- * @param encoding
- * The target encoding.
- */
- public static void transform(String xslUri, String xmlStr, File file,
- Properties params, String encoding) throws Exception {
- FileWriter output = new FileWriter(file);
- if (output != null) {
- transform(xslUri, xmlStr, output, params, encoding);
- try {
- output.close();
- } catch (Exception e) {
- }
- }
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string,
- * target output and encoding.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param file
- * The output file.
- * @param encoding
- * The target encoding.
- */
- public static void transform(String xslUri, String xmlStr, File file,
- String encoding) throws Exception {
- transform(xslUri, xmlStr, file, null, encoding);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML source
- * and target output.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML source.
- * @param params
- * The parameters for the XSL transformation.
- * @param output
- * The output target.
- */
- public static void transform(String xslUri, Source xmlSource,
- Properties params, Writer output) throws Exception {
- transform(xslUri, xmlSource, output, params, null);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML source
- * and target output.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML source.
- * @param output
- * The output target.
- */
- public static void transform(String xslUri, Source xmlSource, Writer output)
- throws Exception {
- transform(xslUri, xmlSource, output, null, null);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string
- * and target output.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param params
- * The parameters for the XSL transformation.
- * @param output
- * The output target.
- */
- public static void transform(String xslUri, String xmlStr,
- Properties params, Writer output) throws Exception {
- transform(xslUri, xmlStr, output, params, null);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string
- * and target output.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param output
- * The output target.
- */
- public static void transform(String xslUri, String xmlStr, Writer output)
- throws Exception {
- transform(xslUri, xmlStr, output, null, null);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string
- * and target output file.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param params
- * The parameters for the XSL transformation.
- * @param output
- * The output target.
- */
- public static void transform(String xslUri, String xmlStr,
- Properties params, File file) throws Exception {
- transform(xslUri, xmlStr, file, params, null);
- }
-
- /**
- * Executes the XSL transformation given the XSL stylesheet URI, XML string
- * and target output file.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- * @param xmlStr
- * The XML string.
- * @param output
- * The output target.
- */
- public static void transform(String xslUri, String xmlStr, File file)
- throws Exception {
- transform(xslUri, xmlStr, file, null, null);
- }
-
- /**
- * Returns the XSL input stream given the XSL stylesheet URI.
- *
- * @param xslURI
- * The XSL stylesheet URI.
- */
- private static InputStream getXslInputStream(String xslUri) {
- InputStream xslInput = null;
- try {
- xslInput = new FileInputStream(xslUri);
- } catch (Exception e) {
- if (xslInput == null) {
- xslInput = XSLTProcessor.class.getClassLoader()
- .getResourceAsStream(xslUri);
- }
- }
- return xslInput;
- }
-
-}
-
-/**
- * A cached XSL Transformer object.
- */
-class CachedTransformer {
-
- private Transformer transformer;
- private Properties params;
-
- public CachedTransformer(Transformer transformer, Properties params) {
- this.transformer = transformer;
- setParams(params);
- }
-
- public Transformer getTransformer() {
- return transformer;
- }
-
- public Properties getParams() {
- return params;
- }
-
- public void setParams(Properties params) {
- if (params != this.params) {
- transformer.clearParameters();
- for (Iterator<Object> i = params.keySet().iterator(); i.hasNext();) {
- String paramName = (String) i.next();
- String paramValue = params.getProperty(paramName);
- transformer.setParameter(paramName, paramValue);
- }
- this.params = params;
- }
- }
-
-}
diff --git a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/package.html b/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/package.html
deleted file mode 100644
index 6e3c33ecf8e..00000000000
--- a/extraplugins/epf-richtext/org.eclipse.epf.common/src/org/eclipse/epf/common/xml/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-Provides XML and XSLT processing services.
-</body>
-</html> \ No newline at end of file

Back to the top