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

The following examples show how to use org.eclipse.swt.dnd.DND#DROP_LINK . 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: ProtocolEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 2
Source File: SecurityEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 3
Source File: InfrastructureEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 4
Source File: WorldEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 5
Source File: DeploymentEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 6
Source File: ChartEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] {
            LocalTransfer.getInstance (),
            LocalSelectionTransfer.getTransfer (),
            FileTransfer.getInstance (),
            ItemTransfer.getInstance ()
    };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
 
Example 7
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 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: CoreEditor.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
	MenuManager contextMenu = new MenuManager("#PopUp");
	contextMenu.add(new Separator("additions"));
	contextMenu.setRemoveAllWhenShown(true);
	contextMenu.addMenuListener(this);
	Menu menu= contextMenu.createContextMenu(viewer.getControl());
	viewer.getControl().setMenu(menu);
	getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

	int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
	Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
	viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
	viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
 
Example 10
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addDragAdapters(StructuredViewer viewer) {
	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance() };
	int ops= DND.DROP_COPY | DND.DROP_LINK;

	JdtViewerDragAdapter dragAdapter= new JdtViewerDragAdapter(viewer);
	dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(viewer));
	dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(viewer));
	dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(viewer));
	viewer.addDragSupport(ops, transfers, dragAdapter);
}
 
Example 11
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 12
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);
}
 
Example 13
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 14
Source File: TypeHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addDragAdapters(StructuredViewer viewer) {
	int ops= DND.DROP_COPY | DND.DROP_LINK;
	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};

	JdtViewerDragAdapter dragAdapter= new JdtViewerDragAdapter(viewer);
	dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(viewer));
	dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(viewer));
	dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(viewer));
	dragAdapter.addDragSourceListener(new FileTransferDragAdapter(viewer));

	viewer.addDragSupport(ops, transfers, dragAdapter);
}
 
Example 15
Source File: JdtViewerDragSupport.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;

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

	fViewer.addDragSupport(ops, transfers, fDragAdapter);

	fStarted= true;
}
 
Example 16
Source File: BeansEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
	MenuManager contextMenu = new MenuManager("#PopUp");
	contextMenu.add(new Separator("additions"));
	contextMenu.setRemoveAllWhenShown(true);
	contextMenu.addMenuListener(this);
	Menu menu= contextMenu.createContextMenu(viewer.getControl());
	viewer.getControl().setMenu(menu);
	getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

	int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
	Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
	viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
	viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
 
Example 17
Source File: EipEditor.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
   * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
   * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
   * @generated
   */
protected void createContextMenuFor(StructuredViewer viewer) {
     MenuManager contextMenu = new MenuManager("#PopUp");
     contextMenu.add(new Separator("additions"));
     contextMenu.setRemoveAllWhenShown(true);
     contextMenu.addMenuListener(this);
     Menu menu= contextMenu.createContextMenu(viewer.getControl());
     viewer.getControl().setMenu(menu);
     getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

     int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
     Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
     viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
     viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
  }
 
Example 18
Source File: TypeScriptSearchResultPage.java    From typescript.java with MIT License 4 votes vote down vote up
private void addDragAdapters(StructuredViewer viewer) {
	Transfer[] transfers= new Transfer[] { ResourceTransfer.getInstance() };
	int ops= DND.DROP_COPY | DND.DROP_LINK;
	viewer.addDragSupport(ops, transfers, new NavigatorDragAdapter(viewer));
}
 
