org.eclipse.swt.dnd.URLTransfer Java Examples
The following examples show how to use
org.eclipse.swt.dnd.URLTransfer.
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: ExampleDropTargetInstaller.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void registerWithExistingTarget(DropTarget target) { Transfer[] transfers = target.getTransfer(); boolean exists = false; if (transfers != null) { for (Transfer transfer : transfers) { if (transfer instanceof URLTransfer) { exists = true; break; } } if (!exists) { Transfer[] newTransfers = new Transfer[transfers.length + 1]; System.arraycopy(transfers, 0, newTransfers, 0, transfers.length); newTransfers[transfers.length] = URLTransfer.getInstance(); target.setTransfer(newTransfers); } } }
Example #2
Source File: ExampleDropTargetListener.java From statecharts with Eclipse Public License 1.0 | 6 votes |
private boolean dropTargetIsValid(DropTargetEvent e, boolean isDrop) { if (URLTransfer.getInstance().isSupportedType(e.currentDataType)) { // on Windows, we get the URL already during drag operations... // FIXME find a way to check the URL early on other platforms, // too... if (isDrop || Util.isWindows()) { if (e.data == null && !extractEventData(e)) { // ... but if we don't, it's no problem, unless this is // already // the final drop event return !isDrop; } final String url = getUrl(e.data); if (!ExampleURLHandler.isValidExample(url)) { return false; } } return true; } return false; }
Example #3
Source File: ExampleDropTargetListener.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override public void drop(DropTargetEvent event) { if (!URLTransfer.getInstance().isSupportedType(event.currentDataType)) { return; } final String url = getUrl(event.data); if (ExampleURLHandler.isValidExample(url)) { DropTarget source = (DropTarget) event.getSource(); Display display = source.getDisplay(); display.asyncExec(new Runnable() { public void run() { proceedInstallation(url); } }); } }
Example #4
Source File: CommonDragAdapterAssistant.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public boolean setDragData ( final DragSourceEvent event, final IStructuredSelection selection ) { logger.debug ( "setDragData ( event: {}, selection: {}", event, selection ); final Collection<Item> items = ItemSelectionHelper.getSelection ( selection ); if ( items.isEmpty () ) { logger.info ( "Empty item set for setDragData" ); return false; } if ( ItemTransfer.getInstance ().isSupportedType ( event.dataType ) ) { event.data = items.toArray ( new Item[items.size ()] ); return true; } else if ( TextTransfer.getInstance ().isSupportedType ( event.dataType ) ) { event.data = getItemUriData ( items ); return true; } else if ( URLTransfer.getInstance ().isSupportedType ( event.dataType ) ) { event.data = getItemUriData ( items ); return true; } logger.debug ( "No possible transfer" ); return false; }
Example #5
Source File: RealtimeListDragSourceListener.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void dragSetData ( final DragSourceEvent event ) { try { final IStructuredSelection selection = (IStructuredSelection)LocalSelectionTransfer.getTransfer ().getSelection (); if ( ItemTransfer.getInstance ().isSupportedType ( event.dataType ) ) { final List<Item> items = new ArrayList<Item> (); for ( final Iterator<?> i = selection.iterator (); i.hasNext (); ) { final ListEntry entry = (ListEntry)i.next (); items.add ( entry.getItem () ); } event.data = items.toArray ( new Item[items.size ()] ); } else if ( TextTransfer.getInstance ().isSupportedType ( event.dataType ) ) { setItemUriData ( event, selection ); } else if ( URLTransfer.getInstance ().isSupportedType ( event.dataType ) ) { setItemUriData ( event, selection ); } } catch ( final Exception e ) { event.doit = false; } }
Example #6
Source File: CommonDragAdapterAssistant.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public boolean setDragData ( final DragSourceEvent event, final IStructuredSelection selection ) { logger.debug ( "setDragData ( event: {}, selection: {}", event, selection ); final Collection<Item> items = ItemSelectionHelper.getSelection ( selection ); if ( items.isEmpty () ) { logger.info ( "Empty item set for setDragData" ); return false; } if ( ItemTransfer.getInstance ().isSupportedType ( event.dataType ) ) { event.data = items.toArray ( new Item[items.size ()] ); return true; } else if ( TextTransfer.getInstance ().isSupportedType ( event.dataType ) ) { event.data = getItemUriData ( items ); return true; } else if ( URLTransfer.getInstance ().isSupportedType ( event.dataType ) ) { event.data = getItemUriData ( items ); return true; } logger.debug ( "No possible transfer" ); return false; }
Example #7
Source File: ExampleDropTargetListener.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private boolean extractEventData(DropTargetEvent e) { TransferData transferData = e.currentDataType; if (transferData != null) { Object data = URLTransfer.getInstance().nativeToJava(transferData); if (data != null && getUrl(data) != null) { e.data = data; return true; } } return false; }
Example #8
Source File: CommonDragAdapterAssistant.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public Transfer[] getSupportedTransferTypes () { return new Transfer[] { ItemTransfer.getInstance (), TextTransfer.getInstance (), URLTransfer.getInstance () }; }
Example #9
Source File: RealTimeListViewer.java From neoscada with Eclipse Public License 1.0 | 4 votes |
private void addDragSupport () { this.viewer.addDragSupport ( DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK, new Transfer[] { ItemTransfer.getInstance (), URLTransfer.getInstance (), TextTransfer.getInstance () }, new RealtimeListDragSourceListener ( this.viewer ) ); }
Example #10
Source File: CommonDragAdapterAssistant.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public Transfer[] getSupportedTransferTypes () { return new Transfer[] { ItemTransfer.getInstance (), TextTransfer.getInstance (), URLTransfer.getInstance () }; }