List of usage examples for org.eclipse.jface.util DelegatingDragAdapter getTransfers
public Transfer[] getTransfers()
Transfers from every TransferDragSourceListener. From source file:eu.geclipse.ui.views.GridModelViewPart.java
License:Open Source License
protected void initDrag(final StructuredViewer sViewer) { int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT; DelegatingDragAdapter adapter = new DelegatingDragAdapter(); addDragSourceListeners(adapter);/*from ww w. jav a 2s.co m*/ sViewer.addDragSupport(operations, adapter.getTransfers(), adapter); }
From source file:org.peprframework.ide.views.pages.input.InputPage.java
License:Apache License
private void createInputTargetViewer() { Section section = toolkit.createSection(panel, Section.SHORT_TITLE_BAR | Section.EXPANDED | Section.CLIENT_INDENT | Section.DESCRIPTION); GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); data.widthHint = 400;/*from w ww . j a v a 2s. com*/ section.setLayoutData(data); section.setText("Input"); section.setDescription("The input parameters of the selected Activity."); targetViewerContentProvider = new InputTargetContentProvider(); targetViewerLabelProvider = new InputTargetLabelProvider(); targetViewer = new TableViewer(section, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE); // targetViewer = new ListViewer(section, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); TableViewerColumn typeColumn = new TableViewerColumn(targetViewer, SWT.NONE); typeColumn.getColumn().setWidth(80); TableViewerColumn nameColumn = new TableViewerColumn(targetViewer, SWT.NONE); nameColumn.getColumn().setWidth(320); targetViewer.getTable().setHeaderVisible(false); targetViewer.setSorter(new ViewerSorter() { /* (non-Javadoc) * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ @Override public int compare(Viewer viewer, Object e1, Object e2) { InputProperty p1 = (InputProperty) e1; InputProperty p2 = (InputProperty) e2; return p1.getName().compareTo(p2.getName()); } }); section.setClient(targetViewer.getControl()); targetViewer.setContentProvider(targetViewerContentProvider); targetViewer.setLabelProvider(targetViewerLabelProvider); // DnD DelegatingDragAdapter dragAdapter = new DelegatingDragAdapter(); dragAdapter.addDragSourceListener(new TransferDragSourceListener() { private IStructuredSelection selection; public void dragStart(DragSourceEvent event) { IStructuredSelection selection = (IStructuredSelection) targetViewer.getSelection(); if (!selection.isEmpty() && selection.getFirstElement() instanceof InputProperty) { this.selection = selection; event.doit = true; } else { this.selection = null; event.doit = false; } } public void dragSetData(DragSourceEvent event) { InputProperty inputProperty = (InputProperty) this.selection.getFirstElement(); event.data = "input." + inputProperty.getName() + " = "; } public void dragFinished(DragSourceEvent event) { } public Transfer getTransfer() { return TextTransfer.getInstance(); } }); targetViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, dragAdapter.getTransfers(), dragAdapter); }
From source file:org.peprframework.ide.views.pages.input.InputPage.java
License:Apache License
private void createInputSourceViewer() { Section section = toolkit.createSection(panel, Section.SHORT_TITLE_BAR | Section.EXPANDED | Section.CLIENT_INDENT | Section.DESCRIPTION); GridData data = new GridData(SWT.FILL, SWT.FILL, false, true); section.setLayoutData(data);// ww w . j a v a 2s .c o m section.setText("Context"); section.setDescription("The available output of previous Activities in the current Context."); sourceViewerContentProvider = new InputSourceContentProvider(); sourceViewerLabelProvider = new InputSourceLabelProvider(); sourceViewer = new TreeViewer(section); section.setClient(sourceViewer.getControl()); sourceViewer.setContentProvider(sourceViewerContentProvider); sourceViewer.setLabelProvider(sourceViewerLabelProvider); sourceViewer.setSorter(new ViewerSorter() { /* (non-Javadoc) * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ @Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof Activity && e2 instanceof Activity) { return ((Activity) e1).getName().compareTo(((Activity) e2).getName()); } return ((OutputProperty) e1).getName().compareTo(((OutputProperty) e2).getName()); } }); // DnD DelegatingDragAdapter dragAdapter = new DelegatingDragAdapter(); dragAdapter.addDragSourceListener(new TransferDragSourceListener() { private ITreeSelection selection; public void dragStart(DragSourceEvent event) { ITreeSelection selection = (ITreeSelection) sourceViewer.getSelection(); if (!selection.isEmpty() && selection.getFirstElement() instanceof OutputProperty) { this.selection = selection; event.doit = true; } else { this.selection = null; event.doit = false; } } public void dragSetData(DragSourceEvent event) { OutputProperty outputProperty = (OutputProperty) this.selection.getFirstElement(); event.data = "context.get(\"" + outputProperty.getSource() + "\")." + outputProperty.getName(); } public void dragFinished(DragSourceEvent event) { } public Transfer getTransfer() { return TextTransfer.getInstance(); } }); sourceViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, dragAdapter.getTransfers(), dragAdapter); }