/** * All selection must be named model objects. */ @Override public void dragStart(DragSourceEvent event) { // Workaround for 1GEUS9V DragSource dragSource = (DragSource) event.widget; Control control = dragSource.getControl(); if (control != control.getDisplay().getFocusControl()) { event.doit = false; return; } event.doit = canDrag(); }
public void preserveValues( Widget widget ) { DragSource dragSource = ( DragSource )widget; IWidgetAdapter adapter = WidgetUtil.getAdapter( dragSource ); adapter.preserve( PROP_CONTROL, dragSource.getControl() ); adapter.preserve( PROP_TRANSFER, dragSource.getTransfer() ); }
/** * All selection must be files or folders. */ @Override public void dragStart(DragSourceEvent event) { // Workaround for 1GEUS9V DragSource dragSource = (DragSource) event.widget; Control control = dragSource.getControl(); if (control != control.getDisplay().getFocusControl()) { event.doit = false; return; } FileAdapter[] files = getSelectedFiles(); if (files.length == 0) { event.doit = false; return; } event.doit = true; }
public void renderInitialization( Widget widget ) throws IOException { DragSource dragSource = ( DragSource )widget; JSWriter writer = JSWriter.getWriterFor( dragSource ); String[] operations = DNDLCAUtil.convertOperations( dragSource.getStyle() ); Object[] args = new Object[]{ dragSource.getControl(), operations }; writer.callStatic( JSFUNC_REGISTER, args ); }
private static void writeTransfer( DragSource dragSource ) throws IOException { Transfer[] newValue = dragSource.getTransfer(); if( WidgetLCAUtil.hasChanged( dragSource, PROP_TRANSFER, newValue, DEFAULT_TRANSFER ) ) { JSWriter writer = JSWriter.getWriterFor( dragSource ); Object[] args = new Object[]{ dragSource.getControl(), DNDLCAUtil.convertTransferTypes( newValue ) }; writer.callStatic( JSFUNC_SET_TRANSFER_TYPES, args ); } }
public void dragSetData(DragSourceEvent event) { if (TextTransfer.getInstance().isSupportedType(event.dataType)){ if (((DragSource) event.widget).getControl() instanceof Tree){ TreeItem selection = dragTree.getSelection()[ 0 ]; Thing thing = (Thing) selection.getData(); event.data = thing.getMetadata().getPath(); } } }
@Override public void renderInitialization( DragSource dragSource ) throws IOException { RemoteObject remoteObject = createRemoteObject( dragSource, TYPE ); remoteObject.setHandler( new DragSourceOperationHandler( dragSource ) ); remoteObject.set( "control", getId( dragSource.getControl() ) ); remoteObject.set( "style", convertOperations( dragSource.getStyle() ) ); }
/** * Start the drag only if the selection contains IUs. */ public void dragStart(DragSourceEvent event) { // Focus workaround copied from navigator drag adapter DragSource dragSource = (DragSource) event.widget; Control control = dragSource.getControl(); if (control != control.getDisplay().getFocusControl()) { event.doit = false; return; } // Check the selection IStructuredSelection selection = (IStructuredSelection) selectionProvider.getSelection(); // No drag if nothing is selected if (selection.isEmpty()) { event.doit = false; return; } if (!areOnlyIUsSelected(selection)) { event.doit = false; return; } LocalSelectionTransfer.getTransfer().setSelection(selection); event.doit = true; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
@Override public void run() { int x = properties.get( EVENT_PARAM_X ).asInt(); int y = properties.get( EVENT_PARAM_Y ).asInt(); int time = properties.get( EVENT_PARAM_TIME ).asInt(); Control control = dragSource.getControl(); Point mappedPoint = control.getDisplay().map( null, control, x, y ); control.notifyListeners( SWT.DragDetect, createDragDetectEvent( mappedPoint, time ) ); DNDEvent event = createDragSourceEvent( mappedPoint, time, DND.DROP_NONE ); dragSource.notifyListeners( DND.DragStart, event ); if( !event.doit ) { cancel(); } } } );
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent a * SWT object that manage a shell, <code>null</code> is returned. * * @param widget * the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * @param widget the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; } }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @param widget The widget to get the shell for * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @param widget The widget to get the shell for * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; } }
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * @param widget the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
@Override public void run() { int x = properties.get( EVENT_PARAM_X ).asInt(); int y = properties.get( EVENT_PARAM_Y ).asInt(); int time = properties.get( EVENT_PARAM_TIME ).asInt(); Control control = dragSource.getControl(); Point mappedPoint = control.getDisplay().map( null, control, x, y ); int detail = hasDetailChanged() ? getDetailChangedValue() : DND.DROP_NONE; DNDEvent event = createDragSourceEvent( mappedPoint, time, detail ); dragSource.notifyListeners( DND.DragEnd, event ); cancelDetailChanged(); cancelFeedbackChanged(); cancelDataTypeChanged(); } } );