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


Java Transferable.isDataFlavorSupported方法代码示例

本文整理汇总了Java中java.awt.datatransfer.Transferable.isDataFlavorSupported方法的典型用法代码示例。如果您正苦于以下问题:Java Transferable.isDataFlavorSupported方法的具体用法?Java Transferable.isDataFlavorSupported怎么用?Java Transferable.isDataFlavorSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.datatransfer.Transferable的用法示例。


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

示例1: addDataFlavors

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public Transferable addDataFlavors(Transferable transferable) {
    try {
        if (transferable.isDataFlavorSupported(ConsumerFlavorProvider.WADL_METHOD_FLAVOR)) {
            Object data = transferable.getTransferData(ConsumerFlavorProvider.WADL_METHOD_FLAVOR);
            if (data instanceof WadlSaasMethod) {
                WadlSaasMethod method = (WadlSaasMethod) data;
                ExTransferable t = ExTransferable.create(transferable);
                RestClientEditorDrop editorDrop = new RestClientEditorDrop(method);
                ActiveEditorDropTransferable s = new ActiveEditorDropTransferable(editorDrop);
                t.put(s);
                return t;
            }
        }
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }

    return transferable;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RestClientFlavorProvider.java

示例2: removeButton

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
 * Remove a toolbar button represented by the given Transferable.
 */
private void removeButton( Transferable t ) {
    try {
        Object o = null;
        if( t.isDataFlavorSupported(buttonDataFlavor) ) {
            o = t.getTransferData(buttonDataFlavor);
        }
        if( null != o && o instanceof DataObject ) {
            ((DataObject) o).delete();
            sourceToolbar.repaint();
        }
    } catch( UnsupportedFlavorException e ) {
        log.log( Level.INFO, null, e );
    } catch( IOException ioE ) {
        log.log( Level.INFO, null, ioE );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:DnDSupport.java

示例3: getClipboardText

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/** Wait until clipboard contains string data and returns the text. */
private String getClipboardText() throws Exception {
    Waiter waiter = new Waiter(new Waitable() {

        @Override
        public Object actionProduced(Object obj) {
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            if (contents == null) {
                return null;
            } else {
                return contents.isDataFlavorSupported(DataFlavor.stringFlavor) ? Boolean.TRUE : null;
            }
        }

        @Override
        public String getDescription() {
            return ("Wait clipboard contains string data");
        }
    });
    waiter.waitAction(null);
    return Toolkit.getDefaultToolkit().getSystemClipboard().
            getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:OutputOperatorTest.java

示例4: getBestCharsetForTextFormat

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
private String getBestCharsetForTextFormat(Long lFormat,
    Transferable localeTransferable) throws IOException
{
    String charset = null;
    if (localeTransferable != null &&
        isLocaleDependentTextFormat(lFormat) &&
        localeTransferable.isDataFlavorSupported(javaTextEncodingFlavor))
    {
        try {
            charset = new String(
                (byte[])localeTransferable.getTransferData(javaTextEncodingFlavor),
                "UTF-8"
            );
        } catch (UnsupportedFlavorException cannotHappen) {
        }
    } else {
        charset = getCharsetForTextFormat(lFormat);
    }
    if (charset == null) {
        // Only happens when we have a custom text type.
        charset = getDefaultTextCharset();
    }
    return charset;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:DataTransferer.java

示例5: processTransferable

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
 * Processes given <code>transferable</code> and returns the corresponding
 * <code>NewComponentDrop</code>.
 *
 * @param formModel corresponding form model.
 * @param transferable description of transferred data.
 * @return <code>NewComponentDrop</code> that corresponds to given
 * <code>transferable</code> or <code>null</code> if this provider
 * don't understand to or don't want to process this data transfer.
 */
@Override
public NewComponentDrop processTransferable(FormModel formModel, Transferable transferable) {
    if (J2EEUtils.supportsJPA(formModel)) {
        try {
            if (transferable.isDataFlavorSupported(DatabaseMetaDataTransfer.CONNECTION_FLAVOR)) {
                DatabaseMetaDataTransfer.Connection connection = (DatabaseMetaDataTransfer.Connection)transferable.getTransferData(DatabaseMetaDataTransfer.CONNECTION_FLAVOR);
                return new DBConnectionDrop(formModel, connection);
            } else if (transferable.isDataFlavorSupported(DatabaseMetaDataTransfer.COLUMN_FLAVOR)) {
                DatabaseMetaDataTransfer.Column column = (DatabaseMetaDataTransfer.Column)transferable.getTransferData(DatabaseMetaDataTransfer.COLUMN_FLAVOR);
                return new DBColumnDrop(formModel, column);
            } else if (transferable.isDataFlavorSupported(DatabaseMetaDataTransfer.TABLE_FLAVOR)) {
                DatabaseMetaDataTransfer.Table table = (DatabaseMetaDataTransfer.Table)transferable.getTransferData(DatabaseMetaDataTransfer.TABLE_FLAVOR);
                return new DBTableDrop(formModel, table);
            }
        } catch (Exception ex) {
            // should not happen
            Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:J2EEComponentDropProvider.java

示例6: getBestCharsetForTextFormat

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
protected String getBestCharsetForTextFormat(Long lFormat,
    Transferable localeTransferable) throws IOException
{
    String charset = null;
    if (localeTransferable != null &&
        isLocaleDependentTextFormat(lFormat) &&
        localeTransferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
        try {
            byte[] charsetNameBytes = (byte[])localeTransferable
                    .getTransferData(javaTextEncodingFlavor);
            charset = new String(charsetNameBytes, StandardCharsets.UTF_8);
        } catch (UnsupportedFlavorException cannotHappen) {
        }
    } else {
        charset = getCharsetForTextFormat(lFormat);
    }
    if (charset == null) {
        // Only happens when we have a custom text type.
        charset = Charset.defaultCharset().name();
    }
    return charset;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:DataTransferer.java

示例7: drop

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent dtde) {
	try {
		Transferable t = dtde.getTransferable();
		List<File> files = null;
		if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
			dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
			files = (List<File>) t
					.getTransferData(DataFlavor.javaFileListFlavor);
		} else if (uriFlavor != null && t.isDataFlavorSupported(uriFlavor)) {
			dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
			files = textURIListToFileList((String) t
					.getTransferData(uriFlavor));
		} else
			dtde.rejectDrop();

		if (files != null && files.size() == 1) {
			openFile(files.get(0));
			dtde.dropComplete(true);
		} else
			dtde.dropComplete(false);
	} catch (UnsupportedFlavorException ex) {
		dtde.rejectDrop();
	} catch (IOException e) {
		dtde.rejectDrop();
	}
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:29,代码来源:FileDropTargetListener.java

示例8: getContents

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
 * Gets the contents of the system clipboard
 *
 * @return The text system clipboad contents
 */
public String getContents() {
    String contents = null;
    try {
        ClipboardService cs = (ClipboardService) ServiceManager.lookup(ClipboardService.class.getName());
        Transferable data = cs.getContents();
        if (data != null && data.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            contents = ((String) (data.getTransferData(DataFlavor.stringFlavor)));
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed getting the clipboard contents: " + e.getMessage(), e);
    }
    return contents;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:19,代码来源:ClipboardHandlerJNLP.java

示例9: translateTransferable

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
@Override
public byte[] translateTransferable(Transferable contents,
                                    DataFlavor flavor,
                                    long format) throws IOException
{
    byte[] bytes = null;
    if (format == CF_HTML) {
        if (contents.isDataFlavorSupported(DataFlavor.selectionHtmlFlavor)) {
            // if a user provides data represented by
            // DataFlavor.selectionHtmlFlavor format, we use this
            // type to store the data in the native clipboard
            bytes = super.translateTransferable(contents,
                    DataFlavor.selectionHtmlFlavor,
                    format);
        } else if (contents.isDataFlavorSupported(DataFlavor.allHtmlFlavor)) {
            // if we cannot get data represented by the
            // DataFlavor.selectionHtmlFlavor format
            // but the DataFlavor.allHtmlFlavor format is avialable
            // we belive that the user knows how to represent
            // the data and how to mark up selection in a
            // system specific manner. Therefor, we use this data
            bytes = super.translateTransferable(contents,
                    DataFlavor.allHtmlFlavor,
                    format);
        } else {
            // handle other html flavor types, including custom and
            // fragment ones
            bytes = HTMLCodec.convertToHTMLFormat(super.translateTransferable(contents, flavor, format));
        }
    } else {
        // we handle non-html types basing on  their
        // flavors
        bytes = super.translateTransferable(contents, flavor, format);
    }
    return bytes;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:WDataTransferer.java

示例10: checkImage

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
void checkImage(DropTargetDropEvent dtde) {
    final Transferable t = dtde.getTransferable();
    if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
        dtde.acceptDrop(DnDConstants.ACTION_COPY);
        Image im;
        try {
            im = (Image) t.getTransferData(DataFlavor.imageFlavor);
            System.err.println("getTransferData was successful");
        } catch (Exception e) {
            System.err.println("Can't getTransferData: " + e);
            dtde.dropComplete(false);
            notifyTransferSuccess(false);
            return;
        }

        if (im == null) {
            System.err.println("getTransferData returned null");
            dtde.dropComplete(false);
            notifyTransferSuccess(false);
        } else if (areImagesIdentical(image, im)) {
            dtde.dropComplete(true);
            notifyTransferSuccess(true);
        } else {
            System.err.println("transferred image is different from initial image");
            dtde.dropComplete(false);
            notifyTransferSuccess(false);
        }

    } else {
        System.err.println("imageFlavor is not supported by Transferable");
        dtde.rejectDrop();
        notifyTransferSuccess(false);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:ImageTransferTest.java

示例11: getAllowedDropActions

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public int getAllowedDropActions(Transferable t) {
    if (t != null && t.isDataFlavorSupported(new DataFlavor(Watch.class, null))) {
        return DnDConstants.ACTION_COPY_OR_MOVE;
    } else {
        return DnDConstants.ACTION_COPY;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:WatchesNodeModel.java

示例12: isAcceptable

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
 * Does @transferable support {@link #dataFlavor}?
 *
 * @param transferable Transferable that is being tested if it supports the
 * data flavor that is accepted by this action.
 * @return True if transferable can be dropped on this.
 */
@Override
public final ConnectorState isAcceptable(Widget arg0, Point arg1, Transferable transferable) {
    if (transferable.isDataFlavorSupported(dataFlavor)) {
        return ConnectorState.ACCEPT;
    }
    return ConnectorState.REJECT;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:15,代码来源:AbstractAcceptAction.java

示例13: getStringFromClipboard

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public static String getStringFromClipboard() { 
	String text = null;
	Transferable trf = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); 
	if (trf != null && trf.isDataFlavorSupported(DataFlavor.stringFlavor)) {
		try {
			text = (String) trf.getTransferData(DataFlavor.stringFlavor);
		}  catch (Exception e) {};
	}
	return text; 
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:11,代码来源:Clipboard.java

示例14: getDropType

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
@Override
public PasteType getDropType(Transferable t, int action, int index) {
    if( t.isDataFlavorSupported( PaletteController.ITEM_DATA_FLAVOR ) )
        return super.getDropType(t, action, index);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:CategoryNode.java

示例15: canPaste

import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public boolean canPaste() {
	Clipboard clip = editor.getToolkit().getSystemClipboard();
	Transferable xfer = clip.getContents(this);
	return xfer.isDataFlavorSupported(binaryFlavor);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:6,代码来源:Clip.java


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