Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 56684 Details for
Bug 170061
Use ResourceDescription API from IDE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
170061 Use ResourceDescription API from IDE_patch.txt (text/plain), 69.70 KB, created by
Markus Keller
on 2007-01-10 05:04:09 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Markus Keller
Created:
2007-01-10 05:04:09 EST
Size:
69.70 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/MarkerDescription.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/MarkerDescription.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/MarkerDescription.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/MarkerDescription.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,108 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import java.util.Map; >- >-import org.eclipse.core.resources.IMarker; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >- >-/** >- * MarkerDescription is a lightweight description of a marker that can be used >- * to describe a marker to be created or updated. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public class MarkerDescription { >- String type; >- >- Map attributes; >- >- IResource resource; >- >- /** >- * >- * Create a marker description from the specified marker. >- * >- * @param marker >- * the marker to be described >- * @throws CoreException >- */ >- public MarkerDescription(IMarker marker) throws CoreException { >- this.type = marker.getType(); >- this.attributes = marker.getAttributes(); >- this.resource = marker.getResource(); >- >- } >- >- /** >- * Create a marker description from the specified marker type, attributes, >- * and resource. >- * >- * @param type >- * the type of marker to be created. >- * @param attributes >- * the attributes to be assigned to the marker >- * @param resource >- * the resource on which the marker should be created >- */ >- public MarkerDescription(String type, Map attributes, IResource resource) { >- this.type = type; >- this.attributes = attributes; >- this.resource = resource; >- } >- >- /** >- * Create a marker from the marker description. >- * >- * @return the created marker >- * @throws CoreException >- */ >- public IMarker createMarker() throws CoreException { >- IMarker marker = resource.createMarker(type); >- marker.setAttributes(attributes); >- return marker; >- } >- >- /** >- * Update an existing marker using the attributes in the marker description. >- * >- * @param marker >- * the marker to be updated >- * @throws CoreException >- */ >- public void updateMarker(IMarker marker) throws CoreException { >- marker.setAttributes(attributes); >- } >- >- /** >- * Return the resource associated with this marker. >- * >- * @return the resource associated with this marker >- */ >- public IResource getResource() { >- return resource; >- } >- >- /** >- * Return the marker type associated with this marker. >- * >- * @return the string marker type of this marker >- */ >- public String getType() { >- return type; >- } >-} >\ No newline at end of file >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/messages.properties >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/messages.properties >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/messages.properties >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/messages.properties 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,55 +0,0 @@ >-############################################################################### >-# Copyright (c) 2006 IBM Corporation and others. >-# All rights reserved. This program and the accompanying materials >-# are made available under the terms of the Eclipse Public License v1.0 >-# which accompanies this distribution, and is available at >-# http://www.eclipse.org/legal/epl-v10.html >-# >-# Contributors: >-# IBM Corporation - initial API and implementation >-############################################################################### >- >-AbstractWorkspaceOperation_ExecuteErrorTitle=Error while executing the "{0}" operation >-AbstractWorkspaceOperation_ErrorInvalidMessage=The operation {0} is no longer valid. >-AbstractWorkspaceOperation_GenericWarningMessage=The operation {0} may not complete as expected. >-AbstractWorkspaceOperation_RedoErrorTitle=Error while redoing the "{0}" operation >-AbstractWorkspaceOperation_UndoErrorTitle=Error while undoing the "{0}" operation >- >-AbstractWorkspaceOperation_SideEffectsWarningTitle=Side effects >-AbstractWorkspaceOperation_ExecuteSideEffectsWarningMessage=Executing "{0}" may have undesirable side effects. >-AbstractWorkspaceOperation_UndoSideEffectsWarningMessage=Undoing "{0}" may have undesirable side effects. >-AbstractWorkspaceOperation_RedoSideEffectsWarningMessage=Redoing "{0}" may have undesirable side effects. >- >-AbstractResourcesOperation_ResourcesDoNotExist=Cannot complete operation because resources no longer exist. >-AbstractResourcesOperation_ResourcesAlreadyExist=Cannot create or restore resource because it already exists. >-AbstractResourcesOperation_NotEnoughInfo=There is not enough information to complete the resource operation. >-AbstractResourcesOperation_InvalidRestoreInfo=There is not enough information to create or restore the resource. >-AbstractResourcesOperation_DeleteResourcesProgress=Deleting resources... >-AbstractResourcesOperation_CreateResourcesProgress=Creating resources... >-AbstractResourcesOperation_CopyingResourcesProgress=Copying resources... >-AbstractResourcesOperation_MovingResources=Moving resources... >-AbstractResourcesOperation_outOfSyncError = Resource is out of sync with the file system. Refresh and try again. >-AbstractResourcesOperation_outOfSyncQuestion = Resource ''{0}'' is out of sync with the file system. Do you want to delete it anyway? >-AbstractResourcesOperation_deletionMessageTitle = Problems deleting >-AbstractResourcesOperation_deletionExceptionMessage=Multiple problems occurred while deleting resources. >- >-AbstractCopyOrMoveResourcesOperation_SameNameOrLocation=Resource cannot be moved or copied to the same location and name. >-AbstractCopyOrMoveResourcesOperation_ResourceDoesNotExist=Resource no longer exists in the workspace. >-AbstractCopyOrMoveResourcesOperation_copyProjectProgress=Copying project... >-AbstractCopyOrMoveResourcesOperation_moveProjectProgress=Moving project... >- >-CopyResourcesOperation_NotAllowedDueToDataLoss=The original resources that were copied no longer exist. Undoing the copy is no longer valid, since data could be lost. >- >-ProjectDescription_NewProjectProgress=Creating new project... >-FileDescription_NewFileProgress=Creating new file... >-FileDescription_ContentsCouldNotBeRestored=Unexpected error. File contents could not be restored from local history during undo/redo. >-FileDescription_SavingUndoInfoProgress=Saving file info... >-FolderDescription_NewFolderProgress=Creating new folder... >-FolderDescription_SavingUndoInfoProgress=Saving folder info... >- >-MarkerOperation_ResourceDoesNotExist=Cannot complete operation because resource no longer exists. >-MarkerOperation_MarkerDoesNotExist=Cannot complete operation because marker no longer exists. >-MarkerOperation_NotEnoughInfo=There is not enough information to perform the marker operation. >-MarkerOperation_CreateProgress=Creating markers... >-MarkerOperation_DeleteProgress=Deleting markers... >-MarkerOperation_UpdateProgress= Updating markers... >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/UndoMessages.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/UndoMessages.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/UndoMessages.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/UndoMessages.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,74 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import org.eclipse.osgi.util.NLS; >- >-/** >- * UndoMessages is the class that handles the messages for performing workspace >- * undo and redo. >- * >- */ >-public class UndoMessages extends NLS { >- >- private static final String BUNDLE_NAME = "org.eclipse.ui.internal.ide.undo.messages"; //$NON-NLS-1$ >- >- static { >- // load message values from bundle file >- NLS.initializeMessages(BUNDLE_NAME, UndoMessages.class); >- } >- >- public static String AbstractWorkspaceOperation_ExecuteErrorTitle; >- public static String AbstractWorkspaceOperation_RedoErrorTitle; >- public static String AbstractWorkspaceOperation_UndoErrorTitle; >- public static String AbstractWorkspaceOperation_SideEffectsWarningTitle; >- public static String AbstractWorkspaceOperation_ExecuteSideEffectsWarningMessage; >- public static String AbstractWorkspaceOperation_UndoSideEffectsWarningMessage; >- public static String AbstractWorkspaceOperation_RedoSideEffectsWarningMessage; >- public static String AbstractWorkspaceOperation_ErrorInvalidMessage; >- public static String AbstractWorkspaceOperation_GenericWarningMessage; >- >- public static String AbstractResourcesOperation_ResourcesDoNotExist; >- public static String AbstractResourcesOperation_ResourcesAlreadyExist; >- public static String AbstractResourcesOperation_NotEnoughInfo; >- public static String AbstractResourcesOperation_InvalidRestoreInfo; >- public static String AbstractResourcesOperation_DeleteResourcesProgress; >- public static String AbstractResourcesOperation_CreateResourcesProgress; >- public static String AbstractResourcesOperation_CopyingResourcesProgress; >- public static String AbstractResourcesOperation_MovingResources; >- public static String AbstractResourcesOperation_outOfSyncError; >- public static String AbstractResourcesOperation_outOfSyncQuestion; >- public static String AbstractResourcesOperation_deletionMessageTitle; >- public static String AbstractResourcesOperation_deletionExceptionMessage; >- >- public static String AbstractCopyOrMoveResourcesOperation_SameNameOrLocation; >- public static String AbstractCopyOrMoveResourcesOperation_ResourceDoesNotExist; >- public static String AbstractCopyOrMoveResourcesOperation_copyProjectProgress; >- public static String AbstractCopyOrMoveResourcesOperation_moveProjectProgress; >- >- public static String CopyResourcesOperation_NotAllowedDueToDataLoss; >- >- public static String ProjectDescription_NewProjectProgress; >- public static String FileDescription_NewFileProgress; >- public static String FileDescription_SavingUndoInfoProgress; >- public static String FileDescription_ContentsCouldNotBeRestored; >- public static String FolderDescription_NewFolderProgress; >- public static String FolderDescription_SavingUndoInfoProgress; >- >- >- public static String MarkerOperation_ResourceDoesNotExist; >- public static String MarkerOperation_MarkerDoesNotExist; >- public static String MarkerOperation_NotEnoughInfo; >- public static String MarkerOperation_CreateProgress; >- public static String MarkerOperation_DeleteProgress; >- public static String MarkerOperation_UpdateProgress; >-} >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/package.html >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/package.html >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/package.html >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/package.html 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,16 +0,0 @@ >-<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> >-<html> >-<head> >- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> >- <meta name="Author" content="IBM"> >- <title>Package-level Javadoc</title> >-</head> >-<body> >- >-This package is a copy of org.eclipse.ui.internal.ide.undo, see >-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=166763">bug 166763</a>. >-<p> >-It will be removed shortly. >- >-</body> >-</html> >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/IFileContentDescription.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/IFileContentDescription.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/IFileContentDescription.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/IFileContentDescription.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,57 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import java.io.InputStream; >- >-import org.eclipse.core.runtime.CoreException; >- >-/** >- * IFileContentDescription is a description of a file's content. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public interface IFileContentDescription { >- /** >- * Returns an open input stream on the contents of the file described. The >- * client is responsible for closing the stream when finished. >- * >- * @return an input stream containing the contents of the file >- * @throws CoreException >- * any CoreException encountered retrieving the contents >- */ >- public InputStream getContents() throws CoreException; >- >- /** >- * Returns whether this file content description still exists. If it does >- * not exist, it will be unable to produce the contents. >- * >- * @return <code>true</code> if this description exists, and >- * <code>false</code> if it does not >- */ >- public boolean exists(); >- >- /** >- * Returns the name of a charset encoding to be used when decoding the >- * contents into characters. Returns <code>null</code> if a charset >- * has not been explicitly specified. >- * >- * @return the name of a charset, or <code>null</code> >- * @throws CoreException >- * any CoreException encountered while determining the character >- * set >- * >- */ >- public String getCharset() throws CoreException; >-} >\ No newline at end of file >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ProjectDescription.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ProjectDescription.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ProjectDescription.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ProjectDescription.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,140 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IProjectDescription; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.Assert; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.OperationCanceledException; >-import org.eclipse.core.runtime.SubProgressMonitor; >- >-/** >- * ProjectDescription is a lightweight description that describes a project to >- * be created. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public class ProjectDescription extends ContainerDescription { >- >- private IProjectDescription projectDescription; >- private boolean openOnCreate = true; >- >- /** >- * Create a project description from a specified project. >- * >- * @param project >- * The project to be described. The project must exist. >- */ >- public ProjectDescription(IProject project) { >- super(project); >- Assert.isLegal(project.exists()); >- if (project.isOpen()) { >- try { >- this.projectDescription = project.getDescription(); >- } catch (CoreException e) { >- // Eat this exception because it only occurs when the project >- // is not accessible and we have already checked this. We >- // don't want to propagate the CoreException into the >- // constructor >- // API. >- } >- } else { >- openOnCreate = false; >- } >- } >- >- /** >- * Create a project description from a specified IProjectDescription. Used >- * when the project does not yet exist. >- * >- * @param projectDescription >- * the project description for the future project >- */ >- public ProjectDescription(IProjectDescription projectDescription) { >- super(); >- this.projectDescription = projectDescription; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ContainerDescription#createResourceHandle() >- */ >- public IResource createResourceHandle() { >- return ResourcesPlugin.getWorkspace().getRoot().getProject(getName()); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#createExistentResourceFromHandle(org.eclipse.core.resources.IResource, >- * org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void createExistentResourceFromHandle(IResource resource, >- IProgressMonitor monitor) throws CoreException { >- Assert.isLegal(resource instanceof IProject); >- if (resource.exists()) { >- return; >- } >- IProject projectHandle = (IProject) resource; >- monitor.beginTask("", 200); //$NON-NLS-1$ >- monitor.setTaskName(UndoMessages.FolderDescription_NewFolderProgress); >- if (projectDescription == null) { >- projectHandle.create(new SubProgressMonitor(monitor, 100)); >- } else { >- projectHandle.create(projectDescription, new SubProgressMonitor( >- monitor, 100)); >- } >- >- if (monitor.isCanceled()) { >- throw new OperationCanceledException(); >- } >- if (openOnCreate) { >- projectHandle.open(IResource.BACKGROUND_REFRESH, >- new SubProgressMonitor(monitor, 100)); >- } >- monitor.done(); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ContainerDescription#getName() >- */ >- public String getName() { >- if (projectDescription != null) { >- return projectDescription.getName(); >- } >- return super.getName(); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#verifyExistence(boolean) >- */ >- public boolean verifyExistence(boolean checkMembers) { >- // We can only check members if the project is open. >- IProject projectHandle = (IProject) createResourceHandle(); >- if (projectHandle.isAccessible()) { >- return super.verifyExistence(checkMembers); >- } >- return super.verifyExistence(false); >- } >-} >\ No newline at end of file >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ResourceDescription.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ResourceDescription.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ResourceDescription.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ResourceDescription.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,227 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IFolder; >-import org.eclipse.core.resources.IMarker; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.ResourceAttributes; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IProgressMonitor; >- >-/** >- * ResourceDescription is a lightweight description that describes the common >- * attributes of a resource to be created. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public abstract class ResourceDescription { >- IContainer parent; >- >- long modificationStamp = IResource.NULL_STAMP; >- >- long localTimeStamp = IResource.NULL_STAMP; >- >- ResourceAttributes resourceAttributes; >- >- MarkerDescription[] markerDescriptions; >- >- /** >- * Create a resource description given the specified resource. The resource >- * is assumed to exist. >- * >- * @param resource >- * the resource from which a description should be created >- * @return the resource description >- */ >- public static ResourceDescription fromResource(IResource resource) { >- if (resource.getType() == IResource.PROJECT) { >- return new ProjectDescription((IProject) resource); >- } else if (resource.getType() == IResource.FOLDER) { >- return new FolderDescription((IFolder) resource); >- } else if (resource.getType() == IResource.FILE) { >- return new FileDescription((IFile) resource); >- } else { >- throw new IllegalArgumentException(); >- } >- } >- >- /** >- * Create a resource description with no initial attributes >- */ >- protected ResourceDescription() { >- super(); >- } >- >- /** >- * Create a resource description from the specified resource. >- * >- * @param resource >- * the resource to be described >- */ >- protected ResourceDescription(IResource resource) { >- super(); >- parent = resource.getParent(); >- if (resource.isAccessible()) { >- modificationStamp = resource.getModificationStamp(); >- localTimeStamp = resource.getLocalTimeStamp(); >- resourceAttributes = resource.getResourceAttributes(); >- try { >- IMarker[] markers = resource.findMarkers(null, true, >- IResource.DEPTH_INFINITE); >- markerDescriptions = new MarkerDescription[markers.length]; >- for (int i = 0; i < markers.length; i++) { >- markerDescriptions[i] = new MarkerDescription(markers[i]); >- } >- } catch (CoreException e) { >- // Eat this exception because it only occurs when the resource >- // does not exist and we have already checked this. >- // We do not want to throw exceptions on the simple constructor, >- // as no one has actually tried to do anything yet. >- } >- } >- } >- >- /** >- * Create a resource handle that can be used to create a resource from this >- * resource description. This handle can be used to create the actual >- * resource, or to describe the creation to a resource delta factory. >- * >- * @return the resource handle that can be used to create a resource from >- * this description >- */ >- public abstract IResource createResourceHandle(); >- >- /** >- * Get the name of this resource. >- * >- * @return the name of the Resource >- */ >- public abstract String getName(); >- >- /** >- * Create an existent resource from this resource description. >- * >- * @param monitor >- * the progress monitor to use >- * @return a resource that has the attributes of this resource description >- * @throws CoreException >- */ >- public IResource createResource(IProgressMonitor monitor) >- throws CoreException { >- IResource resource = createResourceHandle(); >- createExistentResourceFromHandle(resource, monitor); >- restoreResourceAttributes(resource); >- return resource; >- } >- >- /** >- * Given a resource handle, create an actual resource with the attributes of >- * the receiver resource description. >- * >- * @param resource >- * the resource handle >- * @param monitor >- * the progress monitor to be used when creating the resource >- * @throws CoreException >- */ >- public abstract void createExistentResourceFromHandle(IResource resource, >- IProgressMonitor monitor) throws CoreException; >- >- /** >- * Return a boolean indicating whether this resource description has enough >- * information to create a resource. >- * >- * @return <code>true</code> if the resource can be created, and >- * <code>false</code> if it does not have enough information >- */ >- public boolean isValid() { >- return parent == null || parent.exists(); >- } >- >- /** >- * Record the appropriate state of this resource description using >- * any available resource history. >- * >- * @param resource >- * the resource whose state is to be recorded. >- * @param monitor >- * the progress monitor to be used >- * @throws CoreException >- */ >- public abstract void recordStateFromHistory(IResource resource, >- IProgressMonitor monitor) throws CoreException; >- >- /** >- * Restore any saved attributed of the specified resource. This method is >- * called after the existent resource represented by the receiver has been >- * created. >- * >- * @param resource >- * the newly created resource >- * @throws CoreException >- */ >- protected void restoreResourceAttributes(IResource resource) throws CoreException { >- if (modificationStamp != IResource.NULL_STAMP) { >- resource.revertModificationStamp(modificationStamp); >- } >- if (localTimeStamp != IResource.NULL_STAMP) { >- resource.setLocalTimeStamp(localTimeStamp); >- } >- if (resourceAttributes != null) { >- resource.setResourceAttributes(resourceAttributes); >- } >- if (markerDescriptions != null) { >- for (int i = 0; i < markerDescriptions.length; i++) { >- markerDescriptions[i].resource = resource; >- markerDescriptions[i].createMarker(); >- } >- } >- } >- >- /* >- * Return the workspace. >- */ >- IWorkspace getWorkspace() { >- return ResourcesPlugin.getWorkspace(); >- } >- >- /** >- * Return a boolean indicating whether this description represents an >- * existent resource. >- * >- * @param checkMembers >- * Use <code>true</code> if members should also exist in order >- * for this description to be considered existent. A value of >- * <code>false</code> indicates that the existence of members >- * does not matter. >- * >- * @return a boolean indicating whether this description represents an >- * existent resource. >- */ >- public boolean verifyExistence(boolean checkMembers) { >- IContainer p = parent; >- if (p == null) { >- p = getWorkspace().getRoot(); >- } >- IResource handle = p.findMember(getName()); >- return handle != null; >- } >-} >\ No newline at end of file >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FileDescription.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FileDescription.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FileDescription.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FileDescription.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,252 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import java.io.ByteArrayInputStream; >-import java.io.InputStream; >-import java.net.URI; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IFileState; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IResourceStatus; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.runtime.Assert; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.OperationCanceledException; >-import org.eclipse.core.runtime.SubProgressMonitor; >- >-/** >- * FileDescription is a lightweight description that describes a file to be >- * created. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public class FileDescription extends ResourceDescription { >- >- String name; >- >- URI location; >- >- String charset; >- >- private IFileContentDescription fileContentDescription; >- >- /** >- * Create a FileDescription that can be used to later restore the given >- * file. The file typically already exists, but this constructor will not >- * fail if the file does not exist. >- * >- * @param file >- * the file to be restored. >- */ >- public FileDescription(IFile file) { >- super(file); >- this.name = file.getName(); >- try { >- this.charset = file.getCharset(false); >- } catch (CoreException e) { >- // we don't care, a null charset is fine. >- } >- if (file.isLinked()) { >- location = file.getLocationURI(); >- } >- >- } >- >- /** >- * Create a file description from the specified file handle. The handle does >- * not exist, so no information should be derived from it. If a location >- * path is specified, this file should represent a link to another location. >- * The content description describes any state that should be used when the >- * file resource is created. >- * >- * @param file >- * the file to be described >- * @param linkLocation >- * the location of the file's link, or <code>null</code> if the >- * file is not linked >- * @param fileContentDescription >- * the file content description that can be used to get >- * information about the file, such as its initial content >- */ >- public FileDescription(IFile file, URI linkLocation, >- IFileContentDescription fileContentDescription) { >- super(file); >- this.name = file.getName(); >- this.location = linkLocation; >- this.charset = null; >- this.fileContentDescription = fileContentDescription; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#recordStateFromHistory(org.eclipse.core.resources.IResource, >- * org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void recordStateFromHistory(IResource resource, >- IProgressMonitor monitor) throws CoreException { >- Assert.isLegal(resource.getType() == IResource.FILE); >- >- if (location != null) { >- // file is linked, no need to record any history >- return; >- } >- IFileState[] states = ((IFile) resource).getHistory(monitor); >- if (states.length > 0) { >- final IFileState state = getMatchingFileState(states); >- this.fileContentDescription = new IFileContentDescription() { >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#exists() >- */ >- public boolean exists() { >- return state.exists(); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#getContents() >- */ >- public InputStream getContents() throws CoreException { >- return state.getContents(); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#getCharset() >- */ >- public String getCharset() throws CoreException { >- return state.getCharset(); >- } >- }; >- } >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#createResourceHandle() >- */ >- public IResource createResourceHandle() { >- IWorkspaceRoot workspaceRoot = parent.getWorkspace().getRoot(); >- IPath fullPath = parent.getFullPath().append(name); >- return workspaceRoot.getFile(fullPath); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#createExistentResourceFromHandle(org.eclipse.core.resources.IResource, >- * org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void createExistentResourceFromHandle(IResource resource, >- IProgressMonitor monitor) throws CoreException { >- >- Assert.isLegal(resource instanceof IFile); >- if (resource.exists()) { >- return; >- } >- IFile fileHandle = (IFile) resource; >- monitor.beginTask("", 200); //$NON-NLS-1$ >- monitor.setTaskName(UndoMessages.FileDescription_NewFileProgress); >- try { >- if (monitor.isCanceled()) { >- throw new OperationCanceledException(); >- } >- if (location != null) { >- fileHandle.createLink(location, IResource.ALLOW_MISSING_LOCAL, >- new SubProgressMonitor(monitor, 200)); >- } else { >- InputStream contents = new ByteArrayInputStream( >- UndoMessages.FileDescription_ContentsCouldNotBeRestored >- .getBytes()); >- // Retrieve the contents and charset from the file content >- // description. Other file state attributes, such as timestamps, >- // have already been retrieved from the original IResource >- // object and are restored in the superclass. >- if (fileContentDescription != null >- && fileContentDescription.exists()) { >- contents = fileContentDescription.getContents(); >- // If the charset was explicitly recorded from the file >- // handle, >- // use it. But if it is null, get it from the >- // fileContentDescription. >- if (charset == null) { >- charset = fileContentDescription.getCharset(); >- } >- } >- fileHandle.create(contents, false, new SubProgressMonitor( >- monitor, 100)); >- fileHandle.setCharset(charset, new SubProgressMonitor(monitor, >- 100)); >- } >- if (monitor.isCanceled()) { >- throw new OperationCanceledException(); >- } >- } catch (CoreException e) { >- if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED) { >- fileHandle.refreshLocal(IResource.DEPTH_ZERO, null); >- } else { >- throw e; >- } >- } finally { >- monitor.done(); >- } >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#isValid() >- */ >- public boolean isValid() { >- if (location != null) { >- return super.isValid(); >- } >- return super.isValid() && fileContentDescription != null >- && fileContentDescription.exists(); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#getName() >- */ >- public String getName() { >- return name; >- } >- >- /* >- * Get the file state that matches this file description. The local time >- * stamp is used to try to find a matching file state. If none can be found, >- * the most recent copy of the file state is used. >- */ >- private IFileState getMatchingFileState(IFileState[] states) { >- for (int i = 0; i < states.length; i++) { >- if (localTimeStamp == states[i].getModificationTime()) { >- return states[i]; >- } >- } >- return states[0]; >- >- } >-} >\ No newline at end of file >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ContainerDescription.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ContainerDescription.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ContainerDescription.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/ContainerDescription.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,298 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import java.net.URI; >- >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IFolder; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.Assert; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.SubProgressMonitor; >- >-/** >- * ContainerDescription is a lightweight description that describes a container >- * to be created. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public abstract class ContainerDescription extends ResourceDescription { >- >- String name; >- >- URI location; >- >- String defaultCharSet; >- >- ResourceDescription[] members; >- >- /** >- * Create a container description from the specified container handle that >- * can be used to create the container. The returned ContainerDescription >- * should represent any non-existing parents in addition to the specified >- * container. >- * >- * @param container >- * the handle of the container to be described >- * @return a container description describing the container and any >- * non-existing parents. >- */ >- >- public static ContainerDescription fromContainer(IContainer container) { >- IPath fullPath = container.getFullPath(); >- ContainerDescription firstCreatedParent = null; >- ContainerDescription currentContainerDescription = null; >- >- // Does the container exist already? If so, then the parent exists and >- // we use the normal creation constructor. >- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >- IContainer currentContainer = (IContainer) root.findMember(fullPath); >- if (currentContainer != null) { >- return (ContainerDescription) ResourceDescription >- .fromResource(container); >- } >- >- // Create container descriptions for any uncreated parents in the given >- // path. >- currentContainer = root; >- for (int i = 0; i < fullPath.segmentCount(); i++) { >- String currentSegment = fullPath.segment(i); >- IResource resource = currentContainer.findMember(currentSegment); >- if (resource != null) { >- // parent already exists, no need to create a description for it >- currentContainer = (IContainer) resource; >- } else { >- if (i == 0) { >- // parent does not exist and it is a project >- firstCreatedParent = new ProjectDescription(root >- .getProject(currentSegment)); >- currentContainerDescription = firstCreatedParent; >- } else { >- IFolder folderHandle = currentContainer.getFolder(new Path( >- currentSegment)); >- ContainerDescription currentFolder = new FolderDescription( >- folderHandle); >- currentContainer = folderHandle; >- if (currentContainerDescription != null) { >- currentContainerDescription.addMember(currentFolder); >- } >- currentContainerDescription = currentFolder; >- if (firstCreatedParent == null) { >- firstCreatedParent = currentFolder; >- } >- } >- } >- } >- return firstCreatedParent; >- } >- >- /** >- * Create a ContainerDescription with no state. >- */ >- public ContainerDescription() { >- >- } >- >- /** >- * Create a ContainerDescription from the specified container handle. >- * Typically used when the container handle represents a resource that >- * actually exists, although it will not fail if the resource is >- * non-existent. >- * >- * @param container >- * the container to be described >- */ >- public ContainerDescription(IContainer container) { >- super(container); >- this.name = container.getName(); >- if (container.isLinked()) { >- this.location = container.getLocationURI(); >- } >- try { >- if (container.isAccessible()) { >- defaultCharSet = container.getDefaultCharset(false); >- IResource[] resourceMembers = container.members(); >- members = new ResourceDescription[resourceMembers.length]; >- for (int i = 0; i < resourceMembers.length; i++) { >- members[i] = ResourceDescription >- .fromResource(resourceMembers[i]); >- } >- } >- } catch (CoreException e) { >- // Eat this exception because it only occurs when the resource >- // does not exist and we have already checked this. >- // We do not want to throw exceptions on the simple constructor, as >- // no one has actually tried to do anything yet. >- } >- } >- >- /** >- * Create any child resources known by this container description. >- * >- * @param parentHandle >- * the handle of the created parent >- * @param monitor >- * the progress monitor to be used >- * @param ticks >- * the number of ticks allocated for creating children >- * @throws CoreException >- */ >- protected void createChildResources(IContainer parentHandle, >- IProgressMonitor monitor, int ticks) throws CoreException { >- >- // restore any children >- if (members != null && members.length > 0) { >- for (int i = 0; i < members.length; i++) { >- members[i].parent = parentHandle; >- members[i].createResource(new SubProgressMonitor(monitor, ticks >- / members.length)); >- } >- } >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#recordStateFromHistory(org.eclipse.core.resources.IResource, >- * org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void recordStateFromHistory(IResource resource, >- IProgressMonitor monitor) throws CoreException { >- monitor.beginTask( >- UndoMessages.FolderDescription_SavingUndoInfoProgress, 100); >- for (int i = 0; i < members.length; i++) { >- if (members[i] instanceof FileDescription) { >- IPath path = resource.getFullPath().append( >- ((FileDescription) members[i]).name); >- IFile fileHandle = resource.getWorkspace().getRoot().getFile( >- path); >- members[i].recordStateFromHistory(fileHandle, >- new SubProgressMonitor(monitor, 100 / members.length)); >- } else if (members[i] instanceof FolderDescription) { >- IPath path = resource.getFullPath().append( >- ((FolderDescription) members[i]).name); >- IFolder folderHandle = resource.getWorkspace().getRoot() >- .getFolder(path); >- members[i].recordStateFromHistory(folderHandle, >- new SubProgressMonitor(monitor, 100 / members.length)); >- } >- } >- monitor.done(); >- } >- >- /** >- * Return the name of the container described by this ContainerDescription. >- * >- * @return the name of the container. >- */ >- public String getName() { >- return name; >- } >- >- /** >- * Return the first folder found that has no child folders. >- * >- * @return the container description for the first child in the receiver >- * that is a leaf, or this container if there are no children. >- */ >- public ContainerDescription getFirstLeafFolder() { >- // If there are no members, this is a leaf >- if (members == null || members.length == 0) { >- return this; >- } >- // Traverse the members and find the first potential leaf >- for (int i = 0; i < members.length; i++) { >- if (members[i] instanceof ContainerDescription) { >- return ((ContainerDescription) members[i]).getFirstLeafFolder(); >- } >- } >- // No child folders were found, this is a leaf >- return this; >- } >- >- /** >- * Add the specified resource description as a member of this resource >- * description >- * >- * @param member >- * the resource description considered a member of this >- * container. >- */ >- public void addMember(ResourceDescription member) { >- if (members == null) { >- members = new ResourceDescription[] { member }; >- } else { >- ResourceDescription[] expandedMembers = new ResourceDescription[members.length + 1]; >- System.arraycopy(members, 0, expandedMembers, 0, members.length); >- expandedMembers[members.length] = member; >- members = expandedMembers; >- } >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#restoreResourceAttributes(org.eclipse.core.resources.IResource) >- */ >- protected void restoreResourceAttributes(IResource resource) >- throws CoreException { >- super.restoreResourceAttributes(resource); >- Assert.isLegal(resource instanceof IContainer); >- IContainer container = (IContainer) resource; >- if (defaultCharSet != null) { >- container.setDefaultCharset(defaultCharSet, null); >- } >- } >- >- /** >- * Set the location to which this container is linked. >- * >- * @param location >- * the location URI, or <code>null</code> if there is no link >- */ >- public void setLocation(URI location) { >- this.location = location; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#verifyExistence(boolean) >- */ >- public boolean verifyExistence(boolean checkMembers) { >- boolean existence = super.verifyExistence(checkMembers); >- if (existence) { >- if (checkMembers) { >- // restore any children >- if (members != null && members.length > 0) { >- for (int i = 0; i < members.length; i++) { >- if (!members[i].verifyExistence(checkMembers)) { >- return false; >- } >- } >- } >- } >- return true; >- } >- return false; >- } >-} >\ No newline at end of file >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/WorkspaceUndoMonitor.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/WorkspaceUndoMonitor.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/WorkspaceUndoMonitor.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/WorkspaceUndoMonitor.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,257 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.commands.operations.IAdvancedUndoableOperation; >-import org.eclipse.core.commands.operations.IAdvancedUndoableOperation2; >-import org.eclipse.core.commands.operations.IOperationHistory; >-import org.eclipse.core.commands.operations.IOperationHistoryListener; >-import org.eclipse.core.commands.operations.IUndoableOperation; >-import org.eclipse.core.commands.operations.OperationHistoryEvent; >-import org.eclipse.core.resources.IResourceChangeEvent; >-import org.eclipse.core.resources.IResourceChangeListener; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; >- >-/** >- * WorkspaceUndoMonitor monitors the workspace for resource changes and >- * periodically checks the undo history to make sure it is valid. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public class WorkspaceUndoMonitor { >- >- /** >- * Singleton instance. >- */ >- private static WorkspaceUndoMonitor instance; >- >- /** >- * Number of workspace changes that will cause validation of undo history >- */ >- private static int CHANGE_THRESHHOLD = 10; >- >- /** >- * Get the singleton instance of this class. >- * >- * @return the singleton instance of this class. >- */ >- public static WorkspaceUndoMonitor getInstance() { >- if (instance == null) { >- instance = new WorkspaceUndoMonitor(); >- } >- return instance; >- } >- >- /** >- * Number of workspace changes that have occurred since the last undoable >- * operation was executed, undone, or redone. >- */ >- private int numChanges = 0; >- >- /** >- * The IUndoableOperation in progress, or <code>null</code> if there is >- * none in progress. >- */ >- private IUndoableOperation operationInProgress = null; >- >- /** >- * Resource listener used to determine how often to validate the workspace >- * undo history. >- */ >- private IResourceChangeListener resourceListener; >- >- /** >- * Operation history listener used to determine whether there is an undoable >- * operation in progress. >- */ >- private IOperationHistoryListener historyListener; >- >- /** >- * Construct an instance. Should only be called by {@link #getInstance()} >- */ >- private WorkspaceUndoMonitor() { >- resourceListener = getResourceChangeListener(); >- ResourcesPlugin.getWorkspace().addResourceChangeListener( >- resourceListener); >- >- historyListener = getOperationHistoryListener(); >- getOperationHistory().addOperationHistoryListener(historyListener); >- >- } >- >- /** >- * Get a change listener for listening to resource changes. >- * >- * @return the resource change listeners >- */ >- private IResourceChangeListener getResourceChangeListener() { >- return new IResourceChangeListener() { >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) >- */ >- public void resourceChanged(IResourceChangeEvent event) { >- // If there is an operation in progress, this event is to be >- // ignored. >- if (operationInProgress != null) { >- return; >- } >- if (event.getType() == IResourceChangeEvent.POST_CHANGE >- || event.getType() == IResourceChangeEvent.POST_BUILD) { >- // For now, we consider any change a change worth tracking. >- // We can be more specific later if warranted. >- incrementChangeCount(); >- if (numChanges >= CHANGE_THRESHHOLD) { >- checkOperationHistory(); >- } >- } >- } >- }; >- } >- >- /** >- * Get a change listener for listening to operation history changes. >- * >- * @return the resource change listeners >- */ >- private IOperationHistoryListener getOperationHistoryListener() { >- return new IOperationHistoryListener() { >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.core.commands.operations.IOperationHistoryListener#historyNotification(org.eclipse.core.commands.operations.OperationHistoryEvent) >- */ >- public void historyNotification(OperationHistoryEvent event) { >- // We only care about events that have the workspace undo >- // context. >- if (!event.getOperation().hasContext( >- WorkspaceUndoUtil.getWorkspaceUndoContext())) { >- return; >- } >- switch (event.getEventType()) { >- case OperationHistoryEvent.ABOUT_TO_EXECUTE: >- case OperationHistoryEvent.ABOUT_TO_UNDO: >- case OperationHistoryEvent.ABOUT_TO_REDO: >- operationInProgress = event.getOperation(); >- break; >- case OperationHistoryEvent.DONE: >- case OperationHistoryEvent.UNDONE: >- case OperationHistoryEvent.REDONE: >- resetChangeCount(); >- operationInProgress = null; >- break; >- case OperationHistoryEvent.OPERATION_NOT_OK: >- operationInProgress = null; >- break; >- } >- } >- >- }; >- } >- >- /** >- * Shutdown the workspace undo monitor. Unhooks the listeners. >- */ >- public void shutdown() { >- if (resourceListener != null) { >- ResourcesPlugin.getWorkspace().removeResourceChangeListener( >- resourceListener); >- } >- if (historyListener != null) { >- getOperationHistory().removeOperationHistoryListener( >- historyListener); >- } >- } >- >- /** >- * Get the operation history. >- */ >- private IOperationHistory getOperationHistory() { >- return PlatformUI.getWorkbench().getOperationSupport() >- .getOperationHistory(); >- } >- >- /** >- * Check the pending undoable operation to see if it is still valid. >- */ >- private void checkOperationHistory() { >- IUndoableOperation currentOp = getOperationHistory().getUndoOperation( >- WorkspaceUndoUtil.getWorkspaceUndoContext()); >- // If there is no pending op, nothing to do. >- if (currentOp == null) { >- resetChangeCount(); >- return; >- } >- // First try the simple check >- if (!currentOp.canUndo()) { >- flushWorkspaceHistory(currentOp); >- return; >- } >- // Now try a more advanced check. If the undoable status is definitely >- // an error, flush the history. Anything less than an error status >- // should be left alone so that the user can be prompted as to what >- // should be done when an undo is actually attempted. >- if (currentOp instanceof IAdvancedUndoableOperation >- && currentOp instanceof IAdvancedUndoableOperation2) { >- ((IAdvancedUndoableOperation2) currentOp).setQuietCompute(true); >- IStatus status; >- try { >- status = ((IAdvancedUndoableOperation) currentOp) >- .computeUndoableStatus(null); >- } catch (ExecutionException e) { >- // Things are not really OK, but we do not want to >- // interrupt the user with notification of this problem. >- // For now, we pretend that everything is OK, knowing that >- // computation will occur again just before the user attempts to >- // undo this operation. >- status = Status.OK_STATUS; >- } >- ((IAdvancedUndoableOperation2) currentOp).setQuietCompute(false); >- if (status.getSeverity() == IStatus.ERROR) { >- flushWorkspaceHistory(currentOp); >- } >- } >- resetChangeCount(); >- } >- >- /** >- * Flush the undo and redo history for the workspace undo context. >- */ >- private void flushWorkspaceHistory(IUndoableOperation op) { >- getOperationHistory().dispose( >- WorkspaceUndoUtil.getWorkspaceUndoContext(), true, true, false); >- } >- >- /** >- * Reset the workspace change count >- */ >- private void resetChangeCount() { >- numChanges = 0; >- } >- >- /** >- * Increment the workspace change count >- */ >- private void incrementChangeCount() { >- numChanges++; >- } >-} >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FolderDescription.java >=================================================================== >RCS file: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FolderDescription.java >diff -N core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FolderDescription.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/undo/FolderDescription.java 5 Dec 2006 10:25:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,114 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.jdt.internal.corext.refactoring.changes.undo; >- >-import java.net.URI; >- >-import org.eclipse.core.resources.IFolder; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.runtime.Assert; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.OperationCanceledException; >-import org.eclipse.core.runtime.SubProgressMonitor; >- >-/** >- * FolderDescription is a lightweight description that describes a folder to be >- * created. >- * >- * This class is not intended to be instantiated or used by clients. >- * >- * @since 3.3 >- * >- */ >-public class FolderDescription extends ContainerDescription { >- >- /** >- * Create a FolderDescription from the specified folder handle. Typically >- * used when the folder handle represents a resource that actually exists, >- * although it will not fail if the resource is non-existent. >- * >- * @param folder >- * the folder to be described >- */ >- public FolderDescription(IFolder folder) { >- super(folder); >- } >- >- /** >- * Create a FolderDescription from the specified folder handle. If the >- * folder to be created should be linked to a different location, specify >- * the location. >- * >- * @param folder >- * the folder to be described >- * @param linkLocation >- * the location to which the folder is linked, or >- * <code>null</code> if it is not linked >- */ >- public FolderDescription(IFolder folder, URI linkLocation) { >- super(folder); >- this.name = folder.getName(); >- this.location = linkLocation; >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ContainerDescription#createResourceHandle() >- */ >- public IResource createResourceHandle() { >- IWorkspaceRoot workspaceRoot = getWorkspace().getRoot(); >- IPath folderPath = parent.getFullPath().append(name); >- return workspaceRoot.getFolder(folderPath); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#createExistentResourceFromHandle(org.eclipse.core.resources.IResource, >- * org.eclipse.core.runtime.IProgressMonitor) >- */ >- public void createExistentResourceFromHandle(IResource resource, >- IProgressMonitor monitor) throws CoreException { >- >- Assert.isLegal(resource instanceof IFolder); >- if (resource.exists()) { >- return; >- } >- IFolder folderHandle = (IFolder) resource; >- try { >- monitor.beginTask("", 200); //$NON-NLS-1$ >- monitor.setTaskName(UndoMessages.FolderDescription_NewFolderProgress); >- if (monitor.isCanceled()) { >- throw new OperationCanceledException(); >- } >- if (location != null) { >- folderHandle.createLink(location, >- IResource.ALLOW_MISSING_LOCAL, new SubProgressMonitor( >- monitor, 100)); >- } else { >- folderHandle.create(false, true, new SubProgressMonitor( >- monitor, 100)); >- } >- if (monitor.isCanceled()) { >- throw new OperationCanceledException(); >- } >- createChildResources(folderHandle, monitor, 100); >- >- } finally { >- monitor.done(); >- } >- } >-} >\ No newline at end of file >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeletePackageFragmentRootChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeletePackageFragmentRootChange.java,v >retrieving revision 1.15 >diff -u -r1.15 DeletePackageFragmentRootChange.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeletePackageFragmentRootChange.java 11 Dec 2006 15:49:14 -0000 1.15 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeletePackageFragmentRootChange.java 10 Jan 2007 09:56:47 -0000 >@@ -35,6 +35,8 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > >+import org.eclipse.ui.ide.undo.ResourceDescription; >+ > import org.eclipse.ltk.core.refactoring.Change; > import org.eclipse.ltk.core.refactoring.CompositeChange; > import org.eclipse.ltk.core.refactoring.NullChange; >@@ -48,7 +50,6 @@ > > import org.eclipse.jdt.internal.corext.Corext; > import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; >-import org.eclipse.jdt.internal.corext.refactoring.changes.undo.ResourceDescription; > import org.eclipse.jdt.internal.corext.refactoring.reorg.IPackageFragmentRootManipulationQuery; > import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; > import org.eclipse.jdt.internal.corext.util.Messages; >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFileChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFileChange.java,v >retrieving revision 1.21 >diff -u -r1.21 DeleteFileChange.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFileChange.java 11 Dec 2006 15:49:14 -0000 1.21 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFileChange.java 10 Jan 2007 09:56:47 -0000 >@@ -17,11 +17,12 @@ > > import org.eclipse.core.resources.IFile; > >+import org.eclipse.ui.ide.undo.ResourceDescription; >+ > import org.eclipse.ltk.core.refactoring.Change; > import org.eclipse.ltk.core.refactoring.RefactoringStatus; > > import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; >-import org.eclipse.jdt.internal.corext.refactoring.changes.undo.ResourceDescription; > import org.eclipse.jdt.internal.corext.util.Messages; > > public class DeleteFileChange extends AbstractDeleteChange { >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoablePackageDeleteChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoablePackageDeleteChange.java,v >retrieving revision 1.1 >diff -u -r1.1 UndoablePackageDeleteChange.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoablePackageDeleteChange.java 11 Dec 2006 15:49:14 -0000 1.1 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoablePackageDeleteChange.java 10 Jan 2007 09:56:47 -0000 >@@ -19,9 +19,9 @@ > > import org.eclipse.core.resources.IResource; > >-import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ui.ide.undo.ResourceDescription; > >-import org.eclipse.jdt.internal.corext.refactoring.changes.undo.ResourceDescription; >+import org.eclipse.ltk.core.refactoring.Change; > > public class UndoablePackageDeleteChange extends DynamicValidationStateChange { > >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java,v >retrieving revision 1.25 >diff -u -r1.25 DeleteSourceManipulationChange.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java 11 Dec 2006 15:49:14 -0000 1.25 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java 10 Jan 2007 09:56:47 -0000 >@@ -18,6 +18,8 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > >+import org.eclipse.ui.ide.undo.ResourceDescription; >+ > import org.eclipse.ltk.core.refactoring.Change; > import org.eclipse.ltk.core.refactoring.NullChange; > import org.eclipse.ltk.core.refactoring.RefactoringStatus; >@@ -29,7 +31,6 @@ > import org.eclipse.jdt.core.JavaCore; > > import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; >-import org.eclipse.jdt.internal.corext.refactoring.changes.undo.ResourceDescription; > import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; > import org.eclipse.jdt.internal.corext.util.Messages; > >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFolderChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFolderChange.java,v >retrieving revision 1.21 >diff -u -r1.21 DeleteFolderChange.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFolderChange.java 11 Dec 2006 15:49:14 -0000 1.21 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFolderChange.java 10 Jan 2007 09:56:47 -0000 >@@ -23,11 +23,12 @@ > import org.eclipse.core.resources.IResourceVisitor; > import org.eclipse.core.resources.ResourcesPlugin; > >+import org.eclipse.ui.ide.undo.ResourceDescription; >+ > import org.eclipse.ltk.core.refactoring.Change; > import org.eclipse.ltk.core.refactoring.RefactoringStatus; > > import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; >-import org.eclipse.jdt.internal.corext.refactoring.changes.undo.ResourceDescription; > import org.eclipse.jdt.internal.corext.util.Messages; > > public class DeleteFolderChange extends AbstractDeleteChange { >Index: core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoDeleteResourceChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoDeleteResourceChange.java,v >retrieving revision 1.1 >diff -u -r1.1 UndoDeleteResourceChange.java >--- core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoDeleteResourceChange.java 11 Dec 2006 15:49:14 -0000 1.1 >+++ core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/UndoDeleteResourceChange.java 10 Jan 2007 09:56:47 -0000 >@@ -19,11 +19,12 @@ > import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IResource; > >+import org.eclipse.ui.ide.undo.ResourceDescription; >+ > import org.eclipse.ltk.core.refactoring.Change; > import org.eclipse.ltk.core.refactoring.RefactoringStatus; > > import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; >-import org.eclipse.jdt.internal.corext.refactoring.changes.undo.ResourceDescription; > import org.eclipse.jdt.internal.corext.util.Messages; > > >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.46 >diff -u -r1.46 MANIFEST.MF >--- META-INF/MANIFEST.MF 20 Dec 2006 16:33:38 -0000 1.46 >+++ META-INF/MANIFEST.MF 10 Jan 2007 09:56:47 -0000 >@@ -18,7 +18,6 @@ > org.eclipse.jdt.internal.corext.refactoring.base;x-internal:=true, > org.eclipse.jdt.internal.corext.refactoring.binary;x-internal:=true, > org.eclipse.jdt.internal.corext.refactoring.changes;x-internal:=true, >- org.eclipse.jdt.internal.corext.refactoring.changes.undo;x-internal:=true, > org.eclipse.jdt.internal.corext.refactoring.code;x-internal:=true, > org.eclipse.jdt.internal.corext.refactoring.code.flow;x-internal:=true, > org.eclipse.jdt.internal.corext.refactoring.delegates;x-internal:=true,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 170061
: 56684