sun.awt.datatransfer.DataTransferer Java Examples
The following examples show how to use
sun.awt.datatransfer.DataTransferer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XDataTransferer.java From hottub with GNU General Public License v2.0 | 6 votes |
protected String getCharsetForTextFormat(Long lFormat) { long format = lFormat.longValue(); if (isMimeFormat(format, "text")) { String nat = getNativeForFormat(format); DataFlavor df = new DataFlavor(nat, null); // Ignore the charset parameter of the MIME type if the subtype // doesn't support charset. if (!DataTransferer.doesSubtypeSupportCharset(df)) { return null; } String charset = df.getParameter("charset"); if (charset != null) { return charset; } } return super.getCharsetForTextFormat(lFormat); }
Example #2
Source File: XDataTransferer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
protected String getCharsetForTextFormat(Long lFormat) { long format = lFormat.longValue(); if (isMimeFormat(format, "text")) { String nat = getNativeForFormat(format); DataFlavor df = new DataFlavor(nat, null); // Ignore the charset parameter of the MIME type if the subtype // doesn't support charset. if (!DataTransferer.doesSubtypeSupportCharset(df)) { return null; } String charset = df.getParameter("charset"); if (charset != null) { return charset; } } return super.getCharsetForTextFormat(lFormat); }
Example #3
Source File: DataFlavor.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private String paramString() { String params = ""; params += "mimetype="; if (mimeType == null) { params += "null"; } else { params += mimeType.getBaseType(); } params += ";representationclass="; if (representationClass == null) { params += "null"; } else { params += representationClass.getName(); } if (DataTransferer.isFlavorCharsetTextType(this) && (isRepresentationClassInputStream() || isRepresentationClassByteBuffer() || byte[].class.equals(representationClass))) { params += ";charset=" + DataTransferer.getTextCharset(this); } return params; }
Example #4
Source File: XDataTransferer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
protected String getCharsetForTextFormat(Long lFormat) { long format = lFormat.longValue(); if (isMimeFormat(format, "text")) { String nat = getNativeForFormat(format); DataFlavor df = new DataFlavor(nat, null); // Ignore the charset parameter of the MIME type if the subtype // doesn't support charset. if (!DataTransferer.doesSubtypeSupportCharset(df)) { return null; } String charset = df.getParameter("charset"); if (charset != null) { return charset; } } return super.getCharsetForTextFormat(lFormat); }
Example #5
Source File: XDataTransferer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
protected String getCharsetForTextFormat(Long lFormat) { long format = lFormat.longValue(); if (isMimeFormat(format, "text")) { String nat = getNativeForFormat(format); DataFlavor df = new DataFlavor(nat, null); // Ignore the charset parameter of the MIME type if the subtype // doesn't support charset. if (!DataTransferer.doesSubtypeSupportCharset(df)) { return null; } String charset = df.getParameter("charset"); if (charset != null) { return charset; } } return super.getCharsetForTextFormat(lFormat); }
Example #6
Source File: XDataTransferer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
protected String getCharsetForTextFormat(Long lFormat) { long format = lFormat.longValue(); if (isMimeFormat(format, "text")) { String nat = getNativeForFormat(format); DataFlavor df = new DataFlavor(nat, null); // Ignore the charset parameter of the MIME type if the subtype // doesn't support charset. if (!DataTransferer.doesSubtypeSupportCharset(df)) { return null; } String charset = df.getParameter("charset"); if (charset != null) { return charset; } } return super.getCharsetForTextFormat(lFormat); }
Example #7
Source File: SunDropTargetContextPeer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * @return if the flavor is supported */ public boolean isDataFlavorSupported(DataFlavor df) { Transferable localTransferable = local; if (localTransferable != null) { return localTransferable.isDataFlavorSupported(df); } else { return DataTransferer.getInstance().getFlavorsForFormats (currentT, DataTransferer.adaptFlavorMap (currentDT.getFlavorMap())). containsKey(df); } }
Example #8
Source File: XSelection.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Blocks the current thread till SelectionNotify or PropertyNotify (in case of INCR transfer) arrives. */ private static void waitForSelectionNotify(WindowPropertyGetter dataGetter) throws InterruptedException { long startTime = System.currentTimeMillis(); XToolkit.awtLock(); try { do { DataTransferer.getInstance().processDataConversionRequests(); XToolkit.awtLockWait(250); } while (propertyGetter == dataGetter && System.currentTimeMillis() < startTime + UNIXToolkit.getDatatransferTimeout()); } finally { XToolkit.awtUnlock(); } }
Example #9
Source File: SunDropTargetContextPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * @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())); } }
Example #10
Source File: XSelection.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Blocks the current thread till SelectionNotify or PropertyNotify (in case of INCR transfer) arrives. */ private static void waitForSelectionNotify(WindowPropertyGetter dataGetter) throws InterruptedException { long startTime = System.currentTimeMillis(); XToolkit.awtLock(); try { do { DataTransferer.getInstance().processDataConversionRequests(); XToolkit.awtLockWait(250); } while (propertyGetter == dataGetter && System.currentTimeMillis() < startTime + UNIXToolkit.getDatatransferTimeout()); } finally { XToolkit.awtUnlock(); } }
Example #11
Source File: XClipboard.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
protected synchronized void setContentsNative(Transferable contents) { SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().getFormatsForTransferable (contents, DataTransferer.adaptFlavorMap(getDefaultFlavorTable())); long[] formats = DataTransferer.keysToLongArray(formatMap); if (!selection.setOwner(contents, formatMap, formats, XToolkit.getCurrentServerTime())) { this.owner = null; this.contents = null; } }
Example #12
Source File: SunDragSourceContextPeer.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * initiate a DnD operation ... */ public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p) throws InvalidDnDOperationException { /* Fix for 4354044: don't initiate a drag if event sequence provided by * DragGestureRecognizer is empty */ if (getTrigger().getTriggerEvent() == null) { throw new InvalidDnDOperationException("DragGestureEvent has a null trigger"); } dragSourceContext = dsc; cursor = c; sourceActions = getDragSourceContext().getSourceActions(); dragImage = di; dragImageOffset = p; Transferable transferable = getDragSourceContext().getTransferable(); SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance(). getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap (getTrigger().getDragSource().getFlavorMap())); long[] formats = DataTransferer.keysToLongArray(formatMap); startDrag(transferable, formats, formatMap); /* * Fix for 4613903. * Filter out all mouse events that are currently on the event queue. */ discardingMouseEvents = true; EventQueue.invokeLater(new Runnable() { public void run() { discardingMouseEvents = false; } }); }
Example #13
Source File: DataFlavor.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns hash code for this <code>DataFlavor</code>. * For two equal <code>DataFlavor</code>s, hash codes are equal. * For the <code>String</code> * that matches <code>DataFlavor.equals(String)</code>, it is not * guaranteed that <code>DataFlavor</code>'s hash code is equal * to the hash code of the <code>String</code>. * * @return a hash code for this <code>DataFlavor</code> */ public int hashCode() { int total = 0; if (representationClass != null) { total += representationClass.hashCode(); } if (mimeType != null) { String primaryType = mimeType.getPrimaryType(); if (primaryType != null) { total += primaryType.hashCode(); } // Do not add subType.hashCode() to the total. equals uses // MimeType.match which reports a match if one or both of the // subTypes is '*', regardless of the other subType. if ("text".equals(primaryType)) { if (DataTransferer.doesSubtypeSupportCharset(this) && representationClass != null && !isStandardTextRepresentationClass()) { String charset = DataTransferer.canonicalName(getParameter("charset")); if (charset != null) { total += charset.hashCode(); } } if ("html".equals(getSubType())) { String document = this.getParameter("document"); if (document != null) { total += document.hashCode(); } } } } return total; }
Example #14
Source File: DataFlavorComparatorTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator(); DataFlavor flavor1 = DataFlavor.imageFlavor; DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor; if (comparator.compare(flavor1, flavor2) == 0) { throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() + " should not be equal"); } }
Example #15
Source File: XClipboard.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected synchronized void setContentsNative(Transferable contents) { SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().getFormatsForTransferable (contents, DataTransferer.adaptFlavorMap(getDefaultFlavorTable())); long[] formats = DataTransferer.keysToLongArray(formatMap); if (!selection.setOwner(contents, formatMap, formats, XToolkit.getCurrentServerTime())) { this.owner = null; this.contents = null; } }
Example #16
Source File: SunDropTargetContextPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * @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())); } }
Example #17
Source File: SunDropTargetContextPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected int postDropTargetEvent(final Component component, final int x, final int y, final int dropAction, final int actions, final long[] formats, final long nativeCtxt, final int eventID, final boolean dispatchType) { AppContext appContext = SunToolkit.targetToAppContext(component); EventDispatcher dispatcher = new EventDispatcher(this, dropAction, actions, formats, nativeCtxt, dispatchType); SunDropTargetEvent event = new SunDropTargetEvent(component, eventID, x, y, dispatcher); if (dispatchType == SunDropTargetContextPeer.DISPATCH_SYNC) { DataTransferer.getInstance().getToolkitThreadBlockedHandler().lock(); } // schedule callback SunToolkit.postEvent(appContext, event); eventPosted(event); if (dispatchType == SunDropTargetContextPeer.DISPATCH_SYNC) { while (!dispatcher.isDone()) { DataTransferer.getInstance().getToolkitThreadBlockedHandler().enter(); } DataTransferer.getInstance().getToolkitThreadBlockedHandler().unlock(); // return target's response return dispatcher.getReturnValue(); } else { return 0; } }
Example #18
Source File: SunDropTargetContextPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * @return if the flavor is supported */ public boolean isDataFlavorSupported(DataFlavor df) { Transferable localTransferable = local; if (localTransferable != null) { return localTransferable.isDataFlavorSupported(df); } else { return DataTransferer.getInstance().getFlavorsForFormats (currentT, DataTransferer.adaptFlavorMap (currentDT.getFlavorMap())). containsKey(df); } }
Example #19
Source File: DataFlavorComparatorTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator(); DataFlavor flavor1 = DataFlavor.imageFlavor; DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor; if (comparator.compare(flavor1, flavor2) == 0) { throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() + " should not be equal"); } }
Example #20
Source File: SunDropTargetContextPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * @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())); } }
Example #21
Source File: SunDropTargetContextPeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * @return if the flavor is supported */ public boolean isDataFlavorSupported(DataFlavor df) { Transferable localTransferable = local; if (localTransferable != null) { return localTransferable.isDataFlavorSupported(df); } else { return DataTransferer.getInstance().getFlavorsForFormats (currentT, DataTransferer.adaptFlavorMap (currentDT.getFlavorMap())). containsKey(df); } }
Example #22
Source File: SunDropTargetContextPeer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * @return if the flavor is supported */ public boolean isDataFlavorSupported(DataFlavor df) { Transferable localTransferable = local; if (localTransferable != null) { return localTransferable.isDataFlavorSupported(df); } else { return DataTransferer.getInstance().getFlavorsForFormats (currentT, DataTransferer.adaptFlavorMap (currentDT.getFlavorMap())). containsKey(df); } }
Example #23
Source File: SunDropTargetContextPeer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected int postDropTargetEvent(final Component component, final int x, final int y, final int dropAction, final int actions, final long[] formats, final long nativeCtxt, final int eventID, final boolean dispatchType) { AppContext appContext = SunToolkit.targetToAppContext(component); EventDispatcher dispatcher = new EventDispatcher(this, dropAction, actions, formats, nativeCtxt, dispatchType); SunDropTargetEvent event = new SunDropTargetEvent(component, eventID, x, y, dispatcher); if (dispatchType == SunDropTargetContextPeer.DISPATCH_SYNC) { DataTransferer.getInstance().getToolkitThreadBlockedHandler().lock(); } // schedule callback SunToolkit.postEvent(appContext, event); eventPosted(event); if (dispatchType == SunDropTargetContextPeer.DISPATCH_SYNC) { while (!dispatcher.isDone()) { DataTransferer.getInstance().getToolkitThreadBlockedHandler().enter(); } DataTransferer.getInstance().getToolkitThreadBlockedHandler().unlock(); // return target's response return dispatcher.getReturnValue(); } else { return 0; } }
Example #24
Source File: BasicTransferable.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private InputStream createInputStream(DataFlavor flavor, String data) throws IOException, UnsupportedFlavorException { String cs = DataTransferer.getTextCharset(flavor); if (cs == null) { throw new UnsupportedFlavorException(flavor); } return new ByteArrayInputStream(data.getBytes(cs)); }
Example #25
Source File: DataFlavorComparatorTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator(); DataFlavor flavor1 = DataFlavor.imageFlavor; DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor; if (comparator.compare(flavor1, flavor2) == 0) { throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() + " should not be equal"); } }
Example #26
Source File: DataFlavor.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns hash code for this <code>DataFlavor</code>. * For two equal <code>DataFlavor</code>s, hash codes are equal. * For the <code>String</code> * that matches <code>DataFlavor.equals(String)</code>, it is not * guaranteed that <code>DataFlavor</code>'s hash code is equal * to the hash code of the <code>String</code>. * * @return a hash code for this <code>DataFlavor</code> */ public int hashCode() { int total = 0; if (representationClass != null) { total += representationClass.hashCode(); } if (mimeType != null) { String primaryType = mimeType.getPrimaryType(); if (primaryType != null) { total += primaryType.hashCode(); } // Do not add subType.hashCode() to the total. equals uses // MimeType.match which reports a match if one or both of the // subTypes is '*', regardless of the other subType. if ("text".equals(primaryType)) { if (DataTransferer.doesSubtypeSupportCharset(this) && representationClass != null && !isStandardTextRepresentationClass()) { String charset = DataTransferer.canonicalName(getParameter("charset")); if (charset != null) { total += charset.hashCode(); } } if ("html".equals(getSubType())) { String document = this.getParameter("document"); if (document != null) { total += document.hashCode(); } } } } return total; }
Example #27
Source File: XClipboard.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected synchronized void setContentsNative(Transferable contents) { SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().getFormatsForTransferable (contents, DataTransferer.adaptFlavorMap(flavorMap)); long[] formats = DataTransferer.keysToLongArray(formatMap); if (!selection.setOwner(contents, formatMap, formats, XToolkit.getCurrentServerTime())) { this.owner = null; this.contents = null; } }
Example #28
Source File: BasicTransferable.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private InputStream createInputStream(DataFlavor flavor, String data) throws IOException, UnsupportedFlavorException { String cs = DataTransferer.getTextCharset(flavor); if (cs == null) { throw new UnsupportedFlavorException(flavor); } return new ByteArrayInputStream(data.getBytes(cs)); }
Example #29
Source File: SunDragSourceContextPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * initiate a DnD operation ... */ public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p) throws InvalidDnDOperationException { /* Fix for 4354044: don't initiate a drag if event sequence provided by * DragGestureRecognizer is empty */ if (getTrigger().getTriggerEvent() == null) { throw new InvalidDnDOperationException("DragGestureEvent has a null trigger"); } dragSourceContext = dsc; cursor = c; sourceActions = getDragSourceContext().getSourceActions(); dragImage = di; dragImageOffset = p; Transferable transferable = getDragSourceContext().getTransferable(); SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance(). getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap (getTrigger().getDragSource().getFlavorMap())); long[] formats = DataTransferer.getInstance(). keysToLongArray(formatMap); startDrag(transferable, formats, formatMap); /* * Fix for 4613903. * Filter out all mouse events that are currently on the event queue. */ discardingMouseEvents = true; EventQueue.invokeLater(new Runnable() { public void run() { discardingMouseEvents = false; } }); }
Example #30
Source File: XClipboard.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected synchronized void setContentsNative(Transferable contents) { SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().getFormatsForTransferable (contents, DataTransferer.adaptFlavorMap(getDefaultFlavorTable())); long[] formats = DataTransferer.keysToLongArray(formatMap); if (!selection.setOwner(contents, formatMap, formats, XToolkit.getCurrentServerTime())) { this.owner = null; this.contents = null; } }