Example 19
Source File: ProjectExplorerDropAdapterAssistant.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IStatus handleDrop(CommonDropAdapter dropAdapter,
		DropTargetEvent event, Object target) {

	try {
		// drop in folder
		if (target instanceof IXdsFolderContainer || 
				target instanceof IProject || 
				target instanceof IContainer ||
				(dropAdapter.getCurrentOperation() == DND.DROP_COPY && (
						target instanceof IFile ||
						target instanceof IXdsResource))) {

			final Object data= event.data;
			if (data == null) {
				return Status.CANCEL_STATUS;
			}
			final IContainer destination= getDestination(target);
			if (destination == null) {
				return Status.CANCEL_STATUS;
			}
			IResource[] resources = null;
			TransferData currentTransfer = dropAdapter.getCurrentTransfer();
			final int dropOperation = dropAdapter.getCurrentOperation();
			if (LocalSelectionTransfer.getTransfer().isSupportedType(
					currentTransfer)) {
				resources = getSelectedResources();
			} else if (ResourceTransfer.getInstance().isSupportedType(
					currentTransfer)) {
				resources = (IResource[]) event.data;
			}
			if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
				final String[] names = (String[]) data;
				// Run the import operation asynchronously. 
				// Otherwise the drag source (e.g., Windows Explorer) will be blocked 
				Display.getCurrent().asyncExec(new Runnable() {
					public void run() {
						getShell().forceActive();
						CopyFilesAndFoldersOperation op= new CopyFilesAndFoldersOperation(getShell());
						op.copyOrLinkFiles(names, destination, dropOperation);
					}
				});
			} else if (event.detail == DND.DROP_COPY || event.detail == DND.DROP_LINK) {
				return performResourceCopy(dropAdapter, getShell(), resources);
			} else {
				ReadOnlyStateChecker checker = new ReadOnlyStateChecker(
					getShell(), 
					"Move Resource Action",	//$NON-NLS-1$
					"Move Resource Action");//$NON-NLS-1$	
				resources = checker.checkReadOnlyResources(resources);
				MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
				operation.copyResources(resources, destination);
			}
			return Status.OK_STATUS;
		}
	} 
	finally {
		// The drag source listener must not perform any operation
		// since this drop adapter did the remove of the source even
		// if we moved something.
		event.detail= DND.DROP_NONE;
	}
	return Status.CANCEL_STATUS;
}
 
Example 20
Source File: ResourceDropAdapterAssistant.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public IStatus handleDrop(CommonDropAdapter aDropAdapter,
		DropTargetEvent aDropTargetEvent, Object aTarget) {

	if (Policy.DEBUG_DND) {
		System.out
				.println("ResourceDropAdapterAssistant.handleDrop (begin)"); //$NON-NLS-1$
	}

	// alwaysOverwrite = false;
	if (aTarget == null || aDropTargetEvent.data == null) {
		return Status.CANCEL_STATUS;
	}
	IStatus status = null;
	IResource[] resources = null;
	TransferData currentTransfer = aDropAdapter.getCurrentTransfer();
	if (LocalSelectionTransfer.getTransfer().isSupportedType(
			currentTransfer)) {
		resources = getSelectedResources();
	} else if (ResourceTransfer.getInstance().isSupportedType(
			currentTransfer)) {
		resources = (IResource[]) aDropTargetEvent.data;
	}

	if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
		status = performFileDrop(aDropAdapter, aDropTargetEvent.data);
	} else if (resources != null && resources.length > 0) {
		if ((aDropAdapter.getCurrentOperation() == DND.DROP_COPY)
				|| (aDropAdapter.getCurrentOperation() == DND.DROP_LINK)) {
			if (Policy.DEBUG_DND) {
				System.out
						.println("ResourceDropAdapterAssistant.handleDrop executing COPY."); //$NON-NLS-1$
			}
			status = performResourceCopy(aDropAdapter, getShell(),
					resources);
		} else {
			if (Policy.DEBUG_DND) {
				System.out
						.println("ResourceDropAdapterAssistant.handleDrop executing MOVE."); //$NON-NLS-1$
			}

			status = performResourceMove(aDropAdapter, resources);
		}
	}
	openError(status);
	IContainer target = getActualTarget((IResource) aTarget);
	if (target != null && target.isAccessible()) {
		try {
			target.refreshLocal(IResource.DEPTH_ONE, null);
		} catch (CoreException e) {
		}
	}
	return status;
}