/** * Copyright 1999-2009 The Pegadi Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.pegadi.storysketch.views; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; public class RDFTransferable implements Transferable { RDFItem item; DataFlavor rdfFlavor; String localRDFItemType = DataFlavor.javaJVMLocalObjectMimeType + ";class=pegadi.storysketch.views.RDFItem"; private final Logger log = LoggerFactory.getLogger(getClass()); public RDFTransferable(RDFItem item) { this.item = item; try { rdfFlavor = new DataFlavor(localRDFItemType); } catch (ClassNotFoundException e) { log.error("RDFTransferHandler: unable to create data flavor", e); } } public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) { throw new UnsupportedFlavorException(flavor); } return item; } public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { rdfFlavor}; } public boolean isDataFlavorSupported(DataFlavor flavor) { return rdfFlavor.equals(flavor); } }