Java Code Examples for org.eclipse.swt.dnd.DND#DROP_DEFAULT

The following examples show how to use org.eclipse.swt.dnd.DND#DROP_DEFAULT . 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: CallHierarchyTransferDropAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected int determineOperation(Object target, int operation, TransferData transferType, int operations) {
	setSelectionFeedbackEnabled(false);
	setExpandEnabled(false);

	initializeSelection();

	if (target != null) {
		return super.determineOperation(target, operation, transferType, operations);
	} else if (getInputElement(getSelection()) != null) {
		setSelectionFeedbackEnabled(false);
		setExpandEnabled(false);
		return operation == DND.DROP_DEFAULT || operation == DND.DROP_MOVE ? DND.DROP_LINK : operation;
	} else {
		return DND.DROP_NONE;
	}
}
 
Example 2
Source File: Trees.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
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 3
Source File: Tables.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
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 4
Source File: ChartManager.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public DropTarget createDropTarget ( final Transfer[] transfers, final DropTargetListener dropTargetListener )
{
    checkWidget ();

    final DropTarget target = new DropTarget ( this.chartArea, DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_LINK );
    target.setTransfer ( transfers );
    target.addDropListener ( dropTargetListener );
    return target;
}
 
Example 5
Source File: WorkingSetDropAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected int determineOperation(Object target, int operation, TransferData transferType, int operations) {
	switch(operation) {
		case DND.DROP_DEFAULT:
		case DND.DROP_COPY:
		case DND.DROP_MOVE:
			return validateTarget(target, operation);
		default:
			return DND.DROP_NONE;
	}

}
 
Example 6
Source File: SelectionTransferDropAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int internalDetermineOperation(Object target, int operation, int operations) {

		initializeSelection();

		if (target == null)
			return DND.DROP_NONE;

		//Do not allow to drop on itself, bug 14228
		if (getCurrentLocation() == LOCATION_ON) {
			IJavaElement[] javaElements= ReorgUtils.getJavaElements(fElements);
			if (contains(javaElements, target))
				return DND.DROP_NONE;

			IResource[] resources= ReorgUtils.getResources(fElements);
			if (contains(resources, target))
				return DND.DROP_NONE;
		}

		try {
			switch(operation) {
				case DND.DROP_DEFAULT:
					return handleValidateDefault(target, operations);
				case DND.DROP_COPY:
					return handleValidateCopy(target);
				case DND.DROP_MOVE:
					return handleValidateMove(target);
			}
		} catch (JavaModelException e){
			ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message);
		}

		return DND.DROP_NONE;
	}
 
Example 7
Source File: CallHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void initDragAndDrop() {
    addDragAdapters(fCallHierarchyViewer);
    addDropAdapters(fCallHierarchyViewer);
    addDropAdapters(fLocationViewer);

    //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 CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer));
}
 
Example 8
Source File: CallHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addDropAdapters(StructuredViewer viewer) {
	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), PluginTransfer.getInstance() };
	int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;

	DelegatingDropAdapter delegatingDropAdapter= new DelegatingDropAdapter();
	delegatingDropAdapter.addDropTargetListener(new CallHierarchyTransferDropAdapter(this, viewer));
	delegatingDropAdapter.addDropTargetListener(new PluginTransferDropAdapter(viewer));

	viewer.addDropSupport(ops, transfers, delegatingDropAdapter);
}
 
Example 9
Source File: JdtViewerDropSupport.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void start() {
	Assert.isLegal(!fStarted);

	int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT;

	Transfer[] transfers= new Transfer[] {
		LocalSelectionTransfer.getInstance(),
		FileTransfer.getInstance(),
		PluginTransfer.getInstance()};

	fViewer.addDropSupport(ops, transfers, fDelegatingDropAdapter);

	fStarted= true;
}
 
Example 10
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 11
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addDropAdapters(AbstractTreeViewer viewer) {
	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), PluginTransfer.getInstance() };
	int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;

	DelegatingDropAdapter delegatingDropAdapter= new DelegatingDropAdapter();
	delegatingDropAdapter.addDropTargetListener(new TypeHierarchyTransferDropAdapter(this, viewer));
	delegatingDropAdapter.addDropTargetListener(new PluginTransferDropAdapter(viewer));

	viewer.addDropSupport(ops, transfers, delegatingDropAdapter);
}