Package org.eclipse.ui.actions
Class CopyFilesAndFoldersOperation
java.lang.Object
org.eclipse.ui.actions.CopyFilesAndFoldersOperation
- Direct Known Subclasses:
MoveFilesAndFoldersOperation
Perform the copy of file and folder resources from the clipboard when paste
action is invoked.
This class may be instantiated; it is not intended to be subclassed.
- Restriction:
- This class is not intended to be subclassed by clients.
-
Constructor Summary
ConstructorDescriptionCreates a new operation initialized with a shell. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Returns whether this operation is able to perform on-the-fly auto-renaming of resources with name collisions.protected void
copy
(IResource[] resources, IPath destination, IProgressMonitor monitor) Deprecated.void
copyFiles
(String[] fileNames, IContainer destination) Copies the given files and folders to the destination.void
copyFiles
(URI[] uris, IContainer destination) Copies the given URIS and folders to the destination.void
copyFilesInCurrentThread
(String[] fileNames, IContainer destination, IProgressMonitor monitor) Copies the given files and folders to the destination without forking a new Thread or blocking using a WorkspaceModifyOperation.void
copyFilesInCurrentThread
(URI[] uris, IContainer destination, IProgressMonitor monitor) Copies the given files and folders to the destination without forking a new Thread or blocking using a WorkspaceModifyOperation.void
copyOrLinkFiles
(String[] fileNames, IContainer destination, int dropOperation) Depending on the 'Linked Resources' preferences it copies the given files and folders to the destination or creates links or shows a dialog that lets the user choose.copyResources
(IResource[] resources, IContainer destination) Copies the given resources to the destination.copyResourcesInCurrentThread
(IResource[] resources, IContainer destination, IProgressMonitor monitor) Copies the given resources to the destination in the current Thread without forking a new Thread or blocking using a WorkspaceModifyOperation.void
createVirtualFoldersAndLinks
(String[] fileNames, IContainer destination) Create virtual folders and links of the given files and folders to the destination.protected String
getDeepCheckQuestion
(IResource source) Returns the message for querying deep copy/move of a linked resource.protected IFile
Returns the resource either casted to or adapted to an IFile.protected File[]
Deprecated.As of 3.3, this method is no longer in use anywhere in this class and is only provided for backwards compatability with subclasses of the receiver.protected IFolder
Returns the resource either casted to or adapted to an IFolder.String[]
Returns the model provider ids that are known to the client that instantiated this operation.protected String
Returns the task title for this operation's progress dialog.protected String
Returns the message for this operation's problems dialog.protected String
Returns the title for this operation's problems dialog.protected AbstractWorkspaceOperation
getUndoableCopyOrMoveOperation
(IResource[] resources, IPath destinationPath) Returns an AbstractWorkspaceOperation suitable for performing the move or copy operation that will move or copy the given resources to the given destination path.protected boolean
Returns whether the source file in a destination collision will be validateEdited together with the collision itself.protected boolean
homogenousResources
(IResource source, IResource destination) Returns whether the given resources are either both linked or both unlinked.protected boolean
isMove()
Return whether the operation is a move or a copyvoid
linkFiles
(String[] fileNames, IContainer destination) Create links of the given files and folders to the destination.void
setCreateLinks
(boolean value) Set whether or not links will be created under the destination container.void
setModelProviderIds
(String[] modelProviderIds) Sets the model provider ids that are known to the client that instantiated this operation.void
setRelativeVariable
(String variable) Set a variable relative to which the links are createdvoid
setVirtualFolders
(boolean value) Set whether or not virtual folders and links will be created under the destination container.validateDestination
(IContainer destination, IResource[] sourceResources) Checks whether the destination is valid for copying the source resources.validateImportDestination
(IContainer destination, String[] sourceNames) Checks whether the destination is valid for copying the source files.
-
Constructor Details
-
CopyFilesAndFoldersOperation
Creates a new operation initialized with a shell.- Parameters:
shell
- parent shell for error dialogs
-
-
Method Details
-
canPerformAutoRename
protected boolean canPerformAutoRename()Returns whether this operation is able to perform on-the-fly auto-renaming of resources with name collisions.- Returns:
true
if auto-rename is supported, andfalse
otherwise
-
getDeepCheckQuestion
Returns the message for querying deep copy/move of a linked resource.- Parameters:
source
- resource the query is made for- Returns:
- the deep query message
-
copy
@Deprecated protected void copy(IResource[] resources, IPath destination, IProgressMonitor monitor) throws CoreException Deprecated.As of 3.3, the work is performed in the undoable operation created ingetUndoableCopyOrMoveOperation(IResource[], IPath)
Copies the resources to the given destination. This method is called recursively to merge folders during folder copy.- Parameters:
resources
- the resources to copydestination
- destination to which resources will be copiedmonitor
- a progress monitor for showing progress and for cancelation- Throws:
CoreException
-
copyResources
Copies the given resources to the destination. The current Thread is halted while the resources are copied using a WorkspaceModifyOperation. This method should be called from the UIThread.- Parameters:
resources
- the resources to copydestination
- destination to which resources will be copied- Returns:
- the resources which actually got copied
- See Also:
-
copyResourcesInCurrentThread
public IResource[] copyResourcesInCurrentThread(IResource[] resources, IContainer destination, IProgressMonitor monitor) Copies the given resources to the destination in the current Thread without forking a new Thread or blocking using a WorkspaceModifyOperation. It recommended that this method only be called from aWorkspaceJob
to avoid possible deadlock.- Parameters:
resources
- the resources to copydestination
- destination to which resources will be copiedmonitor
- the monitor that information will be sent to.- Returns:
- IResource[] the resulting
IResource
[] - Since:
- 3.2
- See Also:
-
isMove
protected boolean isMove()Return whether the operation is a move or a copy- Returns:
- whether the operation is a move or a copy
- Since:
- 3.2
-
copyFiles
Copies the given URIS and folders to the destination. The current Thread is halted while the resources are copied using a WorkspaceModifyOperation. This method should be called from the UI Thread.- Parameters:
uris
- the URIs to copydestination
- destination to which files will be copied- Since:
- 3.2
- See Also:
-
copyFilesInCurrentThread
Copies the given files and folders to the destination without forking a new Thread or blocking using a WorkspaceModifyOperation. It is recommended that this method only be called from aWorkspaceJob
to avoid possible deadlock.- Parameters:
uris
- the URIs to copydestination
- destination to which URIS will be copiedmonitor
- the monitor that information will be sent to.- Since:
- 3.2
- See Also:
-
copyOrLinkFiles
Depending on the 'Linked Resources' preferences it copies the given files and folders to the destination or creates links or shows a dialog that lets the user choose. The current thread is halted while the resources are copied using aWorkspaceModifyOperation
. This method should be called from the UI Thread.- Parameters:
fileNames
- names of the files to copydestination
- destination to which files will be copieddropOperation
- the drop operation (DND.DROP_NONE
,DND.DROP_MOVE
DND.DROP_COPY
,DND.DROP_LINK
,DND.DROP_DEFAULT
)- Since:
- 3.6
- See Also:
-
copyFiles
Copies the given files and folders to the destination. The current Thread is halted while the resources are copied using a WorkspaceModifyOperation. This method should be called from the UI Thread.- Parameters:
fileNames
- names of the files to copydestination
- destination to which files will be copied- Since:
- 3.2
- See Also:
-
copyFilesInCurrentThread
public void copyFilesInCurrentThread(String[] fileNames, IContainer destination, IProgressMonitor monitor) Copies the given files and folders to the destination without forking a new Thread or blocking using a WorkspaceModifyOperation. It is recommended that this method only be called from aWorkspaceJob
to avoid possible deadlock.- Parameters:
fileNames
- names of the files to copydestination
- destination to which files will be copiedmonitor
- the monitor that information will be sent to.- Since:
- 3.2
- See Also:
-
getFile
Returns the resource either casted to or adapted to an IFile.- Parameters:
resource
- resource to cast/adapt- Returns:
- the resource either casted to or adapted to an IFile.
null
if the resource does not adapt to IFile
-
getFiles
Deprecated.As of 3.3, this method is no longer in use anywhere in this class and is only provided for backwards compatability with subclasses of the receiver.Returns java.io.File objects for the given file names.- Parameters:
fileNames
- files to return File object for.- Returns:
- java.io.File objects for the given file names.
-
getFolder
Returns the resource either casted to or adapted to an IFolder.- Parameters:
resource
- resource to cast/adapt- Returns:
- the resource either casted to or adapted to an IFolder.
null
if the resource does not adapt to IFolder
-
getOperationTitle
Returns the task title for this operation's progress dialog.- Returns:
- the task title
-
getProblemsMessage
Returns the message for this operation's problems dialog.- Returns:
- the problems message
-
getProblemsTitle
Returns the title for this operation's problems dialog.- Returns:
- the problems dialog title
-
getValidateConflictSource
protected boolean getValidateConflictSource()Returns whether the source file in a destination collision will be validateEdited together with the collision itself. Returns false. Should return true if the source file is to be deleted after the operation.- Returns:
- boolean
true
if the source file in a destination collision should be validateEdited.false
if only the destination should be validated.
-
homogenousResources
Returns whether the given resources are either both linked or both unlinked.- Parameters:
source
- source resourcedestination
- destination resource- Returns:
- boolean
true
if both resources are either linked or unlinked.false
otherwise.
-
validateDestination
Checks whether the destination is valid for copying the source resources.Note this method is for internal use only. It is not API.
- Parameters:
destination
- the destination containersourceResources
- the source resources- Returns:
- an error message, or
null
if the path is valid
-
validateImportDestination
Checks whether the destination is valid for copying the source files.Note this method is for internal use only. It is not API.
- Parameters:
destination
- the destination containersourceNames
- the source file names- Returns:
- an error message, or
null
if the path is valid
-
getModelProviderIds
Returns the model provider ids that are known to the client that instantiated this operation.- Returns:
- the model provider ids that are known to the client that instantiated this operation.
- Since:
- 3.2
-
setModelProviderIds
Sets the model provider ids that are known to the client that instantiated this operation. Any potential side effects reported by these models during validation will be ignored.- Parameters:
modelProviderIds
- the model providers known to the client who is using this operation.- Since:
- 3.2
-
createVirtualFoldersAndLinks
Create virtual folders and links of the given files and folders to the destination. The current Thread is halted while the resources are copied using a WorkspaceModifyOperation. This method should be called from the UI Thread.- Parameters:
fileNames
- names of the files to copydestination
- destination to which files will be copied- Since:
- 3.6
- See Also:
-
linkFiles
Create links of the given files and folders to the destination. The current Thread is halted while the resources are copied using a WorkspaceModifyOperation. This method should be called from the UI Thread.- Parameters:
fileNames
- names of the files to copydestination
- destination to which files will be copied- Since:
- 3.6
- See Also:
-
setVirtualFolders
public void setVirtualFolders(boolean value) Set whether or not virtual folders and links will be created under the destination container.- Parameters:
value
-true
to create virtual folders and links under destination container- Since:
- 3.6
-
setCreateLinks
public void setCreateLinks(boolean value) Set whether or not links will be created under the destination container.- Parameters:
value
-true
to create links under destination container- Since:
- 3.6
-
setRelativeVariable
Set a variable relative to which the links are created- Parameters:
variable
- base for relative links- Since:
- 3.6
-
getUndoableCopyOrMoveOperation
protected AbstractWorkspaceOperation getUndoableCopyOrMoveOperation(IResource[] resources, IPath destinationPath) Returns an AbstractWorkspaceOperation suitable for performing the move or copy operation that will move or copy the given resources to the given destination path.- Parameters:
resources
- the resources to be moved or copieddestinationPath
- the destination path to which the resources should be moved- Returns:
- the operation that should be used to perform the move or cop
- Since:
- 3.3
-
getUndoableCopyOrMoveOperation(IResource[], IPath)