public void drop(DropTargetEvent event) { DropTarget dropTarget = (DropTarget) event.getSource(); Item targetItem = (Item) event.item; MetadataColumn targetColumn = null; if (targetItem != null) { targetColumn = (MetadataColumn) targetItem.getData(); } if (targetColumn != null) {} EList columns = ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0].getColumns(); int maxColumnsNumber = CoreUIPlugin.getDefault() .getPreferenceStore() .getInt(ITalendCorePrefConstants.MAXIMUM_AMOUNT_OF_COLUMNS_FOR_XML); if (columns.size() >= maxColumnsNumber) { MessageDialog.openWarning( treeViewer.getTree().getShell(), "Columns Overflow", "The amount of schema columns has reached the max value. Please increase the max value on Preference Page(/Talend/Metadata) if you want to add new columns."); return; } Control control = dropTarget.getControl(); LocalDraggedData draggedData = LocalDataTransfer.getInstance().getDraggedData(); List<Object> transferableObjs = draggedData.getTransferableEntryList(); for (Object obj : transferableObjs) { if (obj instanceof FOXTreeNode) { FOXTreeNode treeNode = (FOXTreeNode) obj; calcuAddedColumns(treeNode, targetColumn, columns); } } tableViewer.setInput(columns); tableViewer.refresh(); treeViewer.refresh(); Display display = tree.getDisplay(); Cursor cursor = new Cursor(display, SWT.CURSOR_WAIT); tree.getShell().setCursor(cursor); linker.valueChanged(targetItem); tree.getShell().setCursor(null); linker.updateLinksStyleAndControlsSelection(control, true); linker.updateConnection(); linker.updateFormStatus(); }
public void dragStart(DragSourceEvent event) { TreeItem[] items = tree.getSelection(); if (items.length == 0) { event.doit = false; } else { boolean isHasChildren = false; for (TreeItem treeItem : items) { if (treeItem.getItemCount() > 0) { isHasChildren = true; break; } } if (isHasChildren) { event.doit = false; } else { LocalDraggedData draggedData = new LocalDraggedData(); for (TreeItem treeItem : items) { draggedData.add(treeItem.getData()); } LocalDataTransfer.getInstance().setLocalDraggedData(draggedData); } } }