public class CopyProjectOperation extends AbstractWorkspaceOperation
This class is intended to be instantiated and used by clients. It is not intended to be subclassed by clients.
Modifier and Type | Field and Description |
---|---|
protected IPath |
destination |
protected IPath[] |
destinationPaths |
protected boolean |
fCreateGroups |
protected boolean |
fCreateLinks |
protected String |
fRelativeToVariable |
protected ResourceDescription[] |
resourceDescriptions |
EXECUTE, quietCompute, REDO, resources, UNDO
Constructor and Description |
---|
CopyProjectOperation(IProject project,
String name,
URI location,
String label)
Create a CopyProjectOperation that copies the specified project and sets
its location to the specified location.
|
Modifier and Type | Method and Description |
---|---|
protected void |
appendDescriptiveText(StringBuffer text)
Append any descriptive text to the specified string buffer to be shown in
the receiver's
AbstractWorkspaceOperation.toString() text. |
protected ISchedulingRule |
computeCreateSchedulingRule()
Compute a scheduling rule for creating resources.
|
protected IStatus |
computeCreateStatus(boolean allowOverwrite)
Compute the status for creating resources from the descriptions.
|
protected ISchedulingRule |
computeDeleteSchedulingRule()
Compute a scheduling rule for deleting resources.
|
protected IStatus |
computeDeleteStatus()
Compute the status for deleting resources.
|
IStatus |
computeExecutionStatus(IProgressMonitor monitor)
Return a status indicating the projected outcome of executing the
receiver.
|
protected IStatus |
computeMoveOrCopyStatus()
Compute the status for moving or copying the resources.
|
IStatus |
computeRedoableStatus(IProgressMonitor monitor)
Return a status indicating the projected outcome of redoing the receiver.
|
IStatus |
computeUndoableStatus(IProgressMonitor monitor)
Return a status indicating the projected outcome of undoing the receiver.
|
protected void |
delete(IProgressMonitor monitor,
IAdaptable uiInfo,
boolean deleteContent)
Delete any resources known by this operation.
|
protected void |
doExecute(IProgressMonitor monitor,
IAdaptable uiInfo)
Perform the specific work involved in executing this operation.
|
protected void |
doUndo(IProgressMonitor monitor,
IAdaptable uiInfo)
Perform the specific work involved in undoing this operation.
|
protected IPath |
getDestinationPath(IResource resource,
int index)
Return the destination path that should be used to move or copy the
specified resource.
|
protected String |
getProposedName(IResource resource,
int index)
Return a string indicating the proposed name for the resource
|
protected boolean |
isDestinationPathValid(IResource resource,
int index)
Return a boolean indicating whether the proposed destination path for a
resource is valid.
|
protected void |
recreate(IProgressMonitor monitor,
IAdaptable uiInfo)
Recreate any resources known by this operation.
|
void |
setCreateLinks(boolean value) |
void |
setCreateVirtualFolders(boolean value) |
void |
setRelativeVariable(String value) |
protected void |
setResourceDescriptions(ResourceDescription[] descriptions)
Set the array of resource descriptions describing resources to be
restored when undoing or redoing this operation.
|
protected void |
setTargetResources(IResource[] targetResources)
Set the resources which are affected by this operation
|
protected boolean |
updateResourceChangeDescriptionFactory(IResourceChangeDescriptionFactory factory,
int operation)
Update the provided resource change description factory so it can
generate a resource delta describing the result of an undo or redo.
|
aboutToNotify, canExecute, canRedo, canUndo, execute, getAffectedObjects, getErrorStatus, getExecuteSchedulingRule, getRedoSchedulingRule, getShell, getUndoSchedulingRule, getWarningStatus, getWorkspace, getWorkspaceRuleFactory, isValid, markInvalid, redo, resourcesExist, resourcesIncludesProjects, runInBackground, setModelProviderIds, setQuietCompute, toString, undo
addContext, dispose, getContexts, getLabel, hasContext, removeContext, setLabel
protected IPath[] destinationPaths
protected IPath destination
protected boolean fCreateGroups
protected boolean fCreateLinks
protected String fRelativeToVariable
protected ResourceDescription[] resourceDescriptions
public CopyProjectOperation(IProject project, String name, URI location, String label)
project
- the project to be copiedname
- the name of the copylocation
- the location for the project's content, or null
if the default project location should be used.label
- the label of the operationprotected IStatus computeMoveOrCopyStatus()
OK
indicates that the copy or move is likely to be
successful. A status severity of ERROR
indicates that the
operation is no longer valid. Other status severities are open to
interpretation by the caller.
Note this method may be called on initial moving or copying of a
resource, or when a move or copy is undone or redone. Therefore, this
method should check conditions that can change over the life of the
operation, such as whether the file to moved or copied exists, and
whether the target location is still valid. One-time static checks should
typically be done by the caller so that the user is not continually
prompted or warned about conditions that were acceptable at the time of
original execution and do not change over time.protected void doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws CoreException
AbstractWorkspaceOperation
doExecute
in class AbstractWorkspaceOperation
monitor
- the progress monitor to use for the operationuiInfo
- the IAdaptable (or null
) provided by the
caller in order to supply UI information for prompting the
user if necessary. When this parameter is not
null
, it contains an adapter for the
org.eclipse.swt.widgets.Shell.classCoreException
- propagates any CoreExceptions thrown from the resources APIprotected void doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws CoreException
AbstractWorkspaceOperation
doUndo
in class AbstractWorkspaceOperation
monitor
- the progress monitor to use for the operationuiInfo
- the IAdaptable (or null
) provided by the
caller in order to supply UI information for prompting the
user if necessary. When this parameter is not
null
, it contains an adapter for the
org.eclipse.swt.widgets.Shell.classCoreException
- propagates any CoreExceptions thrown from the resources APIprotected boolean isDestinationPathValid(IResource resource, int index)
resource
- the resource whose path is to be checkedindex
- the integer index of the resource in the resource arrayprotected String getProposedName(IResource resource, int index)
resource
- the resource whose path is to be checkedindex
- the integer index of the resource in the resource arrayprotected boolean updateResourceChangeDescriptionFactory(IResourceChangeDescriptionFactory factory, int operation)
AbstractWorkspaceOperation
updateResourceChangeDescriptionFactory
in class AbstractWorkspaceOperation
factory
- the factory to updateoperation
- an integer indicating whether the change is part of an
execute, undo, or redopublic IStatus computeUndoableStatus(IProgressMonitor monitor)
AbstractWorkspaceOperation
IOperationApprover2
) who
wish to perform advanced validation of an operation before attempting to
undo it.
If an ERROR status is returned, the undo will not proceed and the user
notified if deemed necessary by the caller. The validity flag on the
operation should be marked as invalid. If an OK status is returned, the
undo will proceed. The caller must interpret any other returned status
severity, and may choose to prompt the user as to how to proceed.
If there are multiple conditions that result in an ambiguous status
severity, it is best for the implementor of this method to consult the
user as to how to proceed for each one, and return an OK or ERROR status
that accurately reflects the user's wishes, or to return a multi-status
that accurately describes all of the issues at hand, so that the caller
may potentially consult the user. (Note that the user should not be
consulted at all if a client has called AbstractWorkspaceOperation.setQuietCompute(boolean)
with a value of true
.)
This implementation computes the validity of undo by computing the
resource delta that would be generated on undo, and checking whether any
registered model providers are affected by the operation.computeUndoableStatus
in interface IAdvancedUndoableOperation
computeUndoableStatus
in class AbstractWorkspaceOperation
monitor
- the progress monitor to be used for computing the statusIAdvancedUndoableOperation.computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor)
,
AbstractWorkspaceOperation.setQuietCompute(boolean)
protected IPath getDestinationPath(IResource resource, int index)
resource
- the resource being moved or copiedindex
- the integer index of the resource in the resource arrayprotected void appendDescriptiveText(StringBuffer text)
AbstractWorkspaceOperation
AbstractWorkspaceOperation.toString()
text.
Note that this method is not intend to be subclassed by clients.
text
- the StringBuffer on which to append the textpublic IStatus computeExecutionStatus(IProgressMonitor monitor)
AbstractWorkspaceOperation
IOperationApprover2
) who
wish to perform advanced validation of an operation before attempting to
execute it.
If an ERROR status is returned, the operation will not proceed and the
user notified if deemed necessary by the caller. The validity flag on the
operation should be marked as invalid. If an OK status is returned, the
operation will proceed. The caller must interpret any other returned
status severity, and may choose to prompt the user as to how to proceed.
If there are multiple conditions that result in an ambiguous status
severity, it is best for the implementor of this method to consult the
user as to how to proceed for each one, and return an OK or ERROR status
that accurately reflects the user's wishes, or to return a multi-status
that accurately describes all of the issues at hand, so that the caller
may potentially consult the user. (Note that the user should not be
consulted at all if a client has called AbstractWorkspaceOperation.setQuietCompute(boolean)
with a value of true
.)
This implementation computes the validity of execution by computing the
resource delta that would be generated on execution, and checking whether
any registered model providers are affected by the operation.computeExecutionStatus
in interface IAdvancedUndoableOperation2
computeExecutionStatus
in class AbstractWorkspaceOperation
monitor
- the progress monitor to be used for computing the statusIAdvancedUndoableOperation.computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor)
,
AbstractWorkspaceOperation.setQuietCompute(boolean)
public IStatus computeRedoableStatus(IProgressMonitor monitor)
AbstractWorkspaceOperation
IOperationApprover2
) who
wish to perform advanced validation of an operation before attempting to
redo it.
If an ERROR status is returned, the redo will not proceed and the user
notified if deemed necessary by the caller. The validity flag on the
operation should be marked as invalid. If an OK status is returned, the
redo will proceed. The caller must interpret any other returned status
severity, and may choose to prompt the user as to how to proceed.
If there are multiple conditions that result in an ambiguous status
severity, it is best for the implementor of this method to consult the
user as to how to proceed for each one, and return an OK or ERROR status
that accurately reflects the user's wishes, or to return a multi-status
that accurately describes all of the issues at hand, so that the caller
may potentially consult the user. (Note that the user should not be
consulted at all if a client has called AbstractWorkspaceOperation.setQuietCompute(boolean)
with a value of true
.)
This implementation computes the validity of redo by computing the
resource delta that would be generated on redo, and checking whether any
registered model providers are affected by the operation.computeRedoableStatus
in interface IAdvancedUndoableOperation
computeRedoableStatus
in class AbstractWorkspaceOperation
monitor
- the progress monitor to be used for computing the statusIAdvancedUndoableOperation.computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor)
,
AbstractWorkspaceOperation.setQuietCompute(boolean)
public void setCreateVirtualFolders(boolean value)
public void setCreateLinks(boolean value)
public void setRelativeVariable(String value)
protected void delete(IProgressMonitor monitor, IAdaptable uiInfo, boolean deleteContent) throws CoreException
monitor
- the progress monitor to use for the operationuiInfo
- the IAdaptable (or null
) provided by the
caller in order to supply UI information for prompting the
user if necessary. When this parameter is not
null
, it contains an adapter for the
org.eclipse.swt.widgets.Shell.classdeleteContent
- true
if the content of any known projects
should be deleted along with the project. false
if project content should not be deleted.CoreException
- propagates any CoreExceptions thrown from the resources APIprotected void recreate(IProgressMonitor monitor, IAdaptable uiInfo) throws CoreException
monitor
- the progress monitor to use for the operationuiInfo
- the IAdaptable (or null
) provided by the
caller in order to supply UI information for prompting the
user if necessary. When this parameter is not
null
, it contains an adapter for the
org.eclipse.swt.widgets.Shell.classCoreException
- propagates any CoreExceptions thrown from the resources APIprotected IStatus computeCreateStatus(boolean allowOverwrite)
OK
indicates that the create is likely to be
successful. A status severity of ERROR
indicates that the
operation is no longer valid. Other status severities are open to
interpretation by the caller.
Note this method may be called on initial creation of a resource, or when
a create or delete operation is being undone or redone. Therefore, this
method should check conditions that can change over the life of the
operation, such as the existence of the information needed to carry out
the operation. One-time static checks should typically be done by the
caller (such as the action that creates the operation) so that the user
is not continually prompted or warned about conditions that were
acceptable at the time of original execution.allowOverwrite
- a boolean that specifies whether resource creation should be
allowed to overwrite an existent resource.protected IStatus computeDeleteStatus()
OK
indicates that the delete is likely to be successful. A
status severity of ERROR
indicates that the operation is
no longer valid. Other status severities are open to interpretation by
the caller.
Note this method may be called on initial deletion of a resource, or when
a create or delete operation is being undone or redone. Therefore, this
method should check conditions that can change over the life of the
operation, such as the existence of the resources to be deleted. One-time
static checks should typically be done by the caller (such as the action
that creates the operation) so that the user is not continually prompted
or warned about conditions that were acceptable at the time of original
execution.protected void setResourceDescriptions(ResourceDescription[] descriptions)
descriptions
- the array of resource descriptionsprotected ISchedulingRule computeCreateSchedulingRule()
protected ISchedulingRule computeDeleteSchedulingRule()
protected void setTargetResources(IResource[] targetResources)
AbstractWorkspaceOperation
setTargetResources
in class AbstractWorkspaceOperation
targetResources
- an array of resources
Copyright (c) 2000, 2013 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.