Java Code Examples for java.awt.datatransfer.DataFlavor#selectionHtmlFlavor()

The following examples show how to use java.awt.datatransfer.DataFlavor#selectionHtmlFlavor() . 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: WDataTransferer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 2
Source File: DataFlavorComparatorTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 3
Source File: DataFlavorComparatorTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 4
Source File: DataFlavorComparatorTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 5
Source File: WDataTransferer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 6
Source File: DataFlavorComparatorTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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 7
Source File: WDataTransferer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source File: DataFlavorComparatorTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 9
Source File: WDataTransferer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 10
Source File: DataFlavorComparatorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    Comparator<DataFlavor> comparator = DataFlavorUtil.getDataFlavorComparator();
    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 11
Source File: WDataTransferer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 12
Source File: DataFlavorComparatorTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 13
Source File: WDataTransferer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 14
Source File: DataFlavorComparatorTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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: WDataTransferer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 16
Source File: DataFlavorComparatorTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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 17
Source File: WDataTransferer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 18
Source File: DataFlavorComparatorTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 19
Source File: WDataTransferer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 20
Source File: DataFlavorComparatorTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
    }
}