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


Java UnsupportedFlavorException类代码示例

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


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

示例1: testClipboard

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
public void testClipboard() throws Exception {
    MockServices.setServices(Cnv.class);
    Clipboard c = Lookup.getDefault().lookup(Clipboard.class);
    ExClipboard ec = Lookup.getDefault().lookup(ExClipboard.class);
    assertEquals("Clipboard == ExClipboard", c, ec);
    assertNotNull(Lookup.getDefault().lookup(ExClipboard.Convertor.class));
    assertEquals(Cnv.class, Lookup.getDefault().lookup(ExClipboard.Convertor.class).getClass());
    c.setContents(new ExTransferable.Single(DataFlavor.stringFlavor) {
        protected Object getData() throws IOException, UnsupportedFlavorException {
            return "17";
        }
    }, null);
    Transferable t = c.getContents(null);
    assertTrue("still supports stringFlavor", t.isDataFlavorSupported(DataFlavor.stringFlavor));
    assertEquals("correct string in clipboard", "17", t.getTransferData(DataFlavor.stringFlavor));
    assertTrue("support Integer too", t.isDataFlavorSupported(MYFLAV));
    assertEquals("correct Integer", new Integer(17), t.getTransferData(MYFLAV));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NbClipboardNativeTest.java

示例2: getBestCharsetForTextFormat

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的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

示例3: ExTransferable

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
/** Creates new support.
* @param t transferable to to copy values from
* @param o clipobard owner (or null)
*/
private ExTransferable(final Transferable t) {
    map = new LinkedHashMap<DataFlavor,Single>();

    final DataFlavor[] df = t.getTransferDataFlavors();

    if (df != null) {
        for (int i = 0; i < df.length; i++) {
            try {
                final int fi = i;
                map.put(
                    df[i],
                    new Single(df[i]) {
                        public Object getData() throws IOException, UnsupportedFlavorException {
                            return t.getTransferData(df[fi]);
                        }
                    }
                );
            } catch (Exception ex) {
                // ignore if the data cannot be retrived
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ExTransferable.java

示例4: reorderProjects

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
private Boolean reorderProjects(TransferHandler.TransferSupport support) {
    JList list = (JList) support.getComponent();
    try {
        int[] selectedIndices = (int[]) support.getTransferable().getTransferData(INDICES);
        DefaultListModel model = (DefaultListModel) list.getModel();
        JList.DropLocation dl = (JList.DropLocation) support.getDropLocation();
        if (dl.getIndex() != -1) {
            for (int selectedIndex : selectedIndices) {
                Object value = model.get(selectedIndex);
                model.removeElement(value);
                model.add(dl.getIndex(), value);
            }
            return true;
        } else {
            LOG.warning("Invalid Drop Location");
        }
    } catch (UnsupportedFlavorException | IOException ex) {
        LOG.log(Level.SEVERE, ex.getMessage(), ex);
    }
    return false;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:InjectScript.java

示例5: removeButton

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的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

示例6: handleDropImpl

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
private boolean handleDropImpl(Transferable t) {       
    try {
        Object o;
        if( t.isDataFlavorSupported( actionDataFlavor ) ) {
            o = t.getTransferData( actionDataFlavor );
            if( o instanceof Node ) {
                DataObject dobj = ((Node)o).getLookup().lookup( DataObject.class );
                return addButton( dobj, dropTargetButtonIndex, insertBefore );
            }
        } else {
            o = t.getTransferData( buttonDataFlavor );
            if( o instanceof DataObject ) {
                return moveButton( (DataObject)o, dropTargetButtonIndex, insertBefore );
            }
        }
    } catch( UnsupportedFlavorException e ) {
        log.log( Level.INFO, null, e );
    } catch( IOException ioE ) {
        log.log( Level.INFO, null, ioE );
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:DnDSupport.java

示例7: getTransferData

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
public Object getTransferData(DataFlavor flavor)
    throws UnsupportedFlavorException, IOException
{
    if (!isDataFlavorSupported(flavor)) {
        throw new UnsupportedFlavorException(flavor);
    }
    Object ret = flavorsToData.get(flavor);
    if (ret instanceof IOException) {
        // rethrow IOExceptions generated while fetching data
        throw (IOException)ret;
    } else if (ret instanceof DataFactory) {
        // Now we can render the data
        DataFactory factory = (DataFactory)ret;
        ret = factory.getTransferData(flavor);
    }
    return ret;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:ClipboardTransferable.java

示例8: clipboardChanged

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
@Override
public void clipboardChanged(ClipboardEvent ev) {
    ExClipboard clipboard = ev.getClipboard();

    Transferable transferable = null;
    String clipboardContent = null;
    try {
        transferable = clipboard.getContents(null);
        if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            clipboardContent = (String) transferable.getTransferData(DataFlavor.stringFlavor);
        }
    } catch (OutOfMemoryError oom) {            
        NotificationDisplayer.getDefault().notify( NbBundle.getBundle(ClipboardHistory.class).getString("clipboard-history-oom"),NotificationDisplayer.Priority.NORMAL.getIcon(), NbBundle.getBundle(ClipboardHistory.class).getString("clipboard-history-oom-details"), null);
        return;
    } catch (IOException ioe) {
        //ignored for bug #218255
    } catch (UnsupportedFlavorException ufe) {
    }

    if (clipboardContent != null) {
        addHistory(transferable, clipboardContent);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ClipboardHistory.java

示例9: getTransferData

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {

	if (flavor.equals(LOCAL_TRANSFERRED_OPERATORS_FLAVOR)) {
		return this.clonedOperators;
	}
	if (flavor.equals(DataFlavor.stringFlavor)) {
		StringBuilder b = new StringBuilder();
		for (Operator op : clonedOperators) {
			b.append(op.getXML(false));
		}
		return b.toString();
	} else {
		throw new UnsupportedFlavorException(flavor);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:TransferableOperator.java

示例10: valueSourceDrop

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
/**
 * Is called if a {@link ValueSourceTreeNode} is dropped on the {@link PlotConfigurationTree}.
 */
private void valueSourceDrop(final ValueSourceTreeNode valueSourceTreeNode, TreePath path, final int childIndex,
		boolean importDataTableColumn) throws UnsupportedFlavorException, IOException, ChartConfigurationException {

	// fetch dropped value source and parent
	final ValueSource valueSource = valueSourceTreeNode.getUserObject();

	Object lastPathComponent = path.getLastPathComponent();
	if (lastPathComponent instanceof RangeAxisConfigTreeNode) {
		valueSourceDropOnRangeAxisConfig(valueSourceTreeNode, childIndex, valueSource, lastPathComponent);
	} else {
		valueSourceDropOnPlotConfiguration(valueSourceTreeNode, childIndex, valueSource, lastPathComponent,
				importDataTableColumn);
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:PlotConfigurationTreeTransferHandler.java

示例11: getTransferData

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
	if (flavor == binaryFlavor) {
		return this;
	} else if (flavor == DataFlavor.stringFlavor) {
		StringBuilder buf = new StringBuilder();
		for (int i = 0; i < headers.length; i++) {
			buf.append(headers[i]);
			buf.append(i == headers.length - 1 ? '\n' : '\t');
		}
		for (int i = 0; i < contents.length; i++) {
			for (int j = 0; j < contents[i].length; j++) {
				buf.append(contents[i][j]);
				buf.append(j == contents[i].length - 1 ? '\n' : '\t');
			}
		}
		return buf.toString();
	} else {
		throw new UnsupportedFlavorException(flavor);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:TableTabClip.java

示例12: drop

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    try {
        Transferable t = dtde.getTransferable();
        DataFlavor[] dataFlavors = t.getTransferDataFlavors();
        for (DataFlavor df : dataFlavors) {
            if (df.isFlavorJavaFileListType()) {
                File[] filesArray = (File[]) ((List<File>) t.getTransferData(df)).toArray();
                pathNameTextField.setText(getFilesName(filesArray));
            }
        }
    } catch (UnsupportedFlavorException e2) {
    } catch (IOException ex) {
        Logger.getLogger(SubtitleDownloaderUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:atulgpt,项目名称:SubtitleDownloader,代码行数:18,代码来源:SubtitleDownloaderUI.java

示例13: isSrcComponentSameAsTargetComponent

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
/**
 * Returns true if the drag came from the same component as we are testing for drop. Used to
 * prevent drops on the src file list.
 */
public boolean isSrcComponentSameAsTargetComponent(TransferHandler.TransferSupport info)
        throws UnsupportedFlavorException, IOException {
    boolean result = false;

    // First get where we are putting this file
    String myPanelDir = profilePanel.getCurrentDirectory().getPath();

    // Don't accept drags from current panel.
    if (info.isDataFlavorSupported(ArrayListTransferrable.flavor)) {
        // Get the Array of items being dropped.
        Transferable t = info.getTransferable();
        ArrayList arrayList = (ArrayList) t.getTransferData(ArrayListTransferrable.flavor);
        ArcMoverFile fileBeingMoved = (ArcMoverFile) arrayList.get(2);
        String fileBeingMovedDir = fileBeingMoved.getParent().getPath();
        if (myPanelDir.equals(fileBeingMovedDir)) {
            result = true;
        }
    }
    return result;
}
 
开发者ID:Hitachi-Data-Systems,项目名称:Open-DM,代码行数:25,代码来源:MoverTransferHandler.java

示例14: getBestCharsetForTextFormat

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:DataTransferer.java

示例15: getTransferData

import java.awt.datatransfer.UnsupportedFlavorException; //导入依赖的package包/类
@Override
public Object getTransferData(DataFlavor flavor)
    throws UnsupportedFlavorException, IOException
{
    if (!isDataFlavorSupported(flavor)) {
        throw new UnsupportedFlavorException(flavor);
    }
    Object ret = flavorsToData.get(flavor);
    if (ret instanceof IOException) {
        // rethrow IOExceptions generated while fetching data
        throw new IOException("Exception fetching data: ", (IOException)ret);
    } else if (ret instanceof DataFactory) {
        // Now we can render the data
        DataFactory factory = (DataFactory)ret;
        ret = factory.getTransferData(flavor);
    }
    return ret;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ClipboardTransferable.java


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