本文整理汇总了Java中java.awt.datatransfer.Transferable.getTransferDataFlavors方法的典型用法代码示例。如果您正苦于以下问题:Java Transferable.getTransferDataFlavors方法的具体用法?Java Transferable.getTransferDataFlavors怎么用?Java Transferable.getTransferDataFlavors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.datatransfer.Transferable
的用法示例。
在下文中一共展示了Transferable.getTransferDataFlavors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLastTransferable
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public synchronized Transferable getLastTransferable(Transferable waitFor) throws Exception {
WAIT: for (int loop = 0; loop < 60; loop++) {
if (loop > 0) {
wait(500);
}
if (lastTransferable != null) {
java.awt.datatransfer.DataFlavor[] arr1 = lastTransferable.getTransferDataFlavors();
java.awt.datatransfer.DataFlavor[] arr2 = waitFor.getTransferDataFlavors();
if (Arrays.asList(arr1).equals(Arrays.asList(arr2))) {
for (int i = 0; i < arr1.length; i++) {
Object f1 = convert(lastTransferable.getTransferData(arr1[i]));
Object f2 = convert(waitFor.getTransferData(arr1[i]));
if (!f1.equals(f2)) {
continue WAIT;
}
}
return lastTransferable;
}
}
}
return null;
}
示例2: paste
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
void paste() throws IOException {
Clipboard clip = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable contents = clip.getContents(this);
DataFlavor[] flavors = contents.getTransferDataFlavors();
for( int k=0 ; k<flavors.length ; k++) {
try {
if( flavors[k].getHumanPresentableName().indexOf("html")>=0 )continue;
BufferedReader in = new BufferedReader(
flavors[k].getReaderForText(contents));
System.out.println( flavors[k].getHumanPresentableName());
read( in );
break;
} catch( UnsupportedFlavorException e) {
}
}
}
示例3: testClipboardCopy
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public void testClipboardCopy() throws Exception {
String tablename = "testtable";
String pkName = "id";
createBasicTable(tablename, pkName);
TableNode tableNode = getTableNode(tablename);
assertNotNull(tableNode);
assertTrue(tableNode.canCopy());
Transferable transferable = (Transferable)tableNode.clipboardCopy();
Set mimeTypes = new HashSet();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
mimeTypes.add(flavors[i].getMimeType());
}
assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-table; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Table"));
assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
dropTable(tablename);
}
示例4: testClipboardCopy
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public void testClipboardCopy() throws Exception {
String tablename = "testtable";
String pkName = "id";
createBasicTable(tablename, pkName);
TableNode tableNode = getTableNode(tablename);
assertNotNull(tableNode);
ColumnNode columnNode = getColumnNode(tableNode);
assertNotNull(columnNode);
assertTrue(columnNode.canCopy());
Transferable transferable = (Transferable)columnNode.clipboardCopy();
Set mimeTypes = new HashSet();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
mimeTypes.add(flavors[i].getMimeType());
}
assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-column; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Column"));
assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
dropTable(tablename);
}
示例5: testClipboardCopy
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public void testClipboardCopy() throws Exception {
JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL[0]);
JDBCDriverManager.getDefault().addDriver(driver);
DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false);
ConnectionManager.getDefault().addConnection(dbconn);
ConnectionNode connectionNode = getConnectionNode();
assertTrue(connectionNode != null);
assertTrue(connectionNode.canCopy());
Transferable transferable = (Transferable)connectionNode.clipboardCopy();
Set mimeTypes = new HashSet();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
mimeTypes.add(flavors[i].getMimeType());
}
assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-connection; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Connection"));
assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
}
示例6: setDataFlavor
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
* Sets and returns the type of the Transferable object of the clipboard
*
* @param t - Transferable object in clipboard
*
* @return t'type - Type of DataFlavor
*/
public static DataFlavor setDataFlavor(Transferable t) {
DataFlavor[] flavors = t.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
if (flavors[i].equals(DataFlavor.stringFlavor)) {
type = Contents.TYPE_STRING;
return DataFlavor.stringFlavor;
} else if (flavors[i].equals(DataFlavor.imageFlavor)) {
type = Contents.TYPE_IMAGE;
return DataFlavor.imageFlavor;
} else if (flavors[i].equals(DataFlavor.javaFileListFlavor)) {
type = Contents.TYPE_FILE;
return DataFlavor.javaFileListFlavor;
} else {
}
}
return null;
}
示例7: showPopup
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
@Override
protected void showPopup(MouseEvent evt) {
// Series of checks.. to enable or disable menus.
if (jpqlEditor.getText().trim().equals("")) {
runJPQLMenuItem.setEnabled(false);
selectAllMenuItem.setEnabled(false);
} else {
runJPQLMenuItem.setEnabled(true);
selectAllMenuItem.setEnabled(true);
}
if (jpqlEditor.getSelectedText() == null || jpqlEditor.getSelectedText().trim().equals("")) {
cutMenuItem.setEnabled(false);
copyMenuItem.setEnabled(false);
} else {
cutMenuItem.setEnabled(true);
copyMenuItem.setEnabled(true);
}
Transferable transferable = (Transferable) systemClipboard.getContents(null);
if (transferable.getTransferDataFlavors().length == 0) {
pasteMenuItem.setEnabled(false);
} else {
pasteMenuItem.setEnabled(true);
}
popupMenu.show(jpqlEditor, evt.getX(), evt.getY());
}
示例8: getTransferDataFlavors
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
* @return current DataFlavors available
*/
// NOTE: This method may be called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
public DataFlavor[] getTransferDataFlavors() {
final Transferable localTransferable = local;
if (localTransferable != null) {
return localTransferable.getTransferDataFlavors();
} else {
return DataTransferer.getInstance().getFlavorsForFormatsAsArray
(currentT, DataTransferer.adaptFlavorMap
(currentDT.getFlavorMap()));
}
}
示例9: node
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/** Obtain a node from a transferable.
* Probes the transferable in case it includes a flavor corresponding
* to a node operation (which you must specify a mask for).
*
* @param t transferable
* @param action one of the <code>DND_*</code> or <code>CLIPBOARD_*</code> constants
* @return the node or <code>null</code>
*/
public static Node node(Transferable t, int action) {
DataFlavor[] flavors = t.getTransferDataFlavors();
if (flavors == null) {
return null;
}
int len = flavors.length;
String subtype = "x-java-openide-nodednd"; // NOI18N
String primary = "application"; // NOI18N
String mask = "mask"; // NOI18N
for (int i = 0; i < len; i++) {
DataFlavor df = flavors[i];
if (df.getSubType().equals(subtype) && df.getPrimaryType().equals(primary)) {
try {
int m = Integer.valueOf(df.getParameter(mask)).intValue();
if ((m & action) != 0) {
// found the node
return (Node) t.getTransferData(df);
}
} catch (NumberFormatException nfe) {
maybeReportException(nfe);
} catch (ClassCastException cce) {
maybeReportException(cce);
} catch (IOException ioe) {
maybeReportException(ioe);
} catch (UnsupportedFlavorException ufe) {
maybeReportException(ufe);
}
}
}
return null;
}
示例10: getFormatsForTransferable
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
* Returns a Map whose keys are all of the possible formats into which the
* Transferable's transfer data flavors can be translated. The value of
* each key is the DataFlavor in which the Transferable's data should be
* requested when converting to the format.
* <p>
* The map keys are sorted according to the native formats preference
* order.
*/
public SortedMap<Long,DataFlavor> getFormatsForTransferable(Transferable contents,
FlavorTable map)
{
DataFlavor[] flavors = contents.getTransferDataFlavors();
if (flavors == null) {
return Collections.emptySortedMap();
}
return getFormatsForFlavors(flavors, map);
}
示例11: getPasteTypes
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public PasteType[] getPasteTypes(final Object node, final Transferable t) throws UnknownTypeException {
if (node != TreeModel.ROOT && getWatch(node) == null) {
return null;
}
DataFlavor[] flavors = t.getTransferDataFlavors();
final DataFlavor textFlavor = DataFlavor.selectBestTextFlavor(flavors);
if (textFlavor != null) {
return new PasteType[] { new PasteType() {
public Transferable paste() {
try {
java.io.Reader r = textFlavor.getReaderForText(t);
java.nio.CharBuffer cb = java.nio.CharBuffer.allocate(1000);
r.read(cb);
cb.flip();
Watch w = getWatch(node);
if (w != null) {
w.setExpression(cb.toString());
//fireModelChange(new ModelEvent.NodeChanged(WatchesNodeModel.this, node));
} else {
// Root => add a new watch
DebuggerManager.getDebuggerManager().createWatch(cb.toString());
}
} catch (Exception ex) {}
return null;
}
} };
} else {
return null;
}
}
示例12: getAvailableDataFlavors
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
* @see java.awt.datatransfer.Clipboard#getAvailableDataFlavors
* @since 1.5
*/
public DataFlavor[] getAvailableDataFlavors() {
Transferable cntnts = getContextContents();
if (cntnts != null) {
return cntnts.getTransferDataFlavors();
}
long[] formats = getClipboardFormatsOpenClose();
return DataTransferer.getInstance().
getFlavorsForFormatsAsArray(formats, getDefaultFlavorTable());
}
示例13: getFormatsForTransferable
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
* Returns a Map whose keys are all of the possible formats into which the
* Transferable's transfer data flavors can be translated. The value of
* each key is the DataFlavor in which the Transferable's data should be
* requested when converting to the format.
* <p>
* The map keys are sorted according to the native formats preference
* order.
*/
public SortedMap<Long,DataFlavor> getFormatsForTransferable(
Transferable contents, FlavorTable map)
{
DataFlavor[] flavors = contents.getTransferDataFlavors();
if (flavors == null) {
return new TreeMap();
}
return getFormatsForFlavors(flavors, map);
}
示例14: getAvailableDataFlavors
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
/**
* @see java.awt.Clipboard#getAvailableDataFlavors
* @since 1.5
*/
public DataFlavor[] getAvailableDataFlavors() {
Transferable cntnts = getContextContents();
if (cntnts != null) {
return cntnts.getTransferDataFlavors();
}
long[] formats = getClipboardFormatsOpenClose();
return DataTransferer.getInstance().
getFlavorsForFormatsAsArray(formats, getDefaultFlavorTable());
}
示例15: getDropType
import java.awt.datatransfer.Transferable; //导入方法依赖的package包/类
public PasteType getDropType(final Object node, final Transferable t, int action,
final int index) throws UnknownTypeException {
//System.err.println("\n\ngetDropType("+node+", "+t+", "+action+", "+index+")");
DataFlavor[] flavors = t.getTransferDataFlavors();
final DataFlavor textFlavor = DataFlavor.selectBestTextFlavor(flavors);
//System.err.println("Text Flavor = "+textFlavor);
if (textFlavor != null) {
return new PasteType() {
public Transferable paste() {
String watchExpression;
try {
java.io.Reader r = textFlavor.getReaderForText(t);
java.nio.CharBuffer cb = java.nio.CharBuffer.allocate(1000);
r.read(cb);
cb.flip();
watchExpression = cb.toString();
} catch (Exception ex) {
return t;
}
Watch w = getWatch(node);
if (w != null) {
w.setExpression(watchExpression);
//fireModelChange(new ModelEvent.NodeChanged(WatchesNodeModel.this, node));
} else {
// Root => add a new watch
if (index < 0) {
DebuggerManager.getDebuggerManager().createWatch(watchExpression);
} else {
DebuggerManager.getDebuggerManager().createWatch(
Math.min(index, DebuggerManager.getDebuggerManager().getWatches().length),
watchExpression);
}
}
return t;
}
};
} else {
return null;
}
}