This commit was manufactured by cvs2svn to create tag 'v20041118'.
diff --git a/plugins/org.eclipse.wst.common.ui/.classpath b/plugins/org.eclipse.wst.common.ui/.classpath
deleted file mode 100644
index 065ac06..0000000
--- a/plugins/org.eclipse.wst.common.ui/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/plugins/org.eclipse.wst.common.ui/.cvsignore b/plugins/org.eclipse.wst.common.ui/.cvsignore
deleted file mode 100644
index db7cdf2..0000000
--- a/plugins/org.eclipse.wst.common.ui/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-bin
-ui.jar
-build.xml
-temp.folder
-org.eclipse.wst.common.ui_1.0.0.jar
diff --git a/plugins/org.eclipse.wst.common.ui/.project b/plugins/org.eclipse.wst.common.ui/.project
deleted file mode 100644
index 8f557ef..0000000
--- a/plugins/org.eclipse.wst.common.ui/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.wst.common.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/plugins/org.eclipse.wst.common.ui/README.txt b/plugins/org.eclipse.wst.common.ui/README.txt
deleted file mode 100644
index 4fc93df..0000000
--- a/plugins/org.eclipse.wst.common.ui/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-UI Utility classes for actions, drag'n'drop and wizards.
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.ui/build.properties b/plugins/org.eclipse.wst.common.ui/build.properties
deleted file mode 100644
index 89adbc5..0000000
--- a/plugins/org.eclipse.wst.common.ui/build.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-bin.includes = plugin.properties,\
- plugin.xml,\
- ui.jar
-jars.compile.order = ui.jar
-source.ui.jar = src/
-output.ui.jar = bin/
diff --git a/plugins/org.eclipse.wst.common.ui/plugin.properties b/plugins/org.eclipse.wst.common.ui/plugin.properties
deleted file mode 100644
index eb3402d..0000000
--- a/plugins/org.eclipse.wst.common.ui/plugin.properties
+++ /dev/null
@@ -1,132 +0,0 @@
-! SelectSingleFilePage and SelectMultiFilePage
-_UI_LABEL_SOURCE_FILES = Workbench Files
-_UI_LABEL_SELECTED_FILES = Selected Files
-
-_UI_IMPORT_BUTTON = Import Files...
-_UI_IMPORT_BUTTON_TOOL_TIP = Import files from file system
-
-
-! SelectMultiFilePage
-! NOTE TO TRANSLATOR: the following three lines refers to _UI_LABEL_SELECTED_FILES label above
-_UI_ADD_BUTTON_TOOL_TIP = Add files to Selected Files list.
-_UI_REMOVE_BUTTON_TOOL_TIP = Remove files from Selected Files list.
-_UI_REMOVE_ALL_BUTTON_TOOL_TIP = Remove all files from Selected Files list.
-
-! NOTE TO TRANSLATOR: No translation needed of following three lines
-_UI_ADD_BUTTON = >
-_UI_REMOVE_BUTTON = <
-_UI_REMOVE_ALL_BUTTON = <<
-
-! SelectJavaProjectView
-_UI_LABEL_CHOOSE_FOLDER = Select a project or folder:
-
-! SelectJavaProjectDialog
-_UI_LABEL_FOLDER_SELECTION = Container Selection
-
-! TextViewerOperationAction
-_UI_MENU_COPY = &Copy
-_UI_MENU_CUT = Cu&t
-_UI_MENU_DELETE = Delete
-_UI_MENU_PASTE = &Paste
-_UI_MENU_PREFIX = Prefix
-_UI_MENU_REDO = Redo
-_UI_MENU_SELECT_ALL = Select All
-_UI_MENU_SHIFT_LEFT = Shift Left
-_UI_MENU_SHIFT_RIGHT = Shift Right
-_UI_MENU_STRIP_PREFIX = Strip Prefix
-_UI_MENU_UNDO = Undo
-
-! SourceViewerGotoLineAction
-_UI_MENU_GOTO_LINE = Go To Line...
-_UI_GOTO_LINE_DIALOG_TITLE = Go To Line
-_UI_GOTO_LINE_DIALOG_TEXT = Enter Line Number
-
-_UI_FILE_CHANGED_TITLE = File Changed
-_UI_FILE_DELETED_SAVE_CHANGES = The file has been deleted from the file system. Do you want to save your changes or close the editor without saving?
-_UI_FILE_DELETED_EDITOR_CLOSED = The file has been deleted from the file system. This editor will be closed.
-_UI_FILE_CHANGED_LOAD_CHANGES = The file has been changed on the file system. Do you want to load the changes?
-_UI_SAVE_BUTTON = Save
-_UI_CLOSE_BUTTON = Close
-
-
-! XSL Prefererence
-_UI_XSLT_SELECT = Select which element to use for your stylesheet
-_UI_XSLT_STYLESHEET = &Use <xsl:stylesheet>
-_UI_XSLT_TRANSFORM = U&se <xsl:transform>
-
-! XSL Debug Prefererence
-_UI_XSL_DEBUG_SELECT_LAUNCHER = Set the default XSL launcher for the XSL Debugging and Transformation tool
-_UI_XSL_DEBUG_LOCAL = &XSL application
-_UI_XSL_DEBUG_REMOTE = XS&L remote application
-_UI_XSL_TILE_EDITOR = &Show all debugging files in a tile editor
-_UI_XSL_DEBUG_AND_TRANSFORM = &Run transformation and open a debugging session
-_UI_XSL_CONTEXT_URI = Context Path
-_UI_XSL_CONTEXT = Specify a &context path for resolving URIs in xsl:import, xsl:include or document()
-
-
-_UI_OVERRIDE_FILE = Overwrite existing files
-_UI_JAVA_EXIST_FILE1 = The following Java classes already exist.
-_UI_JAVA_EXIST_FILE2 = Do you want to overwrite the existing file?
-
-! some options strings common to several plugins
-_UI_ERROR_CREATING_FILE_TITLE = Error Creating File
-_UI_ERROR_CREATING_FILE_SHORT_DESC = Error creating file "{0}"
-_UI_ERROR_CREATING_FILE_LONG_DESC = An error occured while attempting to create the file "{0}".
-_UI_PARENT_FOLDER_IS_READ_ONLY = The parent directory "{0}" is read only.
-_UI_UNKNOWN_ERROR_WITH_HINT = Unknown error. Ensure that the parent directory "{0}" is writeable.
-_UI_UNKNOWN_ERROR = Unknown error. Ensure that the parent directory "{0}" is writeable.
-
-! usage - this label is followed by two radio button options for the file location
-_UI_LABEL_INCLUDE_URL_FILE = Select file location
-_UI_RADIO_FILE = Workbench projects
-_UI_RADIO_URL = HTTP
-
-!======================================================================================
-!
-! Here is the list of Error string that have message IDs - make sure they are unique
-! Range for b2bgui messageIDs: IWAX1201 - IWAX1400
-!
-!======================================================================================
-
-_ERROR_THE_CONTAINER_NAME = The specified container must exist in the workspace and its path must start at the workspace root.
-
-_ERROR_LOCAL_LOCATION = The local location of this container cannot be resolved.
-_ERROR_NOT_JAVA_PROJECT = The specified project is not a Java project.
-
-!NOTE TO TRANSLATOR: this error message text is followed by a message from another plugin
-_ERROR_INVALID_JAVA_PACKAGE = IWAX1201E Invalid package name error:
-
-!NOTE TO TRANSLATOR: (_ERROR_BAD_FILENAME_EXTENSION + string + _UI_LABEL_OR + string) or (_ERROR_BAD_FILENAME_EXTENSION)
-_ERROR_BAD_FILENAME_EXTENSION = The file name must end with
-_ERROR_FILE_ALREADY_EXISTS = The same name already exists.
-
-_ERROR_CONTAINER_NOT_JAVA_BUILDPATH = The container is not a Java source folder for this project
-_ERROR_USE_PROJECT_JAVA_SOURCE_FOLDER = The project is not on the build path. Select a Java source folder for the project.
-
-_UI_ERROR = Error
-
-!NOTE TO TRANSLATOR: this warning message text is followed by a message from another plugin
-_WARN_INVALID_JAVA_PACKAGE = Invalid package name warning:
-
-_ERROR_ROOT_ELEMENT = The XML schema does not contain any global elements that can be used as a root element.
-_ERROR_SAVING_FILE = Error saving file "{0}"
-
-! File Validator
-_UI_ERROR_VALIDATE_FAIL_TITLE = Failed to check out necessary files
-_UI_ERROR_VALIDATE_FAIL_MESSAGE = Generation failed. Necessary files could not be checked out.
-
-! PropertyDirtyChangeListener and PropertyResourceChangeListener
-_UI_ERROR_VALIDATE_EDIT_FAIL_ONE_FILE = Error
-
-ExampleProjectCreationWizard.title=New Example Project
-ExampleProjectCreationWizard.op_error.title=Project Creation Failed
-ExampleProjectCreationWizard.op_error.message=Project could not be created.
-
-ExampleProjectCreationWizard.overwritequery.title=Overwrite
-ExampleProjectCreationWizard.overwritequery.message=Do you want to overwrite {0}?
-
-
-ExampleProjectCreationOperation.op_desc=Creating example projects...
-ExampleProjectCreationOperation.op_desc_proj=Configuring project...
-
-ExampleProjectCreationWizardPage.error.alreadyexists=Project already exists.
diff --git a/plugins/org.eclipse.wst.common.ui/plugin.xml b/plugins/org.eclipse.wst.common.ui/plugin.xml
deleted file mode 100644
index 4bcd4f9..0000000
--- a/plugins/org.eclipse.wst.common.ui/plugin.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.wst.common.ui"
- name="Eclipse Base UI extensions"
- version="1.0.0"
- provider-name="Eclipse.org"
- class="org.eclipse.wst.common.ui.UIPlugin">
-
- <runtime>
- <library name="ui.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.ui.views"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.ui.editors"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- </requires>
-
- <extension point="org.eclipse.ui.newWizards">
- <category id="org.eclipse.wst.xml.samples" name="XML"
- parentCategory="org.eclipse.ui.Examples" />
- </extension>
-
-</plugin>
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/ImageFactory.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/ImageFactory.java
deleted file mode 100644
index 0aa8f5a..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/ImageFactory.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui;
-
-import java.util.Hashtable;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.internal.ide.misc.OverlayIcon;
-import org.eclipse.ui.internal.misc.OverlayComposite;
-
-public class ImageFactory
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- public static final int TOP_LEFT = 1;
- public static final int TOP_RIGHT = 2;
- public static final int BOTTOM_LEFT = 3;
- public static final int BOTTOM_RIGHT = 4;
-
- protected static final int[][] OVERLAY_COORDINATE = {{0,0},{0,2},{2,0},{2,2}};
-
- protected Hashtable compositeImageTable = new Hashtable();
-
- public ImageFactory()
- {
- }
-
- public Image createCompositeImage(Image a, Image b)
- {
- String key = a + "*" + b;
- Image result = (Image)compositeImageTable.get(key);
- if (result == null)
- {
- OverlayComposite composite = new OverlayComposite(a.getImageData());
- composite.addForegroundImage(b.getImageData());
- result = composite.createImage();
- compositeImageTable.put(key, result);
- }
- return result;
- }
-
- public Image createCompositeImage(Image base, Image overlay, int overlayPosition)
- {
- String key = base + "*" + overlay + "*" + overlayPosition;
- Image result = (Image)compositeImageTable.get(key);
- if (result == null)
- {
- ImageDescriptor overlays[][] = new ImageDescriptor[3][3];
- int[] coord = OVERLAY_COORDINATE[overlayPosition];
- overlays[coord[1]][coord[0]] = new ImageBasedImageDescriptor(overlay);
- OverlayIcon icon = new OverlayIcon(new ImageBasedImageDescriptor(base), overlays, new Point(16, 16));
- result = icon.createImage();
- compositeImageTable.put(key, result);
- }
- return result;
- }
-
-
- public static ImageDescriptor createImageDescriptorWrapper(Image image)
- {
- return new ImageBasedImageDescriptor(image);
- }
-
-
- protected static class ImageBasedImageDescriptor extends ImageDescriptor
- {
- protected Image image;
-
- public ImageBasedImageDescriptor(Image image)
- {
- this.image = image;
- }
-
- public ImageData getImageData()
- {
- return image.getImageData();
- }
- }
-}
-
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/OverlayIconManager.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/OverlayIconManager.java
deleted file mode 100644
index a7b7746..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/OverlayIconManager.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui;
-
-import org.eclipse.core.resources.*;
-//import org.eclipse.jface.resource.*;
-import org.eclipse.jface.viewers.*;
-//import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Display;
-import java.util.*;
-
-/**
- * This class used to track the icon overlays that should be used to decorate the icons in a view.
- * Clients should implement the method 'locateObjectForOffset()' that will be used to associate a model object with each marker.
- * When markers are changed, a table of objects -> markers is maintained. When the time comes to display the object in a view
- * the client can call 'getOverlayImageForObject()' to determine the annotation image that should be used when displaying the object.
- */
-public abstract class OverlayIconManager
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- protected IResource resource;
- protected IWorkspace workspace;
- protected Hashtable hashtable = new Hashtable();
- protected ResourceChangeListener resourceChangeListener = new ResourceChangeListener();
- protected List viewerList = new Vector();
-
- // todo... get images for these other kinds of markers
- //
- protected static final Image taskOverlayImage = null; //B2BGUIPlugin.getInstance().getImage("icons/error-overlay.gif");
- protected static final Image bookmarkOverlayImage = null; //B2BGUIPlugin.getInstance().getImage("icons/error-overlay.gif");
- protected static final Image problemInfoOverlayImage = null; //B2BGUIPlugin.getInstance().getImage("icons/error-overlay.gif");
-// TODO protected static final Image problemWarningOverlayImage = B2BGUIPlugin.getInstance().getImage("icons/warning-overlay.gif");
- protected static final Image problemWarningOverlayImage = null;
-// TODO protected static final Image problemErrorOverlayImage = B2BGUIPlugin.getInstance().getImage("icons/error-overlay.gif");
- protected static final Image problemErrorOverlayImage = null;
-
- /**
- * Internal resource change listener.
- */
- class ResourceChangeListener implements IResourceChangeListener
- {
- protected boolean needsUpdate;
-
- public void resourceChanged(IResourceChangeEvent e)
- {
- //if (e.getResource() == resource)
- {
- if (!needsUpdate)
- {
- needsUpdate = true;
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- doUpdate();
- }
- };
-
- // It seems like this current dislay is actually coming back null sometimes.
- // Without this test we get an occasional NPE logged (defect 187099).
- if (Display.getCurrent() != null)
- {
- Display.getCurrent().asyncExec(delayedUpdate);
- }
- }
- }
- }
-
- public void doUpdate()
- {
- needsUpdate = false;
- update();
- }
- };
-
-
- public OverlayIconManager()
- {
- }
-
-
- public void setResource(IResource newResource)
- {
- this.resource = newResource;
- setWorkspace(newResource != null ? newResource.getWorkspace() : null);
- }
-
-
- // I'm not sure why there can be more than 1 workspace.... do I misunderstand something?
- protected void setWorkspace(IWorkspace newWorkspace)
- {
- if (workspace != null && workspace != newWorkspace)
- {
- workspace.removeResourceChangeListener(resourceChangeListener);
- }
- if (newWorkspace != null)
- {
- newWorkspace.addResourceChangeListener(resourceChangeListener);
- }
- workspace = newWorkspace;
- }
-
-
- //
- public IResource getResource()
- {
- return resource;
- }
-
- public void addViewer(Viewer viewer)
- {
- viewerList.add(viewer);
- }
-
- public void removeViewer(Viewer viewer)
- {
- viewerList.remove(viewer);
- }
-
- protected void updateListeners()
- {
- for (Iterator i = viewerList.iterator(); i.hasNext(); )
- {
- Viewer viewer = (Viewer)i.next();
-
- // Make sure the viewer is not disposed before calling refresh on it
- if ( viewer.getControl() != null &&
- !viewer.getControl().isDisposed() )
- {
- viewer.refresh();
- }
- }
- }
-
- public void update()
- {
- // if resource is null, do nothing
- if (resource == null)
- return;
-
- try
- {
- hashtable = new Hashtable();
- IMarker[] markers = resource.findMarkers(IMarker.MARKER, true, IResource.DEPTH_ZERO);
- for (int i = 0 ; i < markers.length; i++)
- {
- IMarker marker = markers[i];
- Object object = locateObjectForMarker(marker);
- Object key = object != null ? getKeyForObject(object) : null;
- if (key != null)
- {
- hashtable.put(key, marker);
- }
- }
- }
- catch (Exception e)
- {
-// TODO B2BGUIPlugin.getPlugin().getMsgLogger().writeCurrentThread();
- }
- updateListeners();
- }
-
-
- protected abstract Object locateObjectForOffset(int offset);
-
- protected Object locateObjectForMarker(IMarker marker)
- {
- Object result = null;
- int offset = marker.getAttribute(IMarker.CHAR_START, -1);
- if (offset != -1)
- {
- result = locateObjectForOffset(offset);
- }
- return result;
- }
-
-
- protected Object getKeyForObject(Object object)
- {
- return object;
- }
-
-
- public Image getOverlayImageForObject(Object object)
- {
- Image result = null;
- try
- {
- IMarker marker = getMarkerForObject(object);
- if (marker != null)
- {
- if (marker.isSubtypeOf(IMarker.TASK))
- {
- result= taskOverlayImage;
- }
- else if (marker.isSubtypeOf(IMarker.BOOKMARK))
- {
- result = bookmarkOverlayImage;
- }
- else if (marker.isSubtypeOf(IMarker.PROBLEM))
- {
- switch (marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO))
- {
- case IMarker.SEVERITY_INFO: { result = problemInfoOverlayImage; break; }
- case IMarker.SEVERITY_WARNING: { result = problemWarningOverlayImage; break; }
- case IMarker.SEVERITY_ERROR: { result = problemErrorOverlayImage; break; }
- }
- }
- }
- }
- catch (Exception e)
- {
- }
- return result;
- }
-
-
- public IMarker getMarkerForObject(Object object)
- {
- IMarker result = null;
- Object key = object != null ? getKeyForObject(object) : null;
- if (key != null)
- {
- result = (IMarker)hashtable.get(key);
- }
- return result;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/UIPlugin.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/UIPlugin.java
deleted file mode 100644
index b85612f..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/UIPlugin.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class UIPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static UIPlugin plugin;
- //Resource bundle.
- // dmw 11/15 private field never read locally
- //private ResourceBundle resourceBundle;
-
- /**
- * The constructor.
- */
- public UIPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- plugin = this;
- try {
- // dmw 11/15 private field never read locally
- ResourceBundle resourceBundle = descriptor.getResourceBundle();
- } catch (java.util.MissingResourceException exception) {
- //TODO... log an error message
- //resourceBundle = null;
- }
- }
-
- /**
- * Returns the shared instance.
- */
- public static UIPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle= UIPlugin.getDefault().getResourceBundle();
- try {
- return bundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * This gets the string resource and does one substitution.
- */
- public String getString(String key, Object s1)
- {
- return MessageFormat.format(getResourceString(key), new Object [] { s1 });
- }
-
- /**
- * This gets the string resource and does two substitutions.
- */
- public String getString(String key, Object s1, Object s2)
- {
- return MessageFormat.format(getResourceString(key), new Object [] { s1, s2 });
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- try {
- return Platform.getResourceBundle(plugin.getBundle());
- } catch (MissingResourceException x) {
- x.printStackTrace();
- }
- return null;
- }
-
- public ImageDescriptor getImageDescriptor(String name) {
- try {
- URL url= new URL(getBundle().getEntry("/"), name);
- return ImageDescriptor.createFromURL(url);
- } catch (MalformedURLException e) {
- return ImageDescriptor.getMissingImageDescriptor();
- }
- }
-
- public Image getImage(String iconName)
- {
- ImageRegistry imageRegistry = getImageRegistry();
-
- if (imageRegistry.get(iconName) != null)
- {
- return imageRegistry.get(iconName);
- }
- else
- {
- imageRegistry.put(iconName, ImageDescriptor.createFromFile(getClass(), iconName));
- return imageRegistry.get(iconName);
- }
- }
-
- public static String getPluginId() {
- return getDefault().getBundle().getSymbolicName();
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void log(String message, Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, e));
- }
-
- public static void log(String message) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null));
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getLocalizedMessage(), e));
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/WindowUtility.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/WindowUtility.java
deleted file mode 100644
index 532e260..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/WindowUtility.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-
-public class WindowUtility
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- public static Object getSelection(ISelection selection)
- {
- if (selection == null)
- {
- return null;
- } // end of if ()
-
- Object result = null;
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection es= (IStructuredSelection)selection;
- Iterator i= es.iterator();
- if (i.hasNext())
- {
- result= i.next();
- }
- }
- return result;
- }
-
- public static List getSelectionList(ISelection selection)
- {
- List result = null;
- if (selection != null)
- {
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection es= (IStructuredSelection)selection;
- result = new Vector();
- for (Iterator i= es.iterator(); i.hasNext(); )
- {
- result.add(i.next());
- }
- }
- }
- return result;
- }
-
- public static void openErrorCreatingFile(Shell shell, IResource resource)
- {
- String title = null;
- String briefMessage = null;
- String reason = null;
- String details = null;
-
-// KCPort TODO
-// title = B2BGUIPlugin.getInstance().getString("_UI_ERROR_CREATING_FILE_TITLE");
-// briefMessage = B2BGUIPlugin.getInstance().getString("_UI_ERROR_CREATING_FILE_SHORT_DESC", resource.getName());
-// details = B2BGUIPlugin.getInstance().getString("_UI_ERROR_CREATING_FILE_LONG_DESC", resource.getLocation().toOSString());
-//
-// IResource parent = resource.getParent();
-// if (parent != null)
-// {
-// if (parent.isReadOnly())
-// {
-// reason = B2BGUIPlugin.getInstance().getString("_UI_PARENT_FOLDER_IS_READ_ONLY", parent.getName());
-// }
-// else
-// {
-// // on windows the isReadOnly() = false for read only shared directory... so we give a hint
-// reason = B2BGUIPlugin.getInstance().getString("_UI_UNKNOWN_ERROR_WITH_HINT", parent.getName());
-// }
-// }
-//
-// if (reason == null)
-// {
-// reason = B2BGUIPlugin.getInstance().getString("_UI_UNKNOWN_ERROR");
-// }
-
- openError(shell, title, briefMessage, reason, details);
- }
-
- public static void openError(Shell shell, String title, String briefMessage, String reason, String detailedMessage)
- {
- ErrorDialog.openError(shell, title, briefMessage, createStatus(reason, detailedMessage));
- }
-
- private static IStatus createStatus(String reason, String msg)
- {
-// KCPort TODO
-// String pluginId = B2BGUIPlugin.getInstance().getDescriptor().getUniqueIdentifier();
- String pluginId = "";
- MultiStatus multiStatus = new MultiStatus(pluginId, 0, reason, null);
- Status status = new Status(IStatus.ERROR, pluginId, 0, msg, null);
- multiStatus.add(status);
- return multiStatus;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/ActionHandlerListener.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/ActionHandlerListener.java
deleted file mode 100644
index 0ff85b0..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/ActionHandlerListener.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.actionhandler;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.MenuListener;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.internal.PartSite;
-import org.eclipse.wst.common.ui.actionhandler.action.CopyAction;
-import org.eclipse.wst.common.ui.actionhandler.action.CutAction;
-import org.eclipse.wst.common.ui.actionhandler.action.EditAction;
-import org.eclipse.wst.common.ui.actionhandler.action.PasteAction;
-
-
-
-public class ActionHandlerListener implements IPartListener, MenuListener
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
-
- /**
- * Constructor for ActionHandlerListener.
- */
- public ActionHandlerListener()
- {
- super();
- createEditActions();
- }
-
- /**
- * Method connectPart. This call registers your part to the actionhandler listener
- * if it hasn't been registered already and hooks up the generic cut/copy/paste action handlers.
- * Invoke this method from the init() routine of your #IViewPart or #IEditorPart if you do not
- * have any custom cut/copy/paste action handlers.
- *
- * If you have a customized cut/copy/paste action handlers, invoke this method after you
- * have finished your custom processing to add/remove your actionhandlers.
- *
- * @param part - the workbench part that you would like to connect the generic cut/copy/paste handlers
- */
- static public void connectPart(IWorkbenchPart part)
- {
- getInstance().connectWorkbenchPart(part);
- }
-
- static protected ActionHandlerListener actionHandlerListener;
- static protected ActionHandlerListener getInstance()
- {
- if (actionHandlerListener == null)
- {
- actionHandlerListener = new ActionHandlerListener();
- }
- return actionHandlerListener;
- }
-
-
-
- protected ArrayList workbenchWindows = new ArrayList();
- public void listenToWorkbenchWindow(IWorkbenchWindow workbenchWindow)
- {
- if (!workbenchWindows.contains(workbenchWindow))
- {
- workbenchWindows.add(workbenchWindow);
- workbenchWindow.getPartService().addPartListener(this);
- MenuManager editMenu = (MenuManager) ((ApplicationWindow)workbenchWindow).getMenuBarManager().findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null)
- editMenu.getMenu().addMenuListener(this);
- }
- }
-
- protected void createEditActions()
- {
- cut = new CutAction();
- copy = new CopyAction();
- paste = new PasteAction();
- }
-
- protected IActionBars getActionBars(IWorkbenchPart part)
- {
- IActionBars actionBars = null;
- if (part != null)
- {
- IWorkbenchPartSite partSite = part.getSite();
- if (partSite instanceof PartSite)
- {
- actionBars = ((PartSite)partSite).getActionBars();
- }
- }
- return actionBars;
- }
-
- /**
- * Method connectWorkbenchPart. Ensure we are already listening to the workbenchwindow,
- * register the part's id and then connect the cut/copy/paste actions
- * @param part
- */
- public void connectWorkbenchPart(IWorkbenchPart part)
- {
- IWorkbenchWindow wbw = part.getSite().getWorkbenchWindow();
- listenToWorkbenchWindow(wbw);
- registerPartId(part);
- connectCutCopyPasteActions(part);
- }
-
- /**
- * Method isRegisteredPart. Returns whether the part has already been
- * registered as being a candidate for the generic cut/copy/paste actions.
- *
- * @param part
- * @return boolean
- */
- public boolean isRegisteredPart(IWorkbenchPart part)
- {
- String partId = part.getSite().getId();
- return registeredParts.contains(partId);
- }
-
- protected ArrayList registeredParts = new ArrayList();
- protected void registerPartId(IWorkbenchPart part)
- {
- if (!isRegisteredPart(part))
- {
- String partId = part.getSite().getId();
- registeredParts.add(partId);
- }
- }
-
- /**
- * Method connectCutCopyPasteActions. Connect the cut/copy/paste actions
- * to the workbench part.
- *
- * @param part
- */
- public void connectCutCopyPasteActions(IWorkbenchPart part)
- {
- IActionBars actionBars = getActionBars(part);
- if (actionBars != null)
- {
- part.getSite().getKeyBindingService().registerAction(cut);
- part.getSite().getKeyBindingService().registerAction(copy);
- part.getSite().getKeyBindingService().registerAction(paste);
- //connectCutCopyPasteActions(actionBars);
- }
- }
-
-
- /**
- * Method connectCutCopyPasteActions. Only set the actionhandlers if
- * there isn't one active for the appropriate action.
- *
- * @param actionBars
- */
- public void connectCutCopyPasteActions(IActionBars actionBars)
- {
- if (actionBars.getGlobalActionHandler(ActionFactory.CUT.getId()) == null)
- {
- actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cut);
- }
- if (actionBars.getGlobalActionHandler(ActionFactory.COPY.getId()) == null)
- {
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copy);
- }
- if (actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId()) == null)
- {
- actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), paste);
- }
- enableActions();
- actionBars.updateActionBars();
- }
-
- protected IWorkbenchPart getWorkbenchPart()
- {
- IWorkbenchWindow wbw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (wbw == null)
- return null;
-
- IWorkbenchPage wbp = wbw.getActivePage();
- if (wbp == null)
- return null;
-
- return wbp.getActivePart();
- }
-
- protected void updateActions()
- {
- IWorkbenchPart part = getWorkbenchPart();
- if (part != null &&
- isRegisteredPart(part))
- {
- IActionBars actionBars = getActionBars(part);
-
- Control focusControl = cut.getFocusControl();
- boolean enable = true;
- if (isValidFocusControl() &&
- actionBars != null)
- {
- String clipboardText = paste.getClipboardText();
- String selectionText = copy.getSelectionText();
- boolean isReadOnly = paste.isReadOnlyFocusControl();
- boolean clipboardNotEmpty = clipboardText != null && !clipboardText.equals("");
- boolean textSelected = selectionText != null && !selectionText.equals("");
-
- cut.setEnabled(!isReadOnly && textSelected);
- copy.setEnabled(textSelected && !(focusControl instanceof Combo && isReadOnly));
- paste.setEnabled(!isReadOnly && clipboardNotEmpty);
- }
- else
- {
- cut.setEnabled(false);
- copy.setEnabled(false);
- paste.setEnabled(false);
- }
- actionBars.updateActionBars();
- }
- }
-
- protected boolean isValidFocusControl()
- {
- // delgate to one of the edit actions
- return cut.isValidFocusControl();
- }
-
- protected void enableActions()
- {
- cut.setEnabled(true);
- copy.setEnabled(true);
- paste.setEnabled(true);
- }
-
- /**
- * Connect the cut/copy/paste actions if a registered part is activated.
- *
- * @see IPartListener#partActivated(IWorkbenchPart)
- */
- public void partActivated(IWorkbenchPart part)
- {
- if (isRegisteredPart(part))
- {
-// System.out.println("registered part activated" + part);
- connectCutCopyPasteActions(part);
- }
- }
-
- protected EditAction cut,copy,paste;
-
- /**
- * @see IPartListener#partBroughtToTop(IWorkbenchPart)
- */
- public void partBroughtToTop(IWorkbenchPart part)
- {
- }
- /**
- * @see IPartListener#partClosed(IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart part)
- {
- }
- /**
- * @see IPartListener#partDeactivated(IWorkbenchPart)
- */
- public void partDeactivated(IWorkbenchPart part)
- {
- }
- /**
- * @see IPartListener#partOpened(IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart part)
- {
- }
-
-
- /**
- * If the menu is hidden on a registered part, then renable all actions. This
- * takes away the need for us to monitor the control traversal. If the individual
- * action isn't applicable when it is invoked, the action becomes a no op.
- * @see MenuListener#menuHidden(MenuEvent)
- */
- public void menuHidden(MenuEvent e)
- {
- IWorkbenchPart part = getWorkbenchPart();
- if (part != null &&
- isRegisteredPart(part))
- {
- enableActions();
-
- IActionBars actionbars = getActionBars(part);
- actionbars.updateActionBars();
- }
- }
-
- /**
- * Update the cut/copy/paste enablement (if a registered part is active) just
- * before showing the edit menu.
- *
- * @see MenuListener#menuShown(MenuEvent)
- */
- public void menuShown(MenuEvent e)
- {
- updateActions();
- }
-
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/CopyAction.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/CopyAction.java
deleted file mode 100644
index e0e1a83..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/CopyAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.actionhandler.action;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-
-public class CopyAction extends EditAction
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#getActionDefinitionId()
- */
- public String getActionDefinitionId()
- {
- return IWorkbenchActionDefinitionIds.COPY;
- }
-
- public void run()
- {
- Control control = getFocusControl();
- if (control instanceof Text)
- {
- ((Text)control).copy();
- }
- else if (control instanceof StyledText)
- {
- ((StyledText)control).copy();
- }
- else if (control instanceof Combo)
- {
- ((Combo)control).copy();
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/CutAction.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/CutAction.java
deleted file mode 100644
index 4433fb2..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/CutAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.actionhandler.action;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-
-public class CutAction extends EditAction
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#getActionDefinitionId()
- */
- public String getActionDefinitionId()
- {
- return IWorkbenchActionDefinitionIds.CUT;
- }
-
- public void run()
- {
- Control control = getFocusControl();
- if (control instanceof Text)
- {
- ((Text)control).cut();
- }
- if (control instanceof StyledText)
- {
- ((StyledText)control).cut();
- }
- if (control instanceof Combo)
- {
- ((Combo)control).cut();
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/EditAction.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/EditAction.java
deleted file mode 100644
index 6d82f99..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/EditAction.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.actionhandler.action;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-
-public class EditAction extends Action
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- public Control getFocusControl()
- {
- return Display.getCurrent().getFocusControl();
- }
-
- public String getClipboardText()
- {
- Control focusControl = getFocusControl();
- if (focusControl != null)
- {
- Clipboard clipboard = new Clipboard(getFocusControl().getDisplay());
- TextTransfer textTransfer = TextTransfer.getInstance();
- String availableText = (String) clipboard.getContents(textTransfer);
- clipboard.dispose();
- return availableText;
- }
- return null;
-// String string = "";
-// if (OS.OpenClipboard (0)) {
-// int hMem = OS.GetClipboardData (OS.IsUnicode ? OS.CF_UNICODETEXT : OS.CF_TEXT);
-// if (hMem != 0) {
-// int byteCount = OS.GlobalSize (hMem);
-// int ptr = OS.GlobalLock (hMem);
-// if (ptr != 0) {
-// /* Use the character encoding for the default locale */
-// TCHAR buffer = new TCHAR (0, byteCount / TCHAR.sizeof);
-// OS.MoveMemory (buffer, ptr, byteCount);
-// string = buffer.toString (0, buffer.strlen ());
-// OS.GlobalUnlock (hMem);
-// }
-// }
-// OS.CloseClipboard ();
-// }
-// return string;
- }
-
- public String getSelectionText()
- {
- Control control = getFocusControl();
- if (control instanceof Text)
- {
- return ((Text)control).getSelectionText();
- }
- if (control instanceof StyledText)
- {
- return ((StyledText)control).getSelectionText();
- }
- if (control instanceof Combo)
- {
- Combo combo = (Combo)control;
- Point selection = combo.getSelection();
- return combo.getText().substring(selection.x, selection.y);
- }
- return "";
- }
-
- public boolean isReadOnlyFocusControl()
- {
- Control control = getFocusControl();
- if (control instanceof Text)
- {
- return !((Text)control).getEditable();
- }
- if (control instanceof StyledText)
- {
- return !((StyledText)control).getEditable();
- }
- if (control instanceof Combo)
- {
- Combo combo = (Combo)control;
- return (combo.getStyle() & SWT.READ_ONLY) == SWT.READ_ONLY;
- }
- return false;
- }
-
- public boolean isValidFocusControl()
- {
- Control control = getFocusControl();
- return (control instanceof Text ||
- control instanceof StyledText ||
- control instanceof Combo);
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/PasteAction.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/PasteAction.java
deleted file mode 100644
index 64e0d46..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/actionhandler/action/PasteAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.actionhandler.action;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-
-public class PasteAction extends EditAction
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#getActionDefinitionId()
- */
- public String getActionDefinitionId()
- {
- return IWorkbenchActionDefinitionIds.PASTE;
- }
-
- public void run()
- {
- Control control = getFocusControl();
- if (control instanceof Text)
- {
- ((Text)control).paste();
- }
- if (control instanceof StyledText)
- {
- ((StyledText)control).paste();
- }
- if (control instanceof Combo)
- {
- ((Combo)control).paste();
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dialogs/SelectSingleFileDialog.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dialogs/SelectSingleFileDialog.java
deleted file mode 100644
index 5076a20..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dialogs/SelectSingleFileDialog.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.dialogs;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
-import org.eclipse.ui.internal.WorkbenchImages;
-import org.eclipse.wst.common.ui.viewers.SelectSingleFileView;
-
-
-
-public class SelectSingleFileDialog extends TitleAreaDialog
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2001, 2002.";
- protected SelectSingleFileView selectSingleFileView;
- protected Button okButton;
-
- public SelectSingleFileDialog(Shell parentShell, IStructuredSelection selection, boolean isFileMandatory)
- {
- super(parentShell);
- if (selection == null)
- {
- selection = new StructuredSelection();
- }
- selectSingleFileView = new SelectSingleFileView(selection, isFileMandatory)
- {
- public void createFilterControl(Composite composite)
- {
- SelectSingleFileDialog.this.createFilterControl(composite);
- }
- };
- }
-
- protected Control createDialogArea(Composite parent)
- {
- Composite dialogArea = (Composite)super.createDialogArea(parent);
-
- //TODO.. enable context help
- //WorkbenchHelp.setHelp(dialogArea, B2BGUIContextIds.BTBG_SELECT_SINGLE_FILE_DIALOG);
-
- Composite composite = new Composite(dialogArea, SWT.NONE);
- composite.setLayout(new GridLayout());
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = 350;
- gd.heightHint = 350;
- composite.setLayoutData(gd);
-
- SelectSingleFileView.Listener listener = new SelectSingleFileView.Listener()
- {
- public void setControlComplete(boolean isComplete)
- {
- okButton.setEnabled(isComplete);
- }
- };
- selectSingleFileView.setListener(listener);
- selectSingleFileView.createControl(composite);
- return dialogArea;
- }
-
- protected void createButtonsForButtonBar(Composite parent)
- {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- public void create()
- {
- super.create();
- selectSingleFileView.setVisibleHelper(true);
- setTitleImage(WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_DLGBAN_SAVEAS_DLG).createImage());
- }
-
- public void createFilterCombo(Composite composite)
- {
- }
-
- public IFile getFile()
- {
- return selectSingleFileView.getFile();
- }
-
- public void addFilterExtensions(String[] filterExtensions)
- {
- selectSingleFileView.addFilterExtensions(filterExtensions);
- }
-
- public void addFilterExtensions(String[] filterExtensions, IFile [] excludedFiles)
- {
- selectSingleFileView.addFilterExtensions(filterExtensions, excludedFiles);
- }
-
- public void createFilterControl(Composite composite)
- {
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DefaultDragAndDropCommand.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DefaultDragAndDropCommand.java
deleted file mode 100644
index 8e6fc0d..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DefaultDragAndDropCommand.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.dnd;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.swt.dnd.DND;
-
-
-abstract public class DefaultDragAndDropCommand implements DragAndDropCommand
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- /**
- * This keeps track of the owner that is the target of the drag and drop.
- */
- protected Object target;
-
- /**
- * This keeps track of the location of the drag and drop.
- */
- protected float location;
-
- /**
- * This keeps track of the lower range of locations in which the effect of this command remains unchanged.
- */
- protected float lowerLocationBound;
-
- /**
- * This keeps track of the upper range of locations in which the effect of this command remains unchanged.
- */
- protected float upperLocationBound;
-
- /**
- * This keeps track of the permitted operations.
- */
- protected int operations;
-
- /**
- * This keeps track of the current operation that will be returned by {@link #getOperation}.
- */
- protected int operation;
-
- /**
- * This keeps track of the feedback that will be returned by {@link #getFeedback}.
- */
- protected int feedback;
-
- /**
- * This keeps track of the collection of dragged sources.
- */
- protected Collection sources;
-
- public DefaultDragAndDropCommand(Object target, float location, int operations, int operation, Collection sources)
- {
- this.target = target;
- this.location = location;
- this.operations = operations;
- this.operation = operation;
- this.sources = new ArrayList(sources);
- if (!canExecute())
- {
- this.operation = DND.DROP_NONE;
- }
-
- }
-
- public int getFeedback()
- {
- if (isAfter())
- {
- return DND.FEEDBACK_INSERT_AFTER;
- }
- else
- {
- return DND.FEEDBACK_INSERT_BEFORE;
- }
- }
-
- public boolean isAfter()
- {
- return location > 0.5;
- }
-
- public int getOperation()
- {
- return operation;
- }
-
- public void reinitialize(Object target, float location, int operations, int operation, Collection sources)
- {
- this.target = target;
- this.location = location;
- this.operations = operations;
- this.operation = operation;
- this.sources = new ArrayList(sources);
- if (!canExecute())
- {
- this.operation = DND.DROP_NONE;
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DragAndDropCommand.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DragAndDropCommand.java
deleted file mode 100644
index 627f481..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DragAndDropCommand.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.dnd;
-
-import java.util.Collection;
-
-public interface DragAndDropCommand
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- // public DragAndDropCommand(Object target, float location, int operations, int operation, Collection sources);
-
- public boolean canExecute();
-
- public void execute();
-
- public int getFeedback();
-
- public int getOperation();
-
- public void reinitialize(Object target, float location, int operations, int operation, Collection sources);
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DragAndDropManager.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DragAndDropManager.java
deleted file mode 100644
index 83b0ff2..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/DragAndDropManager.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.dnd;
-
-import java.util.Collection;
-
-public interface DragAndDropManager
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- public DragAndDropCommand createCommand(Object target, float location, int operations, int operation, Collection source);
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ObjectTransfer.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ObjectTransfer.java
deleted file mode 100644
index 90b1c78..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ObjectTransfer.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.dnd;
-
-
-import org.eclipse.swt.dnd.ByteArrayTransfer;
-import org.eclipse.swt.dnd.TransferData;
-
-
-/**
- * This derived implementation of a byte array transfer short circuits the transfer process
- * so that a local transfer does not serialize the object
- * and hence can and will return the original object, not just a clone.
- * You only really need ever know about {@link #getInstance ObjectTransfer.getInstance()},
- * so that you can include it in when adding drag support to a viewer.
- * See {@link EditingDomainViewerDropAdapter} and {@link ViewerDragAdapter} for more details.
- * <p>
- * As an addded guard, the time is recorded and serialized in javaToNative
- * to that navive to java can ensure that it's returns the value that was really to have been transferred.
- */
-public class ObjectTransfer extends ByteArrayTransfer
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- /**
- * This is the register transfer type name.
- */
- protected static final String TYPE_NAME = "local-transfer-format";
-
- /**
- * This is the ID that is registered to the name.
- */
- protected static final int TYPE_ID = registerType(TYPE_NAME);
-
- /**
- * This is initialized and returned by {@link #getInstance}.
- */
- protected static ObjectTransfer instance;
-
- /**
- * This returns the one instance of this transfer agent.
- */
- public static ObjectTransfer getInstance()
- {
- if (instance == null)
- {
- instance = new ObjectTransfer();
- }
-
- return instance;
- }
-
- /**
- * This records the time at which the transfer data was recorded.
- */
- protected long startTime;
-
- /**
- * This records the data being transferred.
- */
- protected Object object;
-
- /**
- * This creates an instance; typically you get one from {@link #getInstance}.
- */
- protected ObjectTransfer()
- {
- }
-
- /**
- * This returns the transfer ids that this agent supports.
- */
- protected int[] getTypeIds()
- {
- return new int[] { TYPE_ID };
- }
-
- /**
- * This returns the transfer names that this agent supports.
- */
- public String[] getTypeNames()
- {
- return new String[] { TYPE_NAME };
- }
-
- /**
- * This records the object and current time and encodes only the current time into the transfer data.
- */
- public void javaToNative(Object object, TransferData transferData)
- {
- startTime = System.currentTimeMillis();
- this.object = object;
- if (transferData != null)
- {
- super.javaToNative(String.valueOf(startTime).getBytes(), transferData);
- }
- }
-
- /**
- * This decodes the time of the transfer and returns the recorded the object if the recorded time and the decoded time match.
- */
- public Object nativeToJava(TransferData transferData)
- {
- long startTime = Long.valueOf(new String((byte[])super.nativeToJava(transferData))).longValue();
- return
- this.startTime == startTime ?
- object :
- null;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ViewerDragAdapter.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ViewerDragAdapter.java
deleted file mode 100644
index f04ed93..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ViewerDragAdapter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.dnd;
-
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-
-
-/**
- * This is an implemention of {@link DragSourceListener}.
- * It allows the selection in effect at the start of the drag and drop interaction to be recorded,
- * which is especially important for a drag and drop interaction within a single view.
- * This is how one of these adapters is typically hooked up:
- * <pre>
- * viewer.addDragSupport
- * (DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK,
- * new Transfer [] { LocalTransfer.getInstance() },
- * ViewerDragAdapter(viewer));
- * </pre>
- * Doing so simply allows a drag operation to be initiated from the viewer
- * such that the viewer's selection is transferred to the drop target.
- * See {@link EditingDomainViewerDropAdapter} and {@link LocalTransfer} for more details.
- */
-public class ViewerDragAdapter implements DragSourceListener
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- /**
- * This keeps track of the viewer to which we are listening.
- */
- protected Viewer viewer;
-
- /**
- * This keeps track of the selection that is in effect at the start of the drag operation
- */
- protected ISelection selection;
-
- /**
- * This creates an instance for the given viewer.
- */
- public ViewerDragAdapter(Viewer viewer)
- {
- super();
-
- // Remember the viewer and listen to SWT.DragDetect to alert the start of the drag operation.
- //
- this.viewer = viewer;
- }
-
- /**
- * This is called when dragging is initiated; it records the {@link #selection} of {@link #viewer}.
- */
- public void dragStart(DragSourceEvent event)
- {
- selection = viewer.getSelection();
- }
-
- /**
- * This is called when dragging is completed; it forgets the {@link #selection}.
- */
- public void dragFinished(DragSourceEvent event)
- {
- selection = null;
- }
-
- /**
- * This is called to transfer the data.
- */
- public void dragSetData(DragSourceEvent event)
- {
- if (ObjectTransfer.getInstance().isSupportedType(event.dataType))
- {
- event.data = selection;
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ViewerDropAdapter.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ViewerDropAdapter.java
deleted file mode 100644
index 3988a7f..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/dnd/ViewerDropAdapter.java
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.dnd;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * This implementation of a drop target listener
- * is designed to turn a drag and drop operation into a {@link Command} based on the model objects of an {@link EditingDomain}
- * and created by {@link DragAndDropManager#create}.
- * It is designed to do early data transfer so the the enablement and feedback of the drag and drop interaction
- * can intimately depend on the state of the model objects involed.
- * <p>
- * The base implementation of this class should be sufficient for most applications.
- * Any change in behaviour is typically accomplished by overriding
- * {@link ItemProviderAdapter}.createDragAndDropCommand
- * to return a derived implementation of {@link DragAndDropCommand}.
- * This is how one these adapters is typically hooked up:
- * <pre>
- * viewer.addDropSupport
- * (DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK,
- * new Transfer [] { ObjectTransfer.getInstance() },
- * EditingDomainViewerDropAdapter(viewer));
- * </pre>
- * <p>
- * This implementation prefers to use a {@link ObjectTransfer},
- * which short-circuits the transfer process for simple transfers within the workbench,
- * the method {@link #getDragSource} can be overriden to change the behaviour.
- * The implementation also only handles an {@link IStructuredSelection},
- * but the method {@link #extractDragSource} can be overriden to change the behaviour.
- * <p>
- * You can call {@link #setHoverThreshold} to set the amount of time, in milliseconds,
- * to hover over an item before {@link #hover} is called;
- * the default is 1500 milliseconds.
- */
-public class ViewerDropAdapter extends DropTargetAdapter
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- /**
- * This is the viewer for which this is a drop target listener.
- */
- protected Viewer viewer;
-
- /**
- * This is the collection of source objects being dragged.
- */
- protected Collection source;
-
- /**
- * This is the command created during dragging which provides the feedback and will carry out the action upon completion.
- */
- // protected Command command;
- protected DragAndDropCommand command;
-
- /**
- * This records the object for which the {@link #command} was created.
- */
- protected Object commandTarget;
-
- /**
- * The amount of time to hover over a tree item before expanding it
- */
- protected int hoverThreshold = 1500;
-
- /**
- * The is the time the mouse first started hovering over the current item.
- */
- protected long hoverStart = 0;
-
- /**
- * This keeps track of the most recent item for the {@link #hoverStart}.
- */
- protected Widget previousItem;
-
- /**
- * This keeps track of the original operation that was in effect before we set the event.detail in here.
- */
- protected int originalOperation;
-
- /**
- * This keeps track of the information used to create the current command.
- */
- protected DragAndDropCommandInformation dragAndDropCommandInformation;
-
- protected DragAndDropManager dragAndDropManager;
-
- /**
- * This creates and instance of the given domain and viewer.
- */
- public ViewerDropAdapter(Viewer viewer, DragAndDropManager dragAndDropManager)
- {
- this.viewer = viewer;
- this.dragAndDropManager = dragAndDropManager;
- }
-
- /**
- * This is called when the mouse first enters or starts dragging in the viewer.
- */
- public void dragEnter(DropTargetEvent event)
- {
- originalOperation = event.detail;
- helper(event);
- }
-
- /**
- * This is called when the mouse leaves or stops dragging in the viewer
- */
- public void dragLeave(DropTargetEvent event)
- {
- // Clean up the command if there is one.
- //
- if (command != null)
- {
-// command.dispose();
- command = null;
- commandTarget = null;
- }
-
- // Reset the other values.
- //
- previousItem = null;
- hoverStart = 0;
- source = null;
- }
-
- /**
- * This is called when the operation has changed in some way, typically because the user changes keyboard modifiers.
- */
- public void dragOperationChanged(DropTargetEvent event)
- {
- originalOperation = event.detail;
- helper(event);
- }
-
- /**
- * This is called repeated when the mouse over the viewer.
- */
- public void dragOver(DropTargetEvent event)
- {
- helper(event);
- }
-
- /**
- * This is called just as the mouse is released over the viewer to initiate a drop.
- */
- public void dropAccept(DropTargetEvent event)
- {
- // There seems to be a bug in SWT that the view may have scrolled.
- // helper(event);
- }
-
- /**
- * This is called to indate that the drop action should be invoked.
- */
- public void drop(DropTargetEvent event)
- {
- // There seems to be a bug in SWT that the view may have scrolled.
- // helper(event);
- if (dragAndDropCommandInformation != null)
- {
- command = dragAndDropCommandInformation.createCommand();
-
- // Execute the command
- command.execute();
-
- // Clean up the state.
- //
- command = null;
- commandTarget = null;
- previousItem = null;
- hoverStart = 0;
- source = null;
- }
- }
-
- /**
- * This method is called the same way for each of the {@link org.eclipse.swt.dnd.DropTargetListener} methods, except during leave.
- */
- protected void helper(DropTargetEvent event)
- {
- // Try to get the source if there isn't one.
- //
- if (source == null)
- {
- source = getDragSource(event);
- }
- else if (event.currentDataType == null)
- {
- setCurrentDataType(event);
- }
-
- // If there's still no source, wait until the next time to try again.
- //
- if (source == null)
- {
- event.detail = DND.DROP_NONE;
- event.feedback = DND.FEEDBACK_SELECT;
- }
- // Otherwise, if we need to scroll...
- //
- else if (scrollIfNeeded(event))
- {
- // In the case that we scroll, we just do all the work on the next event and only just scroll now.
- //
- event.feedback = DND.FEEDBACK_SELECT;
- }
- else
- {
- // Get the data from the item, if there is one.
- //
- Object target = event.item == null ? null : event.item.getData();
- if (target instanceof TableTreeItem)
- {
- target = ((TableTreeItem)target).getData();
- }
-
- // Do the logic to determine the hover information.
- // If we're over a new item from before.
- //
- if (event.item != previousItem)
- {
- // Remember the item and the time.
- //
- previousItem = event.item;
- hoverStart = event.time;
- }
- else if (target != null)
- {
- if (event.time - hoverStart > hoverThreshold)
- {
- hover(target);
-
- // We don't need to hover over this guy again.
- //
- hoverStart = Integer.MAX_VALUE;
- }
- }
-
- // Determine if we can create a valid command at the current mouse location.
- //
- boolean valid = false;
-
- // If we don't have a previous cached command...
- //
- if (command == null)
- {
- // Create the command and test if it is executable.
- //
- commandTarget = target;
- command = dragAndDropManager.createCommand(target, getLocation(event), event.operations, event.detail, source);
- valid = command.canExecute();
- }
- else
- {
- int operation = originalOperation != event.detail ? originalOperation : event.detail;
-
- // Check if the cached command is able to provide drag and drop feedback.
- //
- if (target == commandTarget)// && command instanceof DragAndDropFeedback)
- {
- float location = getLocation(event);
-
- dragAndDropCommandInformation =
- new DragAndDropCommandInformation(target, location, event.operations, operation, source);
-
- // If so, revalidate the command.
- //
- command.reinitialize(target, location, event.operations, operation, source);
- valid = command.canExecute();
- }
- else
- {
- // If not, dispose the current command and create a new one.
- //
- // command.dispose();
- commandTarget = target;
-
- dragAndDropCommandInformation =
- new DragAndDropCommandInformation(target, getLocation(event), event.operations, operation, source);
-
- // DragAndDropManager.create(domain, target, getLocation(event), event.operations, operation, source);
- //
- command = dragAndDropCommandInformation.createCommand();
-
- valid = command.canExecute();
- }
- }
-
- // If this command can provide detailed drag and drop feedback...
- //
- //if (command instanceof DragAndDropCommand)
- if (command != null)
- {
- // Use the feedback for the operation and mouse point from the command.
- //
- event.detail = command.getOperation();
- event.feedback = command.getFeedback();
- }
- else if (valid)
- {
- // All we can know is to provide selection feedback.
- //
- event.feedback = DND.FEEDBACK_SELECT;
- }
- else
- {
- // There is no executable command, so we'd better nix the whole deal.
- //
- event.detail = DND.DROP_NONE;
- event.feedback = DND.FEEDBACK_SELECT;
- }
- }
- }
-
-
- protected void setCurrentDataType(DropTargetEvent event)
- {
- ObjectTransfer objectTransfer = ObjectTransfer.getInstance();
- TransferData [] dataTypes = event.dataTypes;
- for (int i = 0; i < dataTypes.length; ++i)
- {
- TransferData transferData = dataTypes[i];
- // If the local tansfer supports this datatype, switch to that data type
- //
- if (objectTransfer.isSupportedType(transferData))
- {
- event.currentDataType = transferData;
- }
- }
- }
-
- /**
- * This attempts to extract the drag source from the event early, i.e., before the drop method.
- * This implementation tries to use a {@link org.eclipse.wst.common.ui.dnd.ObjectTransfer}.
- */
- protected Collection getDragSource(DropTargetEvent event)
- {
- // Check whether the current data type can be transfered locally.
- //
- ObjectTransfer objectTransfer = ObjectTransfer.getInstance();
- if (!objectTransfer.isSupportedType(event.currentDataType))
- {
- // Iterate over the data types to see if there is a datatype that supports a local transfer.
- //
- setCurrentDataType(event);
- return null;
- }
- else
- {
- // Transfer the data and extract it.
- //
- Object object = objectTransfer.nativeToJava(event.currentDataType);
- return extractDragSource(object);
- }
- }
-
- /**
- * This extracts a collection of dragged source objects from the given object retrieved from the transfer agent.
- * This default implementation converts a structured selection into a collection of elements.
- */
- protected Collection extractDragSource(Object object)
- {
- // Transfer the data and convert the structured selection to a collection of objects.
- //
- if (object instanceof IStructuredSelection)
- {
- Collection result = new ArrayList();
- for (Iterator elements = ((IStructuredSelection)object).iterator(); elements.hasNext(); )
- {
- result.add(elements.next());
- }
- return result;
- }
- else
- {
- return Collections.EMPTY_LIST;
- }
- }
-
- /**
- * This gets the amount of time, in milliseconds, to hover over an item before {@link #hover} is called.
- */
- public int getHoverThreshold()
- {
- return hoverThreshold;
- }
-
- /**
- * This set the amount of time, in milliseconds, to hover over an item before {@link #hover} is called.
- */
- public void setHoverThreshold(int hoverThreshold)
- {
- this.hoverThreshold = hoverThreshold;
- }
-
- /**
- * This is called when the cursor has hovered over the given target for longer than {@link #hoverThreshold}.
- */
- protected void hover(Object target)
- {
- if (viewer instanceof AbstractTreeViewer)
- {
- ((AbstractTreeViewer)viewer).expandToLevel(target, 1);
- }
- }
-
- /**
- * This returns whether a scroll was performed based on the given drag coordinates.
- */
- protected boolean scrollIfNeeded(DropTargetEvent event)
- {
- // By default we'll not scroll
- //
- boolean result = false;
-
- // We only handle a tree item right now.
- //
- if (event.item instanceof TreeItem)
- {
- // Tree items have special data that will help.
- //
- TreeItem treeItem = (TreeItem)event.item;
-
- // We need need the point in the coordinates of the control and the control's bounds.
- //
- Tree tree = treeItem.getParent();
- Point point = tree.toControl(new Point(event.x, event.y));
- Rectangle bounds = tree.getClientArea();
-
- // This is the distance in pixels from the top or bottom that will cause scrolling.
- //
- int scrollEpsilon = Math.min(treeItem.getBounds().height, bounds.height / 3);
-
- // This will be the item that should be scrolled into the view.
- //
- TreeItem scrollTreeItem = null;
-
- // If we should scroll up.
- //
- if (point.y < scrollEpsilon)
- {
- // Determine the parent to find the sibling.
- //
- TreeItem parent = treeItem.getParentItem();
- // Walk through the siblings.
- //
- TreeItem [] children = parent == null ? tree.getItems() : parent.getItems();
- for (int i = 0; i < children.length; ++i)
- {
- // Is this a match.
- //
- if (children[i] == treeItem)
- {
- // If there is a previous sibling...
- //
- if (i > 0)
- {
- scrollTreeItem = children[i - 1];
-
- // Get the last deepest descendent of this previous sibling.
- //
- for (;;)
- {
- children = scrollTreeItem.getItems();
- if (children != null && children.length != 0 && scrollTreeItem.getExpanded())
- {
- scrollTreeItem = children[children.length - 1];
- }
- else
- {
- break;
- }
- }
- }
- else
- {
- // The parent must be the previous.
- //
- scrollTreeItem = parent;
- }
-
- // We're done after the match.
- //
- break;
- }
- }
- }
- // If we should scroll down...
- //
- else if (bounds.height - point.y < scrollEpsilon)
- {
- // If this thing has visible children, then the first child must be next.
- //
- TreeItem [] children = treeItem.getItems();
- if (children != null && children.length != 0 && treeItem.getExpanded())
- {
- scrollTreeItem = children[0];
- }
- else
- {
- // We need the parent to determine siblings and will walk up the tree if we are the last sibling.
- //
- while (scrollTreeItem == null)
- {
- // If there's no parent, we're done.
- //
- TreeItem parent = treeItem.getParentItem();
- // Walk the children.
- //
- children = parent == null ? tree.getItems() : parent.getItems();
- for (int i = 0; i < children.length; ++i)
- {
- // When we find the child.
- //
- if (children[i] == treeItem)
- {
- // If the next index is a valid index...
- //
- if (++i < children.length)
- {
- // We've found the item.
- //
- scrollTreeItem = children[i];
- }
-
- // We're done with this parent.
- //
- break;
- }
- }
-
- if (parent == null)
- {
- break;
- }
-
- // Walk up.
- //
- treeItem = parent;
- }
- }
- }
-
- // If we should scroll.
- //
- if (scrollTreeItem != null)
- {
- // Only scroll if we're on an item for a while.
- //
- if (previousItem != null && event.time - hoverStart > 200)
- {
- ScrollBar verticalScrollBar = tree.getVerticalBar();
- if (verticalScrollBar != null)
- {
- int before = verticalScrollBar.getSelection();
-
- // Make sure the item is scrolled in place.
- //
- tree.showItem(scrollTreeItem);
-
- // Make sure we don't scroll again quickly.
- //
- previousItem = null;
-
- // Indicate that we've done a scroll and nothing else should be done.
- //
- result = before != verticalScrollBar.getSelection();
- }
- }
- else
- {
- // If the item changes, reset the timer information.
- //
- if (event.item != previousItem)
- {
- previousItem = event.item;
- hoverStart = event.time;
- }
- }
- }
- }
- else if (event.item instanceof TableItem)
- {
- // Table items have special data that will help.
- //
- TableItem tableItem = (TableItem)event.item;
-
- // We need need the point in the coordinates of the control and the control's bounds.
- //
- Table table = tableItem.getParent();
- Point point = table.toControl(new Point(event.x, event.y));
- Rectangle bounds = table.getClientArea();
- if (table.getHeaderVisible())
- {
- int offset = table.getItemHeight();
- bounds.y += offset;
- bounds.height -= offset;
- point.y -= offset;
- }
-
- // The position of this item.
- //
- int index = table.indexOf(tableItem);
-
- // This is the distance in pixels from the top or bottom that will cause scrolling.
- //
- int scrollEpsilon = Math.min(tableItem.getBounds(0).height, bounds.height / 3);
-
- // This will be the item that should be scrolled into the view.
- //
- TableItem scrollTableItem = null;
-
- // If we should scroll up.
- //
- if (point.y < scrollEpsilon)
- {
- if (index > 0)
- {
- scrollTableItem = table.getItems()[index - 1];
- }
- }
- // If we should scroll down...
- //
- else if (bounds.height - point.y < scrollEpsilon)
- {
- if (index + 1 < table.getItems().length)
- {
- scrollTableItem = table.getItems()[index + 1];
- }
- }
-
- // If we should scroll.
- //
- if (scrollTableItem != null)
- {
- // Only scroll if we're on an item for a while.
- //
- if (previousItem != null && event.time - hoverStart > 200)
- {
- ScrollBar verticalScrollBar = table.getVerticalBar();
- if (verticalScrollBar != null)
- {
- int before = verticalScrollBar.getSelection();
-
- // Make sure the item is scrolled in place.
- //
- table.showItem(scrollTableItem);
-
- // Make sure we don't scroll again quickly.
- //
- previousItem = null;
-
- // Indicate that we've done a scroll and nothing else should be done.
- //
- result = before != verticalScrollBar.getSelection();
- }
- }
- else
- {
- // If the item changes, reset the timer information.
- //
- if (event.item != previousItem)
- {
- previousItem = event.item;
- hoverStart = event.time;
- }
- }
- }
- }
-
- return result;
- }
-
- protected static float getLocation(DropTargetEvent event)
- {
- if (event.item instanceof TreeItem)
- {
- TreeItem treeItem = (TreeItem)event.item;
- Control control = treeItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = treeItem.getBounds();
- return (float)(point.y - bounds.y) / (float)bounds.height;
- }
- else if (event.item instanceof TableItem)
- {
- TableItem tableItem = (TableItem)event.item;
- Control control = tableItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = tableItem.getBounds(0);
- return (float)(point.y - bounds.y) / (float)bounds.height;
- }
- else
- {
- return 0.0F;
- }
- }
-
- protected class DragAndDropCommandInformation
- {
- // protected EditingDomain domain;
- protected Object target;
- protected float location;
- protected int operations;
- protected int operation;
- protected Collection source;
- public DragAndDropCommandInformation
- (Object target, float location, int operations, int operation, Collection source)
- {
- this.target = target;
- this.location = location;
- this.operations = operations;
- this.operation = operation;
- this.source = new ArrayList(source);
- }
-
- public DragAndDropCommand createCommand()
- {
- return dragAndDropManager.createCommand(target, location, operations, operation, source);
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/ChangeHelper.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/ChangeHelper.java
deleted file mode 100644
index 8188269..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/ChangeHelper.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.internal.resources;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.common.ui.UIPlugin;
-
-
-public class ChangeHelper
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- protected IEditorPart editor;
-
- public ChangeHelper(IEditorPart editor)
- {
- this.editor = editor;
- }
-
- boolean handlingEditorInput = false;
-
- public void handleEditorInputChanged()
- {
- if (handlingEditorInput)
- return;
-
- handlingEditorInput = true;
-
- if (isDeleted(editor.getEditorInput()))
- {
- // if saveas is allowed, give the user an opportunity to
- // save the existing contents to another file
- if (editor.isDirty() && editor.isSaveAsAllowed())
- {
- boolean isDone = false;
- while (isDone == false)
- {
- String[] buttons= { UIPlugin.getResourceString("_UI_SAVE_BUTTON"),
- UIPlugin.getResourceString("_UI_CLOSE_BUTTON") };
-
- final MessageDialog msg = new MessageDialog(editor.getSite().getShell(),
- UIPlugin.getResourceString("_UI_FILE_CHANGED_TITLE"),
- null,
- UIPlugin.getResourceString("_UI_FILE_DELETED_SAVE_CHANGES"),
- MessageDialog.QUESTION,
- buttons,
- 0);
-
- int rc = msg.open();
- if (rc == 0)
- {
- editor.doSaveAs();
- }
- else
- {
- close(false);
- break;
- }
- if (!editor.isDirty())//!isDeleted(editor.getEditorInput()))
- {
- isDone = true;
- }
- }
- // refresh it so it gets removed from the workspace
-// WorkbenchUtility.refreshLocalWorkspaceFile(((IFileEditorInput)editor.getEditorInput()).getFile(), new NullProgressMonitor());
- }
- else
- {
- // otherwise time to shutdown the editor.
-// MessageDialog.openConfirm(editor.getSite().getShell(), B2BGUIPlugin.getGUIString("_UI_FILE_CHANGED_TITLE"), B2BGUIPlugin.getGUIString("_UI_FILE_DELETED_EDITOR_CLOSED"));
- close(false);
- }
- }
- else
- {
- // The file has just had its contents modified
- if (editor instanceof IExternalChangeEditorListener)
- {
-
- boolean rc = MessageDialog.openQuestion(editor.getSite().getShell(), UIPlugin.getResourceString("_UI_FILE_CHANGED_TITLE"), UIPlugin.getResourceString("_UI_FILE_CHANGED_LOAD_CHANGES"));
- if (rc == true)
- {
- ((IExternalChangeEditorListener)editor).reload();
- }
- }
- }
- handlingEditorInput = false;
- }
-
- // close the editor
- public void close(final boolean save)
- {
- Display display= editor.getSite().getShell().getDisplay();
- display.asyncExec(new Runnable()
- {
- public void run()
- {
- editor.getSite().getPage().closeEditor(editor, save);
- }
- });
- }
-
- /*
- * check if file is deleted
- */
- public boolean isDeleted(Object element)
- {
- if (element instanceof IFileEditorInput)
- {
- IFileEditorInput input= (IFileEditorInput) element;
-
- IPath path= input.getFile().getLocation();
- if (path == null)
- {
- return true;
- }
- return !path.toFile().exists();
- }
- return false;
- }
-}// ChangeHelper
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/IExternalChangeEditorListener.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/IExternalChangeEditorListener.java
deleted file mode 100644
index 5474096..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/IExternalChangeEditorListener.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.internal.resources;
-
-import org.eclipse.core.runtime.IPath;
-
-public interface IExternalChangeEditorListener
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- public void handleEditorInputChanged();
- public void handleEditorPathChanged(IPath newPath);
- public void reload();
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/IValidateEditEditor.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/IValidateEditEditor.java
deleted file mode 100644
index d24fd7d..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/IValidateEditEditor.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.internal.resources;
-
-public interface IValidateEditEditor
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2002.";
- public void undoChange();
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/PropertyResourceChangeListener.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/PropertyResourceChangeListener.java
deleted file mode 100644
index 1d64b25..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/PropertyResourceChangeListener.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.internal.resources;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.wst.common.ui.UIPlugin;
-
-
-public class PropertyResourceChangeListener extends ResourceChangeListener implements IPropertyListener
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2002.";
- public PropertyResourceChangeListener(IEditorPart editPart)
- {
- super(editPart);
- editPart.addPropertyListener(this);
- }
-
- boolean dirtyState = false;
- IFile[] iFileList = null;
- IEditorPart editorPart = null;
- Runnable currentRunnable = null;
- boolean inValidateEditCall = false;
-
- public void propertyChanged(Object source, int propId)
- {
- if (propId == IEditorPart.PROP_DIRTY)
- {
- if ((source instanceof IEditorPart) && (currentRunnable == null))
- {
- editorPart = (IEditorPart)source;
- if (editorPart.isDirty() && (editorPart.getEditorInput() instanceof IFileEditorInput))
- {
- IFileEditorInput editorInput = (IFileEditorInput)(editorPart.getEditorInput());
- // Only call validateEdit if the file is read only
- if (editorInput.getFile().isReadOnly())
- {
- iFileList = new IFile[1];
- iFileList[0] = editorInput.getFile();
-
- currentRunnable = new Runnable()
- {
- public void run()
- {
- inValidateEditCall = true;
- IStatus status = ResourcesPlugin.getWorkspace().validateEdit(iFileList, editorPart.getSite().getShell());
- if (status.getCode() != IStatus.OK)
- {
- ((IValidateEditEditor)editorPart).undoChange();
- setDirtyState(editorPart.isDirty());
-
- if (status.getCode() == IStatus.ERROR)
- MessageDialog.openError(Display.getCurrent().getActiveShell() ,
- UIPlugin.getResourceString("_UI_ERROR_VALIDATE_EDIT_FAIL_ONE_FILE"),
- status.getMessage());
- }
- else
- {
- checkChanged(editorPart);
- }
-
- inValidateEditCall = false;
- currentRunnable = null;
- }
- };
-
- // we need to ensure that this is run via 'asyncExec' since these
- // notifications can come from a non-ui thread
- if (Display.getCurrent() != null)
- Display.getCurrent().timerExec(100,currentRunnable);
- else
- Display.getDefault().timerExec(100,currentRunnable);
- }
- }
- }
- }
- }
-
-public boolean inValidateEditCall()
-{
- return inValidateEditCall;
-}
-
-/**
- * Gets the dirtyState.
- * @return Returns a boolean
- */
-public boolean getDirtyState() {
- return dirtyState;
-}
-
-/**
- * Sets the dirtyState.
- * @param dirtyState The dirtyState to set
- */
-public void setDirtyState(boolean dirtyState) {
- this.dirtyState = dirtyState;
-}
-
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/ResourceChangeListener.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/ResourceChangeListener.java
deleted file mode 100644
index 18b64d4..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/internal/resources/ResourceChangeListener.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.internal.resources;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class ResourceChangeListener implements IPartListener, IResourceChangeListener, IResourceDeltaVisitor
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- protected ArrayList recognizedEditorParts = new ArrayList();
- protected IEditorPart editor;
- protected long fileTimestamp;
-
- public ResourceChangeListener(IEditorPart editPart)
- {
- editor = editPart;
- // add a part activate listener
- editor.getSite().getWorkbenchWindow().getPartService().addPartListener(this);
- // add resource change listener
- getFile().getWorkspace().addResourceChangeListener(this);
- setTimestamp();
- }
-
- protected void setTimestamp()
- {
- fileTimestamp = computeModificationStamp(getFile());
- }
-
- /**
- * Computes the initial modification stamp for the given resource.
- *
- * @param resource the resource
- * @return the modification stamp
- */
- protected long computeModificationStamp(IResource resource) {
- long modificationStamp= resource.getModificationStamp();
-
- IPath path= resource.getLocation();
- if (path == null)
- return modificationStamp;
-
- modificationStamp= path.toFile().lastModified();
- return modificationStamp;
- }
-
- protected IFile getFile()
- {
- IFileEditorInput fileInput = (IFileEditorInput) editor.getEditorInput();
- return fileInput.getFile();
- }
-
- protected void checkChanged(final IEditorPart editorPart)
- {
- if (!getFile().exists() ||
- fileTimestamp != computeModificationStamp(getFile()))
- {
- if (editorPart instanceof IExternalChangeEditorListener)
- {
- editorPart.getSite().getShell().getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- ((IExternalChangeEditorListener)editorPart).handleEditorInputChanged();
- setTimestamp();
- }
- });
- }
- }
- }
-
- /**
- * @see IPartListener#partActivated(IWorkbenchPart)
- */
- public void partActivated(IWorkbenchPart part)
- {
- if (part == editor)
- checkChanged(editor);
- }
-
- /**
- * @see IPartListener#partBroughtToTop(IWorkbenchPart)
- */
- public void partBroughtToTop(IWorkbenchPart arg0) {
-// if (arg0 == editor)
-// B2BGUIPlugin.getPlugin().getMsgLogger().write("part brought to top");
- }
-
- /**
- * @see IPartListener#partClosed(IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart part) {
- if (part == editor)
- {
- // add a part activate listener
- editor.getSite().getWorkbenchWindow().getPartService().removePartListener(this);
- // add resource change listener
- getFile().getWorkspace().removeResourceChangeListener(this);
-// B2BGUIPlugin.getPlugin().getMsgLogger().write("part closed");
- }
- }
-
- /**
- * @see IPartListener#partDeactivated(IWorkbenchPart)
- */
- public void partDeactivated(IWorkbenchPart part) {}
-
- /**
- * @see IPartListener#partOpened(IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart part) {}
-
- // IResourceChangeListener interface
- public void resourceChanged(IResourceChangeEvent event)
- {
- IResourceDelta resourceDelta = event.getDelta();
-
- try
- {
- if (resourceDelta != null)
- {
- resourceDelta.accept(this);
- }
- }
- catch (Exception e)
- {
-// B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception caught during resource change" + e);
-// B2BGUIPlugin.getPlugin().getMsgLogger().writeCurrentThread();
- }
- }
-
- // IResourceDeltaVisitor
- public boolean visit(IResourceDelta delta)
- {
- if (delta.getResource().equals(getFile()))
- {
- switch (delta.getKind())
- {
- case IResourceDelta.CHANGED:
- setTimestamp();
- break;
- case IResourceDelta.REMOVED:
- if ((IResourceDelta.MOVED_TO & delta.getFlags()) != 0)
- {
- final IPath movedToPath = delta.getMovedToPath();
-
- editor.getSite().getShell().getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- // if the resource has moved or been renamed, let the editor do some work now
- ((IExternalChangeEditorListener)editor).handleEditorPathChanged(movedToPath);
- setTimestamp();
- }
- });
- }
- else
- {
- editor.getSite().getShell().getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- // if the resource is deleted, let the editor do some work now
- ((IExternalChangeEditorListener)editor).handleEditorInputChanged();
- setTimestamp();
- }
- });
-
- }
- break;
-
- default:
- break;
- }
- }
- return true;
- }
-}
-
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/resource/ResourceDeleteListener.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/resource/ResourceDeleteListener.java
deleted file mode 100644
index b1f852e..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/resource/ResourceDeleteListener.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.resource;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.wst.common.ui.UIPlugin;
-
-
-public class ResourceDeleteListener implements IResourceChangeListener, IResourceDeltaVisitor
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- protected ArrayList recognizedEditorParts = new ArrayList();
-
- public void addEditorPartClass(Class editorPartClass)
- {
- recognizedEditorParts.add(editorPartClass);
- }
-
- public void resourceChanged(IResourceChangeEvent event)
- {
- IResourceDelta resourceDelta = event.getDelta();
-
- try
- {
- if (resourceDelta != null)
- {
- resourceDelta.accept(this);
- }
- }
- catch (Exception e)
- {
-// B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception caught during resource change" + e);
-// B2BGUIPlugin.getPlugin().getMsgLogger().writeCurrentThread();
- }
- }
-
- public boolean visit(IResourceDelta delta)
- {
- if (delta.getKind() == IResourceDelta.REMOVED)
- {
- // handle removed resource
- //closeEditors(delta.getResource());
- /*
- * defect 235374
- * Without ayncExec, RuntimeException is raised:
- * "The resource tree is locked for modifications."
- * from Resource.refreshLocal().
- */
- Display.getDefault().asyncExec
- (new CloseEditors(recognizedEditorParts,delta.getResource()));
- }
- return true;
- }
-
- public static class CloseEditors implements Runnable
- {
- private IResource resource;
- private ArrayList recognizedEditorParts;
-
- public CloseEditors(ArrayList editorParts, IResource res)
- {
- recognizedEditorParts = editorParts;
- resource = res;
- }
-
- public void run()
- {
- // close all associated editors that are editing this resource,
- // if it is one of the recognizedEditorParts
- IWorkbenchWindow windows[] =
- UIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
-
- for (int i = 0; i < windows.length; i++)
- {
- IWorkbenchPage pages[] = windows[i].getPages();
-
- for (int j = 0; j < pages.length; j++ )
- {
- IEditorPart editors[] = pages[j].getEditors();
- for (int k = 0; k < editors.length; k++)
- {
- IEditorPart editor = editors[k];
- IEditorInput editorInput = editor.getEditorInput();
-
- if (editorInput instanceof IFileEditorInput)
- {
- if (((IFileEditorInput)editorInput).getFile().equals(resource) &&
- recognizedEditorParts.contains(editor.getClass()))
- {
- IWorkbenchPage page = pages[j];
- page.closeEditor(editor, false);
- }
- }
- }
- }
- }
- }
- }
-
- /*
- private void closeEditors(IResource deletedResource)
- {
- // close all associated editors that are editing this resource,
- // if it is one of the recognizedEditorParts
- IWorkbenchWindow windows[] = B2BGUIPlugin.getInstance().getWorkbench().getWorkbenchWindows();
-
- for (int i = 0; i < windows.length; i++)
- {
- IWorkbenchPage pages[] = windows[i].getPages();
-
- for (int j = 0; j < pages.length; j++ )
- {
- IEditorPart editors[] = pages[j].getEditors();
- for (int k = 0; k < editors.length; k++)
- {
- IEditorPart editor = editors[k];
- IEditorInput editorInput = editor.getEditorInput();
-
- if (editorInput instanceof IFileEditorInput)
- {
- if (((IFileEditorInput)editorInput).getFile().equals(deletedResource) &&
- recognizedEditorParts.contains(editor.getClass()))
- {
- IWorkbenchPage page = pages[j];
- org.eclipse.swt.widgets.
- Display.getDefault().asyncExec(new CloseEditor(page, editor));
- }
- }
- }
- }
- }
- }
- */
-
- public static class CloseEditor implements Runnable
- {
- protected IWorkbenchPage page;
- protected IEditorPart editor;
- public CloseEditor(IWorkbenchPage page, IEditorPart editor)
- {
- this.page = page;
- this.editor = editor;
- }
- public void run()
- {
- page.closeEditor(editor, false);
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/NavigableTableViewer.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/NavigableTableViewer.java
deleted file mode 100644
index 2f63b32..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/NavigableTableViewer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.viewers;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.widgets.Table;
-
-public class NavigableTableViewer extends TableViewer
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
-
- TableNavigator navigator;
-
- public NavigableTableViewer(Table parent)
- {
- super(parent);
- navigator = new TableNavigator(getTable(), this);
- }
-
- //override setCellEditors to put in call to moveAboveCellEditors for TableNavigator
- public void setCellEditors(CellEditor[] editors)
- {
- super.setCellEditors(editors);
- navigator.moveCellEditorsAbove(editors);
-
- }
-
- //override refresh so that TableNavigator is refreshed for all model changes
- public void refresh()
- {
- if( !this.getTable().isDisposed() )
- {
- super.refresh();
- navigator.refresh();
- }
- }
-
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/ResourceFilter.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/ResourceFilter.java
deleted file mode 100644
index 3212435..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/ResourceFilter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.viewers;
-
-import java.util.Collection;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-public class ResourceFilter extends ViewerFilter
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2002.";
- protected String[] fExtensions;
- protected IFile[] fExcludedFiles;
- protected Collection fExcludes;
-
- public ResourceFilter(String[] extensions, Collection exclude)
- {
- fExtensions= extensions;
- fExcludes= exclude;
- fExcludedFiles = null;
- }
-
- public ResourceFilter(String[] extensions, IFile[] excludedFiles, Collection exclude)
- {
- fExtensions= extensions;
- fExcludes= exclude;
- fExcludedFiles = excludedFiles;
- }
-
- public boolean isFilterProperty(Object element, Object property)
- {
- return false;
- }
-
- public boolean select(Viewer viewer, Object parent, Object element)
- {
- if (element instanceof IFile)
- {
- if (fExcludes != null && fExcludes.contains(element))
- {
- return false;
- }
- String name= ((IFile)element).getName();
- if (fExcludedFiles != null)
- {
- for (int j= 0; j < fExcludedFiles.length; j++)
- {
- if ( ((IFile)element).getLocation().
- toOSString().compareTo((fExcludedFiles[j]).getLocation().toOSString()) == 0 )
- return false;
- }
- }
- if (fExtensions.length == 0)
- {
- // assume that we don't want to filter any files based on
- // extension
- return true;
- }
- for (int i= 0; i < fExtensions.length; i++)
- {
- if (name.endsWith(fExtensions[i]))
- {
- return true;
- }
- }
- return false;
- }
- else if (element instanceof IContainer)
- { // IProject, IFolder
- try
- {
- IResource[] resources= ((IContainer)element).members();
- for (int i= 0; i < resources.length; i++)
- {
- // recursive!
- if (select(viewer, parent, resources[i]))
- {
- return true;
- }
- }
- }
- catch (CoreException e)
- {
- }
- }
- return false;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectMultiFilePage.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectMultiFilePage.java
deleted file mode 100644
index 5b86876..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectMultiFilePage.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.viewers;
-
-import java.util.*;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.wizard.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.core.resources.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.model.*;
-import org.eclipse.ui.wizards.datatransfer.*;
-import org.eclipse.wst.common.ui.UIPlugin;
-
-
-// Page to specify the source files
-public class SelectMultiFilePage extends WizardPage {
- public static final String copyright =
- "(c) Copyright IBM Corporation 2000, 2001, 2002.";
- IWorkbench workbench;
- IStructuredSelection selection;
- boolean isFileMandatory;
- TreeViewer sourceFileViewer;
- Button addButton;
- Button removeButton;
- Button removeAllButton;
- org.eclipse.swt.widgets.List selectedListBox;
- Button importButton;
- private Vector fFilters;
- protected IFile[] fileNames;
- IWorkspaceRoot workspaceRoot;
-
- private final static int SIZING_LISTS_HEIGHT = 200;
- private final static int SIZING_LISTS_WIDTH = 150;
-
- // parameter isFileMandatory is used to determine if at least one file must be selected
- // before being able to proceed to the next page
- public SelectMultiFilePage(
- IWorkbench workbench,
- IStructuredSelection selection,
- boolean isFileMandatory) {
- super("SelectMultiFilePage");
- this.workbench = workbench;
- this.selection = selection;
- this.isFileMandatory = isFileMandatory;
- this.workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- this.fileNames = null;
- }
-
- public void createControl(Composite parent) {
-
- Composite pageContent = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- pageContent.setLayout(layout);
- pageContent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- GridData outerFrameGridData = (GridData) pageContent.getLayoutData();
- // outerFrameGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
- // outerFrameGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL;
-
- // WorkbenchHelp.setHelp(
- // pageContent,
- // B2BGUIContextIds.BTBG_SELECT_MULTI_FILE_PAGE);
-
- createLabels(pageContent);
- createSourceViewer(pageContent);
- createButtonPanel(pageContent);
- createSelectedListBox(pageContent);
- createImportButton(pageContent);
-
- setControl(pageContent);
- if (isFileMandatory)
- setPageComplete(false);
-
- }
-
- public IFile[] getFiles() {
- return fileNames;
- }
-
- // This is a convenience method that allows filtering of the given file
- // exensions. It internally creates a ResourceFilter so that users of this
- // class don't have to construct one.
- // If the extensions provided don't have '.', one will be added.
- public void addFilterExtensions(String[] filterExtensions) {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions =
- new String[filterExtensions.length];
- for (int i = 0; i < filterExtensions.length; i++) {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- correctedFilterExtensions[i] = filterExtensions[i];
- else
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
-
- ViewerFilter filter =
- new ResourceFilter(correctedFilterExtensions, null);
- addFilter(filter);
- }
-
- public boolean isValidSourceFileViewerSelection(ISelection selection) {
- return true;
- }
-
- public void setVisible(boolean visible) {
- if (visible == true) {
- if (fFilters != null) {
- sourceFileViewer.resetFilters();
- for (Iterator i = fFilters.iterator(); i.hasNext();)
- sourceFileViewer.addFilter((ViewerFilter) i.next());
- }
- sourceFileViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
- }
- super.setVisible(visible);
- }
-
- public void setFiles(String[] fileNames) {
- int size = Arrays.asList(fileNames).size();
- Vector iFileNames = new Vector();
- for (int i = 0; i < size; i++) {
- IResource resource = workspaceRoot.findMember(fileNames[i]);
- if (resource instanceof IFile)
- iFileNames.addElement(resource);
- }
- IFile[] dummyArray = new IFile[iFileNames.size()];
- this.fileNames = (IFile[]) (iFileNames.toArray(dummyArray));
- }
-
- public void resetFilters() {
- fFilters = null;
- }
-
- public void addFilter(ViewerFilter filter) {
- if (fFilters == null)
- fFilters = new Vector();
- fFilters.add(filter);
- }
-
- public void setAddButtonEnabled(boolean isEnabled) {
- addButton.setEnabled(isEnabled);
- }
-
- public void setRemoveButtonEnabled(boolean isEnabled) {
- removeButton.setEnabled(isEnabled);
- }
-
- private void createLabels(Composite pageContent) {
- Label label = new Label(pageContent, SWT.LEFT);
- label.setText(UIPlugin.getResourceString("_UI_LABEL_SOURCE_FILES"));
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- label = new Label(pageContent, SWT.LEFT);
- label.setText(UIPlugin.getResourceString("_UI_LABEL_SELECTED_FILES"));
- }
-
- public boolean checkIfFileInTarget(IFile fileToCheck) {
- String[] strings = selectedListBox.getItems();
- int size = selectedListBox.getItemCount();
- for (int i = 0; i < size; i++) {
- if (strings[i].compareTo(fileToCheck.getFullPath().toString())
- == 0)
- return true;
- }
- return false;
- }
-
- private void createSourceViewer(Composite parent) {
- sourceFileViewer =
- new TreeViewer(
- new Tree(
- parent,
- SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER));
- sourceFileViewer.setContentProvider(new WorkbenchContentProvider());
- sourceFileViewer.setLabelProvider(new WorkbenchLabelProvider());
- sourceFileViewer
- .addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- java.util.List list;
- ISelection selection = event.getSelection();
- boolean newFilesSelected = false;
-
- if (selection instanceof IStructuredSelection) {
- list = ((IStructuredSelection) selection).toList();
- for (Iterator i = list.iterator(); i.hasNext();) {
- IResource resource = (IResource) i.next();
- if (resource instanceof IFile) {
- if (checkIfFileInTarget((IFile) resource) == false)
- newFilesSelected = true;
- }
- }
- setAddButtonEnabled(newFilesSelected);
- }
- }
- });
- sourceFileViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- addSelectedFilesToTargetList();
- }
- });
-
- Control treeWidget = sourceFileViewer.getTree();
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = SIZING_LISTS_WIDTH;
- gd.heightHint = SIZING_LISTS_HEIGHT;
- treeWidget.setLayoutData(gd);
- }
-
- private void createButtonPanel(Composite pageContent) {
- Composite buttonPanel = new Composite(pageContent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- buttonPanel.setLayout(layout);
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.grabExcessVerticalSpace = true;
- gridData.verticalAlignment = GridData.CENTER;
- gridData.horizontalAlignment = GridData.CENTER;
- buttonPanel.setLayoutData(gridData);
-
- addButton = new Button(buttonPanel, SWT.PUSH);
- addButton.setText(UIPlugin.getResourceString("_UI_ADD_BUTTON"));
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.CENTER;
- addButton.setLayoutData(gridData);
- addButton.addSelectionListener(new ButtonSelectListener());
- addButton.setToolTipText(
- UIPlugin.getResourceString("_UI_ADD_BUTTON_TOOL_TIP"));
- addButton.setEnabled(false);
-
- removeButton = new Button(buttonPanel, SWT.PUSH);
- removeButton.setText(UIPlugin.getResourceString("_UI_REMOVE_BUTTON"));
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.CENTER;
- removeButton.setLayoutData(gridData);
- removeButton.addSelectionListener(new ButtonSelectListener());
- removeButton.setToolTipText(
- UIPlugin.getResourceString("_UI_REMOVE_BUTTON_TOOL_TIP"));
- removeButton.setEnabled(false);
-
- removeAllButton = new Button(buttonPanel, SWT.PUSH);
- removeAllButton.setText(UIPlugin.getResourceString("_UI_REMOVE_ALL_BUTTON"));
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.CENTER;
- removeAllButton.setLayoutData(gridData);
- removeAllButton.addSelectionListener(new ButtonSelectListener());
- removeAllButton.setToolTipText(
- UIPlugin.getResourceString("_UI_REMOVE_ALL_BUTTON_TOOL_TIP"));
- removeAllButton.setEnabled(false);
- }
-
- private void createSelectedListBox(Composite parent) {
- selectedListBox = new List(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- selectedListBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent event) {
- }
-
- public void widgetSelected(SelectionEvent event) {
- java.util.List list;
- if (selectedListBox.getSelectionCount() > 0)
- setRemoveButtonEnabled(true);
- else
- setRemoveButtonEnabled(false);
- return;
- }
- });
-
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = SIZING_LISTS_WIDTH;
- gd.heightHint = SIZING_LISTS_HEIGHT;
- selectedListBox.setLayoutData(gd);
- }
-
- void createImportButton(Composite parent) {
- importButton = new Button(parent, SWT.PUSH);
- importButton.setText(UIPlugin.getResourceString("_UI_IMPORT_BUTTON"));
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.CENTER;
- importButton.setLayoutData(gridData);
- importButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- FileSystemImportWizard importWizard =
- new FileSystemImportWizard();
- importWizard.init(workbench, selection);
- Shell shell = Display.getCurrent().getActiveShell();
- WizardDialog wizardDialog =
- new WizardDialog(shell, importWizard);
- wizardDialog.create();
- wizardDialog.open();
- sourceFileViewer.refresh();
- }
- });
- importButton.setToolTipText(
- UIPlugin.getResourceString("_UI_IMPORT_BUTTON_TOOL_TIP"));
- }
-
- public void addSelectedFilesToTargetList() {
- ISelection selection = sourceFileViewer.getSelection();
-
- if (isValidSourceFileViewerSelection(selection)) {
- java.util.List list = null;
- if (selection instanceof IStructuredSelection) {
- list = ((IStructuredSelection) selection).toList();
-
- if (list != null) {
- list = ((IStructuredSelection) selection).toList();
- for (Iterator i = list.iterator(); i.hasNext();) {
- IResource resource = (IResource) i.next();
- if (resource instanceof IFile) {
- // Check if its in the list. Don't add it if it is.
- String resourceName =
- resource.getFullPath().toString();
- if (selectedListBox.indexOf(resourceName) == -1)
- selectedListBox.add(resourceName);
- }
- }
- setFiles(selectedListBox.getItems());
- }
-
- setAddButtonEnabled(false);
-
- if (selectedListBox.getItemCount() > 0) {
- removeAllButton.setEnabled(true);
- if (isFileMandatory)
- setPageComplete(true);
- if (selectedListBox.getSelectionCount() > 0)
- setRemoveButtonEnabled(true);
- else
- setRemoveButtonEnabled(false);
- }
- }
- }
- }
-
- class ButtonSelectListener implements SelectionListener {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == addButton) {
- addSelectedFilesToTargetList();
- } else if (e.widget == removeButton) {
- String[] strings = selectedListBox.getSelection();
- int size = selectedListBox.getSelectionCount();
- for (int i = 0; i < size; i++) {
- selectedListBox.remove(strings[i]);
- }
- removeButton.setEnabled(false);
- if (selectedListBox.getItemCount() == 0) {
- removeAllButton.setEnabled(false);
- if (isFileMandatory)
- setPageComplete(false);
- }
- setFiles(selectedListBox.getItems());
- } else if (e.widget == removeAllButton) {
- selectedListBox.removeAll();
- removeButton.setEnabled(false);
- removeAllButton.setEnabled(false);
- if (isFileMandatory)
- setPageComplete(false);
- setFiles(selectedListBox.getItems());
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectSingleFilePage.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectSingleFilePage.java
deleted file mode 100644
index b77cad2..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectSingleFilePage.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.viewers;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-//import org.eclipse.ui.help.WorkbenchHelp;
-
-public class SelectSingleFilePage extends WizardPage
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2001, 2002.";
- protected IWorkbench workbench;
- protected SelectSingleFileView selectSingleFileView;
-
- // parameter isFileMandatory is used to determine if a file must be selected
- // before being able to proceed to the next page
- public SelectSingleFilePage(IWorkbench workbench, IStructuredSelection selection, boolean isFileMandatory)
- {
- super("SelectSingleFilePage");
- this.workbench = workbench;
- selectSingleFileView = new SelectSingleFileView(selection, isFileMandatory);
- }
-
- public void setVisible(boolean visible)
- {
- selectSingleFileView.setVisibleHelper(visible);
- super.setVisible(visible);
- }
-
- public void createControl(Composite parent)
- {
- SelectSingleFileView.Listener listener = new SelectSingleFileView.Listener()
- {
- public void setControlComplete(boolean isComplete)
- {
- setPageComplete(isComplete);
- }
- };
- selectSingleFileView.setListener(listener);
- Control control = selectSingleFileView.createControl(parent);
-// WorkbenchHelp.setHelp(control, B2BGUIContextIds.BTBG_SELECT_SINGLE_FILE_PAGE);
- setControl(control);
- }
-
- public void addFilter(ViewerFilter filter)
- {
- selectSingleFileView.addFilter(filter);
- }
-
- public void addFilterExtensions(String[] filterExtensions)
- {
- selectSingleFileView.addFilterExtensions(filterExtensions);
- }
-
- public void resetFilters()
- {
- selectSingleFileView.resetFilters();
- }
-
- public IFile getFile()
- {
- return selectSingleFileView.getFile();
- }
-
-
- /**
- * Returns the selectSingleFileView.
- * @return SelectSingleFileView
- */
- public TreeViewer getSourceFileViewer() {
- return selectSingleFileView.sourceFileViewer;
- }
-
- /**
- * Returns the selectSingleFileView.
- * @return SelectSingleFileView
- */
- public SelectSingleFileView getSelectSingleFileView() {
- return selectSingleFileView;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectSingleFileView.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectSingleFileView.java
deleted file mode 100644
index a3291a1..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/SelectSingleFileView.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.viewers;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.wizards.datatransfer.FileSystemImportWizard;
-import org.eclipse.wst.common.ui.UIPlugin;
-
-
-
-public class SelectSingleFileView
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2001, 2002.";
- protected Composite composite;
- protected IStructuredSelection selection;
- protected boolean isFileMandatory;
- protected TreeViewer sourceFileViewer;
- protected Button importButton;
- protected Vector fFilters;
- protected IFile selectedFile;
- protected ISelection defaultSelection;
- protected Listener listener;
-
- public static interface Listener
- {
- public void setControlComplete(boolean isComplete);
- }
-
- public SelectSingleFileView(IStructuredSelection selection, boolean isFileMandatory)
- {
- this.selection = selection;
- this.isFileMandatory = isFileMandatory;
- this.selectedFile= null;
- this.defaultSelection = null;
- }
-
- public Composite createControl(Composite parent)
- {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- Label label = new Label(composite, SWT.NONE);
- label.setText(UIPlugin.getResourceString("_UI_LABEL_SOURCE_FILES"));
- createSourceViewer(composite);
- createFilterControl(composite);
- createImportButton(composite);
- return composite;
- }
-
-
- protected void createFilterControl(Composite composite)
- {
- }
-
-public void setListener(Listener listener)
- {
- this.listener = listener;
- }
-
- protected void createSourceViewer(Composite parent)
- {
- sourceFileViewer = new TreeViewer(new Tree(parent, SWT.SINGLE | SWT.BORDER));
- sourceFileViewer.setContentProvider(new WorkbenchContentProvider());
- sourceFileViewer.setLabelProvider(new WorkbenchLabelProvider());
- sourceFileViewer.addSelectionChangedListener(new ISelectionChangedListener()
- {
- public void selectionChanged(SelectionChangedEvent event)
- {
- boolean isComplete = true;
- java.util.List list;
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection)
- {
- list = ((IStructuredSelection)selection).toList();
- for (Iterator i = list.iterator(); i.hasNext();)
- {
- IResource resource = (IResource) i.next();
- if (resource instanceof IFile)
- {
- selectedFile = (IFile) resource;
- if (isFileMandatory)
- {
- isComplete = true;
- break;
- }
- }
- else
- {
- selectedFile = null;
- if (isFileMandatory)
- {
- isComplete = false;
- }
- }
- }
-
- if (listener != null)
- {
- listener.setControlComplete(isComplete);
- }
- }
- }
- });
- Control treeWidget = sourceFileViewer.getTree();
- GridData gd = new GridData(GridData.FILL_BOTH);
- treeWidget.setLayoutData(gd);
- }
-
-
- protected void createImportButton(Composite parent)
- {
- importButton = new Button(parent, SWT.NONE);
- importButton.setText(UIPlugin.getResourceString("_UI_IMPORT_BUTTON"));
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.CENTER;
- importButton.setLayoutData(gridData);
- importButton.addSelectionListener(new SelectionListener()
- {
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- // This listener is if the Import Wizard adds a new few, we want
- // it to be selected when we come back from it
- ImportAddResourceListener importAddResourceListener= new ImportAddResourceListener();
-
- ResourcesPlugin.getWorkspace().addResourceChangeListener(importAddResourceListener);
-
- FileSystemImportWizard importWizard = new FileSystemImportWizard();
- IWorkbench workbench = UIPlugin.getDefault().getWorkbench();
- selection = (IStructuredSelection) sourceFileViewer.getSelection();
- importWizard.init(workbench, selection != null ? selection : new StructuredSelection());
- Shell shell = Display.getCurrent().getActiveShell();
- WizardDialog wizardDialog = new WizardDialog(shell, importWizard);
- wizardDialog.create();
- wizardDialog.open();
- sourceFileViewer.refresh();
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(importAddResourceListener);
- IFile importedFile = importAddResourceListener.getImportedFile();
- if (importedFile != null)
- {
- StructuredSelection structuredSelection = new StructuredSelection(importedFile);
- sourceFileViewer.setSelection(structuredSelection);
- }
- }
- });
- importButton.setToolTipText(UIPlugin.getResourceString("_UI_IMPORT_BUTTON_TOOL_TIP"));
- }
-
- public IFile getFile()
- {
- return selectedFile;
- }
-
- public void setDefaultSelection(ISelection selection)
- {
- this.defaultSelection = selection;
- }
-
- public void resetFilters()
- {
- fFilters=null;
- }
-
- public void addFilter(ViewerFilter filter)
- {
- if (fFilters == null)
- {
- fFilters= new Vector();
- }
- fFilters.add(filter);
- }
-
- // This is a convenience method that allows filtering of the given file
- // exensions. It internally creates a ResourceFilter so that users of this
- // class don't have to construct one.
- // If the extensions provided don't have '.', one will be added.
- public void addFilterExtensions(String[] filterExtensions)
- {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions = new String[filterExtensions.length];
- for (int i=0; i < filterExtensions.length; i++)
- {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- {
- correctedFilterExtensions[i] = filterExtensions[i];
- }
- else
- {
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
- }
-
- ViewerFilter filter = new ResourceFilter(correctedFilterExtensions, null);
- addFilter(filter);
- }
-
-// This is a convenience method that allows filtering of the given file
-// exensions. It internally creates a ResourceFilter so that users of this
-// class don't have to construct one.
-// If the extensions provided don't have '.', one will be added.
- public void addFilterExtensions(String[] filterExtensions, IFile [] excludedFiles)
- {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions = new String[filterExtensions.length];
- for (int i=0; i < filterExtensions.length; i++)
- {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- {
- correctedFilterExtensions[i] = filterExtensions[i];
- }
- else
- {
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
- }
- ViewerFilter filter;
- if (excludedFiles != null)
- {
- filter = new ResourceFilter(correctedFilterExtensions, excludedFiles, null);
- }
- else
- {
- filter = new ResourceFilter(correctedFilterExtensions, null);
- }
- addFilter(filter);
- }
-
- // This is a convenience method that allows filtering of the given file
- // exensions. It internally creates a ResourceFilter so that users of this
- // class don't have to construct one.
- // If the extensions provided don't have '.', one will be added.
- public void setFilterExtensions(String[] filterExtensions)
- {
- // First add the '.' to the filterExtensions if they don't already have one
- String[] correctedFilterExtensions = new String[filterExtensions.length];
- for (int i=0; i < filterExtensions.length; i++)
- {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith("."))
- {
- correctedFilterExtensions[i] = filterExtensions[i];
- }
- else
- {
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
- }
- ViewerFilter filter = new ResourceFilter(correctedFilterExtensions, null);
- fFilters= new Vector();
- fFilters.add(filter);
- if (sourceFileViewer != null)
- {
- sourceFileViewer.getTree().setRedraw(false);
- sourceFileViewer.resetFilters();
- for (Iterator i=fFilters.iterator(); i.hasNext();)
- {
- sourceFileViewer.addFilter((ViewerFilter)i.next());
- }
- sourceFileViewer.getTree().setRedraw(true);
- sourceFileViewer.getTree().redraw();
- }
- }
-
- // this method should be called by a Wizard page or Dialog when it becomes visible
- public void setVisibleHelper(boolean visible)
- {
- if (visible == true)
- {
- if (fFilters != null)
- {
- sourceFileViewer.resetFilters();
- for (Iterator i=fFilters.iterator(); i.hasNext();)
- sourceFileViewer.addFilter((ViewerFilter)i.next());
- }
- sourceFileViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
- sourceFileViewer.expandToLevel(2);
-
- if (defaultSelection != null)
- {
- sourceFileViewer.setSelection(defaultSelection, true);
- }
- else if (!sourceFileViewer.getSelection().isEmpty())
- {
- sourceFileViewer.setSelection(sourceFileViewer.getSelection());
- }
- else
- {
- if (isFileMandatory && listener != null)
- {
- listener.setControlComplete(false);
- }
- }
- }
- }
-
- class ImportAddResourceListener implements IResourceChangeListener, IResourceDeltaVisitor
- {
- public static final String copyright = "(c) Copyright IBM Corporation 2002.";
- Vector importedFiles;
-
- ImportAddResourceListener()
- {
- importedFiles = new Vector();
- }
-
- public void resourceChanged(IResourceChangeEvent event)
- {
- IResourceDelta resourceDelta = event.getDelta();
-
- try
- {
- if (resourceDelta != null)
- {
- resourceDelta.accept(this);
- }
- }
- catch (Exception e)
- {
- //TODO... log exception
- //UIPlugin.getMsgLogger().write("Exception caught during resource change" + e);
- //UIPlugin.getMsgLogger().writeCurrentThread();
- }
- }
-
- public boolean visit(IResourceDelta delta)
- {
- if (delta.getKind() == IResourceDelta.ADDED)
- {
- if (delta.getResource() instanceof IFile)
- importedFiles.add(delta.getResource());
- }
- return true;
- }
-
- public Collection getImportedFiles()
- {
- return importedFiles;
- }
-
- // This returns the first imported file in the list of imported files
- public IFile getImportedFile()
- {
- if (importedFiles.isEmpty() == false)
- return (IFile)importedFiles.firstElement();
-
- return null;
- }
- }
-}
-
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/TableNavigator.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/TableNavigator.java
deleted file mode 100644
index 0b07833..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/viewers/TableNavigator.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.viewers;
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.*;
-
-import org.eclipse.swt.custom.TableCursor;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.jface.viewers.*;
-
-
- /**
- * Adds a TableCursor to a StructuredViewer - for keyboard navigation of the table
- * The intent of this class is to provide the standard listeners for using F2 to
- * activate cell editors.
- *
- * Due to a current bug in the TableCursor, TableViewers using this class must make
- * a call similar to the TableNavigator method moveCellEditorsAbove(cellEditors)
- * whenever a setCellEditors call is made in the StructuredViewer. This is so that the
- * cell editor control shows up above the table cursor control.
- */
-
-public class TableNavigator extends TableCursor
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
- private static final String TABLETREEITEM_ID = "TableTreeItemID";
-
- final Table table;
-
- public TableNavigator(Table table, StructuredViewer viewer)
- {
- super(table, SWT.NONE);
- this.table = table;
- final Table currentTable = table;
- final StructuredViewer sViewer = viewer;
-
- // Linux index out of bounds fix. See defect 253429, 253433, and more
- setVisible(false);
-
- addPaintListener(viewer);
- addKeyListeners(viewer);
- addMouseListeners(viewer);
- addSelectionListener(new SelectionAdapter()
- {
- /**
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- if (sViewer instanceof TableTreeViewer)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)getRow().getData(TABLETREEITEM_ID);
- StructuredSelection selection = new StructuredSelection(tableTreeItem.getData());
- sViewer.setSelection(selection, true);
- }
- }
-
-
- });
- addFocusListener(new FocusAdapter(){
- public void focusGained(FocusEvent e)
- {
- // if e.source is not a child of the table then set selection - this is for tab into viewer
- Object eventSource = e.getSource();
- if (eventSource instanceof Control)
- {
- if (!isChild(currentTable, (Control)eventSource))
- {
- if (currentTable.getItemCount() > 0 && currentTable.getSelectionCount() <= 0)
- {
- if (sViewer instanceof TableTreeViewer)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)getRow().getData(TABLETREEITEM_ID);
- StructuredSelection selection = new StructuredSelection(tableTreeItem.getData());
- sViewer.setSelection(selection, true);
- }
- else
- {
- currentTable.setSelection(0);
- setSelection(0,0);
- }
- }
- }
- else
- {
- if (currentTable.getItems().length > 0)
- {
- // cursor can end up on a non-existent table row
- // currently no way to get the current table cursor row
- // so for now just catch the exception since it doesn't
- // cause any side effects.
- try
- {
- setVisible(true);
- }
- catch (Exception ee)
- {
- currentTable.setSelection(0);
- setSelection(0,0);
- }
- }
- else // do not show table cursor if there are no elements in the table - avoid repaint
- {
- setVisible(false);
- }
- }
- }
- }
-
- protected boolean isChild(Control parent, Control child)
- {
- Control tempChild = child;
- while (tempChild != null)
- {
- if (tempChild == parent)
- {
- return true;
- }
- tempChild = tempChild.getParent();
- }
- return false;
- }
-
- /**
- * @see org.eclipse.swt.events.FocusAdapter#focusLost(FocusEvent)
- */
- public void focusLost(FocusEvent e)
- {
- // Set the table navigator to be not visible if the the table
- // is not in focus and a child of the table is not in focus
- // note that we do this asynchronously so we don't mess up the
- // current focus handling.
- Display.getDefault().asyncExec(new Runnable()
- {
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- if (currentTable != null && !currentTable.isDisposed() && !currentTable.isFocusControl() &&
- !isChild(currentTable, Display.getDefault().getFocusControl()))
- {
- setVisible(false);
- }
- }
- });
- }
-
- });
-
-
-
-
- table.addFocusListener(new FocusAdapter()
- {
- /**
- * @see org.eclipse.swt.events.FocusListener#focusGained(FocusEvent)
- */
- public void focusGained(FocusEvent e)
- {
- // only display navigator if there are items in the table
- // and if the focus wasn't gained from our own table navigator
- // (ie focus came from outside)
- if (currentTable.getItemCount() > 0 &&
- (Display.getDefault().getFocusControl() != null) &&
- !Display.getDefault().getFocusControl().equals(TableNavigator.this))
- {
- // note that we do this asynchronously so we don't mess up the
- // current focus handling.
- Display.getDefault().asyncExec(new Runnable()
- {
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- if (!isVisible())
- {
- try
- {
- setVisible(true);
- setFocus();
- }
- catch (Exception e)
- {
- // catch IllegalArgumentExceptions here - index out of bounds on tableviewer
- if (currentTable.getItemCount() > 0)
- {
- currentTable.setSelection(0);
- setSelection(0,0);
- }
- else // do not show table cursor if there are no elements in the table - avoid repaint
- {
- setVisible(false);
- }
- }
- }
- }
- });
- }
- }
- });
- }
-
- public Table getTable()
- {
- return table;
- }
-
- public void addPaintListener(StructuredViewer viewer)
- {
- final StructuredViewer tableViewer = viewer;
-
- addPaintListener(new PaintListener()
- {
- public void paintControl(PaintEvent e)
- {
- TableItem[] selection = table.getSelection();
- final TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
- final String cellText = row.getText(getColumn());
- final Image cellImage = row.getImage(getColumn());
- final int col = getColumn();
-
- Display.getCurrent().asyncExec(new Runnable()
- {
- public void run()
- {
- if (!row.isDisposed())
- {
- String newText = row.getText(getColumn());
- TableItem cursorRow = getRow();
- if (!newText.equals(cellText) || !(row.getImage(col) == cellImage))
- {
- redraw();
- }
- }
- }
- });
- }
- });
- }
-
-
- public SelectionKeyAdapter getKeyAdapter(StructuredViewer viewer)
- {
- if (keyAdapter == null)
- {
- return new SelectionKeyAdapter(viewer);
- }
- else return keyAdapter;
- }
-
- public void setKeyAdapter(SelectionKeyAdapter kAdapter)
- {
- keyAdapter = kAdapter;
- }
-
- protected SelectionKeyAdapter keyAdapter = null;
-
- public class SelectionKeyAdapter extends KeyAdapter
- {
- StructuredViewer structuredViewer;
-
- public SelectionKeyAdapter(StructuredViewer viewer)
- {
- super();
- this.structuredViewer = viewer;
- }
-
- int lastKeyPressed = -1; // used to cache the last key for key combos
-
- public void keyPressed(KeyEvent e)
- {
- TableItem row = getRow();
- int column = getColumn();
-
- // hack to emulate SHIFT+F10 popup menu - otherwise table cursor
- // obscures the table popup mechanism and it doesn't work.
- if (lastKeyPressed == SWT.SHIFT && e.keyCode == SWT.F10)
- {
- Menu popup = getTable().getMenu();
- popup.setVisible(true);
- }
- lastKeyPressed = e.keyCode;
-
- //jvh - look for + or - key
- // column == 0
- if (row.getData(TABLETREEITEM_ID) instanceof TableTreeItem)
- {
- if (column == 0 && e.character == '+')
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).setExpandedState(tableTreeItem.getData(), true);
- refresh();
- }
- else if (column == 0 && e.character == '-')
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).setExpandedState(tableTreeItem.getData(), false);
- refresh();
- }
- }
- // use F2 to invoke editing for a cell
- if (e.keyCode == SWT.F2)
- {
- if (structuredViewer instanceof TableViewer)
- {
- ((TableViewer)structuredViewer).editElement(row.getData(), column);
- }
- else if (structuredViewer instanceof TableTreeViewer)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).editElement(tableTreeItem.getData(), column);
- }
- }
- }
- }
-
- public void addKeyListeners(StructuredViewer viewer)
- {
- final StructuredViewer structuredViewer = viewer;
-
- addKeyListener(getKeyAdapter(structuredViewer));
- }
-
- public void addMouseListeners(StructuredViewer viewer)
- {
- final StructuredViewer structuredViewer = viewer;
-
- addMouseListener(new MouseAdapter()
- {
-
- public void mouseUp(MouseEvent e)
- {
- TableItem row = getRow();
- int column = getColumn();
-
- // use mouse button 1 to invoke editing for a cell
- if (e.button == 1)
- {
- if (structuredViewer instanceof TableViewer)
- {
- ((TableViewer)structuredViewer).editElement(row.getData(), column);
- }
- else if (structuredViewer instanceof TableTreeViewer && column == 1)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- ((TableTreeViewer)structuredViewer).editElement(tableTreeItem.getData(), column);
- }
-
- if (structuredViewer instanceof TableTreeViewer && row.getData(TABLETREEITEM_ID) instanceof TableTreeItem)
- {
- if (column == 0)
- {
- TableTreeItem tableTreeItem = (TableTreeItem)row.getData(TABLETREEITEM_ID);
- boolean expandState = tableTreeItem.getExpanded();
- ((TableTreeViewer)structuredViewer).setExpandedState(tableTreeItem.getData(), !expandState);
- refresh();
- }
- }
- }
- }
- });
- }
-
-
- /**
- * Ensure that cell editor control shows up above the table cursor control.
- * Should be called whenever the table viewer makes a new call to setCellEditors
- * i.e. in constructor and in refreshCellEditors
- *
- * @param - array of cell editors for the StructuredViewer
- */
-
- public void moveCellEditorsAbove(CellEditor[] editorArray)
- {
- for (int i = 0; i < editorArray.length ; i++)
- {
- CellEditor cEd = editorArray[i];
- if (cEd != null && cEd.getControl() != null)
- {
- cEd.getControl().moveAbove(null);
- }
- }
- }
-
- public void refresh()
- {
- Display.getCurrent().asyncExec(new Runnable()
- {
- public void run()
- {
- if (!isDisposed() && isVisible())
- redraw();
- }
- });
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationOperation.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationOperation.java
deleted file mode 100644
index aff782e..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationOperation.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.wizards;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.wizards.datatransfer.ImportOperation;
-import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
-import org.eclipse.wst.common.ui.UIPlugin;
-import org.osgi.framework.Bundle;
-
-
-
-
-public class ExampleProjectCreationOperation implements IRunnableWithProgress {
-
- private IResource fElementToOpen;
-
- private ExampleProjectCreationWizardPage[] fPages;
- private IOverwriteQuery fOverwriteQuery;
-
- /**
- * Constructor for ExampleProjectCreationOperation
- */
- public ExampleProjectCreationOperation(ExampleProjectCreationWizardPage[] pages, IOverwriteQuery overwriteQuery) {
- fElementToOpen= null;
- fPages= pages;
- fOverwriteQuery= overwriteQuery;
- }
-
- /*
- * @see IRunnableWithProgress#run(IProgressMonitor)
- */
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- if (monitor == null) {
- monitor= new NullProgressMonitor();
- }
- try {
- monitor.beginTask(UIPlugin.getResourceString("ExampleProjectCreationOperation.op_desc"), fPages.length); //$NON-NLS-1$
- IWorkspaceRoot root= UIPlugin.getWorkspace().getRoot();
-
- for (int i= 0; i < fPages.length; i++) {
- createProject(root, fPages[i], new SubProgressMonitor(monitor, 1));
- }
- } finally {
- monitor.done();
- }
- }
-
- public IResource getElementToOpen() {
- return fElementToOpen;
- }
-
-
- private void createProject(IWorkspaceRoot root, ExampleProjectCreationWizardPage page, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- IConfigurationElement desc= page.getConfigurationElement();
-
- IConfigurationElement[] imports= desc.getChildren("import"); //$NON-NLS-1$
- IConfigurationElement[] natures= desc.getChildren("nature"); //$NON-NLS-1$
- IConfigurationElement[] references= desc.getChildren("references"); //$NON-NLS-1$
- int nImports= (imports == null) ? 0 : imports.length;
- int nNatures= (natures == null) ? 0 : natures.length;
- int nReferences= (references == null) ? 0 : references.length;
-
- monitor.beginTask(UIPlugin.getResourceString("ExampleProjectCreationOperation.op_desc_proj"), nImports + 1); //$NON-NLS-1$
-
- String name= page.getName();
-
- String[] natureIds= new String[nNatures];
- for (int i= 0; i < nNatures; i++) {
- natureIds[i]= natures[i].getAttribute("id"); //$NON-NLS-1$
- }
- IProject[] referencedProjects= new IProject[nReferences];
- for (int i= 0; i < nReferences; i++) {
- referencedProjects[i]= root.getProject(references[i].getAttribute("id")); //$NON-NLS-1$
- }
-
- IProject proj= configNewProject(root, name, natureIds, referencedProjects, monitor);
-
- for (int i= 0; i < nImports; i++) {
- doImports(proj, imports[i], new SubProgressMonitor(monitor, 1));
- }
-
- String open= desc.getAttribute("open"); //$NON-NLS-1$
- if (open != null && open.length() > 0) {
- IResource fileToOpen= proj.findMember(new Path(open));
- if (fileToOpen != null) {
- fElementToOpen= fileToOpen;
- }
- }
-
- }
-
- private IProject configNewProject(IWorkspaceRoot root, String name, String[] natureIds, IProject[] referencedProjects, IProgressMonitor monitor) throws InvocationTargetException {
- try {
- IProject project= root.getProject(name);
- if (!project.exists()) {
- project.create(null);
- }
- if (!project.isOpen()) {
- project.open(null);
- }
- IProjectDescription desc= project.getDescription();
- desc.setLocation(null);
- desc.setNatureIds(natureIds);
- desc.setReferencedProjects(referencedProjects);
-
- project.setDescription(desc, new SubProgressMonitor(monitor, 1));
-
- return project;
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- private void doImports(IProject project, IConfigurationElement curr, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- IPath destPath;
- String name= curr.getAttribute("dest"); //$NON-NLS-1$
- if (name == null || name.length() == 0) {
- destPath= project.getFullPath();
- } else {
- IFolder folder= project.getFolder(name);
- if (!folder.exists()) {
- folder.create(true, true, null);
- }
- destPath= folder.getFullPath();
- }
- String importPath= curr.getAttribute("src"); //$NON-NLS-1$
- if (importPath == null) {
- importPath= ""; //$NON-NLS-1$
- UIPlugin.log("projectsetup descriptor: import missing"); //$NON-NLS-1$
- return;
- }
-
- ZipFile zipFile= getZipFileFromPluginDir(importPath, getContributingPlugin(curr));
- importFilesFromZip(zipFile, destPath, new SubProgressMonitor(monitor, 1));
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- private String getContributingPlugin(IConfigurationElement configurationElement) {
- Object parent= configurationElement;
- while(parent != null) {
- if (parent instanceof IExtension)
- return ((IExtension)parent).getNamespace();
- parent= ((IConfigurationElement)parent).getParent();
- }
- return null;
- }
-
- private ZipFile getZipFileFromPluginDir(String pluginRelativePath, String symbolicName) throws CoreException {
- try {
- Bundle bundle = Platform.getBundle(symbolicName);
- URL starterURL= new URL(bundle.getEntry("/"), pluginRelativePath);
- return new ZipFile(Platform.asLocalURL(starterURL).getFile());
- } catch (IOException e) {
- String message= pluginRelativePath + ": " + e.getMessage(); //$NON-NLS-1$
- Status status= new Status(IStatus.ERROR, UIPlugin.getPluginId(), IStatus.ERROR, message, e);
- throw new CoreException(status);
- }
- }
-
- private void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- ZipFileStructureProvider structureProvider= new ZipFileStructureProvider(srcZipFile);
- ImportOperation op= new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, fOverwriteQuery);
- op.run(monitor);
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationWizard.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationWizard.java
deleted file mode 100644
index e7838cd..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationWizard.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.wizards;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
-import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
-import org.eclipse.wst.common.ui.UIPlugin;
-
-
-
-
-public class ExampleProjectCreationWizard extends BasicNewResourceWizard implements INewWizard, IExecutableExtension {
-
- private ExampleProjectCreationWizardPage[] fPages;
- private IConfigurationElement fConfigElement;
-
- public ExampleProjectCreationWizard() {
- super();
- setDialogSettings(UIPlugin.getDefault().getDialogSettings());
- setWindowTitle(UIPlugin.getResourceString("ExampleProjectCreationWizard.title")); //$NON-NLS-1$
- setNeedsProgressMonitor(true);
-
-
- }
-
- public void initializeDefaultPageImageDescriptor() {
- if (fConfigElement != null) {
- String banner= fConfigElement.getAttribute("banner"); //$NON-NLS-1$
- if (banner != null) {
- ImageDescriptor desc= this.getImageDescriptor(banner);
- setDefaultPageImageDescriptor(desc);
- }
- }
- }
-
- protected ImageDescriptor getImageDescriptor(String banner) {
- return null;
- }
-
- /*
- * @see Wizard#addPages
- */
- public void addPages() {
- super.addPages();
-
- IConfigurationElement[] children = fConfigElement.getChildren("projectsetup"); //$NON-NLS-1$
- if (children == null || children.length == 0) {
- UIPlugin.log("descriptor must contain one ore more projectsetup tags"); //$NON-NLS-1$
- return;
- }
-
- fPages= new ExampleProjectCreationWizardPage[children.length];
-
- for (int i= 0; i < children.length; i++) {
- fPages[i]= new ExampleProjectCreationWizardPage(i, children[i]);
- addPage(fPages[i]);
- }
- }
-
- /*
- * @see Wizard#performFinish
- */
- public boolean performFinish() {
- ExampleProjectCreationOperation runnable= new ExampleProjectCreationOperation(fPages, new ImportOverwriteQuery());
-
- IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
- try {
- getContainer().run(false, true, op);
- } catch (InvocationTargetException e) {
- handleException(e.getTargetException());
- return false;
- } catch (InterruptedException e) {
- return false;
- }
- BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
- IResource res= runnable.getElementToOpen();
- if (res != null) {
- openResource(res);
- }
- return true;
- }
-
- private void handleException(Throwable target) {
- String title= UIPlugin.getResourceString("ExampleProjectCreationWizard.op_error.title"); //$NON-NLS-1$
- String message= UIPlugin.getResourceString("ExampleProjectCreationWizard.op_error.message"); //$NON-NLS-1$
- if (target instanceof CoreException) {
- IStatus status= ((CoreException)target).getStatus();
- ErrorDialog.openError(getShell(), title, message, status);
- UIPlugin.log(status);
- } else {
- MessageDialog.openError(getShell(), title, target.getMessage());
- UIPlugin.log(target);
- }
- }
-
- private void openResource(final IResource resource) {
- if (resource.getType() != IResource.FILE) {
- return;
- }
- IWorkbenchWindow window= UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return;
- }
- final IWorkbenchPage activePage= window.getActivePage();
- if (activePage != null) {
- final Display display= getShell().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- try {
- IDE.openEditor(activePage, (IFile)resource, true);
- } catch (PartInitException e) {
- UIPlugin.log(e);
- }
- }
- });
- BasicNewResourceWizard.selectAndReveal(resource, activePage.getWorkbenchWindow());
- }
- }
-
- /**
- * Stores the configuration element for the wizard. The config element will be used
- * in <code>performFinish</code> to set the result perspective.
- */
- public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
- fConfigElement= cfig;
-
- initializeDefaultPageImageDescriptor();
-
- String title= fConfigElement.getAttribute("name"); //$NON-NLS-1$
- if (title != null) {
- //setWindowTitle(title);
- }
- }
-
- // overwrite dialog
-
- private class ImportOverwriteQuery implements IOverwriteQuery {
- public String queryOverwrite(String file) {
- String[] returnCodes= { YES, NO, ALL, CANCEL};
- int returnVal= openDialog(file);
- return returnVal < 0 ? CANCEL : returnCodes[returnVal];
- }
-
- private int openDialog(final String file) {
- final int[] result= { IDialogConstants.CANCEL_ID };
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- String title= UIPlugin.getResourceString("ExampleProjectCreationWizard.overwritequery.title"); //$NON-NLS-1$
- String msg= UIPlugin.getDefault().getString("ExampleProjectCreationWizard.overwritequery.message", file); //$NON-NLS-1$
- String[] options= {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL};
- MessageDialog dialog= new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION, options, 0);
- result[0]= dialog.open();
- }
- });
- return result[0];
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- // Empty
- }
-}
diff --git a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationWizardPage.java b/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationWizardPage.java
deleted file mode 100644
index 0eba6e1..0000000
--- a/plugins/org.eclipse.wst.common.ui/src/org/eclipse/wst/common/ui/wizards/ExampleProjectCreationWizardPage.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.ui.wizards;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.common.ui.UIPlugin;
-
-
-
-
-public class ExampleProjectCreationWizardPage extends WizardPage {
-
- private IStatus fCurrStatus;
-
- private boolean fPageVisible;
-
- private IConfigurationElement fConfigurationElement;
-
- private String fNameLabel;
- private String fProjectName;
-
- private Text fTextControl;
-
- public ExampleProjectCreationWizardPage(int pageNumber, IConfigurationElement elem) {
- super("page" + pageNumber); //$NON-NLS-1$
- fCurrStatus= createStatus(IStatus.OK, ""); //$NON-NLS-1$
-
- fConfigurationElement= elem;
-
- setTitle(getAttribute(elem, "pagetitle")); //$NON-NLS-1$
- setDescription(getAttribute(elem, "pagedescription")); //$NON-NLS-1$
-
- fNameLabel= getAttribute(elem, "label"); //$NON-NLS-1$
- String name = getAttribute(elem, "name"); //$NON-NLS-1$
- fProjectName = getInitialProjectName(name);
- }
-
- private String getAttribute(IConfigurationElement elem, String tag) {
- String res= elem.getAttribute(tag);
- if (res == null) {
- return '!' + tag + '!';
- }
- return res;
- }
-
- /*
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout gd= new GridLayout();
- gd.numColumns= 2;
- composite.setLayout(gd);
-
- Label label= new Label(composite, SWT.LEFT);
- label.setText(fNameLabel);
- label.setLayoutData(new GridData());
-
- fTextControl= new Text(composite, SWT.SINGLE | SWT.BORDER);
- fTextControl.setText(fProjectName);
- fTextControl.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (!fTextControl.isDisposed()) {
- validateText(fTextControl.getText());
- }
- }
- });
- fTextControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- setControl(composite);
-
- }
-
- private void validateText(String text) {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IStatus status= workspace.validateName(text, IResource.PROJECT);
- if (status.isOK()) {
- if (workspace.getRoot().getProject(text).exists()) {
- status= createStatus(IStatus.ERROR, UIPlugin.getResourceString("ExampleProjectCreationWizardPage.error.alreadyexists")); //$NON-NLS-1$
- }
- }
- updateStatus(status);
-
- fProjectName= text;
- }
-
-
- /*
- * @see WizardPage#becomesVisible
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- fPageVisible= visible;
- // policy: wizards are not allowed to come up with an error message
- if (visible && fCurrStatus.matches(IStatus.ERROR)) {
- // keep the error state, but remove the message
- fCurrStatus= createStatus(IStatus.ERROR, ""); //$NON-NLS-1$
- }
- updateStatus(fCurrStatus);
- }
-
- /**
- * Updates the status line and the ok button depending on the status
- */
- private void updateStatus(IStatus status) {
- fCurrStatus= status;
- setPageComplete(!status.matches(IStatus.ERROR));
- if (fPageVisible) {
- applyToStatusLine(this, status);
- }
- }
-
- /**
- * Applies the status to a dialog page
- */
- private static void applyToStatusLine(DialogPage page, IStatus status) {
- String errorMessage= null;
- String warningMessage= null;
- String statusMessage= status.getMessage();
- if (statusMessage.length() > 0) {
- if (status.matches(IStatus.ERROR)) {
- errorMessage= statusMessage;
- } else if (!status.isOK()) {
- warningMessage= statusMessage;
- }
- }
- page.setErrorMessage(errorMessage);
- page.setMessage(warningMessage);
- }
-
-
- private static IStatus createStatus(int severity, String message) {
- return new Status(severity, UIPlugin.getPluginId(), severity, message, null);
- }
-
- /**
- * Returns the name entered by the user
- */
- public String getName() {
- return fProjectName;
- }
-
- /**
- * Returns the configuration element of this page.
- * @return Returns a IConfigurationElement
- */
- public IConfigurationElement getConfigurationElement() {
- return fConfigurationElement;
- }
-
- /*
- * Set the default project name that is to appear on the initialPage
- * page of this wizard.
- */
- public String getInitialProjectName(String projectName)
- {
- IProject projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (!projectHandle.exists())
- {
- return projectName;
- }
- else
- {
- // Change the name until it doesn't exists. Try 9 times and then give up.
- for (int i = 1; i < 10; i++)
- {
- projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName + i);
- if (!projectHandle.exists())
- {
- return projectName + i;
- }
- }
- return projectName + "9";
- }
- }
-
-}
-
diff --git a/plugins/org.eclipse.wst.common.uriresolver/.classpath b/plugins/org.eclipse.wst.common.uriresolver/.classpath
deleted file mode 100644
index 065ac06..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/plugins/org.eclipse.wst.common.uriresolver/.cvsignore b/plugins/org.eclipse.wst.common.uriresolver/.cvsignore
deleted file mode 100644
index 5b853a4..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-bin
-uriresolver.jar
-build.xml
-temp.folder
-org.eclipse.wst.common.uriresolver_1.0.0.jar
diff --git a/plugins/org.eclipse.wst.common.uriresolver/.project b/plugins/org.eclipse.wst.common.uriresolver/.project
deleted file mode 100644
index e19b693..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.wst.common.uriresolver</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/plugins/org.eclipse.wst.common.uriresolver/README.txt b/plugins/org.eclipse.wst.common.uriresolver/README.txt
deleted file mode 100644
index acaf514..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-API for an URI resolver.
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.uriresolver/build.properties b/plugins/org.eclipse.wst.common.uriresolver/build.properties
deleted file mode 100644
index 08364ab..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-bin.includes = plugin.xml,\
- uriresolver.jar
-jars.compile.order = uriresolver.jar
-source.uriresolver.jar = src/
-output.uriresolver.jar = bin/
diff --git a/plugins/org.eclipse.wst.common.uriresolver/plugin.xml b/plugins/org.eclipse.wst.common.uriresolver/plugin.xml
deleted file mode 100644
index 820fba0..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/plugin.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.wst.common.uriresolver"
- name="org.eclipse.wst.common.uriresolver"
- version="1.0.0"
- provider-name="Eclipse.org"
- class="org.eclipse.wst.common.uriresolver.URIResolverPlugin">
-
- <runtime>
- <library name="uriresolver.jar">
- <export name="*" />
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- </requires>
-
-
- <extension-point id="resolverExtensions" name="URI Resolver Extension"/>
-
-</plugin>
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolver.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolver.java
deleted file mode 100644
index 88451b2..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolver.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver;
-
-/**
- * A URIResolver is used to resolve URI references to resources.
- *
- */
-public interface URIResolver {
-
- /**
- * @param baseLocation - the location of the resource that contains the uri
- * @param publicId - an optional public identifier (i.e. namespace name), or null if none
- * @param systemId - an absolute or relative URI, or null if none
- * @return an absolute URI
- */
- public String resolve(String baseLocation, String publicId, String systemId);
-}
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolverExtension.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolverExtension.java
deleted file mode 100644
index 377a144..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolverExtension.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver;
-
-import org.eclipse.core.resources.IProject;
-
-/**
- * An extension to augment the behaviour of a URIResolver. Extensions are project aware
- * so that they can apply specialized project specific resolving rules.
- */
-public interface URIResolverExtension {
- public String resolve(IProject project, String baseLocation, String publicId, String systemId);
-}
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolverPlugin.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolverPlugin.java
deleted file mode 100644
index e652718..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/URIResolverPlugin.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.wst.common.uriresolver.internal.ExtensibleURIResolver;
-import org.eclipse.wst.common.uriresolver.internal.URIResolverExtensionRegistry;
-import org.eclipse.wst.common.uriresolver.internal.URIResolverExtensionRegistryReader;
-
-
-public class URIResolverPlugin extends Plugin {
- protected static URIResolverPlugin instance;
- protected URIResolverExtensionRegistry xmlResolverExtensionRegistry;
-
- public static URIResolverPlugin getInstance()
- {
- return instance;
- }
-
- public URIResolverPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- instance = this;
- }
-
-
- public static URIResolver createResolver()
- {
- return createResolver(null);
- }
-
- public static URIResolver createResolver(Map properties)
- {
- // TODO... utilize properties
- return new ExtensibleURIResolver();
- }
-
- //public static URIResolver createResolver(IProject project)
- //{
- // return new ExtensibleURIResolver(project);
- //}
-
- public URIResolverExtensionRegistry getXMLResolverExtensionRegistry()
- {
- if (xmlResolverExtensionRegistry == null)
- {
- xmlResolverExtensionRegistry = new URIResolverExtensionRegistry();
- new URIResolverExtensionRegistryReader(xmlResolverExtensionRegistry).readRegistry();
- }
- return xmlResolverExtensionRegistry;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/ExtensibleURIResolver.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/ExtensibleURIResolver.java
deleted file mode 100644
index a16713a..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/ExtensibleURIResolver.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver.internal;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.common.uriresolver.URIResolver;
-import org.eclipse.wst.common.uriresolver.URIResolverExtension;
-import org.eclipse.wst.common.uriresolver.URIResolverPlugin;
-
-
-/**
- * @author csalter
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class ExtensibleURIResolver implements URIResolver
-{
-
- //protected IProject project;
-
- //TODO... consider ctor that takes a project arg
- //public ExtensibleURIResolver(IProject project)
- //{
- // this.project = project;
- //}
-
- public ExtensibleURIResolver()
- {
- }
-
- public String resolve(String baseLocation, String publicId, String systemId)
- {
- String result = systemId;
-
- // compute the project that holds the resource
- //
- IProject project = computeProject(baseLocation);
- String fileName = null; // todo.. get the file name for systemId
-
- URIResolverExtensionRegistry resolverRegistry = URIResolverPlugin.getInstance().getXMLResolverExtensionRegistry();
- List list = resolverRegistry.getExtensionDescriptors(project);
-
- // get the list of applicable pre-normalized resolvers from the
- // extension registry
- //
- for (Iterator i = resolverRegistry.getMatchingURIResolvers(list, URIResolverExtensionRegistry.STAGE_PRENORMALIZATION).iterator(); i.hasNext();)
- {
- URIResolverExtension resolver = (URIResolverExtension) i.next();
- result = resolver.resolve(project, baseLocation, publicId, result);
- }
-
- // normalize the uri
- //
- result = normalize(baseLocation, result);
-
- // get the list of applicable post-normalized resolvers from the
- // extension registry
- //
- for (Iterator i = resolverRegistry.getMatchingURIResolvers(list, URIResolverExtensionRegistry.STAGE_POSTNORMALIZATION).iterator(); i.hasNext();)
- {
- URIResolverExtension resolver = (URIResolverExtension) i.next();
- result = resolver.resolve(project, baseLocation, publicId, result);
- }
-
- return result;
- }
-
- protected String normalize(String baseLocation, String systemId)
- {
- // If no systemId has been specified there is nothing to do
- // so return null;
- if(systemId == null)
- return null;
- String result = systemId;
- // normalize the URI
- URI systemURI = URI.createURI(systemId);
- if (systemURI.isRelative())
- {
- URI baseURI = URI.createURI(baseLocation);
- try
- {
- result = systemURI.resolve(baseURI).toString();
- }
- catch(IllegalArgumentException e)
- {}
-
- }
- return result;
- }
-
- protected IProject computeProject(String baseLocation)
- {
- if(baseLocation != null)
- {
- String pattern = "file:///";
- if (baseLocation.startsWith(pattern))
- {
- baseLocation = baseLocation.substring(pattern.length());
- }
- IPath path = new Path(baseLocation);
- //path = path.removeFirstSegments(1);
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
- //IContainer c =
- // ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
- return file != null ? file.getProject() : null;
- }
- return null;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URI.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URI.java
deleted file mode 100644
index 3aac823..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URI.java
+++ /dev/null
@@ -1,2019 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver.internal;
-
-import java.io.File;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A representation of a Uniform Resource Identifier (URI), as specified by
- * <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>, with certain
- * enhancements. A <code>URI</code> instance can be created by specifying
- * values for its components, or by providing a single URI string, which is
- * parsed into its components. Static factory methods whose names begin
- * with "create" are used for both forms of object creation. No public or
- * protected constructors are provided; this class can not be subclassed.
- *
- * <p>Like <code>String</code>, <code>URI</code> is an immutable class;
- * a <code>URI</code> instance offers several by-value methods that return a
- * new <code>URI</code> object based on its current state. Most useful,
- * a relative <code>URI</code> can be {@link #resolve(URI) resolve}d against
- * a base absolute <code>URI</code> -- the latter typically identifies the
- * document in which the former appears. The inverse to this is {@link
- * #deresolve(URI) deresolve}, which answers the question, "what relative
- * URI will resolve, against the given base, to this absolute URI?"
- *
- * <p>In the <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC</a>, much
- * attention is focused on a hierarchical naming system used widely to
- * locate resources via common protocols such as HTTP, FTP, and Gopher, and
- * to identify files on a local file system. Acordingly, most of this
- * class's functionality is for handling such URIs, which can be identified
- * via {@link #isHierarchical()}.
- *
- * <p><a name="device_explaination">
- * The primary enhancement beyond the RFC description is an optional
- * device component. Instead of treating the device as just another segment
- * in the path, it can be stored as a separate component (almost a
- * sub-authority), with the root below it. For example, resolving
- * <code>/bar</code> against <code>file:///c:/foo</code> would result in
- * <code>file:///c:/bar</code> being returned. Also, you cannot take
- * the parent of a device, so resolving <code>..</code> against
- * <code>file:///c:/</code> would not yield <code>file:///</code>, as you
- * might expect. This feature is useful when working with file-scheme
- * URIs, as devices do not typically occur in protocol-based ones. A
- * device-enabled <code>URI</code> can be created by parsing a string with
- * {@link #createURI} or by specifying a non-null <code>device</code>
- * paramter for either the {@link #createHierarchicalURI(String, String,
- * String, String, String) no-path} or the {@link
- * #createHierarchicalURI(String, String, String, String[], String, String)
- * absolute-path} form of <code>createHierarchicalURI()</code>.
- *
- * <p>Compared to the RFC description, this implementation is quite relaxed
- * about validity. Static methods whose names begin with "valid" test
- * whether a given string is a valid value for the various URI components.
- * Presently, these tests place no restrictions beyond what would have been
- * required in order for {@link #createURI} to
- * have parsed them correctly from a single URI string. Note that all of
- * the static factory methods invoke the appropriate validation methods and
- * throw exceptions in response to a negative result, ensuring that
- * invalid URIs are never created.
- *
- * <p>Finally, note the difference between a <code>null</code> parameter to
- * the static factory methods and an empty string. The former signifies the
- * absense of a given URI component, while the latter simply makes the
- * component blank. This can have a significant effect when resolving. For
- * example, consider the following two URIs: <code>/bar</code> (with no
- * authority) and <code>///bar</code> (with a blank authority). Imagine
- * resolving them against a base with an authority, such as
- * <code>http://www.eclipse.org/</code>. The former case will yield
- * <code>http://www.eclipse.org/bar</code>, as the base authority will be
- * preserved. In the latter case, the empty authority will override the
- * base authority, resulting in <code>http:///bar</code>!
- */
-public final class URI
-{
- // Common to all URI types.
- private final int hashCode;
- private final boolean hierarchical;
- private final String scheme; // null -> relative URI reference
- private final String authority;
- private final String fragment;
- private URI cachedTrimFragment;
- private String cachedToString;
-
- // Applicable only to a hierarchical URI.
- private final String device;
- private final boolean absolutePath;
- private final String[] segments; // empty last segment -> trailing separator
- private final String query;
-
- // Identifies a file-type absolute URI.
- private static final String SCHEME_FILE = "file";
- private static final String SCHEME_JAR = "jar";
-
- // Special segment values interpreted at resolve and resolve time.
- private static final String SEGMENT_EMPTY = "";
- private static final String SEGMENT_SELF = ".";
- private static final String SEGMENT_PARENT = "..";
- private static final String[] NO_SEGMENTS = new String[0];
-
- // Separators for parsing a URI string
- private static final char SCHEME_SEPARATOR = ':';
- private static final String AUTHORITY_SEPARATOR = "//";
- private static final char DEVICE_IDENTIFIER = ':';
- private static final char SEGMENT_SEPARATOR = '/';
- private static final char QUERY_SEPARATOR = '?';
- private static final char FRAGMENT_SEPARATOR = '#';
- private static final char USER_INFO_SEPARATOR = '@';
- private static final char PORT_SEPARATOR = ':';
- private static final char FILE_EXTENSION_SEPARATOR = '.';
- private static final char[] MAJOR_SEPARATORS = {
- SCHEME_SEPARATOR, SEGMENT_SEPARATOR, QUERY_SEPARATOR, FRAGMENT_SEPARATOR };
- private static final char[] SEGMENT_END = {
- SEGMENT_SEPARATOR, QUERY_SEPARATOR, FRAGMENT_SEPARATOR };
-
- /**
- * Static factory method for a generic, non-hierarchical URI. There is no
- * concept of a relative non-hierarchical URI; such an object cannot be
- * created.
- *
- * @exception java.lang.IllegalArgumentException if <code>scheme</code> is
- * null, or if <code>scheme</code>, <code>opaquePart</code>, or
- * <code>fragment</code> is not valid according to {@link #validScheme},
- * {@link #validOpaquePart}, or {@link #validFragment}, respectively.
- */
- public static URI createGenericURI(String scheme, String opaquePart,
- String fragment)
- {
- if (scheme == null)
- {
- throw new IllegalArgumentException("relative non-hierarchical URI");
- }
-
- return new URI(false, scheme, opaquePart, null, false, NO_SEGMENTS,
- null, fragment);
- }
-
- /**
- * Static factory method for a hierarchical URI with no path. The
- * URI will be relative if <code>scheme</code> is non-null, and absolute
- * otherwise. An absolute URI with no path requires a non-null
- * <code>authority</code> and/or <code>device</code>.
- *
- * @exception java.lang.IllegalArgumentException if <code>scheme</code> is
- * non-null while <code>authority</code> and <code>device</code> are null,
- * or if <code>scheme</code>, <code>authority</code>, <code>device</code>,
- * <code>query</code>, or <code>fragment</code> is not valid according to
- * {@link #validScheme}, {@link #validAuthority}, {@link #validDevice},
- * {@link #validQuery}, or {@link #validFragment}, respectively.
- */
- public static URI createHierarchicalURI(String scheme, String authority,
- String device, String query,
- String fragment)
- {
- if (scheme != null && authority == null && device == null)
- {
- throw new IllegalArgumentException(
- "absolute hierarchical URI without authority, device, path");
- }
-
- return new URI(true, scheme, authority, device, false, NO_SEGMENTS,
- query, fragment);
- }
-
- /**
- * Static factory method for a hierarchical URI with absolute path.
- * The URI will be relative if <code>scheme</code> is non-null, and
- * absolute otherwise.
- *
- * @param segments an array of non-null strings, each representing one
- * segment of the path. As an absolute path, it is automatically
- * preceeded by a <code>/</code> separator. If desired, a trailing
- * separator should be represented by an empty-string segment as the last
- * element of the array.
- *
- * @exception java.lang.IllegalArgumentException if <code>scheme</code>,
- * <code>authority</code>, <code>device</code>, <code>segments</code>,
- * <code>query</code>, or <code>fragment</code> is not valid according to
- * {@link #validScheme}, {@link #validAuthority}, {@link #validDevice},
- * {@link #validSegments}, {@link #validQuery}, or {@link #validFragment},
- * respectively.
- */
- public static URI createHierarchicalURI(String scheme, String authority,
- String device, String[] segments,
- String query, String fragment)
- {
- return new URI(true, scheme, authority, device, true, fix(segments),
- query, fragment);
- }
-
- /**
- * Static factory method for a relative hierarchical URI with relative
- * path.
- *
- * @param segments an array of non-null strings, each representing one
- * segment of the path. A trailing separator is represented by an
- * empty-string segment at the end of the array.
- *
- * @exception java.lang.IllegalArgumentException if <code>segments</code>,
- * <code>query</code>, or <code>fragment</code> is not valid according to
- * {@link #validSegments}, {@link #validQuery}, or {@link #validFragment},
- * respectively.
- */
- public static URI createHierarchicalURI(String[] segments, String query,
- String fragment)
- {
- return new URI(true, null, null, null, false, fix(segments), query,
- fragment);
- }
-
- // Converts null to length-zero array, and clones array to ensure
- // immutability.
- private static String[] fix(String[] segments)
- {
- return segments == null ? NO_SEGMENTS : (String[])segments.clone();
- }
-
- /**
- * Static factory method based on parsing a URI string, with
- * <a href="#device_explaination">explicit device support</a> enabled.
- * The specified string is parsed as described in <a
- * href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>, and an
- * appropriate <code>URI</code> is created and returned. Note that
- * validity testing is not as strict as in the RFC; essentially, only
- * separator characters are considered. So, for example, non-Latin
- * alphabet characters appearing in the scheme would not be considered an
- * error.
- *
- * @exception java.lang.IllegalArgumentException if any component parsed
- * from <code>uri</code> is not valid according to {@link #validScheme},
- * {@link #validOpaquePart}, {@link #validAuthority}, {@link
- * #validDevice}, {@link #validSegments}, {@link #validQuery}, or {@link
- * #validFragment}, as appropriate.
- */
- public static URI createURI(String uri)
- {
- return parseIntoURI(uri);
- }
-
- /**
- * Static factory method based on parsing a URI string, with
- * <a href="#device_explaination">explicit device support</a> enabled.
- * Note that validity testing is not a strict as in the RFC; essentially,
- * only separator characters are considered. So, for example, non-Latin
- * alphabet characters appearing in the scheme would not be considered an
- * error.
- * @exception java.lang.IllegalArgumentException if any component parsed
- * from <code>uri</code> is not valid according to {@link #validScheme},
- * {@link #validOpaquePart}, {@link #validAuthority}, {@link
- * #validDevice}, {@link #validSegments}, {@link #validQuery}, or {@link
- * #validFragment}, as appropriate.
- * @deprecated
- */
- public static URI createDeviceURI(String uri)
- {
- return parseIntoURI(uri);
- }
-
- // String-parsing implementation.
- private static URI parseIntoURI(String uri)
- {
- boolean hierarchical = true;
- String scheme = null;
- String authority = null;
- String device = null;
- boolean absolutePath = false;
- String[] segments = NO_SEGMENTS;
- String query = null;
- String fragment = null;
-
- int i = 0;
- int j = findSeparator(uri, i, MAJOR_SEPARATORS);
-
- if (j < uri.length() && uri.charAt(j) == SCHEME_SEPARATOR)
- {
- scheme = uri.substring(i, j);
- i = j + 1;
- }
-
- if (uri.startsWith(AUTHORITY_SEPARATOR, i))
- {
- i += AUTHORITY_SEPARATOR.length();
- j = findSeparator(uri, i, SEGMENT_END);
- authority = uri.substring(i, j);
- i = j;
- }
- else if (scheme != null &&
- (i == uri.length() ||
- uri.charAt(i) != SEGMENT_SEPARATOR &&
- !(scheme.equalsIgnoreCase(SCHEME_FILE) || scheme.equalsIgnoreCase(SCHEME_JAR))))
- {
- hierarchical = false;
- j = findSeparator(uri, i, new char[] { FRAGMENT_SEPARATOR });
- authority = uri.substring(i, j);
- i = j;
- }
-
- if (i < uri.length() &&
- uri.charAt(i) == SEGMENT_SEPARATOR)
- {
- j = findSeparator(uri, i + 1, SEGMENT_END);
- String s = uri.substring(i + 1, j);
-
- if (s.length() > 0 && s.charAt(s.length() - 1) == DEVICE_IDENTIFIER)
- {
- device = s;
- i = j;
- }
- }
-
- if (i < uri.length() && uri.charAt(i) == SEGMENT_SEPARATOR)
- {
- i++;
- absolutePath = true;
- }
-
- if (segmentsRemain(uri, i))
- {
- List segmentList = new ArrayList();
-
- while (segmentsRemain(uri, i))
- {
- j = findSeparator(uri, i, SEGMENT_END);
- segmentList.add(uri.substring(i, j));
- i = j;
-
- if (i < uri.length() && uri.charAt(i) == SEGMENT_SEPARATOR)
- {
- if (!segmentsRemain(uri, ++i)) segmentList.add(SEGMENT_EMPTY);
- }
- }
- segments = new String[segmentList.size()];
- segmentList.toArray(segments);
- }
-
- if (i < uri.length() && uri.charAt(i) == QUERY_SEPARATOR)
- {
- j = findSeparator(uri, ++i, new char[] { FRAGMENT_SEPARATOR });
- query = uri.substring(i, j);
- i = j;
- }
-
- if (i < uri.length()) // && uri.charAt(i) == FRAGMENT_SEPARATOR (implied)
- {
- fragment = uri.substring(++i);
- }
-
- return new URI(hierarchical, scheme, authority, device, absolutePath,
- segments, query, fragment);
- }
-
- /**
- * Static factory method based on parsing File path string, with
- * <a href="#device_explaination">explicit device support</a> enabled.
- * Note that validity testing is not a strict as in the RFC; essentially,
- * only separator characters are considered. So, for example, non-Latin
- * alphabet characters appearing in a path segment would not be considered an
- * error.
- * @exception java.lang.IllegalArgumentException if any component parsed
- * from <code>uri</code> is not valid according to {@link #validScheme},
- * {@link #validOpaquePart}, {@link #validAuthority}, {@link
- * #validDevice}, {@link #validSegments}, {@link #validQuery}, or {@link
- * #validFragment}, as appropriate.
- */
- public static URI createFileURI(String pathName)
- {
- File file = new File(pathName);
- String uri = File.separatorChar != '/' ? pathName.replace(File.separatorChar, SEGMENT_SEPARATOR) : pathName;
- if (file.isAbsolute())
- {
- URI result = parseIntoURI((uri.charAt(0) == SEGMENT_SEPARATOR ? "file:" : "file:/") + uri);
- return result;
- }
- else
- {
- URI result = parseIntoURI(uri);
- if (result.scheme() != null)
- {
- throw new IllegalArgumentException("invalid relative pathName: " + pathName);
- }
- return result;
- }
- }
-
- /**
- * Static factory method based on parsing a platform-relative path string.
- * The <code>pathName</code> must be of the form
- *<pre>
- * /project-name/path
- *</pre>
- * and the result will be of the form
- *<pre>
- * platform:/resource/project-name/path
- *</pre>
- * The leading separator of the path will be provided if not present.
- * This scheme supports relocatable projects in Eclipse and in stand-alone EMF.
- * @exception java.lang.IllegalArgumentException if any component parsed
- * from <code>uri</code> is not valid according to {@link #validScheme},
- * {@link #validOpaquePart}, {@link #validAuthority}, {@link
- * #validDevice}, {@link #validSegments}, {@link #validQuery}, or {@link
- * #validFragment}, as appropriate.
- * @see org.eclipse.core.runtime.Platform#resolve
- */
- public static URI createPlatformResourceURI(String pathName)
- {
- URI result = parseIntoURI((pathName.charAt(0) == SEGMENT_SEPARATOR ? "platform:/resource" : "platform:/resource/") + pathName);
- return result;
- }
-
- // Checks whether the string contains any more segments after the one that
- // starts at position i.
- private static boolean segmentsRemain(String uri, int i)
- {
- return i < uri.length() && uri.charAt(i) != QUERY_SEPARATOR &&
- uri.charAt(i) != FRAGMENT_SEPARATOR;
- }
-
- // Finds the next occurance of one of the characters specified in
- // separators in the given URI, beginning at index i. The index of the
- // first separator, or uri.length() if there is no such character, is
- // returned. Before searching, i is limited to be in the range
- // [0, uri.length()].
- private static int findSeparator(String uri, int i, char[] separators)
- {
- int len = uri.length();
- if (i >= len) return len;
-
- outerLoop: for (i = i > 0 ? i : 0; i < len; i++)
- {
- for (int j = 0, slen = separators.length; j < slen; j++)
- {
- if (uri.charAt(i) == separators[j]) break outerLoop;
- }
- }
- return i;
- }
-
- // Private constructor for use of static factory methods. Does validation
- // of each component, but assumes that the inter-component requirements
- // described in the factory doc-comments are all satisfied.
- private URI(boolean hierarchical, String scheme, String authority,
- String device, boolean absolutePath, String[] segments,
- String query, String fragment)
- {
- String name = null;
- String value = null;
-
- if (!validScheme(scheme))
- {
- throw new IllegalArgumentException("invalid scheme: " + scheme);
- }
- if (!hierarchical && !validOpaquePart(authority))
- {
- throw new IllegalArgumentException("invalid opaquePart: " + authority);
- }
- if (hierarchical && !validAuthority(authority))
- {
- throw new IllegalArgumentException("invalid authority: " + authority);
- }
- if (!validDevice(device))
- {
- throw new IllegalArgumentException("invalid device: " + device);
- }
- if (!validSegments(segments))
- {
- String s = segments == null ? "invalid segments: " + segments :
- "invalid segment: " + firstInvalidSegment(segments);
- throw new IllegalArgumentException(s);
- }
- if (!validQuery(query))
- {
- throw new IllegalArgumentException("invalid query: " + query);
- }
- if (!validFragment(fragment))
- {
- throw new IllegalArgumentException("invalid fragment: " + fragment);
- }
-
- int hashCode = 0;
- if (hierarchical)
- {
- ++hashCode;
- }
- if (absolutePath)
- {
- hashCode += 2;
- }
- if (scheme != null)
- {
- hashCode ^= scheme.hashCode();
- }
- if (authority != null)
- {
- hashCode ^= authority.hashCode();
- }
- if (device != null)
- {
- hashCode ^= device.hashCode();
- }
- if (query != null)
- {
- hashCode ^= query.hashCode();
- }
- if (fragment != null)
- {
- hashCode ^= fragment.hashCode();
- }
-
- for (int i = 0, len = segments.length; i < len; i++)
- {
- hashCode ^= segments[i].hashCode();
- }
-
- this.hashCode = hashCode;
- this.hierarchical = hierarchical;
- this.scheme = scheme;
- this.authority = authority;
- this.device = device;
- this.absolutePath = absolutePath;
- this.segments = segments;
- this.query = query;
- this.fragment = fragment;
- }
-
- // Searches the specified string for any of the specified target
- // characters, and if any occur, returns true; false otherwise.
- private static boolean contains(String s, char[] targets)
- {
- for (int i = 0, len = s.length(); i < len; i++)
- {
- for (int j = 0, tlen = targets.length; j < tlen; j++)
- {
- if (s.charAt(i) == targets[j]) return true;
- }
- }
- return false;
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * valid as the scheme component of a URI; <code>false</code> otherwise.
- *
- * <p>A valid scheme may be null or contain any characters except for the
- * following: <code>: / ? #</code>
- */
- public static boolean validScheme(String value)
- {
- return value == null || !contains(value, MAJOR_SEPARATORS);
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * valid as the opaque part component of a URI; <code>false</code>
- * otherwise.
- *
- * <p>A valid opaque part must be non-null, non-empty, and not contain the
- * <code>#</code> character. In addition, its first character must not be
- * <code>/</code>
- */
- public static boolean validOpaquePart(String value)
- {
- return value != null && value.indexOf(FRAGMENT_SEPARATOR) == -1 &&
- value.length() > 0 && value.charAt(0) != SEGMENT_SEPARATOR;
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * valid as the authority component of a URI; <code>false</code> otherwise.
- *
- * <p>A valid authority may be null or contain any characters except for
- * the following: <code>/ ? #</code>
- */
- public static boolean validAuthority(String value)
- {
- return value == null || !contains(value, SEGMENT_END);
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * valid as the device component of a URI; <code>false</code> otherwise.
- *
- * <p>A valid device may be null or non-empty, containing any characters
- * except for the following: <code>/ ? #</code> In addition, its last
- * character must be <code>:</code>
- */
- public static boolean validDevice(String value)
- {
- if (value == null) return true;
- int len = value.length();
- return len > 0 && value.charAt(len - 1) == DEVICE_IDENTIFIER &&
- !contains(value, SEGMENT_END);
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * a valid path segment of a URI; <code>false</code> otherwise.
- *
- * <p>A valid path segment must be non-null and not contain any of the
- * following characters: <code>/ ? #</code>
- */
- public static boolean validSegment(String value)
- {
- return value != null && !contains(value, SEGMENT_END);
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * a valid path segment array of a URI; <code>false</code> otherwise.
- *
- * <p>A valid path segment array must be non-null and contain only path
- * segements that are valid, according to {@link #validSegment}.
- */
- public static boolean validSegments(String[] value)
- {
- if (value == null) return false;
- for (int i = 0, len = value.length; i < len; i++)
- {
- if (!validSegment(value[i])) return false;
- }
- return true;
- }
-
- // Returns null if the specicied value is null or would be a valid path
- // segment array of a URI; otherwise, the value of the first invalid
- // segment.
- private static String firstInvalidSegment(String[] value)
- {
- if (value == null) return null;
- for (int i = 0, len = value.length; i < len; i++)
- {
- if (!validSegment(value[i])) return value[i];
- }
- return null;
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * valid as the query component of a URI; <code>false</code> otherwise.
- *
- * <p>A valid query may be null or contain any characters except for
- * <code>#</code>
- */
- public static boolean validQuery(String value)
- {
- return value == null || value.indexOf(FRAGMENT_SEPARATOR) == -1;
- }
-
- /**
- * Returns <code>true</code> if the specified <code>value</code> would be
- * valid as the fragment component of a URI; <code>false</code> otherwise.
- *
- * <p>A fragment is taken to be unconditionally valid.
- */
- public static boolean validFragment(String value)
- {
- return true;
- }
-
- /**
- * Returns <code>true</code> if this is a relative URI, or
- * <code>false</code> if it is an absolute URI.
- */
- public boolean isRelative()
- {
- return scheme == null;
- }
-
- /**
- * Returns <code>true</code> if this a a hierarchical URI, or
- * <code>false</code> if it is of the generic form.
- */
- public boolean isHierarchical()
- {
- return hierarchical;
- }
-
- /**
- * Returns <code>true</code> if this is a hierarcical URI with an authority
- * component; <code>false</code> otherwise.
- */
- public boolean hasAuthority()
- {
- return hierarchical && authority != null;
- }
-
- /**
- * Returns <code>true</code> if this is a non-hierarchical URI with an
- * opaque part component; <code>false</code> otherwise.
- */
- public boolean hasOpaquePart()
- {
- // note: hierarchical -> authority != null
- return !hierarchical;
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI with a device
- * component; <code>false</code> otherwise.
- */
- public boolean hasDevice()
- {
- // note: device != null -> hierarchical
- return device != null;
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI with an
- * absolute or relative path; <code>false</code> otherwise.
- */
- public boolean hasPath()
- {
- // note: (absolutePath || authority == null) -> hierarchical
- // (authority == null && device == null && !absolutePath) -> scheme == null
- return absolutePath || (authority == null && device == null);
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI with an
- * absolute path, or <code>false</code> if it is non-hierarchical, has no
- * path, or has a relative path.
- */
- public boolean hasAbsolutePath()
- {
- // note: absolutePath -> hierarchical
- return absolutePath;
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI with a relative
- * path, or <code>false</code> if it is non-hierarchical, has no path, or
- * has an absolute path.
- */
- public boolean hasRelativePath()
- {
- // note: authority == null -> hierarchical
- // (authority == null && device == null && !absolutePath) -> scheme == null
- return authority == null && device == null && !absolutePath;
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI with an empty
- * relative path; <code>false</code> otherwise.
- *
- * <p>Note that <code>!hasEmpty()</code> does <em>not</em> imply that this
- * URI has any path segments; however, <code>hasRelativePath &&
- * !hasEmptyPath()</code> does.
- */
- public boolean hasEmptyPath()
- {
- // note: authority == null -> hierarchical
- // (authority == null && device == null && !absolutePath) -> scheme == null
- return authority == null && device == null && !absolutePath &&
- segments.length == 0;
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI with a query
- * component; <code>false</code> otherwise.
- */
- public boolean hasQuery()
- {
- // note: query != null -> hierarchical
- return query != null;
- }
-
- /**
- * Returns <code>true</code> if this URI has a fragment component;
- * <code>false</code> otherwise.
- */
- public boolean hasFragment()
- {
- return fragment != null;
- }
-
- /**
- * Returns <code>true</code> if this is a current document reference; that
- * is, if it is a relative hierarchical URI with no authority, device or
- * query components, and no path segments; <code>false</code> is returned
- * otherwise.
- */
- public boolean isCurrentDocumentReference()
- {
- // note: authority == null -> hierarchical
- // (authority == null && device == null && !absolutePath) -> scheme == null
- return authority == null && device == null && !absolutePath &&
- segments.length == 0 && query == null;
- }
-
- /**
- * Returns <code>true</code> if this is a {@link
- * #isCurrentDocumentReference() current document reference} with no
- * fragment component; <code>false</code> otherwise.
- *
- * @see #isCurrentDocumentReference()
- */
- public boolean isEmpty()
- {
- // note: authority == null -> hierarchical
- // (authority == null && device == null && !absolutePath) -> scheme == null
- return authority == null && device == null && !absolutePath &&
- segments.length == 0 && query == null && fragment == null;
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI that may refer
- * directly to a locally accessible file. This is considered to be the
- * case for a file-scheme absolute URI, or for a relative URI with no query;
- * <code>false</code> is returned otherwise.
- */
- public boolean isFile()
- {
- return isHierarchical() &&
- ((isRelative() && !hasQuery()) || SCHEME_FILE.equalsIgnoreCase(scheme));
- }
-
- /**
- * Returns the hash code.
- */
- public int hashCode()
- {
- return hashCode;
- }
-
- /**
- * Returns <code>true</code> if <code>obj</code> is an instance of
- * <code>URI</code> equal to this one; <code>false</code> otherwise.
- *
- * <p>Equality is determined strictly by comparing components, not by
- * attempting to interpret what resource is being identified.
- */
- public boolean equals(Object obj)
- {
- if (this == obj) return true;
- if (!(obj instanceof URI)) return false;
- URI uri = (URI) obj;
-
- return hashCode == uri.hashCode() &&
- hierarchical == uri.isHierarchical() &&
- absolutePath == uri.hasAbsolutePath() &&
- equals(scheme, uri.scheme()) &&
- equals(authority, hierarchical ? uri.authority() : uri.opaquePart()) &&
- equals(device, uri.device()) &&
- equals(query, uri.query()) &&
- equals(fragment, uri.fragment()) &&
- segmentsEqual(uri);
- }
-
- // Tests whether this URI's path segment array is equal to that of the
- // given uri.
- private boolean segmentsEqual(URI uri)
- {
- if (segments.length != uri.segmentCount()) return false;
- for (int i = 0, len = segments.length; i < len; i++)
- {
- if (!segments[i].equals(uri.segment(i))) return false;
- }
- return true;
- }
-
- // Tests two objects for equality, tolerating nulls; null is considered
- // to be a valid value that is only equal to itself.
- private static boolean equals(Object o1, Object o2)
- {
- return o1 == null ? o2 == null : o1.equals(o2);
- }
-
- /**
- * If this is an absolute URI, returns the scheme component;
- * <code>null</code> otherwise.
- */
- public String scheme()
- {
- return scheme;
- }
-
- /**
- * If this is a non-hierarchical URI, returns the opaque part component;
- * <code>null</code> otherwise.
- */
- public String opaquePart()
- {
- return isHierarchical() ? null : authority;
- }
-
- /**
- * If this is a hierarchical URI with an authority component, returns it;
- * <code>null</code> otherwise.
- */
- public String authority()
- {
- return isHierarchical() ? authority : null;
- }
-
- /**
- * If this is a hierarchical URI with an authority component that has a
- * user info portion, returns it; <code>null</code> otherwise.
- */
- public String userInfo()
- {
- if (!hasAuthority()) return null;
-
- int i = authority.indexOf(USER_INFO_SEPARATOR);
- return i < 0 ? null : authority.substring(0, i);
- }
-
- /**
- * If this is a hierarchical URI with an authority component that has a
- * host portion, returns it; <code>null</code> otherwise.
- */
- public String host()
- {
- if (!hasAuthority()) return null;
-
- int i = authority.indexOf(USER_INFO_SEPARATOR);
- int j = authority.indexOf(PORT_SEPARATOR);
- return j < 0 ? authority.substring(i + 1) : authority.substring(i + 1, j);
- }
-
- /**
- * If this is a hierarchical URI with an authority component that has a
- * port portion, returns it; <code>null</code> otherwise.
- */
- public String port()
- {
- if (!hasAuthority()) return null;
-
- int i = authority.indexOf(PORT_SEPARATOR);
- return i < 0 ? null : authority.substring(i + 1);
- }
-
- /**
- * If this is a hierarchical URI with a device component, returns it;
- * <code>null</code> otherwise.
- */
- public String device()
- {
- return device;
- }
-
- /**
- * If this is a hierarchical URI with a path, returns an array containing
- * the segments of the path; an empty array otherwise. The leading
- * separator in an absolute path is not represented in this array, but a
- * trailing separator is represented by an empty-string segment as the
- * final element.
- */
- public String[] segments()
- {
- return (String[])segments.clone();
- }
-
- /**
- * Returns an unmodifiable list containing the same segments as the array
- * returned by {@link #segments()}.
- */
- public List segmentsList()
- {
- return Collections.unmodifiableList(Arrays.asList(segments));
- }
-
- /**
- * Returns the number of elements in the segment array that would be
- * returned by {@link #segments()}.
- */
- public int segmentCount()
- {
- return segments.length;
- }
-
- /**
- * Provides fast, indexed access to individual segments in the path
- * segment array.
- *
- * @exception java.lang.IndexOutOfBoundsException if <code>i < 0</code> or
- * <code>i >= segmentCount()</code>.
- */
- public String segment(int i)
- {
- return segments[i];
- }
-
- /**
- * Returns the last segment in the segment array, or <code>null</code>.
- */
- public String lastSegment()
- {
- int len = segments.length;
- if (len == 0) return null;
- return segments[len - 1];
- }
-
- /**
- * If this is a hierarchical URI with a path, returns a string
- * representation of the path; <code>null</code> otherwise. The path
- * consists of a leading segment separator character (a slash), if the
- * path is absolute, followed by the slash-separated path segments. If
- * this URI has a separate <a href="#device_explaination">device
- * component</a>, it is <em>not</em> included in the path. If it has a
- * device stored as a path segment, it is included.
- */
- public String path()
- {
- if (!hasPath()) return null;
-
- StringBuffer result = new StringBuffer();
- if (hasAbsolutePath()) result.append(SEGMENT_SEPARATOR);
-
- for (int i = 0, len = segments.length; i < len; i++)
- {
- if (i != 0) result.append(SEGMENT_SEPARATOR);
- result.append(segments[i]);
- }
- return result.toString();
- }
-
- /**
- * If this is a hierarchical URI with a path, returns a string
- * representation of the path, including the authority and the
- * <a href="#device_explaination">device component</a>;
- * <code>null</code> otherwise.
- * <p>The format of this string is
- * <pre>
- * //authority/device/pathSegment1/pathSegment2...
- *</pre>
- */
- public String devicePath()
- {
- if (!hasPath()) return null;
-
- StringBuffer result = new StringBuffer();
- if (hasAuthority())
- {
- result.append(SEGMENT_SEPARATOR);
- result.append(SEGMENT_SEPARATOR);
- result.append(authority);
-
- if (hasDevice()) result.append(SEGMENT_SEPARATOR);
- }
-
- if (hasDevice()) result.append(device);
- if (hasAbsolutePath()) result.append(SEGMENT_SEPARATOR);
-
- for (int i = 0, len = segments.length; i < len; i++)
- {
- if (i != 0) result.append(SEGMENT_SEPARATOR);
- result.append(segments[i]);
- }
- return result.toString();
- }
-
- /**
- * If this is a hierarchical URI with a query component, returns it;
- * <code>null</code> otherwise.
- */
- public String query()
- {
- return query;
- }
-
-
- /**
- * Returns the URI formed from this URI and the given query.
- *
- * @exception java.lang.IllegalArgumentException if
- * <code>query</code> is not a valid query (portion) according
- * to {@link #validQuery}.
- */
- public URI appendQuery(String query)
- {
- if (!validQuery(query))
- {
- throw new IllegalArgumentException(
- "invalid query portion: " + query);
- }
- return new URI(hierarchical, scheme, authority, device, absolutePath, segments, query, fragment);
- }
-
- /**
- * If this URI has a non-null {@link #query}, returns the URI
- * formed by removing it; this URI unchanged, otherwise.
- */
- public URI trimQuery()
- {
- if (query == null)
- {
- return this;
- }
- else
- {
- return new URI(hierarchical, scheme, authority, device, absolutePath, segments, null, fragment);
- }
- }
-
- /**
- * If this URI has a fragment component, returns it; <code>null</code>
- * otherwise.
- */
- public String fragment()
- {
- return fragment;
- }
-
- /**
- * Returns the URI formed from this URI and the given fragment.
- *
- * @exception java.lang.IllegalArgumentException if
- * <code>fragment</code> is not a valid fragment (portion) according
- * to {@link #validFragment}.
- */
- public URI appendFragment(String fragment)
- {
- if (!validFragment(fragment))
- {
- throw new IllegalArgumentException(
- "invalid fragment portion: " + fragment);
- }
- URI result = new URI(hierarchical, scheme, authority, device, absolutePath, segments, query, fragment);
- result.cachedTrimFragment = this;
- return result;
- }
-
- /**
- * If this URI has a non-null {@link #fragment}, returns the URI
- * formed by removing it; this URI unchanged, otherwise.
- */
- public URI trimFragment()
- {
- if (fragment == null)
- {
- return this;
- }
- else if (cachedTrimFragment == null)
- {
- cachedTrimFragment = new URI(hierarchical, scheme, authority, device, absolutePath, segments, query, null);
- }
-
- return cachedTrimFragment;
- }
-
- /**
- * Resolves this URI reference against a <code>base</code> absolute
- * hierarchical URI, returning the resulting absolute URI. If already
- * absolute, the URI itself is returned. URI resolution is described in
- * detail in section 5.2 of <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC
- * 2396</a>, "Resolving Relative References to Absolute Form."
- *
- * <p>During resolution, empty segments, self references ("."), and parent
- * references ("..") are interpreted, so that they can be removed from the
- * path. Step 6(g) gives a choice of how to handle the case where parent
- * references point to a path above the root: the offending segments can
- * be preserved or discarded. This method preserves them. To have them
- * discarded, please use the {@link #resolve(URI, boolean)} method.
- *
- * @exception java.lang.IllegalArgumentException if <code>base</code> is
- * non-hierarchical or is relative.
- */
- public URI resolve(URI base)
- {
- return resolve(base, true);
- }
-
- /**
- * Resolves this URI reference against a <code>base</code> absolute
- * hierarchical URI, returning the resulting absolute URI. If already
- * absolute, the URI itself is returned. URI resolution is described in
- * detail in section 5.2 of <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC
- * 2396</a>, "Resolving Relative References to Absolute Form."
- *
- * <p>During resultion, empty segments, self references ("."), and parent
- * references ("..") are interpreted, so that they can be removed from the
- * path. Step 6(g) gives a choice of how to handle the case where parent
- * references point to a path above the root: the offending segments can
- * be preserved or discarded. This method can do either.
- *
- * @param preserveRootParent <code>true</code> if segments refering to the
- * parent of the root path are to be preserved; <code>false</code> if they
- * are to be discarded.
- *
- * @exception java.lang.IllegalArgumentException if <code>base</code> is
- * non-hierarchical or is relative.
- */
- public URI resolve(URI base, boolean preserveRootParents)
- {
- if (!base.isHierarchical() || base.isRelative())
- {
- throw new IllegalArgumentException(
- "resolve against non-hierarchical or relative base");
- }
-
- // an absolute URI needs no resolving
- if (!isRelative()) return this;
-
- // note: isRelative() -> hierarchical
-
- String newAuthority = authority;
- String newDevice = device;
- boolean newAbsolutePath = absolutePath;
- String[] newSegments = segments;
- String newQuery = query;
- // note: it's okay for two URIs to share a segments array, since
- // neither will ever modify it
-
- if (authority == null)
- {
- // no authority: use base's
- newAuthority = base.authority();
-
- if (device == null)
- {
- // no device: use base's
- newDevice = base.device();
-
- if (hasEmptyPath() && query == null)
- {
- // current document reference: use base path and query
- newAbsolutePath = base.hasAbsolutePath();
- newSegments = base.segments();
- newQuery = base.query();
- }
- else if (hasRelativePath())
- {
- // relative path: merge with base and keep query (note: if the
- // base has no path and this a non-empty relative path, there is
- // an implied root in the resulting path)
- newAbsolutePath = base.hasAbsolutePath() || !hasEmptyPath();
- newSegments = newAbsolutePath ? mergePath(base, preserveRootParents)
- : NO_SEGMENTS;
- }
- // else absolute path: keep it and query
- }
- // else keep device, path, and query
- }
- // else keep authority, device, path, and query
-
- // always keep fragment, even if null, and use scheme from base
- return new URI(true, base.scheme(), newAuthority, newDevice,
- newAbsolutePath, newSegments, newQuery, fragment);
- }
-
- // Merges this URI's relative path with the base non-relative path. If
- // base has no path, treat it as the root absolute path, unless this has
- // no path either.
- private String[] mergePath(URI base, boolean preserveRootParents)
- {
- if (base.hasRelativePath())
- {
- throw new IllegalArgumentException("merge against relative path");
- }
- if (!hasRelativePath())
- {
- throw new IllegalStateException("merge non-relative path");
- }
-
- int baseSegmentCount = base.segmentCount();
- int segmentCount = segments.length;
- String[] stack = new String[baseSegmentCount + segmentCount];
- int sp = 0;
-
- // use a stack to accumulate segments of base, except for the last
- // (i.e. skip trailing separator and anything following it), and of
- // relative path
- for (int i = 0; i < baseSegmentCount - 1; i++)
- {
- sp = accumulate(stack, sp, base.segment(i), preserveRootParents);
- }
-
- for (int i = 0; i < segmentCount; i++)
- {
- sp = accumulate(stack, sp, segments[i], preserveRootParents);
- }
-
- // if the relative path is empty or ends in an empty segment, a parent
- // reference, or a self referenfce, add a trailing separator to a
- // non-empty path
- if (sp > 0 && (segmentCount == 0 ||
- SEGMENT_EMPTY.equals(segments[segmentCount - 1]) ||
- SEGMENT_PARENT.equals(segments[segmentCount - 1]) ||
- SEGMENT_SELF.equals(segments[segmentCount - 1])))
- {
- stack[sp++] = SEGMENT_EMPTY;
- }
-
- // return a correctly sized result
- String[] result = new String[sp];
- System.arraycopy(stack, 0, result, 0, sp);
- return result;
- }
-
- // Adds a segment to a stack, skipping empty segments and self references,
- // and interpreting parent references.
- private static int accumulate(String[] stack, int sp, String segment,
- boolean preserveRootParents)
- {
- if (SEGMENT_PARENT.equals(segment))
- {
- if (sp == 0)
- {
- // special care must be taken for a root's parent reference: it is
- // either ignored or the symbolic reference itself is pushed
- if (preserveRootParents) stack[sp++] = segment;
- }
- else
- {
- // unless we're already accumulating root parent references,
- // parent references simply pop the last segment descended
- if (SEGMENT_PARENT.equals(stack[sp - 1])) stack[sp++] = segment;
- else sp--;
- }
- }
- else if (!SEGMENT_EMPTY.equals(segment) && !SEGMENT_SELF.equals(segment))
- {
- // skip empty segments and self references; push everything else
- stack[sp++] = segment;
- }
- return sp;
- }
-
- /**
- * Finds the shortest relative or, if necessary, the absolute URI that,
- * when resolved against the given <code>base</code> absolute hierarchical
- * URI using {@link #resolve(URI)}, will yield this absolute URI.
- *
- * @exception java.lang.IllegalArgumentException if <code>base</code> is
- * non-hierarchical or is relative.
- * @exception java.lang.IllegalStateException if <code>this</code> is
- * relative.
- */
- public URI deresolve(URI base)
- {
- return deresolve(base, true, false, true);
- }
-
- /**
- * Finds an absolute URI that, when resolved against the given
- * <code>base</code> absolute hierarchical URI using {@link #resolve(URI,
- * boolean)}, will yield this absolute URI.
- *
- * @param preserveRootParents the boolean argument to <code>resolve(URI,
- * boolean)</code> for which the returned URI should resolve to this URI.
- * @param anyRelPath if <code>true</code>, the returned URI's path (if
- * any) will be relative, if possible. If <code>false</code>, the form of
- * the result's path will depend upon the next parameter.
- * @param shorterRelPath if <code>anyRelPath</code> is <code>false</code>
- * and this parameter is <code>true</code>, the returned URI's path (if
- * any) will be relative, if one can be found that is no longer (by number
- * of segments) than the absolute path. If both <code>anyRelPath</code>
- * and this parameter are <code>false</code>, it will be absolute.
- *
- * @exception java.lang.IllegalArgumentException if <code>base</code> is
- * non-hierarchical or is relative.
- * @exception java.lang.IllegalStateException if <code>this</code> is
- * relative.
- */
- public URI deresolve(URI base, boolean preserveRootParents,
- boolean anyRelPath, boolean shorterRelPath)
- {
- if (!base.isHierarchical() || base.isRelative())
- {
- throw new IllegalArgumentException(
- "deresolve against non-hierarchical or relative base");
- }
- if (isRelative())
- {
- throw new IllegalStateException("deresolve relative URI");
- }
-
- // note: these assertions imply that neither this nor the base URI has a
- // relative path; thus, both have either an absolute path or no path
-
- // different scheme: need complete, absolute URI
- if (!scheme.equals(base.scheme())) return this;
-
- // since base must be hierarchical, and since a non-hierarchical URI
- // must have both scheme and opaque part, the complete absolute URI is
- // needed to resolve to a non-hierarchical URI
- if (!isHierarchical()) return this;
-
- String newAuthority = authority;
- String newDevice = device;
- boolean newAbsolutePath = absolutePath;
- String[] newSegments = segments;
- String newQuery = query;
-
- if (equals(authority, base.authority()) &&
- (hasDevice() || hasPath() || (!base.hasDevice() && !base.hasPath())))
- {
- // matching authorities and no device or path removal
- newAuthority = null;
-
- if (equals(device, base.device()) && (hasPath() || !base.hasPath()))
- {
- // matching devices and no path removal
- newDevice = null;
-
- // exception if (!hasPath() && base.hasPath())
-
- if (!anyRelPath && !shorterRelPath)
- {
- // user rejects a relative path: keep absolute or no path
- }
- else if (hasPath() == base.hasPath() && segmentsEqual(base) &&
- equals(query, base.query()))
- {
- // current document reference: keep no path or query
- newAbsolutePath = false;
- newSegments = NO_SEGMENTS;
- newQuery = null;
- }
- else if (!hasPath() && !base.hasPath())
- {
- // no paths: keep query only
- newAbsolutePath = false;
- newSegments = NO_SEGMENTS;
- }
- // exception if (!hasAbsolutePath())
- else if (hasCollapsableSegments(preserveRootParents))
- {
- // path form demands an absolute path: keep it and query
- }
- else
- {
- // keep query and select relative or absolute path based on length
- String[] rel = findRelativePath(base, preserveRootParents);
- if (anyRelPath || segments.length > rel.length)
- {
- // user demands a relative path or the absolute path is longer
- newAbsolutePath = false;
- newSegments = rel;
- }
- // else keep shorter absolute path
- }
- }
- // else keep device, path, and query
- }
- // else keep authority, device, path, and query
-
- // always include fragment, even if null
- return new URI(true, null, newAuthority, newDevice, newAbsolutePath,
- newSegments, newQuery, fragment);
- }
-
- // Returns true if the non-relative path includes segments that would be
- // collapsed when resolving; false otherwise. If preserveRootParents is
- // true, collapsable segments include any empty segments, except for the
- // last segment, as well as and parent and self references. If
- // preserveRootsParents is false, parent references are not collapsable if
- // they are the first segment or preceeded only by other parent
- // references.
- private boolean hasCollapsableSegments(boolean preserveRootParents)
- {
- if (hasRelativePath())
- {
- throw new IllegalStateException("test collapsability of relative path");
- }
-
- for (int i = 0, len = segments.length; i < len; i++)
- {
- String segment = segments[i];
- if ((i < len - 1 && SEGMENT_EMPTY.equals(segment)) ||
- SEGMENT_SELF.equals(segment) ||
- SEGMENT_PARENT.equals(segment) && (
- !preserveRootParents || (
- i != 0 && !SEGMENT_PARENT.equals(segments[i - 1]))))
- {
- return true;
- }
- }
- return false;
- }
-
- // Returns the shortest relative path between the the non-relative path of
- // the given base and this absolute path. If the base has no path, it is
- // treated as the root absolute path.
- private String[] findRelativePath(URI base, boolean preserveRootParents)
- {
- if (base.hasRelativePath())
- {
- throw new IllegalArgumentException(
- "find relative path against base with relative path");
- }
- if (!hasAbsolutePath())
- {
- throw new IllegalArgumentException(
- "find relative path of non-absolute path");
- }
-
- // treat an empty base path as the root absolute path
- String[] startPath = base.collapseSegments(preserveRootParents);
- String[] endPath = segments;
-
- // drop last segment from base, as in resolving
- int startCount = startPath.length > 0 ? startPath.length - 1 : 0;
- int endCount = endPath.length;
-
- // index of first segment that is different between endPath and startPath
- int diff = 0;
-
- // if endPath is shorter than startPath, the last segment of endPath may
- // not be compared: because startPath has been collapsed and had its
- // last segment removed, all preceeding segments can be considered non-
- // empty and followed by a separator, while the last segment of endPath
- // will either be non-empty and not followed by a separator, or just empty
- for (int count = startCount < endCount ? startCount : endCount - 1;
- diff < count && startPath[diff].equals(endPath[diff]); diff++);
-
- int upCount = startCount - diff;
- int downCount = endCount - diff;
-
- // a single separator, possibly preceeded by some parent reference
- // segments, is redundant
- if (downCount == 1 && SEGMENT_EMPTY.equals(endPath[endCount - 1]))
- {
- downCount = 0;
- }
-
- // an empty path needs to be replaced by a single "." if there is no
- // query, to distinguish it from a current document reference
- if (upCount + downCount == 0)
- {
- if (query == null) return new String[] { SEGMENT_SELF };
- return NO_SEGMENTS;
- }
-
- // return a correctly sized result
- String[] result = new String[upCount + downCount];
- Arrays.fill(result, 0, upCount, SEGMENT_PARENT);
- System.arraycopy(endPath, diff, result, upCount, downCount);
- return result;
- }
-
- // Collapses non-ending empty segments, parent references, and self
- // references in a non-relative path, returning the same path that would
- // be produced from the base hierarchical URI as part of a resolve.
- String[] collapseSegments(boolean preserveRootParents)
- {
- if (hasRelativePath())
- {
- throw new IllegalStateException("collapse relative path");
- }
-
- if (!hasCollapsableSegments(preserveRootParents)) return segments();
-
- // use a stack to accumulate segments
- int segmentCount = segments.length;
- String[] stack = new String[segmentCount];
- int sp = 0;
-
- for (int i = 0; i < segmentCount; i++)
- {
- sp = accumulate(stack, sp, segments[i], preserveRootParents);
- }
-
- // if the path is non-empty and originally ended in an empty segment, a
- // parent reference, or a self reference, add a trailing separator
- if (sp > 0 && (SEGMENT_EMPTY.equals(segments[segmentCount - 1]) ||
- SEGMENT_PARENT.equals(segments[segmentCount - 1]) ||
- SEGMENT_SELF.equals(segments[segmentCount - 1])))
- {
- stack[sp++] = SEGMENT_EMPTY;
- }
-
- // return a correctly sized result
- String[] result = new String[sp];
- System.arraycopy(stack, 0, result, 0, sp);
- return result;
- }
-
- /**
- * Returns the string representation of this URI. For a generic,
- * non-hierarchical URI, this looks like:
- *
- * <pre>
- * scheme:opaquePart#fragment</pre>
- *
- * <p>For a hierarchical URI, it looks like:
- * <pre>
- * scheme://authority/device/pathSegment1/pathSegment2...?query#fragment</pre>
- *
- * <p>Of course, absent components and their separators will be omitted.
- */
- public String toString()
- {
- if (cachedToString == null)
- {
- StringBuffer result = new StringBuffer();
- if (!isRelative())
- {
- result.append(scheme);
- result.append(SCHEME_SEPARATOR);
- }
-
- if (isHierarchical())
- {
- if (hasAuthority())
- {
- result.append(AUTHORITY_SEPARATOR);
- result.append(authority);
- }
-
- if (hasDevice())
- {
- result.append(SEGMENT_SEPARATOR);
- result.append(device);
- }
-
- if (hasAbsolutePath()) result.append(SEGMENT_SEPARATOR);
-
- for (int i = 0, len = segments.length; i < len; i++)
- {
- if (i != 0) result.append(SEGMENT_SEPARATOR);
- result.append(segments[i]);
- }
-
- if (hasQuery())
- {
- result.append(QUERY_SEPARATOR);
- result.append(query);
- }
- }
- else
- {
- result.append(authority);
- }
-
- if (hasFragment())
- {
- result.append(FRAGMENT_SEPARATOR);
- result.append(fragment);
- }
- cachedToString = result.toString();
- }
- return cachedToString;
- }
-
- // Returns a string representation of this URI for debugging, explicitly
- // showing each of the components.
- String toString(boolean includeSimpleForm)
- {
- StringBuffer result = new StringBuffer();
- if (includeSimpleForm) result.append(toString());
- result.append("\n hierarchical: ");
- result.append(hierarchical);
- result.append("\n scheme: ");
- result.append(scheme);
- result.append("\n authority: ");
- result.append(authority);
- result.append("\n device: ");
- result.append(device);
- result.append("\n absolutePath: ");
- result.append(absolutePath);
- result.append("\n segments: ");
- if (segments.length == 0) result.append("<empty>");
- for (int i = 0, len = segments.length; i < len; i++)
- {
- if (i > 0) result.append("\n ");
- result.append(segments[i]);
- }
- result.append("\n query: ");
- result.append(query);
- result.append("\n fragment: ");
- result.append(fragment);
- return result.toString();
- }
-
- /**
- * If this URI may refer directly to a locally accessible file, as
- * determined by {@link #isFile()}, returns the URI formatted as a
- * pathname to that file; null otherwise.
- *
- * <p>The format of this string is
- * <pre>
- * //authority/device/pathSegment1/pathSegment2...</pre>
- *
- * <p>However, the character used as a separator is system-dependant and
- * obtained from {@link java.io.File#separatorChar}.
- */
- public String toFileString()
- {
- if (!isFile()) return null;
-
- StringBuffer result = new StringBuffer();
- char separator = File.separatorChar;
-
- if (hasAuthority())
- {
- result.append(separator);
- result.append(separator);
- result.append(authority);
-
- if (hasDevice()) result.append(separator);
- }
-
- if (hasDevice()) result.append(device);
- if (hasAbsolutePath()) result.append(separator);
-
- for (int i = 0, len = segments.length; i < len; i++)
- {
- if (i != 0) result.append(separator);
- result.append(segments[i]);
- }
- return result.toString();
- }
-
- /**
- * Returns the URI formed by appending the specified segment on to the end
- * of the path of this URI, if hierarchical; this URI unchanged,
- * otherwise. If this URI has an authority and/or device, but no path,
- * the segment becomes the first under the root in an absolute path.
- *
- * @exception java.lang.IllegalArgumentException if <code>segment</code>
- * is not a valid segment according to {@link #validSegment}.
- */
- public URI appendSegment(String segment)
- {
- if (!validSegment(segment))
- {
- throw new IllegalArgumentException("invalid segment: " + segment);
- }
-
- if (!isHierarchical()) return this;
-
- // absolute path or no path -> absolute path
- boolean newAbsolutePath = !hasRelativePath();
-
- int len = segments.length;
- String[] newSegments = new String[len + 1];
- System.arraycopy(segments, 0, newSegments, 0, len);
- newSegments[len] = segment;
-
- return new URI(true, scheme, authority, device, newAbsolutePath,
- newSegments, query, fragment);
- }
-
- /**
- * Returns the URI formed by appending the specified segments on to the
- * end of the path of this URI, if hierarchical; this URI unchanged,
- * otherwise. If this URI has an authority and/or device, but no path,
- * the segments are made to form an absolute path.
- *
- * @param segments an array of non-null strings, each representing one
- * segment of the path. If desired, a trailing separator should be
- * represented by an empty-string segment as the last element of the
- * array.
- *
- * @exception java.lang.IllegalArgumentException if <code>segments</code>
- * is not a valid segment array according to {@link #validSegments}.
- */
- public URI appendSegments(String[] segments)
- {
- if (!validSegments(segments))
- {
- String s = segments == null ? "invalid segments: " + segments :
- "invalid segment: " + firstInvalidSegment(segments);
- throw new IllegalArgumentException(s);
- }
-
- if (!isHierarchical()) return this;
-
- // absolute path or no path -> absolute path
- boolean newAbsolutePath = !hasRelativePath();
-
- int len = this.segments.length;
- int segmentsCount = segments.length;
- String[] newSegments = new String[len + segmentsCount];
- System.arraycopy(this.segments, 0, newSegments, 0, len);
- System.arraycopy(segments, 0, newSegments, len, segmentsCount);
-
- return new URI(true, scheme, authority, device, newAbsolutePath,
- newSegments, query, fragment);
- }
-
- /**
- * Returns the URI formed by trimming the specified number of segments
- * (including empty segments, such as one representing a trailing
- * separator) from the end of the path of this URI, if hierarchical;
- * otherwise, this URI is returned unchanged.
- *
- * <p>Note that if all segments are trimmed from an absolute path, the
- * root absolute path remains.
- *
- * @param i the number of segments to be trimmed in the returned URI. If
- * less than 1, this URI is returned unchanged; if equal to or greater
- * than the number of segments in this URI's path, all segments are
- * trimmed.
- */
- public URI trimSegments(int i)
- {
- if (!isHierarchical() || i < 1) return this;
-
- String[] newSegments = NO_SEGMENTS;
- int len = segments.length - i;
- if (len > 0)
- {
- newSegments = new String[len];
- System.arraycopy(segments, 0, newSegments, 0, len);
- }
- return new URI(true, scheme, authority, device, absolutePath,
- newSegments, query, fragment);
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI that has a path
- * that ends with a trailing separator; <code>false</code> otherwise.
- *
- * <p>A trailing separator is represented as an empty segment as the
- * last segment in the path; note that this definition does <em>not</em>
- * include the lone separator in the root absolute path.
- */
- public boolean hasTrailingPathSeparator()
- {
- return segments.length > 0 &&
- SEGMENT_EMPTY.equals(segments[segments.length - 1]);
- }
-
- /**
- * If this is a hierarchical URI whose path includes a file extension,
- * that file extension is returned; null otherwise. We define a file
- * extension as any string following the last period (".") in the final
- * path segment. If there is no path, the path ends in a trailing
- * separator, or the final segment contains no period, then we consider
- * there to be no file extension. If the final segment ends in a period,
- * then the file extension is an empty string.
- */
- public String fileExtension()
- {
- int len = segments.length;
- if (len == 0) return null;
-
- String lastSegment = segments[len - 1];
- int i = lastSegment.lastIndexOf(FILE_EXTENSION_SEPARATOR);
- return i < 0 ? null : lastSegment.substring(i + 1);
- }
-
- /**
- * Returns the URI formed by appending a period (".") followed by the
- * specified file extension to the last path segment of this URI, if it is
- * hierarchical with a non-empty path ending in a non-empty segment;
- * otherwise, this URI is returned unchanged.
-
- * <p>The extension is appended regardless of whether the segment already
- * contains an extension.
- *
- * @exception java.lang.IllegalArgumentException if
- * <code>fileExtension</code> is not a valid segment (portion) according
- * to {@link #validSegment}.
- */
- public URI appendFileExtension(String fileExtension)
- {
- if (!validSegment(fileExtension))
- {
- throw new IllegalArgumentException(
- "invalid segment portion: " + fileExtension);
- }
-
- int len = segments.length;
- if (len == 0) return this;
-
- String lastSegment = segments[len - 1];
- if (SEGMENT_EMPTY.equals(lastSegment)) return this;
- StringBuffer newLastSegment = new StringBuffer(lastSegment);
- newLastSegment.append(FILE_EXTENSION_SEPARATOR);
- newLastSegment.append(fileExtension);
-
- String[] newSegments = new String[len];
- System.arraycopy(segments, 0, newSegments, 0, len - 1);
- newSegments[len - 1] = newLastSegment.toString();
-
- // note: segments.length > 0 -> hierarchical
- return new URI(true, scheme, authority, device, absolutePath,
- newSegments, query, fragment);
- }
-
- /**
- * If this URI has a non-null {@link #fileExtension}, returns the URI
- * formed by removing it; this URI unchanged, otherwise.
- */
- public URI trimFileExtension()
- {
- int len = segments.length;
- if (len == 0) return this;
-
- String lastSegment = segments[len - 1];
- int i = lastSegment.lastIndexOf(FILE_EXTENSION_SEPARATOR);
- if (i < 0) return this;
-
- String newLastSegment = lastSegment.substring(0, i);
- String[] newSegments = new String[len];
- System.arraycopy(segments, 0, newSegments, 0, len - 1);
- newSegments[len - 1] = newLastSegment;
-
- // note: segments.length > 0 -> hierarchical
- return new URI(true, scheme, authority, device, absolutePath,
- newSegments, query, fragment);
- }
-
- /**
- * Returns <code>true</code> if this is a hierarchical URI that ends in a
- * slash; that is, it has a trailing path separator or is the root
- * absolute path, and has no query and no fragment; <code>false</code>
- * is returned otherwise.
- */
- public boolean isPrefix()
- {
- return hierarchical && query == null && fragment == null &&
- (hasTrailingPathSeparator() || (absolutePath && segments.length == 0));
- }
-
- /**
- * If this is a hierarchical URI reference and <code>oldPrefix</code> is a
- * prefix of it, this returns the URI formed by replacing it by
- * <code>newPrefix</code>; <code>null</code> otherwise.
- *
- * <p>In order to be a prefix, the <code>oldPrefix</code>'s
- * {@link #isPrefix} must return <code>true</code>, and it must match this
- * URI's scheme, authority, and device. Also, the paths must match, up to
- * prefix's end.
- *
- * @exception java.lang.IllegalArgumentException if either
- * <code>oldPrefix</code> or <code>newPrefix</code> is not a prefix URI
- * according to {@link #isPrefix}.
- */
- public URI replacePrefix(URI oldPrefix, URI newPrefix)
- {
- if (!oldPrefix.isPrefix() || !newPrefix.isPrefix())
- {
- String which = oldPrefix.isPrefix() ? "new" : "old";
- throw new IllegalArgumentException("non-prefix " + which + " value");
- }
-
- // Get what's left of the segments after trimming the prefix.
- String[] tailSegments = getTailSegments(oldPrefix);
- if (tailSegments == null) return null;
-
- // If the new prefix has segments, it is not the root absolute path,
- // and we need to drop the trailing empty segment and append the tail
- // segments.
- String[] mergedSegments = tailSegments;
- if (newPrefix.segmentCount() != 0)
- {
- int segmentsToKeep = newPrefix.segmentCount() - 1;
- mergedSegments = new String[segmentsToKeep + tailSegments.length];
- System.arraycopy(newPrefix.segments(), 0, mergedSegments, 0,
- segmentsToKeep);
-
- if (tailSegments.length != 0)
- {
- System.arraycopy(tailSegments, 0, mergedSegments, segmentsToKeep,
- tailSegments.length);
- }
- }
-
- return new URI(true, newPrefix.scheme(), newPrefix.authority(),
- newPrefix.device(), newPrefix.hasAbsolutePath(),
- mergedSegments, query, fragment);
- }
-
- // If this is a hierarchical URI reference and prefix is a prefix of it,
- // returns the portion of the path remaining after that prefix has been
- // trimmed; null otherwise.
- private String[] getTailSegments(URI prefix)
- {
- if (!prefix.isPrefix())
- {
- throw new IllegalArgumentException("non-prefix trim");
- }
-
- // Don't even consider it unless this is hierarchical and has scheme,
- // authority, device and path absoluteness equal to those of the prefix.
- if (!hierarchical ||
- !equals(scheme, prefix.scheme()) ||
- !equals(authority, prefix.authority()) ||
- !equals(device, prefix.device()) ||
- absolutePath != prefix.hasAbsolutePath())
- {
- return null;
- }
-
- // If the prefix has no segments, then it is the root absolute path, and
- // we know this is an absolute path, too.
- if (prefix.segmentCount() == 0) return segments;
-
- // This must have no fewer segments than the prefix. Since the prefix
- // is not the root absolute path, its last segment is empty; all others
- // must match.
- int i = 0;
- int segmentsToCompare = prefix.segmentCount() - 1;
- if (segments.length <= segmentsToCompare) return null;
-
- for (; i < segmentsToCompare; i++)
- {
- if (!segments[i].equals(prefix.segment(i))) return null;
- }
-
- // The prefix really is a prefix of this. If this has just one more,
- // empty segment, the paths are the same.
- if (i == segments.length - 1 && SEGMENT_EMPTY.equals(segments[i]))
- {
- return NO_SEGMENTS;
- }
-
- // Otherwise, the path needs only the remaining segments.
- String[] newSegments = new String[segments.length - i];
- System.arraycopy(segments, i, newSegments, 0, newSegments.length);
- return newSegments;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionDescriptor.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionDescriptor.java
deleted file mode 100644
index 1e34175..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionDescriptor.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver.internal;
-
-import java.util.List;
-
-import org.eclipse.wst.common.uriresolver.URIResolverExtension;
-
-
-/**
- * @author csalter
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-public class URIResolverExtensionDescriptor
-{
- protected URIResolverExtension resolver;
- //protected String projectNature;
- protected String fileType;
- protected String className;
- public List projectNatureIds;
- protected String resourceType;
- protected int stage = URIResolverExtensionRegistry.STAGE_POSTNORMALIZATION;
- protected ClassLoader classLoader;
- protected boolean error;
-
- public URIResolverExtensionDescriptor(String className, ClassLoader classLoader, List projectNatureIds, String resourceType, int stage)
- {
- this.className = className;
- this.classLoader = classLoader;
- this.projectNatureIds = projectNatureIds;
- this.resourceType = resourceType;
- this.stage = stage;
- }
-
- public URIResolverExtension getResolver()
- {
-
- if (resolver == null && className != null && !error)
- {
- try
- {
- Class theClass = classLoader != null ? classLoader.loadClass(className) : Class.forName(className);
- resolver = (URIResolverExtension) theClass.newInstance();
- }
- catch (Exception e)
- {
- error = true;
- e.printStackTrace();
- }
- }
- return resolver;
- }
-
- public boolean matches(String projectNatureId, String resourceType, int stage)
- {
- if(projectNatureIds.contains(projectNatureId))
- {
- return matches(this.resourceType, resourceType) && this.stage == stage;
- }
- return false;
- }
-
- public boolean matches(String a, String b)
- {
- return (a != null) ? a.equals(b) : a == b;
- }
-}
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionRegistry.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionRegistry.java
deleted file mode 100644
index 1e5bfd5..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionRegistry.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver.internal;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.common.uriresolver.URIResolverExtension;
-
-
-
-public class URIResolverExtensionRegistry {
- protected HashMap map = new HashMap();
- public static final int STAGE_PRENORMALIZATION = 1;
- public static final int STAGE_POSTNORMALIZATION = 2;
- protected final static String NULL_PROJECT_NATURE_ID = "";
-
- public URIResolverExtensionRegistry() {
- }
-
- public void put(String className, ClassLoader classLoader, List projectNatureIds, String resourceType, int stage) {
- if(projectNatureIds == null)
- projectNatureIds = new ArrayList();
- if(projectNatureIds.isEmpty())
- {
- projectNatureIds.add(NULL_PROJECT_NATURE_ID);
- }
- URIResolverExtensionDescriptor info = new URIResolverExtensionDescriptor(className, classLoader, projectNatureIds, resourceType, stage);
-
- Iterator idsIter = projectNatureIds.iterator();
- while(idsIter.hasNext())
- {
- String key = (String)idsIter.next();
-
- List list = (List)map.get(key);
- if (list == null)
- {
- list = new ArrayList();
- map.put(key, list);
- }
-
- list.add(info);
- }
- }
-
-
- /**
- * Return a list of URIResolverExtensionDescriptor objects that apply to this project.
- *
- */
- public List getExtensionDescriptors(IProject project)
- {
- List result = new ArrayList();
- for (Iterator i = map.keySet().iterator(); i.hasNext(); )
- {
- String key = (String)i.next();
- try{
- if (key == NULL_PROJECT_NATURE_ID ||
- project == null ||
- project.hasNature(key))
- {
- result.addAll((List)map.get(key));
- }
- }
- catch (CoreException e)
- {}
- }
- return result;
- }
-
- /**
- * Return a list of URIResolver objects that match the stage.
- *
- */
- public List getMatchingURIResolvers(List resolverInfoList, int stage)
- {
- List result = new ArrayList();
- for (Iterator i = resolverInfoList.iterator(); i.hasNext(); ){
- URIResolverExtensionDescriptor info = (URIResolverExtensionDescriptor)i.next();
- if (info.stage == stage)
- {
- Object resolver = info.getResolver();
- if (resolver != null)
- {
- result.add(resolver);
- }
- }
- }
- return result;
- }
-
- public URIResolverExtension get(String key) {
- URIResolverExtensionDescriptor info = (URIResolverExtensionDescriptor) map.get(key);
- return info != null ? info.getResolver() : null;
- }
-
-
-
- /*
- protected URIResolverExtensionDescriptor getMatchingURIResolverExtensionDescriptor(List list, String projectNatureId, String resourceType, int stage)
- {
- URIResolverExtensionDescriptor result = null;
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- URIResolverExtensionDescriptor info = (URIResolverExtensionDescriptor)i.next();
- if (info.matches(projectNatureId, resourceType, stage))
- {
- result = info;
- break;
- }
- }
- return result;
- }*/
-}
-
diff --git a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionRegistryReader.java b/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionRegistryReader.java
deleted file mode 100644
index 4da8b1a..0000000
--- a/plugins/org.eclipse.wst.common.uriresolver/src/org/eclipse/wst/common/uriresolver/internal/URIResolverExtensionRegistryReader.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.common.uriresolver.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.common.uriresolver.URIResolverPlugin;
-
-/**
- * @author csalter
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class URIResolverExtensionRegistryReader {
-
- protected static final String EXTENSION_POINT_ID = "resolverExtensions";
- protected static final String TAG_NAME = "resolverExtension";
- protected static final String ATT_ID = "id";
- protected static final String ELEM_PROJECT_NATURE_ID = "projectNature";
- protected static final String ATT_RESOURCE_TYPE = "resourceType";
- protected static final String ATT_CLASS = "class";
- protected static final String ATT_STAGE = "stage";
- protected static final String VAL_STAGE_PRE = "prenormalization";
- protected static final String VAL_STAGE_POST = "postnormalization";
- protected static final String ATT_VALUE = "value";
-
-
- protected URIResolverExtensionRegistry registry;
-
- public URIResolverExtensionRegistryReader(URIResolverExtensionRegistry registry) {
- this.registry = registry;
- }
-
- /**
- * read from plugin registry and parse it.
- */
- public void readRegistry() {
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(URIResolverPlugin.getInstance().getDescriptor().getUniqueIdentifier(), EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- readElement(elements[i]);
- }
- }
- }
-
- /**
- * readElement() - parse and deal with an extension like:
- *
- * <extension point="org.eclipse.wst.contentmodel.util_implementation">
- * <util_implementation class = org.eclipse.wst.baseutil.CMUtilImplementationImpl />
- * </extension>
- */
- protected void readElement(IConfigurationElement element) {
- if (element.getName().equals(TAG_NAME)) {
- //String id = element.getAttribute(ATT_ID);
- String className = element.getAttribute(ATT_CLASS);
- //String projectNatureId = element.getAttribute(ATT_PROJECT_NATURE_ID);
- String resourceType = element.getAttribute(ATT_RESOURCE_TYPE);
- String stage = element.getAttribute(ATT_STAGE);
- List projectNatureIds = new ArrayList();
- IConfigurationElement[] ids = element.getChildren(ELEM_PROJECT_NATURE_ID);
- int numids = ids.length;
- for(int i = 0; i < numids; i++)
- {
- String tempid = ids[i].getAttribute(ATT_VALUE);
-
- if(tempid != null)
- {
- projectNatureIds.add(tempid);
- }
- }
- if (className != null) {
- try {
- ClassLoader classLoader = element.getDeclaringExtension().getDeclaringPluginDescriptor().getPlugin().getClass().getClassLoader();
- int stageint = URIResolverExtensionRegistry.STAGE_POSTNORMALIZATION;
- if(stage.equalsIgnoreCase(VAL_STAGE_PRE))
- {
- stageint = URIResolverExtensionRegistry.STAGE_PRENORMALIZATION;
- }
- registry.put(className, classLoader, projectNatureIds, resourceType, stageint);
- } catch (Exception e) {
- }
- }
- }
- }
- }