當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。