Java 类org.eclipse.ui.part.ResourceTransfer 实例源码

项目:gama    文件:CopyAction.java   
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 *
 * @param resources
 *            the resources to copy to the clipboard
 * @param fileNames
 *            file names of the resources to copy to the clipboard
 * @param names
 *            string representation of all names
 */
private void setClipboard(final IResource[] resources, final String[] fileNames, final String names) {
    try {
        // set the clipboard contents
        if (fileNames.length > 0) {
            clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] {
                    ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
        } else {
            clipboard.setContents(new Object[] { resources, names },
                    new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
        }
    } catch (final SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; }
        if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO //$NON-NLS-1$
                                                                            // ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,
                "Problem with copy.")) { //$NON-NLS-1$
            setClipboard(resources, fileNames, names);
        }
    }
}
项目:pep-tools    文件:FeatureAndPluginCopyAction.java   
@Override
public void runWithEvent(Event event) {
    ISelection selection = selectionProvider.getSelection();
    Collection<IProductModel> productModels = ProductSupport.toProductModels(selection);
    Collection<IFeatureModel> featureModels = FeatureSupport.toFeatureModels(selection);
    Collection<IPluginModelBase> pluginModels = PluginSupport.toPluginModels(selection);

    Collection<IProject> projects = new HashSet<IProject>();
    addUnderlyingResources(projects, productModels);
    addUnderlyingResources(projects, featureModels);
    addUnderlyingResources(projects, pluginModels);

    String[] fileData = new String[projects.size()];
    int i = 0;
    for (IProject project : projects) {
        fileData[i++] = project.getLocation().toOSString();
    }

    String textData = getTextData(productModels, featureModels, pluginModels);

    Object[] data = { projects.toArray(new IResource[projects.size()]), textData, fileData };
    Transfer[] dataTypes = { ResourceTransfer.getInstance(), TextTransfer.getInstance(), FileTransfer.getInstance() };
    clipboard.setContents(data, dataTypes);
}
项目:PDFReporter-Studio    文件:AbstractVisualEditor.java   
protected void initializeEditor() {
    GraphicalViewer graphicalViewer = getGraphicalViewer();
    graphicalViewer.addDropTargetListener(new JSSTemplateTransferDropTargetListener(graphicalViewer));
    graphicalViewer.addDropTargetListener(new ReportUnitDropTargetListener(graphicalViewer));
    graphicalViewer.addDropTargetListener(new ImageResourceDropTargetListener(graphicalViewer, ResourceTransfer
            .getInstance()));
    graphicalViewer.addDropTargetListener(new ImageResourceDropTargetListener(graphicalViewer, FileTransfer
            .getInstance()));
    graphicalViewer.addDropTargetListener(new ImageResourceDropTargetListener(graphicalViewer, ImageURLTransfer
            .getInstance()));

    // Load the contributed drop providers for the contributed template styles
    List<TemplateViewProvider> dropProviders = JaspersoftStudioPlugin.getExtensionManager().getStylesViewProvider();
    for (TemplateViewProvider provider : dropProviders) {
        AbstractTransferDropTargetListener listener = provider.getDropListener(graphicalViewer);
        if (listener != null)
            graphicalViewer.addDropTargetListener(listener);
    }

    getEditorSite().getActionBarContributor();
}
项目:limpet    文件:ApplicationWorkbenchWindowAdvisor.java   
public void preWindowOpen()
{
  IWorkbenchWindowConfigurer configurer = getWindowConfigurer();

  // show the shortcut bar and progress indicator, which are hidden by
  // default
  configurer.setShowPerspectiveBar(true);
  configurer.setShowFastViewBars(true);
  configurer.setShowProgressIndicator(true);

  // add the drag and drop support for the editor area
  configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
  configurer.addEditorAreaTransfer(ResourceTransfer.getInstance());
  configurer.addEditorAreaTransfer(FileTransfer.getInstance());
  configurer.addEditorAreaTransfer(MarkerTransfer.getInstance());
  configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(
      configurer.getWindow()));

  hookTitleUpdateListeners(configurer);
}
项目:OpenSPIFe    文件:EditActionProvider.java   
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 * 
 * @param resources
 *            the resources to copy to the clipboard
 * @param fileNames
 *            file names of the resources to copy to the clipboard
 * @param names
 *            string representation of all names
 */
