当前位置: 首页>>代码示例>>Java>>正文


Java URLTransfer类代码示例

本文整理汇总了Java中org.eclipse.swt.dnd.URLTransfer的典型用法代码示例。如果您正苦于以下问题:Java URLTransfer类的具体用法?Java URLTransfer怎么用?Java URLTransfer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


URLTransfer类属于org.eclipse.swt.dnd包,在下文中一共展示了URLTransfer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTransferType

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
Transfer getTransferType(String mime) {
    if (mime.equals("text/plain")) {
      return TextTransfer.getInstance();
    }
    if (mime.equals("text/rtf")) {
      return RTFTransfer.getInstance();
    }
    if (mime.equals("text/html")) {
      return HTMLTransfer.getInstance();
    }
    if (mime.equals("text/uri-list")) {
      return URLTransfer.getInstance();
    }
    if (mime.equals("application/x-java-rawimage")) {
      return ImageTransfer.getInstance();
    }
    if (mime.equals("application/x-java-file-list") || mime.equals("java.file-list")) {
        return FileTransfer.getInstance();
    }
    return getCustomTransfer(mime);
}
 
开发者ID:TRUEJASONFANS,项目名称:JavaFX-FrameRateMeter,代码行数:22,代码来源:OldFXCanvas.java

示例2: getMime

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
String getMime(Transfer transfer) {
    if (transfer.equals(TextTransfer.getInstance())) {
      return "text/plain";
    }
    if (transfer.equals(RTFTransfer.getInstance())) {
      return "text/rtf";
    } ;
    if (transfer.equals( HTMLTransfer.getInstance())) {
      return "text/html";
    }
    if (transfer.equals(URLTransfer.getInstance())) {
      return "text/uri-list";
    }
    if (transfer.equals( ImageTransfer.getInstance())) {
      return "application/x-java-rawimage";
    }
    if (transfer.equals(FileTransfer.getInstance())) {
      return "application/x-java-file-list";
    }
    if (transfer instanceof CustomTransfer) {
      return ((CustomTransfer)transfer).getMime();
    }
    return null;
}
 
开发者ID:TRUEJASONFANS,项目名称:JavaFX-FrameRateMeter,代码行数:25,代码来源:OldFXCanvas.java

示例3: getStructuredSelection

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
private IStructuredSelection getStructuredSelection(Object data, TransferData currentDataType) {
	if (LocalSelectionTransfer.getTransfer().isSupportedType(currentDataType)) {
		return (IStructuredSelection) data;
	}
	if (URLTransfer.getInstance().isSupportedType(currentDataType)) {
		try {
			return new StructuredSelection(new URL((String) data));
		} catch (MalformedURLException e) {
			// ignore
		}
	}
	if (FileTransfer.getInstance().isSupportedType(currentDataType)) {
		return new StructuredSelection(Arrays.stream((String[]) data).map(Path::new).collect(Collectors.toList()));
	}
	return new StructuredSelection();
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:17,代码来源:BookmarksViewerDropListener.java

示例4: getStructuredSelectionFromClipboard

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
private IStructuredSelection getStructuredSelectionFromClipboard(Display display) {
	Clipboard clipboard = new Clipboard(display);
	try {
		String text = (String) clipboard.getContents(URLTransfer.getInstance());
		if (text == null) {
			text = (String) clipboard.getContents(TextTransfer.getInstance());
		}
		if (text != null) {
			try {
				URL url = new URL(text);
				return new StructuredSelection(url);
			} catch (MalformedURLException e) {

			}
		}
		String[] paths = (String[]) clipboard.getContents(FileTransfer.getInstance());
		if (paths != null) {
			return new StructuredSelection(Arrays.stream(paths).map(Path::new).collect(Collectors.toList()));
		}
		return new StructuredSelection();
	} finally {
		clipboard.dispose();
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:25,代码来源:PasteBookmarkOperation.java

示例5: registerWithExistingTarget

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
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);
		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:ExampleDropTargetInstaller.java

示例6: dropTargetIsValid

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
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;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:22,代码来源:ExampleDropTargetListener.java

示例7: drop

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
@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);
			}
		});
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:18,代码来源:ExampleDropTargetListener.java

