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

The following examples show how to use org.eclipse.swt.dnd.DND#DROP_COPY . 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: 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 3
Source File: ComponentEditor.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 4
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 5
Source File: ProfileEditor.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: 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 7
Source File: MemoryEditor.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" );
    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 8
Source File: CrossflowEditor.java    From scava with Eclipse Public 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 9
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 10
Source File: IdentifiableDragSource.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void setup(){
	DragSource mine = new DragSource(viewer.getControl(), DND.DROP_COPY);
	mine.setTransfer(new Transfer[] {
		myTransfer
	});
	mine.addDragListener(this);
}
 
Example 11
Source File: DesignerDropListener.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void dragEnter( DropTargetEvent event )
{
	if ( ( event.operations & DND.DROP_COPY ) != 0
			&& ( event.operations & DND.DROP_MOVE ) == 0 )
	{
		event.detail = DND.DROP_COPY;
	}
	super.dragEnter( event );
}
 
Example 12
Source File: CustomPreviewTableDragListener.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void dragFinished( DragSourceEvent event )
{
	super.dragFinished( event );

	if ( event.detail == DND.DROP_COPY )
	{
		// Reset column color
		for ( int i = 0; i < customTable.getColumnNumber( ); i++ )
		{
			customTable.setColumnColor( i,
					ColorPalette.getInstance( )
					.getColor( customTable.getColumnHeading( i ) ) );
		}
	}
}
 
Example 13
Source File: ScriptConsoleViewer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void initDragDrop() {
    DragSource dragSource = new DragSource(this, DND.DROP_COPY | DND.DROP_MOVE);
    dragSource.addDragListener(new DragSourceAdapter());
    dragSource.setTransfer(new Transfer[] { org.eclipse.swt.dnd.TextTransfer.getInstance() });

    DropTarget dropTarget = new DropTarget(this, DND.DROP_COPY | DND.DROP_MOVE);
    dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer(),
            org.eclipse.swt.dnd.TextTransfer.getInstance() });
    dropTarget.addDropListener(new DragTargetAdapter());
}
 
Example 14
Source File: GenericObjectDragSource.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void setup(){
	DragSource mine = new DragSource(dragSource, DND.DROP_COPY);
	mine.setTransfer(new Transfer[] {
		myTransfer
	});
	mine.addDragListener(this);
}
 
Example 15
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 16
Source File: ExtensionsEditor.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 17
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 18
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 19
Source File: EditorAreaDropAdapter.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void dragOperationChanged(DropTargetEvent event) {
	// always indicate a copy
	event.detail = DND.DROP_COPY;
}
 
Example 20
Source File: DragAndDropSupport.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void dragEnter(DropTargetEvent event){
	event.detail = DND.DROP_COPY;
}