private void setClipboard(IResource[] resources, String[] fileNames, String names) {
    try {
        // set the clipboard contents
        if (fileNames.length > 0) {
            clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
        } else {
            clipboard.setContents(new Object[] { resources, names }, new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
        }
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
            throw e;
        }
        if (MessageDialog.openQuestion(shell, "Problem Copying to Clipboard", "There was a problem when accessing the system clipboard. Retry?")) {
            setClipboard(resources, fileNames, names);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CallHierarchyViewPart.java   
private void addDragAdapters(StructuredViewer viewer) {
    int ops= DND.DROP_COPY | DND.DROP_LINK;

    Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};

    DelegatingDragAdapter dragAdapter= new DelegatingDragAdapter() {
        @Override
        public void dragStart(DragSourceEvent event) {
            IStructuredSelection selection= (IStructuredSelection) fSelectionProviderMediator.getSelection();
            if (selection.isEmpty()) {
                event.doit= false;
                return;
            }
            super.dragStart(event);
        }
    };
    dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(fSelectionProviderMediator));
    dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(fSelectionProviderMediator));
    dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(fSelectionProviderMediator));
    dragAdapter.addDragSourceListener(new FileTransferDragAdapter(fSelectionProviderMediator));

    viewer.addDragSupport(ops, transfers, dragAdapter);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CallHierarchyViewPart.java   
private void addDragAdapters(StructuredViewer viewer) {
    int ops= DND.DROP_COPY | DND.DROP_LINK;

    Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};

    DelegatingDragAdapter dragAdapter= new DelegatingDragAdapter() {
        @Override
        public void dragStart(DragSourceEvent event) {
            IStructuredSelection selection= (IStructuredSelection) fSelectionProviderMediator.getSelection();
            if (selection.isEmpty()) {
                event.doit= false;
                return;
            }
            super.dragStart(event);
        }
    };
    dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(fSelectionProviderMediator));
    dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(fSelectionProviderMediator));
    dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(fSelectionProviderMediator));
    dragAdapter.addDragSourceListener(new FileTransferDragAdapter(fSelectionProviderMediator));

    viewer.addDragSupport(ops, transfers, dragAdapter);
}
项目:Pydev    文件:CopyAction.java   
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 * 
 * @param resources the resources to copy to the clipboard
 * @param fileNames file names of the resources to copy to the clipboard
 * @param names string representation of all names
 */
