Java Code Examples for org.eclipse.ui.internal.ide.IDEWorkbenchMessages#CopyFilesAndFoldersOperation_destinationDescendentError

The following examples show how to use org.eclipse.ui.internal.ide.IDEWorkbenchMessages#CopyFilesAndFoldersOperation_destinationDescendentError . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks whether the destination is valid for copying the source file
 * stores.
 * <p>
 * Note this method is for internal use only. It is not API.
 * </p>
 * <p>
 * TODO Bug 117804. This method has been renamed to avoid a bug in the
 * Eclipse compiler with regards to visibility and type resolution when
 * linking.
 * </p>
 *
 * @param destination
 *            the destination container
 * @param sourceStores
 *            the source IFileStore
 * @return an error message, or <code>null</code> if the path is valid
 */
private String validateImportDestinationInternal(IContainer destination, IFileStore[] sourceStores) {
    if (!isAccessible(destination)) {
        return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationAccessError;
    }

    IFileStore destinationStore;
    try {
        destinationStore = EFS.getStore(destination.getLocationURI());
    } catch (CoreException exception) {
        IDEWorkbenchPlugin.log(exception.getLocalizedMessage(), exception);
        return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_internalError,
                exception.getLocalizedMessage());
    }
    for (int i = 0; i < sourceStores.length; i++) {
        IFileStore sourceStore = sourceStores[i];
        IFileStore sourceParentStore = sourceStore.getParent();

        if (sourceStore != null) {
            if (destinationStore.equals(sourceStore)
                    || (sourceParentStore != null && destinationStore.equals(sourceParentStore))) {
                return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_importSameSourceAndDest,
                        sourceStore.getName());
            }
            // work around bug 16202. replacement for
            // sourcePath.isPrefixOf(destinationPath)
            IFileStore destinationParent = destinationStore.getParent();
            if (sourceStore.isParentOf(destinationParent)) {
                return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationDescendentError;
            }

        }
    }
    return null;
}
 
Example 2
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Checks whether the destination is valid for copying the source resources.
 * <p>
 * Note this method is for internal use only. It is not API.
 * </p>
 *
 * @param destination
 *            the destination container
 * @param sourceResources
 *            the source resources
 * @return an error message, or <code>null</code> if the path is valid
 */
public String validateDestination(IContainer destination, IResource[] sourceResources) {
    if (!isAccessible(destination)) {
        return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationAccessError;
    }
    IContainer firstParent = null;
    URI destinationLocation = destination.getLocationURI();
    for (int i = 0; i < sourceResources.length; i++) {
        IResource sourceResource = sourceResources[i];
        if (firstParent == null) {
            firstParent = sourceResource.getParent();
        } else if (firstParent.equals(sourceResource.getParent()) == false) {
            // Resources must have common parent. Fixes bug 33398.
            return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_parentNotEqual;
        }

        URI sourceLocation = sourceResource.getLocationURI();
        if (sourceLocation == null) {
            if (sourceResource.isLinked()) {
                // Don't allow copying linked resources with undefined path
                // variables. See bug 28754.
                return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_missingPathVariable,
                        sourceResource.getName());
            }
            return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted,
                    sourceResource.getName());

        }
        if (sourceLocation.equals(destinationLocation)) {
            return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_sameSourceAndDest,
                    sourceResource.getName());
        }
        // is the source a parent of the destination?
        if (new Path(sourceLocation.toString()).isPrefixOf(new Path(destinationLocation.toString()))) {
            return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationDescendentError;
        }

        String linkedResourceMessage = validateLinkedResource(destination, sourceResource);
        if (linkedResourceMessage != null) {
            return linkedResourceMessage;
        }
    }
    return null;
}