示例8: drop

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
@Override
public void drop(DropTargetEvent event) {
	if (!URLTransfer.getInstance().isSupportedType(event.currentDataType)) {
		traceUnsupportedDataType(event);
		//ignore
		return;
	}
	if (event.data == null) {
		traceMissingEventData(event);
		//reject
		event.detail = DND.DROP_NONE;
		return;
	}
	if (!dropTargetIsValid(event, true)) {
		//reject
		event.detail = DND.DROP_NONE;
		return;
	}
	final String url = getUrl(event.data);
	ForceIdeUrlActionHandler urlActionHandler = new ForceIdeUrlActionHandler(url, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay());
	ForceIdeUrlActionHandler.ProjectAction result = urlActionHandler.processCommand();
	if (result == ForceIdeUrlActionHandler.ProjectAction.IGNORE || result == ForceIdeUrlActionHandler.ProjectAction.INVALID)
		traceInvalidEventData(event);
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:25,代码来源:ForceIdeUrlDropHandler.java

示例9: dragSetData

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
@Override
public void dragSetData(DragSourceEvent event) {
	IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
	GitBlitViewModel model= (ProjectViewModel) selection.getFirstElement();

	String gitURL=null;
	if(model instanceof ProjectViewModel){
		ProjectViewModel pm = (ProjectViewModel)model;
		gitURL = pm.getGitUrl();
	}
	if(gitURL == null){
		return;
	}
	if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
		event.data = gitURL;
	}
	if (URLTransfer.getInstance().isSupportedType(event.dataType)) {
		try{
			event.data = new URL(gitURL);
		}
		catch(Exception e){
			Activator.logError("Error while performin drag & drop",e);
		}
	}
}
 
开发者ID:baloise,项目名称:egitblit,代码行数:26,代码来源:RepoDragListener.java

示例10: setDragData

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
@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;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:33,代码来源:CommonDragAdapterAssistant.java

示例11: dragSetData

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:31,代码来源:RealtimeListDragSourceListener.java

示例12: installDragAndDropSupport

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
private void installDragAndDropSupport() {
	int operations = DND.DROP_MOVE;
	addDragSupport(operations, new Transfer[] { LocalSelectionTransfer.getTransfer() },
			new BookmarksViewerDragListener(this));
	addDropSupport(DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK,
			new Transfer[] { LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance(),
					URLTransfer.getInstance() },
			new BookmarksViewerDropListener(this, bookmarkDatabase, bookmarkPropertiesProvider));
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:10,代码来源:BookmarksTreeViewer.java

示例13: testPasteUrl

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
@Test
public void testPasteUrl() throws BookmarksException {
	// Given
	// on mac, when you copy from chrome
	copyToClipboard("http://www.google.com", URLTransfer.getInstance());
	int numberOfBookmarksBefore = bookmarkDatabase.getBookmarksTree().size();

	// When
	pasteBookmarkOperation.paste(getBookmarkFolder(bookmarkDatabase.getBookmarksTree(), 0, 0, 0).getId(),
			new NullProgressMonitor());

	// Then
	assertEquals(numberOfBookmarksBefore + 1, bookmarkDatabase.getBookmarksTree().size());		
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:15,代码来源:PasteBookmarkOperationTest.java

示例14: extractEventData

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
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;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:12,代码来源:ExampleDropTargetListener.java

示例15: onDropRunnable

import org.eclipse.swt.dnd.URLTransfer; //导入依赖的package包/类
private void onDropRunnable(final DropTargetEvent event) {

		final TransferData transferDataType = event.currentDataType;

		boolean isPOI = false;

		if (TextTransfer.getInstance().isSupportedType(transferDataType)) {

			if (event.data instanceof String) {
				isPOI = parsePOIText((String) event.data);
			}

		} else if (URLTransfer.getInstance().isSupportedType(transferDataType)) {
			isPOI = parsePOIText((String) event.data);
		}

		if (isPOI == false) {

			String poiText = Messages.Dialog_DropNoPOI_InvalidData;

			if (event.data instanceof String) {

				poiText = (String) event.data;

				final int maxLength = 1000;
				if (poiText.length() > maxLength) {
					poiText = poiText.substring(0, maxLength) + "..."; //$NON-NLS-1$
				}
			}

			MessageDialog.openInformation(
					getShell(), //
					Messages.Dialog_DropNoPOI_Title,
					NLS.bind(Messages.Dialog_DropNoPOI_Message, poiText));
		}
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:37,代码来源:Map.java


注:本文中的org.eclipse.swt.dnd.URLTransfer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。