private void setClipboard(IResource[] resources, String[] fileNames, String names) {
    try {
        // set the clipboard contents
        if (fileNames.length > 0) {
            clipboard.setContents(
                    new Object[] { resources, fileNames, names },
                    new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(),
                            TextTransfer.getInstance() });
        } else {
            clipboard.setContents(new Object[] { resources, names },
                    new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
        }
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
            throw e;
        }
        if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,  //$NON-NLS-1$
                "Problem with copy.")) { //$NON-NLS-1$
            setClipboard(resources, fileNames, names);
        }
    }
}
项目:PDFReporter-Studio    文件:ImageResourceDropTargetListener.java   
private boolean isDroppedDataAnImage(DropTargetEvent event) {
    if (ResourceTransfer.getInstance().isSupportedType(event.currentDataType)){
        if(event.data instanceof IResource[]){
            // Dropping an image resource from inside workspace
            IResource imgResource = ((IResource[])event.data)[0];
            return ImageUtils.hasValidFileImageExtension(
                    imgResource.getProjectRelativePath().getFileExtension());
        }
    }
    else if(FileTransfer.getInstance().isSupportedType(event.currentDataType)){
        // Dropping an image resource from outside workspace
        if(event.data instanceof String[]){
            String filepath = ((String[])event.data)[0];
            if(filepath!=null){
                int lastIndexOfDot = filepath.lastIndexOf(".");
                if(lastIndexOfDot!=-1){
                    String extension = filepath.substring(lastIndexOfDot+1);
                    return ImageUtils.hasValidFileImageExtension(extension);                
                }
            }
        }
    }
    else if(ImageURLTransfer.getInstance().isSupportedType(event.currentDataType)){
        // Dropping an image dropped from a contributed view (i.e: repository view)
        return (event.data instanceof String);
    }

    return false;
}
项目:gama    文件:NavigatorDropAssistant.java   
@Override
public IStatus handleDrop(final CommonDropAdapter adapter, final DropTargetEvent event, final Object target) {
    if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
        final String[] files = (String[]) event.data;
        if (files != null && files.length > 0) {
            PasteAction.handlePaste(files);
            return Status.OK_STATUS;
        }
    } else if (ResourceTransfer.getInstance().isSupportedType(event.currentDataType)) {

    }
    return Status.CANCEL_STATUS;
}
项目:Eclipse-Postfix-Code-Completion    文件:PasteAction.java   
protected final IResource[] getClipboardResources(TransferData[] availableDataTypes) {
    Transfer transfer= ResourceTransfer.getInstance();
    if (isAvailable(transfer, availableDataTypes)) {
        return (IResource[])getContents(fClipboard2, transfer, getShell());
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:PasteAction.java   
@Override
public boolean canEnable(TransferData[] availableDataTypes) {
    boolean resourceTransfer= isAvailable(ResourceTransfer.getInstance(), availableDataTypes);
    boolean javaElementTransfer= isAvailable(JavaElementTransfer.getInstance(), availableDataTypes);
    if (! javaElementTransfer)
        return canPasteSimpleProjects(availableDataTypes);
    if (! resourceTransfer)
        return canPasteJavaProjects(availableDataTypes);
    return canPasteJavaProjects(availableDataTypes) && canPasteSimpleProjects(availableDataTypes);
    }
项目:Eclipse-Postfix-Code-Completion    文件:CopyToClipboardAction.java   
private static Transfer[] createDataTypeArray(IResource[] resources, IJavaElement[] javaElements, String[] fileNames, TypedSource[] typedSources) {
    List<ByteArrayTransfer> result= new ArrayList<ByteArrayTransfer>(4);
    if (resources.length != 0)
        result.add(ResourceTransfer.getInstance());
    if (javaElements.length != 0)
        result.add(JavaElementTransfer.getInstance());
    if (fileNames.length != 0)
        result.add(FileTransfer.getInstance());
    if (typedSources.length != 0)
        result.add(TypedSourceTransfer.getInstance());
    result.add(TextTransfer.getInstance());
    return result.toArray(new Transfer[result.size()]);
}
项目:Eclipse-Postfix-Code-Completion    文件:JdtViewerDragSupport.java   
public void start() {
    Assert.isLegal(!fStarted);

    int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;

    Transfer[] transfers= new Transfer[] {
        LocalSelectionTransfer.getInstance(),
        ResourceTransfer.getInstance(),
        FileTransfer.getInstance()};

    fViewer.addDragSupport(ops, transfers, fDragAdapter);

    fStarted= true;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaSearchResultPage.java   
private void addDragAdapters(StructuredViewer viewer) {
    Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance() };
    int ops= DND.DROP_COPY | DND.DROP_LINK;

    JdtViewerDragAdapter dragAdapter= new JdtViewerDragAdapter(viewer);
    dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(viewer));
    viewer.addDragSupport(ops, transfers, dragAdapter);
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchyViewPart.java   
private void addDragAdapters(StructuredViewer viewer) {
    int ops= DND.DROP_COPY | DND.DROP_LINK;
    Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};

    JdtViewerDragAdapter dragAdapter= new JdtViewerDragAdapter(viewer);
    dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new FileTransferDragAdapter(viewer));

    viewer.addDragSupport(ops, transfers, dragAdapter);
}
项目:translationstudio8    文件:CopyAction.java   
/**
  * Set the clipboard contents. Prompt to retry if clipboard is busy.
  * 
  * @param resources the resources to copy to the clipboard
  * @param fileNames file names of the resources to copy to the clipboard
  * @param names string representation of all names
  */
 private void setClipboard(IResource[] resources, String[] fileNames,
         String names) {
     try {
         // set the clipboard contents
         if (fileNames.length > 0) {
             clipboard.setContents(new Object[] { resources, fileNames,
                     names },
                     new Transfer[] { ResourceTransfer.getInstance(),
                             FileTransfer.getInstance(),
                             TextTransfer.getInstance() });
         } else {
             clipboard.setContents(new Object[] { resources, names },
                     new Transfer[] { ResourceTransfer.getInstance(),
                             TextTransfer.getInstance() });
         }
     } catch (SWTError e) {
         if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
    throw e;
}
         if (MessageDialog
                 .openQuestion(
                         shell,
                         WorkbenchNavigatorMessages.actions_CopyAction_msgTitle, // TODO ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,  //$NON-NLS-1$
                         WorkbenchNavigatorMessages.actions_CopyAction_msg)) { //$NON-NLS-1$
    setClipboard(resources, fileNames, names);
}
     }
 }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PasteAction.java   
