Java 类org.eclipse.ui.actions.CopyFilesAndFoldersOperation 实例源码
项目:gama
文件:NavigatorResourceDropAssistant.java
/**
* Performs a drop using the FileTransfer transfer type.
*/
private IStatus performFileDrop(final CommonDropAdapter anAdapter, final Object data) {
final int currentOperation = anAdapter.getCurrentOperation();
final MultiStatus problems =
new MultiStatus(PlatformUI.PLUGIN_ID, 0, WorkbenchNavigatorMessages.DropAdapter_problemImporting, null);
mergeStatus(problems,
validateTarget(anAdapter.getCurrentTarget(), anAdapter.getCurrentTransfer(), currentOperation));
final IContainer target = getActualTarget(ResourceManager.getResource(anAdapter.getCurrentTarget()));
final String[] names = (String[]) data;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 16478.
Display.getCurrent().asyncExec(() -> {
getShell().forceActive();
new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation);
});
return problems;
}
项目:synergyview
文件:ProjectsDropAdapterAssistant.java
/**
* Performs a drop using the FileTransfer transfer type.
*
* @param anAdapter
* the an adapter
* @param data
* the data
* @return the i status
*/
private IStatus performFileDrop(CommonDropAdapter anAdapter, Object data) {
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0, WorkbenchNavigatorMessages.DropAdapter_problemImporting, null);
mergeStatus(problems, validateTarget(anAdapter.getCurrentTarget(), anAdapter.getCurrentTransfer(), anAdapter.getCurrentOperation()));
final IContainer target = getActualTarget(((MediaRootNode) anAdapter.getCurrentTarget()).getResource());
final String[] names = (String[]) data;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 16478.
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
getShell().forceActive();
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
operation.copyFiles(names, target);
}
});
return problems;
}
项目:translationstudio8
文件:ResourceDropAdapterAssistant.java
/**
* Performs a drop using the FileTransfer transfer type.
*/
private IStatus performFileDrop(final CommonDropAdapter anAdapter, Object data) {
final int currentOperation = anAdapter.getCurrentOperation();
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0,
WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemImporting, null);
mergeStatus(problems,
validateTarget(anAdapter.getCurrentTarget(), anAdapter
.getCurrentTransfer(), currentOperation));
final IContainer target = getActualTarget((IResource) anAdapter
.getCurrentTarget());
final String[] names = (String[]) data;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 16478.
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
getShell().forceActive();
new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation);
}
});
return problems;
}
项目:tmxeditor8
文件:ResourceDropAdapterAssistant.java
/**
* Performs a drop using the FileTransfer transfer type.
*/
private IStatus performFileDrop(final CommonDropAdapter anAdapter, Object data) {
final int currentOperation = anAdapter.getCurrentOperation();
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0,
WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemImporting, null);
mergeStatus(problems,
validateTarget(anAdapter.getCurrentTarget(), anAdapter
.getCurrentTransfer(), currentOperation));
final IContainer target = getActualTarget((IResource) anAdapter
.getCurrentTarget());
final String[] names = (String[]) data;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 16478.
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
getShell().forceActive();
new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation);
}
});
return problems;
}
项目:Pydev
文件:PyResourceDropAdapterAssistant.java
/**
* Performs a resource copy
*/
private IStatus performResourceCopy(CommonDropAdapter dropAdapter, Shell shell, IResource[] sources) {
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1,
WorkbenchNavigatorMessages.DropAdapter_problemsMoving, null);
mergeStatus(
problems,
validateTarget(getCurrentTarget(dropAdapter), dropAdapter.getCurrentTransfer(),
dropAdapter.getCurrentOperation()));
IContainer target = getActualTarget((IResource) getCurrentTarget(dropAdapter));
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
IResource[] copiedResources = operation.copyResources(sources, target);
if (copiedResources.length > 0) {
PythonPathHelper.updatePyPath(copiedResources, target, PythonPathHelper.OPERATION_COPY);
}
return problems;
}
项目:Pydev
文件:PyResourceDropAdapterAssistant.java
/**
* Performs a drop using the FileTransfer transfer type.
*/
private IStatus performFileDrop(CommonDropAdapter anAdapter, Object data) {
data = getActual(data);
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0,
WorkbenchNavigatorMessages.DropAdapter_problemImporting, null);
mergeStatus(
problems,
validateTarget(getCurrentTarget(anAdapter), anAdapter.getCurrentTransfer(),
anAdapter.getCurrentOperation()));
final IContainer target = getActualTarget((IResource) getCurrentTarget(anAdapter));
final String[] names = (String[]) data;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 16478.
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
getShell().forceActive();
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
operation.copyFiles(names, target);
}
});
return problems;
}
项目:synergyview
文件:ProjectsDropAdapterAssistant.java
/**
* Ensures that the drop target meets certain criteria.
*
* @param target
* the target
* @param transferType
* the transfer type
* @param dropOperation
* the drop operation
* @return the i status
*/
private IStatus validateTarget(Object target, TransferData transferType, int dropOperation) {
if (!(target instanceof IResource)) {
return WorkbenchNavigatorPlugin.createInfoStatus(WorkbenchNavigatorMessages.DropAdapter_targetMustBeResource);
}
IResource resource = (IResource) target;
if (!resource.isAccessible()) {
return WorkbenchNavigatorPlugin.createErrorStatus(WorkbenchNavigatorMessages.DropAdapter_canNotDropIntoClosedProject);
}
IContainer destination = getActualTarget(resource);
if (destination.getType() == IResource.ROOT) {
return WorkbenchNavigatorPlugin.createErrorStatus(WorkbenchNavigatorMessages.DropAdapter_resourcesCanNotBeSiblings);
}
String message = null;
if (FileTransfer.getInstance().isSupportedType(transferType)) {
String[] sourceNames = (String[]) FileTransfer.getInstance().nativeToJava(transferType);
if (sourceNames == null) {
// source names will be null on Linux. Use empty names to do
// destination validation.
// Fixes bug 29778
sourceNames = new String[0];
}
CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(getShell());
message = copyOperation.validateImportDestination(destination, sourceNames);
}
if (message != null) {
return WorkbenchNavigatorPlugin.createErrorStatus(message);
}
return Status.OK_STATUS;
}
项目:Eclipse-Postfix-Code-Completion
文件:PasteAction.java
@Override
public void paste(IJavaElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaModelException {
String[] fileData= getClipboardFiles(availableTypes);
if (fileData == null)
return;
IContainer container= getAsContainer(getTarget(javaElements, resources));
if (container == null)
return;
new CopyFilesAndFoldersOperation(getShell()).copyFiles(fileData, container);
}
项目:Eclipse-Postfix-Code-Completion
文件:FileTransferDropAdapter.java
/**
* {@inheritDoc}
*/
@Override
public boolean performDrop(final Object data) {
try {
final int currentOperation= getCurrentOperation();
if (data == null || !(data instanceof String[]) || currentOperation != DND.DROP_COPY)
return false;
final IContainer target= getActualTarget(getCurrentTarget());
if (target == null)
return false;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 35796.
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
getShell().forceActive();
new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles((String[])data, target, currentOperation);
}
});
return true;
} catch (JavaModelException e) {
String title= PackagesMessages.DropAdapter_errorTitle;
String message= PackagesMessages.DropAdapter_errorMessage;
ExceptionHandler.handle(e, getShell(), title, message);
return false;
}
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:PasteAction.java
@Override
public void paste(IJavaElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaModelException {
String[] fileData= getClipboardFiles(availableTypes);
if (fileData == null)
return;
IContainer container= getAsContainer(getTarget(javaElements, resources));
if (container == null)
return;
new CopyFilesAndFoldersOperation(getShell()).copyFiles(fileData, container);
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:FileTransferDropAdapter.java
/**
* {@inheritDoc}
*/
@Override
public boolean performDrop(final Object data) {
try {
final int currentOperation= getCurrentOperation();
if (data == null || !(data instanceof String[]) || currentOperation != DND.DROP_COPY)
return false;
final IContainer target= getActualTarget(getCurrentTarget());
if (target == null)
return false;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 35796.
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
getShell().forceActive();
new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles((String[])data, target, currentOperation);
}
});
return true;
} catch (JavaModelException e) {
String title= PackagesMessages.DropAdapter_errorTitle;
String message= PackagesMessages.DropAdapter_errorMessage;
ExceptionHandler.handle(e, getShell(), title, message);
return false;
}
}
项目:gama
文件:NavigatorResourceDropAssistant.java
/**
* Performs a resource copy
*/
private IStatus performResourceCopy(final CommonDropAdapter dropAdapter, final Shell shell,
final IResource[] sources) {
final MultiStatus problems =
new MultiStatus(PlatformUI.PLUGIN_ID, 1, WorkbenchNavigatorMessages.DropAdapter_problemsMoving, null);
mergeStatus(problems, validateTarget(dropAdapter.getCurrentTarget(), dropAdapter.getCurrentTransfer(),
dropAdapter.getCurrentOperation()));
final IContainer target = getActualTarget(ResourceManager.getResource(dropAdapter.getCurrentTarget()));
boolean shouldLinkAutomatically = false;
if (target.isVirtual()) {
shouldLinkAutomatically = true;
for (int i = 0; i < sources.length; i++) {
if (sources[i].getType() != IResource.FILE && sources[i].getLocation() != null) {
// If the source is a folder, but the location is null (a
// broken link, for example),
// we still generate a link automatically (the best option).
shouldLinkAutomatically = false;
break;
}
}
}
final CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
// if the target is a virtual folder and all sources are files, then
// automatically create links
if (shouldLinkAutomatically) {
operation.setCreateLinks(true);
operation.copyResources(sources, target);
} else {
boolean allSourceAreLinksOrVirtualFolders = true;
for (int i = 0; i < sources.length; i++) {
if (!sources[i].isVirtual() && !sources[i].isLinked()) {
allSourceAreLinksOrVirtualFolders = false;
break;
}
}
// if all sources are either links or groups, copy then normally,
// don't show the dialog
if (!allSourceAreLinksOrVirtualFolders) {
final IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
final String dndPreference = store.getString(
target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE
: IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);
if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) {
final ImportTypeDialog dialog =
new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
dialog.setResource(target);
if (dialog.open() == Window.OK) {
if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
operation.setVirtualFolders(true);
if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
operation.setCreateLinks(true);
if (dialog.getVariable() != null)
operation.setRelativeVariable(dialog.getVariable());
operation.copyResources(sources, target);
} else
return problems;
} else
operation.copyResources(sources, target);
} else
operation.copyResources(sources, target);
}
return problems;
}
项目:limpet
文件:SampleProjectWizardPage.java
public boolean performFinish()
{
try
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
project.create(null);
project.open(null);
Bundle bundle = Platform.getBundle("info.limpet.sample_data");
if (bundle == null)
{
MessageDialog
.openWarning(getShell(), "Warning",
"The sample_data plugin is missing. Please check your installation");
return true;
}
URL entry = bundle.getEntry("/");
File file = new File(FileLocator.resolve(entry).toURI());
if (file.isDirectory())
{
CopyFilesAndFoldersOperation operation =
new CopyFilesAndFoldersOperation(getShell());
List<URI> uris = new ArrayList<URI>();
File f = new File(file, "data");
if (f.isDirectory())
{
uris.add(f.toURI());
}
f = new File(file, "americas_cup");
if (f.isDirectory())
{
uris.add(f.toURI());
}
if (uris.size() == 0)
{
return true;
}
operation.copyFiles(uris.toArray(new URI[0]), project);
}
}
catch (CoreException | URISyntaxException | IOException e)
{
MessageDialog.openError(getShell(), "Error",
"Cannot create project. Reason: " + e.getMessage());
Activator.log(e);
return false;
}
return true;
}
项目:translationstudio8
文件:ResourceDropAdapterAssistant.java
/**
* Performs a resource copy
*/
private IStatus performResourceCopy(CommonDropAdapter dropAdapter,
Shell shell, IResource[] sources) {
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1,
WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemsMoving, null);
mergeStatus(problems, validateTarget(dropAdapter.getCurrentTarget(), dropAdapter.getCurrentTransfer(),
dropAdapter.getCurrentOperation()));
IContainer target = getActualTarget((IResource) dropAdapter.getCurrentTarget());
boolean shouldLinkAutomatically = false;
if (target.isVirtual()) {
shouldLinkAutomatically = true;
for (int i = 0; i < sources.length; i++) {
if ((sources[i].getType() != IResource.FILE) && (sources[i].getLocation() != null)) {
// If the source is a folder, but the location is null (a
// broken link, for example),
// we still generate a link automatically (the best option).
shouldLinkAutomatically = false;
break;
}
}
}
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
// if the target is a virtual folder and all sources are files, then
// automatically create links
if (shouldLinkAutomatically) {
operation.setCreateLinks(true);
operation.copyResources(sources, target);
} else {
// boolean allSourceAreLinksOrVirtualFolders = true;
// for (int i = 0; i < sources.length; i++) {
// if (!sources[i].isVirtual() && !sources[i].isLinked()) {
// allSourceAreLinksOrVirtualFolders = false;
// break;
// }
// }
// // if all sources are either links or groups, copy then normally,
// // don't show the dialog
// if (!allSourceAreLinksOrVirtualFolders) {
// IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
// String dndPreference= store.getString(target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE : IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);
//
// if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) {
// ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
// dialog.setResource(target);
// if (dialog.open() == Window.OK) {
// if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
// operation.setVirtualFolders(true);
// if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
// operation.setCreateLinks(true);
// if (dialog.getVariable() != null)
// operation.setRelativeVariable(dialog.getVariable());
// operation.copyResources(sources, target);
// } else
// return problems;
// }
// else
// operation.copyResources(sources, target);
// } else
operation.copyResources(sources, target);
}
return problems;
}
项目:tmxeditor8
文件:ResourceDropAdapterAssistant.java
/**
* Performs a resource copy
*/
private IStatus performResourceCopy(CommonDropAdapter dropAdapter,
Shell shell, IResource[] sources) {
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1,
WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemsMoving, null);
mergeStatus(problems, validateTarget(dropAdapter.getCurrentTarget(), dropAdapter.getCurrentTransfer(),
dropAdapter.getCurrentOperation()));
IContainer target = getActualTarget((IResource) dropAdapter.getCurrentTarget());
boolean shouldLinkAutomatically = false;
if (target.isVirtual()) {
shouldLinkAutomatically = true;
for (int i = 0; i < sources.length; i++) {
if ((sources[i].getType() != IResource.FILE) && (sources[i].getLocation() != null)) {
// If the source is a folder, but the location is null (a
// broken link, for example),
// we still generate a link automatically (the best option).
shouldLinkAutomatically = false;
break;
}
}
}
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
// if the target is a virtual folder and all sources are files, then
// automatically create links
if (shouldLinkAutomatically) {
operation.setCreateLinks(true);
operation.copyResources(sources, target);
} else {
// boolean allSourceAreLinksOrVirtualFolders = true;
// for (int i = 0; i < sources.length; i++) {
// if (!sources[i].isVirtual() && !sources[i].isLinked()) {
// allSourceAreLinksOrVirtualFolders = false;
// break;
// }
// }
// // if all sources are either links or groups, copy then normally,
// // don't show the dialog
// if (!allSourceAreLinksOrVirtualFolders) {
// IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
// String dndPreference= store.getString(target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE : IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);
//
// if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) {
// ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
// dialog.setResource(target);
// if (dialog.open() == Window.OK) {
// if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
// operation.setVirtualFolders(true);
// if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
// operation.setCreateLinks(true);
// if (dialog.getVariable() != null)
// operation.setRelativeVariable(dialog.getVariable());
// operation.copyResources(sources, target);
// } else
// return problems;
// }
// else
// operation.copyResources(sources, target);
// } else
operation.copyResources(sources, target);
}
return problems;
}