org.eclipse.swt.dnd.DropTargetAdapter Java Examples
The following examples show how to use
org.eclipse.swt.dnd.DropTargetAdapter.
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: TmxEditorViewer.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@Override public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); this.container = parent; CellEditorGlobalActionHanlder.getInstance().setIActionBars(getViewSite().getActionBars()); DropTarget target = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY); Transfer[] tfs = new Transfer[] { FileTransfer.getInstance() }; target.setTransfer(tfs); target.addDropListener(new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { Object o = event.data; if (o instanceof String[]) { String[] s = (String[]) o; if (s.length == 0 && s[0] == null || s[0].length() == 0) { return; } File f = new File(s[0]); if (f.exists() && f.isFile()) { open(f); } } } }); }
Example #3
Source File: Trees.java From olca-app with Mozilla Public License 2.0 | 6 votes |
public static void addDropSupport(TreeViewer tree, Consumer<List<Descriptor>> handler) { Transfer transfer = ModelTransfer.getInstance(); DropTarget dropTarget = new DropTarget(tree.getTree(), DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT); dropTarget.setTransfer(new Transfer[] { transfer }); dropTarget.addDropListener(new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { if (!transfer.isSupportedType(event.currentDataType)) return; var list = ModelTransfer.getDescriptors(event.data); handler.accept(list); } }); }
Example #4
Source File: Tables.java From olca-app with Mozilla Public License 2.0 | 6 votes |
public static void onDrop(TableViewer table, Consumer<List<Descriptor>> fn) { Transfer transfer = ModelTransfer.getInstance(); DropTarget target = new DropTarget(table.getTable(), DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT); target.setTransfer(new Transfer[] { transfer }); target.addDropListener(new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { if (!transfer.isSupportedType(event.currentDataType)) return; var list = ModelTransfer.getDescriptors(event.data); fn.accept(list); } }); }
Example #5
Source File: LogViewer.java From LogViewer with Eclipse Public License 2.0 | 5 votes |
public void createPartControl(Composite parent) { //viewer this.parent = parent; documentListener = new ViewDocumentListener(); tabfolder = new TabFolder(parent,0); tabfolder.addSelectionListener(new TabSelectionListener()); viewer = new LogFileViewer(tabfolder,SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); // DnD DropTarget target = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK); target.setTransfer(new Transfer[] {FileTransfer.getInstance(), TextTransfer.getInstance()}); target.addDropListener (new DropTargetAdapter() { public void dragEnter(DropTargetEvent e) { if (e.detail == DND.DROP_NONE) e.detail = DND.DROP_COPY; } public void drop(DropTargetEvent event) { if (event.data == null || ((String[])event.data).length < 1) { event.detail = DND.DROP_NONE; return; } //File file = new File(((String[])event.data)[0]); if (!checkAndOpenFile(LogFileType.LOGFILE_SYSTEM_FILE,((String[])event.data)[0], null, false)) event.detail = DND.DROP_NONE; } }); // fill the menues makeActions(); hookContextMenu(); contributeToActionBars(); openAllLastOpenFiles(); }
Example #6
Source File: TypeHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void initDragAndDrop() { for (int i= 0; i < fAllViewers.length; i++) { addDragAdapters(fAllViewers[i]); addDropAdapters(fAllViewers[i]); } addDragAdapters(fMethodsViewer); fMethodsViewer.addDropSupport(DND.DROP_NONE, new Transfer[0], new DropTargetAdapter()); //DND on empty hierarchy DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT); dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getInstance() }); dropTarget.addDropListener(new TypeHierarchyTransferDropAdapter(this, fAllViewers[0])); }
Example #7
Source File: View.java From codeexamples-eclipse with Eclipse Public License 1.0 | 5 votes |
private void addDropListener(Composite parent) { LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer(); DropTargetAdapter dragAdapter = new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { Control droppedObj = (Control) ((StructuredSelection) transfer.getSelection()).getFirstElement(); // Get the existing parent of the dragged control Composite oldParent = droppedObj.getParent(); if (oldParent == parent) { return; } if (droppedObj instanceof Label) { System.out.println("Dropped"); } // handle the drop if (droppedObj instanceof Label) { Label droppedLabel = (Label) droppedObj; droppedLabel.setParent(parent); // Change parent } if (droppedObj instanceof Button) { Button droppedButton = (Button) droppedObj; droppedButton.setParent(parent); // Change parent } // request a layout pass oldParent.requestLayout(); // If you change that to layout the layout will be correct parent.layout(); } }; DropTarget dropTarget = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY); dropTarget.setTransfer(new Transfer[] { transfer }); dropTarget.addDropListener(dragAdapter); }
Example #8
Source File: ExampleDropTargetInstaller.java From statecharts with Eclipse Public License 1.0 | 4 votes |
protected DropTargetAdapter getDropTargetListener() { return new ExampleDropTargetListener(); }
Example #9
Source File: IndexEditionControl.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private void createAvailableAttributesTableViewer(Composite parent) { Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED); section.setLayout(GridLayoutFactory.fillDefaults().create()); section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); section.setText(Messages.availableAttributes); Composite client = formPage.getToolkit().createComposite(section); client.setLayout(GridLayoutFactory.fillDefaults().create()); client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); availableAttributesTableViewer = new TableViewer(client, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI); availableAttributesTableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); availableAttributesTableViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, AVAILABLE_FIELDS_VIEWER_ID); formPage.getToolkit().adapt(availableAttributesTableViewer.getTable()); ColumnViewerToolTipSupport.enableFor(availableAttributesTableViewer); availableAttributesTableViewer.setUseHashlookup(true); availableAttributesTableViewer.getTable().setLinesVisible(true); availableAttributesTableViewer.setFilters(indexableFieldFilter, indexedFieldsFilter()); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(1, true)); availableAttributesTableViewer.getTable().setLayout(layout); createAttributesColumn(availableAttributesTableViewer); availableAttributesTableViewer.setContentProvider(new ObservableListContentProvider()); availableAttributesTableViewer.setInput(actualsFieldsObservable); selectedAvailableAttributeObservable = ViewersObservables.observeMultiSelection(availableAttributesTableViewer); availableAttributesTableViewer.getTable().addMouseMoveListener(e -> updateCursor(e, availableAttributesTableViewer)); availableAttributesTableViewer.addDragSupport(DND.DROP_MOVE, new Transfer[] { FieldTransfer.getInstance() }, dragSourceAdapter(selectedAvailableAttributeObservable)); availableAttributesTableViewer.addDropSupport(DND.DROP_MOVE, new Transfer[] { FieldTransfer.getInstance() }, new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { dragLeave(event); indexedFieldsObservable.removeAll((Collection<?>) event.data); } }); section.setClient(client); }