protected final IResource[] getClipboardResources(TransferData[] availableDataTypes) {
    Transfer transfer= ResourceTransfer.getInstance();
    if (isAvailable(transfer, availableDataTypes)) {
        return (IResource[])getContents(fClipboard2, transfer, getShell());
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PasteAction.java   
@Override
public boolean canEnable(TransferData[] availableDataTypes) {
    boolean resourceTransfer= isAvailable(ResourceTransfer.getInstance(), availableDataTypes);
    boolean javaElementTransfer= isAvailable(JavaElementTransfer.getInstance(), availableDataTypes);
    if (! javaElementTransfer)
        return canPasteSimpleProjects(availableDataTypes);
    if (! resourceTransfer)
        return canPasteJavaProjects(availableDataTypes);
    return canPasteJavaProjects(availableDataTypes) && canPasteSimpleProjects(availableDataTypes);
    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CopyToClipboardAction.java   
private static Transfer[] createDataTypeArray(IResource[] resources, IJavaElement[] javaElements, String[] fileNames, TypedSource[] typedSources) {
    List<ByteArrayTransfer> result= new ArrayList<ByteArrayTransfer>(4);
    if (resources.length != 0)
        result.add(ResourceTransfer.getInstance());
    if (javaElements.length != 0)
        result.add(JavaElementTransfer.getInstance());
    if (fileNames.length != 0)
        result.add(FileTransfer.getInstance());
    if (typedSources.length != 0)
        result.add(TypedSourceTransfer.getInstance());
    result.add(TextTransfer.getInstance());
    return result.toArray(new Transfer[result.size()]);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JdtViewerDragSupport.java   
public void start() {
    Assert.isLegal(!fStarted);

    int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;

    Transfer[] transfers= new Transfer[] {
        LocalSelectionTransfer.getInstance(),
        ResourceTransfer.getInstance(),
        FileTransfer.getInstance()};

    fViewer.addDragSupport(ops, transfers, fDragAdapter);

    fStarted= true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaSearchResultPage.java   
private void addDragAdapters(StructuredViewer viewer) {
    Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance() };
    int ops= DND.DROP_COPY | DND.DROP_LINK;

    JdtViewerDragAdapter dragAdapter= new JdtViewerDragAdapter(viewer);
    dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(viewer));
    viewer.addDragSupport(ops, transfers, dragAdapter);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeHierarchyViewPart.java   
private void addDragAdapters(StructuredViewer viewer) {
    int ops= DND.DROP_COPY | DND.DROP_LINK;
    Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};

    JdtViewerDragAdapter dragAdapter= new JdtViewerDragAdapter(viewer);
    dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(viewer));
    dragAdapter.addDragSourceListener(new FileTransferDragAdapter(viewer));

    viewer.addDragSupport(ops, transfers, dragAdapter);
}
项目:tmxeditor8    文件:CopyAction.java   
/**
  * Set the clipboard contents. Prompt to retry if clipboard is busy.
  * 
  * @param resources the resources to copy to the clipboard
  * @param fileNames file names of the resources to copy to the clipboard
  * @param names string representation of all names
  */
 private void setClipboard(IResource[] resources, String[] fileNames,
         String names) {
     try {
         // set the clipboard contents
         if (fileNames.length > 0) {
             clipboard.setContents(new Object[] { resources, fileNames,
                     names },
                     new Transfer[] { ResourceTransfer.getInstance(),
                             FileTransfer.getInstance(),
                             TextTransfer.getInstance() });
         } else {
             clipboard.setContents(new Object[] { resources, names },
                     new Transfer[] { ResourceTransfer.getInstance(),
                             TextTransfer.getInstance() });
         }
     } catch (SWTError e) {
         if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
    throw e;
}
         if (MessageDialog
                 .openQuestion(
                         shell,
                         WorkbenchNavigatorMessages.actions_CopyAction_msgTitle, // TODO ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,  //$NON-NLS-1$
                         WorkbenchNavigatorMessages.actions_CopyAction_msg)) { //$NON-NLS-1$
    setClipboard(resources, fileNames, names);
}
     }
 }
项目:typescript.java    文件:TypeScriptSearchResultPage.java   
private void addDragAdapters(StructuredViewer viewer) {
    Transfer[] transfers= new Transfer[] { ResourceTransfer.getInstance() };
    int ops= DND.DROP_COPY | DND.DROP_LINK;
    viewer.addDragSupport(ops, transfers, new NavigatorDragAdapter(viewer));
}
项目:PDFReporter-Studio    文件:JDReportOutlineView.java   
/**
 * Configure outline viewer.
 */
protected void configureOutlineViewer() {
    final EditPartViewer viewer = getViewer();
    viewer.setEditDomain(editor.getEditDomain());
    viewer.setEditPartFactory(getEditPartFactory());
    ContextMenuProvider provider = getMenuContentProvider();
    viewer.setContextMenu(provider);

    viewer.addDropTargetListener(new JSSTemplateTransferDropTargetListener(viewer));
    viewer.addDragSourceListener(new TemplateTransferDragSourceListener(viewer) {
        @Override
        protected Object getTemplate() {
            List<Object> models = new ArrayList<Object>();
            Object obj = super.getTemplate();
            if (obj == null) {
                List<?> selection = getViewer().getSelectedEditParts();
                for (Object it : selection) {
                    if (it instanceof EditPart) {
                        Object model = ((EditPart) it).getModel();
                        if (model instanceof IDragable) {
                            models.add(model);
                        }
                        if (model instanceof MBand){
                            BandTypeEnum bandType =((MBand)model).getBandType();
                            if (BandTypeEnum.DETAIL.equals(bandType) || BandTypeEnum.GROUP_FOOTER.equals(bandType) || BandTypeEnum.GROUP_HEADER.equals(bandType)){
                                models.add(model);
                            }
                        }
                    }
                }
            }
            return models;
        }
    });
    // Add images drop listeners
    viewer.addDropTargetListener(new ImageResourceDropTargetListener(viewer, ResourceTransfer.getInstance()));
    viewer.addDropTargetListener(new ImageResourceDropTargetListener(viewer, FileTransfer.getInstance()));
    viewer.addDropTargetListener(new ImageResourceDropTargetListener(viewer, ImageURLTransfer.getInstance()));

    IPageSite site = getSite();
    site.registerContextMenu(provider.getId(), provider, site.getSelectionProvider());

    IToolBarManager tbm = site.getActionBars().getToolBarManager();
    registerToolbarAction(tbm);

    showPage(ID_ACTION_OUTLINE);
}
项目:gama    文件:PasteAction.java   
/**
 * The <code>PasteAction</code> implementation of this <code>SelectionListenerAction</code> method enables this
 * action if a resource compatible with what is on the clipboard is selected.
 *
 * -Clipboard must have IResource or java.io.File -Projects can always be pasted if they are open -Workspace folder
 * may not be copied into itself -Files and folders may be pasted to a single selected folder in open project or
 * multiple selected files in the same folder
 */
@Override
protected boolean updateSelection(final IStructuredSelection selection) {
    if (!super.updateSelection(selection)) { return false; }

    final IResource[][] clipboardData = new IResource[1][];
    shell.getDisplay().syncExec(() -> {
        // clipboard must have resources or files
        final ResourceTransfer resTransfer = ResourceTransfer.getInstance();
        clipboardData[0] = (IResource[]) clipboard.getContents(resTransfer);
    });
    final IResource[] resourceData = clipboardData[0];
    final boolean isProjectRes =
            resourceData != null && resourceData.length > 0 && resourceData[0].getType() == IResource.PROJECT;

    if (isProjectRes) {
        for (int i = 0; i < resourceData.length; i++) {
            // make sure all resource data are open projects
            // can paste open projects regardless of selection
            if (resourceData[i].getType() != IResource.PROJECT
                    || ((IProject) resourceData[i]).isOpen() == false) { return false; }
        }
        return true;
    }

    if (getSelectedNonResources().size() > 0) { return false; }

    final IResource targetResource = getTarget();
    // targetResource is null if no valid target is selected (e.g., open project)
    // or selection is empty
    if (targetResource == null) { return false; }

    // can paste files and folders to a single selection (file, folder,
    // open project) or multiple file selection with the same parent
    final List<? extends IResource> selectedResources = getSelectedResources();
    if (selectedResources.size() > 1) {
        for (final IResource resource : selectedResources) {
            if (resource.getType() != IResource.FILE) { return false; }
            if (!targetResource.equals(resource.getParent())) { return false; }
        }
    }
    if (resourceData != null) {
        // linked resources can only be pasted into projects
        if (isLinked(resourceData) && targetResource.getType() != IResource.PROJECT
                && targetResource.getType() != IResource.FOLDER) { return false; }

        if (targetResource.getType() == IResource.FOLDER) {
            // don't try to copy folder to self
            for (int i = 0; i < resourceData.length; i++) {
                if (targetResource.equals(resourceData[i])) { return false; }
            }
        }
        return true;
    }
    final TransferData[] transfers = clipboard.getAvailableTypes();
    final FileTransfer fileTransfer = FileTransfer.getInstance();
    for (int i = 0; i < transfers.length; i++) {
        if (fileTransfer.isSupportedType(transfers[i])) { return true; }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:PasteAction.java   
@Override
public boolean canEnable(TransferData[] availableTypes) {
    return isAvailable(ResourceTransfer.getInstance(), availableTypes) ||
        isAvailable(JavaElementTransfer.getInstance(), availableTypes);
}
项目:Eclipse-Postfix-Code-Completion    文件:PasteAction.java   
@Override
public boolean canEnable(TransferData[] availableTypes) {
    fAvailableTypes= availableTypes;
    return isAvailable(JavaElementTransfer.getInstance(), availableTypes) || isAvailable(ResourceTransfer.getInstance(), availableTypes);
}
项目:Eclipse-Postfix-Code-Completion    文件:ResourceTransferDragAdapter.java   
public Transfer getTransfer() {
    return ResourceTransfer.getInstance();
}
项目:translationstudio8    文件:ResourceDropAdapterAssistant.java   
public IStatus handleDrop(CommonDropAdapter aDropAdapter,
        DropTargetEvent aDropTargetEvent, Object aTarget) {

    if (Policy.DEBUG_DND) {
        System.out
                .println("ResourceDropAdapterAssistant.handleDrop (begin)"); //$NON-NLS-1$
    }

    // alwaysOverwrite = false;
    if (aTarget == null || aDropTargetEvent.data == null) {
        return Status.CANCEL_STATUS;
    }
    IStatus status = null;
    IResource[] resources = null;
    TransferData currentTransfer = aDropAdapter.getCurrentTransfer();
    if (LocalSelectionTransfer.getTransfer().isSupportedType(
            currentTransfer)) {
        resources = getSelectedResources();
    } else if (ResourceTransfer.getInstance().isSupportedType(
            currentTransfer)) {
        resources = (IResource[]) aDropTargetEvent.data;
    }

    if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
        status = performFileDrop(aDropAdapter, aDropTargetEvent.data);
    } else if (resources != null && resources.length > 0) {
        if ((aDropAdapter.getCurrentOperation() == DND.DROP_COPY)
                || (aDropAdapter.getCurrentOperation() == DND.DROP_LINK)) {
            if (Policy.DEBUG_DND) {
                System.out
                        .println("ResourceDropAdapterAssistant.handleDrop executing COPY."); //$NON-NLS-1$
            }
            status = performResourceCopy(aDropAdapter, getShell(),
                    resources);
        } else {
            if (Policy.DEBUG_DND) {
                System.out
                        .println("ResourceDropAdapterAssistant.handleDrop executing MOVE."); //$NON-NLS-1$
            }

            status = performResourceMove(aDropAdapter, resources);
        }
    }
    openError(status);
    IContainer target = getActualTarget((IResource) aTarget);
    if (target != null && target.isAccessible()) {
        try {
            target.refreshLocal(IResource.DEPTH_ONE, null);
        } catch (CoreException e) {
        }
    }
    return status;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PasteAction.java   
@Override
public boolean canEnable(TransferData[] availableTypes) {
    return isAvailable(ResourceTransfer.getInstance(), availableTypes) ||
        isAvailable(JavaElementTransfer.getInstance(), availableTypes);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PasteAction.java   
@Override
public boolean canEnable(TransferData[] availableTypes) {
    fAvailableTypes= availableTypes;
    return isAvailable(JavaElementTransfer.getInstance(), availableTypes) || isAvailable(ResourceTransfer.getInstance(), availableTypes);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ResourceTransferDragAdapter.java   
public Transfer getTransfer() {
    return ResourceTransfer.getInstance();
}
项目:tmxeditor8    文件:ResourceDropAdapterAssistant.java   
public IStatus handleDrop(CommonDropAdapter aDropAdapter,
        DropTargetEvent aDropTargetEvent, Object aTarget) {

    if (Policy.DEBUG_DND) {
        System.out
                .println("ResourceDropAdapterAssistant.handleDrop (begin)"); //$NON-NLS-1$
    }

    // alwaysOverwrite = false;
    if (aTarget == null || aDropTargetEvent.data == null) {
        return Status.CANCEL_STATUS;
    }
    IStatus status = null;
    IResource[] resources = null;
    TransferData currentTransfer = aDropAdapter.getCurrentTransfer();
    if (LocalSelectionTransfer.getTransfer().isSupportedType(
            currentTransfer)) {
        resources = getSelectedResources();
    } else if (ResourceTransfer.getInstance().isSupportedType(
            currentTransfer)) {
        resources = (IResource[]) aDropTargetEvent.data;
    }

    if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
        status = performFileDrop(aDropAdapter, aDropTargetEvent.data);
    } else if (resources != null && resources.length > 0) {
        if ((aDropAdapter.getCurrentOperation() == DND.DROP_COPY)
                || (aDropAdapter.getCurrentOperation() == DND.DROP_LINK)) {
            if (Policy.DEBUG_DND) {
                System.out
                        .println("ResourceDropAdapterAssistant.handleDrop executing COPY."); //$NON-NLS-1$
            }
            status = performResourceCopy(aDropAdapter, getShell(),
                    resources);
        } else {
            if (Policy.DEBUG_DND) {
                System.out
                        .println("ResourceDropAdapterAssistant.handleDrop executing MOVE."); //$NON-NLS-1$
            }

            status = performResourceMove(aDropAdapter, resources);
        }
    }
    openError(status);
    IContainer target = getActualTarget((IResource) aTarget);
    if (target != null && target.isAccessible()) {
        try {
            target.refreshLocal(IResource.DEPTH_ONE, null);
        } catch (CoreException e) {
        }
    }
    return status;
}
项目:Pydev    文件:AbstractSearchIndexResultPage.java   
private void addDragAdapters(StructuredViewer viewer) {
    Transfer[] transfers = new Transfer[] { ResourceTransfer.getInstance() };
    int ops = DND.DROP_COPY | DND.DROP_LINK;
    viewer.addDragSupport(ops, transfers, new NavigatorDragAdapter(viewer));
}
项目:Pydev    文件:FileSearchPage.java   
private void addDragAdapters(StructuredViewer viewer) {
    Transfer[] transfers = new Transfer[] { ResourceTransfer.getInstance() };
    int ops = DND.DROP_COPY | DND.DROP_LINK;
    viewer.addDragSupport(ops, transfers, new NavigatorDragAdapter(viewer));
}
项目:Pydev    文件:PyResourceDropAdapterAssistant.java   
@Override
public IStatus handleDrop(CommonDropAdapter aDropAdapter, DropTargetEvent aDropTargetEvent, Object aTarget) {
    //        aTarget = getActual(aTarget);
    if (DEBUG) {
        System.out.println("ResourceDropAdapterAssistant.handleDrop (begin)"); //$NON-NLS-1$
    }

    // alwaysOverwrite = false;
    if (getCurrentTarget(aDropAdapter) == null || aDropTargetEvent.data == null) {
        return Status.CANCEL_STATUS;
    }
    IStatus status = null;
    IResource[] resources = null;
    TransferData currentTransfer = aDropAdapter.getCurrentTransfer();
    if (LocalSelectionTransfer.getTransfer().isSupportedType(currentTransfer)) {
        resources = getSelectedResources();
    } else if (ResourceTransfer.getInstance().isSupportedType(currentTransfer)) {
        resources = (IResource[]) aDropTargetEvent.data;
    }

    if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
        status = performFileDrop(aDropAdapter, aDropTargetEvent.data);
    } else if (resources != null && resources.length > 0) {
        if (aDropAdapter.getCurrentOperation() == DND.DROP_COPY) {
            if (DEBUG) {
                System.out.println("ResourceDropAdapterAssistant.handleDrop executing COPY."); //$NON-NLS-1$
            }
            status = performResourceCopy(aDropAdapter, getShell(), resources);
        } else {
            if (DEBUG) {
                System.out.println("ResourceDropAdapterAssistant.handleDrop executing MOVE."); //$NON-NLS-1$
            }

            status = performResourceMove(aDropAdapter, resources);
        }
    }
    openError(status);
    IContainer target = getActualTarget((IResource) getCurrentTarget(aDropAdapter));
    if (target != null && target.isAccessible()) {
        try {
            target.refreshLocal(IResource.DEPTH_ONE, null);
        } catch (CoreException e) {
        }
    }
    return status;
}