X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fdnd%2FLocalObjectTransferable.java;h=152679190692daa7fc5bfd4b177d1f324382c854;hp=1b95a49e217e65ae139c2c20139ac0b0c5bc0283;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalObjectTransferable.java b/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalObjectTransferable.java index 1b95a49e2..152679190 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalObjectTransferable.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/dnd/LocalObjectTransferable.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.ui.dnd; - -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.ClipboardOwner; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -public class LocalObjectTransferable implements Transferable, ClipboardOwner { - - //public static final String TYPE_NAME = "application/x-java-jvm-local-objectref" + (new Long(System.currentTimeMillis())).toString() + ";class=java.lang.Object"; //$NON-NLS-1$; - /** - * For transferring JVM local objects as references, does not work between - * applications. The System.currentTimeMillis suffix is added to prevent - * application to application transfer. - */ - public static final String TYPE_NAME = "application/local-object-transfer-format" + (new Long(System.currentTimeMillis())).toString(); //$NON-NLS-1$; - public static final DataFlavor FLAVOR = new DataFlavor(TYPE_NAME, null); - - Object object; - - public LocalObjectTransferable(Object object) { - this.object = new ByteArrayInputStream(new byte[0]); - LocalObjectTransfer.getTransfer().setObject(object); - } - - /** - * Returns an array of flavors in which this Transferable can - * provide the data. DataFlavor.stringFlavor is properly - * supported. Support for DataFlavor.plainTextFlavor is - * deprecated. - * - * @return an array of length two, whose elements are DataFlavor. - * stringFlavor and DataFlavor.plainTextFlavor - */ - public DataFlavor[] getTransferDataFlavors() { - return new DataFlavor[] { FLAVOR }; - } - - public boolean isDataFlavorSupported(DataFlavor flavor) { - return flavor.equals(FLAVOR); - } - - public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { - if (flavor.equals(FLAVOR)) - return object; - throw new UnsupportedFlavorException(flavor); - } - - public void lostOwnership(Clipboard clipboard, Transferable contents) { - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.ui.dnd; + +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.ByteArrayInputStream; +import java.io.IOException; + +public class LocalObjectTransferable implements Transferable, ClipboardOwner { + + //public static final String TYPE_NAME = "application/x-java-jvm-local-objectref" + (new Long(System.currentTimeMillis())).toString() + ";class=java.lang.Object"; //$NON-NLS-1$; + /** + * For transferring JVM local objects as references, does not work between + * applications. The System.currentTimeMillis suffix is added to prevent + * application to application transfer. + */ + public static final String TYPE_NAME = "application/local-object-transfer-format" + (new Long(System.currentTimeMillis())).toString(); //$NON-NLS-1$; + public static final DataFlavor FLAVOR = new DataFlavor(TYPE_NAME, null); + + Object object; + + public LocalObjectTransferable(Object object) { + this.object = new ByteArrayInputStream(new byte[0]); + LocalObjectTransfer.getTransfer().setObject(object); + } + + /** + * Returns an array of flavors in which this Transferable can + * provide the data. DataFlavor.stringFlavor is properly + * supported. Support for DataFlavor.plainTextFlavor is + * deprecated. + * + * @return an array of length two, whose elements are DataFlavor. + * stringFlavor and DataFlavor.plainTextFlavor + */ + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] { FLAVOR }; + } + + public boolean isDataFlavorSupported(DataFlavor flavor) { + return flavor.equals(FLAVOR); + } + + public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { + if (flavor.equals(FLAVOR)) + return object; + throw new UnsupportedFlavorException(flavor); + } + + public void lostOwnership(Clipboard clipboard, Transferable contents) { + } + +}