Java Code Examples for org.eclipse.jface.viewers.TreeViewer#addDragSupport()
The following examples show how to use
org.eclipse.jface.viewers.TreeViewer#addDragSupport() .
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: AbapGitStagingView.java From ADT_Frontend with MIT License | 6 votes |
private void addDragAndDropSupport(TreeViewer viewer, final boolean unstaged) { viewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK, new Transfer[] { LocalSelectionTransfer.getTransfer(), LocalSelectionTransfer.getTransfer() }, new StagingDragListener(viewer, ArrayContentProvider.getInstance(), unstaged)); viewer.addDropSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK, new Transfer[] { LocalSelectionTransfer.getTransfer() }, new DropTargetAdapter() { public void drop(DropTargetEvent event) { event.detail = DND.DROP_COPY; if (event.data instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event.data; if (selection instanceof StagingDragSelection && ((StagingDragSelection) selection).isFromUnstaged() == unstaged) { return; } if (((StagingDragSelection) selection).isFromUnstaged()) { stageSelectedObjects(selection); } else { unstageSelectedObjects(selection); } } } }); }
Example 2
Source File: TexOutlinePage.java From texlipse with Eclipse Public License 1.0 | 4 votes |
/** * Creates the control ie. creates all the stuff that matters and * is visible in the outline. * * Actions must be created before menus and toolbars. * * @param parent */ public void createControl(Composite parent) { super.createControl(parent); // create the context actions createActions(); // initialize the tree viewer TreeViewer viewer = getTreeViewer(); filter = new TexOutlineFilter(); viewer.setContentProvider(new TexContentProvider(filter)); viewer.setLabelProvider(new TexLabelProvider()); viewer.setComparer(new TexOutlineNodeComparer()); // get and apply the preferences this.getOutlinePreferences(); viewer.addFilter(filter); // set the selection listener viewer.addSelectionChangedListener(this); // enable drag'n'drop support TexOutlineDNDAdapter dndAdapter = new TexOutlineDNDAdapter(viewer, this); int ops = DND.DROP_COPY | DND.DROP_MOVE; Transfer[] transfers = new Transfer[] {TextTransfer.getInstance()}; viewer.addDragSupport(ops, transfers, dndAdapter); viewer.addDropSupport(ops, transfers, dndAdapter); // enable copy-paste initCopyPaste(viewer); // create the menu bar and the context menu createToolbar(); resetToolbarButtons(); createContextMenu(); // finally set the input if (this.input != null) { viewer.setInput(this.input.getRootNodes()); // set update button status and also the context actions outlineActions.get(ACTION_UPDATE).setEnabled(false); outlineActions.get(ACTION_COPY).setEnabled(true); outlineActions.get(ACTION_CUT).setEnabled(true); outlineActions.get(ACTION_PASTE).setEnabled(true); outlineActions.get(ACTION_DELETE).setEnabled(true); } }