001package jmri.jmrit.throttle.list; 002 003import java.awt.datatransfer.DataFlavor; 004import java.awt.datatransfer.Transferable; 005import java.awt.datatransfer.UnsupportedFlavorException; 006import java.io.IOException; 007 008import jmri.jmrit.throttle.interfaces.ThrottleControllerUI; 009 010/** 011 * A class to handle transfers (drag'n drop) of throttle UI controllers within the throttle list panel 012 * 013 * <hr> 014 * This file is part of JMRI. 015 * <p> 016 * JMRI is free software; you can redistribute it and/or modify it under the 017 * terms of version 2 of the GNU General Public License as published by the Free 018 * Software Foundation. See the "COPYING" file for a copy of this license. 019 * <p> 020 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 022 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 023 * 024 * @author Lionel Jeanson 025 */ 026 027class ThrottleUITransferable implements Transferable { 028 public static final DataFlavor ThrottleControllerUIObjectFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + ThrottleControllerUI.class.getName(), "JMRI Throttle Controller UI"); 029 private ThrottleControllerUI tcui; 030 031 public ThrottleUITransferable(ThrottleControllerUI tcui) { 032 this.tcui = tcui; 033 } 034 035 @Override 036 public DataFlavor[] getTransferDataFlavors() { 037 return new DataFlavor[] { ThrottleControllerUIObjectFlavor }; 038 } 039 040 @Override 041 public boolean isDataFlavorSupported(DataFlavor flavor) { 042 return flavor.equals(ThrottleControllerUIObjectFlavor); 043 } 044 045 @Override 046 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { 047 return tcui; 048 } 049 050}