/** * 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); } } }
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void createContextMenuFor ( StructuredViewer viewer ) { MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$ contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$ contextMenu.setRemoveAllWhenShown ( true ); contextMenu.addMenuListener ( this ); Menu menu = contextMenu.createContextMenu ( viewer.getControl () ); viewer.getControl ().setMenu ( menu ); getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) ); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () }; viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) ); viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) ); }
/** * This creates a context menu for the viewer and adds a listener as well * registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ protected void createContextMenuFor ( final StructuredViewer viewer ) { final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$ contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$ contextMenu.setRemoveAllWhenShown ( true ); contextMenu.addMenuListener ( this ); final Menu menu = contextMenu.createContextMenu ( viewer.getControl () ); viewer.getControl ().setMenu ( menu ); getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) ); final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance (), ItemTransfer.getInstance () }; viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) ); viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) ); }
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void createContextMenuFor ( StructuredViewer viewer ) { MenuManager contextMenu = new MenuManager ( "#PopUp" ); contextMenu.add ( new Separator ( "additions" ) ); contextMenu.setRemoveAllWhenShown ( true ); contextMenu.addMenuListener ( this ); Menu menu = contextMenu.createContextMenu ( viewer.getControl () ); viewer.getControl ().setMenu ( menu ); getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) ); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () }; viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) ); viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) ); }
Transfer getTransferType(String mime) { if (mime.equals("text/plain")) { return TextTransfer.getInstance(); } if (mime.equals("text/rtf")) { return RTFTransfer.getInstance(); } if (mime.equals("text/html")) { return HTMLTransfer.getInstance(); } if (mime.equals("text/uri-list")) { return URLTransfer.getInstance(); } if (mime.equals("application/x-java-rawimage")) { return ImageTransfer.getInstance(); } if (mime.equals("application/x-java-file-list") || mime.equals("java.file-list")) { return FileTransfer.getInstance(); } return getCustomTransfer(mime); }
String getMime(Transfer transfer) { if (transfer.equals(TextTransfer.getInstance())) { return "text/plain"; } if (transfer.equals(RTFTransfer.getInstance())) { return "text/rtf"; } ; if (transfer.equals( HTMLTransfer.getInstance())) { return "text/html"; } if (transfer.equals(URLTransfer.getInstance())) { return "text/uri-list"; } if (transfer.equals( ImageTransfer.getInstance())) { return "application/x-java-rawimage"; } if (transfer.equals(FileTransfer.getInstance())) { return "application/x-java-file-list"; } if (transfer instanceof CustomTransfer) { return ((CustomTransfer)transfer).getMime(); } return null; }
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ protected void createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance()}; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); }
private IStructuredSelection getStructuredSelection(Object data, TransferData currentDataType) { if (LocalSelectionTransfer.getTransfer().isSupportedType(currentDataType)) { return (IStructuredSelection) data; } if (URLTransfer.getInstance().isSupportedType(currentDataType)) { try { return new StructuredSelection(new URL((String) data)); } catch (MalformedURLException e) { // ignore } } if (FileTransfer.getInstance().isSupportedType(currentDataType)) { return new StructuredSelection(Arrays.stream((String[]) data).map(Path::new).collect(Collectors.toList())); } return new StructuredSelection(); }
private IStructuredSelection getStructuredSelectionFromClipboard(Display display) { Clipboard clipboard = new Clipboard(display); try { String text = (String) clipboard.getContents(URLTransfer.getInstance()); if (text == null) { text = (String) clipboard.getContents(TextTransfer.getInstance()); } if (text != null) { try { URL url = new URL(text); return new StructuredSelection(url); } catch (MalformedURLException e) { } } String[] paths = (String[]) clipboard.getContents(FileTransfer.getInstance()); if (paths != null) { return new StructuredSelection(Arrays.stream(paths).map(Path::new).collect(Collectors.toList())); } return new StructuredSelection(); } finally { clipboard.dispose(); } }
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu= contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); }
/** * This creates a context menu for the viewer and adds a listener as well * registering the menu for extension. <!-- begin-user-doc --> <!-- * end-user-doc --> * * @generated */ protected void createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); }
public void run() { ISelection sel = viewer.getSelection(); if (sel instanceof StructuredSelection) { if (sel.isEmpty()) return; List<String> paths = new ArrayList<String>(); @SuppressWarnings("unchecked") Iterator<File> i = ((StructuredSelection)sel).iterator(); while (i.hasNext()) { File file = i.next(); if (file.isDirectory()) continue; paths.add(file.getAbsolutePath()); } Clipboard clipboard = new Clipboard(Display.getDefault()); clipboard.setContents(new Object[] { (String[])paths.toArray(new String[paths.size()]) }, new Transfer[] { FileTransfer.getInstance() }); clipboard.dispose(); } }
@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); }
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(); }
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); }
/** * 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); } } }
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); }
/** * This creates a context menu for the viewer and adds a listener as well * registering the menu for extension. <!-- begin-user-doc --> <!-- * end-user-doc --> * * @generated */ protected void createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter( viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); }
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); }
/** * This creates a context menu for the viewer and adds a listener as well registering the menu * for extension. <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ protected void createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); }
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected void createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); }
private final MenuManager createContextMenuFor(StructuredViewer viewer) { MenuManager contextMenu = new MenuManager("#PopUp", "eu.cloudscale.env.toolcahin.treeview.menumanager"); contextMenu.add(new Separator("additions")); contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(this); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); return contextMenu; }