Class RosterEntrySelection

  • All Implemented Interfaces:
    java.awt.datatransfer.ClipboardOwner, java.awt.datatransfer.Transferable

    public class RosterEntrySelection
    extends java.lang.Object
    implements java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner
    Transfer roster entries either via drag-and-drop or via the clipboard.

    Note that roster entries can only be transfered within a single JVM instance, and cannot be shared between programs via this mechanism.


    This file is part of JMRI.

    JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

    JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    • Field Detail

      • rosterEntryFlavor

        public static final java.awt.datatransfer.DataFlavor rosterEntryFlavor
    • Constructor Detail

      • RosterEntrySelection

        public RosterEntrySelection​(java.util.ArrayList<java.lang.String> rosterEntries)
        Create the transferable.

        Takes as a parameter an ArrayList containing Strings representing RosterEntry Ids.

        Parameters:
        rosterEntries - an ArrayList of RosterEntry Ids
    • Method Detail

      • createRosterEntrySelection

        public static RosterEntrySelection createRosterEntrySelection​(java.util.ArrayList<RosterEntry> rosterEntries)
        Create a transferable with a list of RosterEntries.
        Parameters:
        rosterEntries - entries to include in the selection
        Returns:
        a new selection with the given entries
      • getTransferDataFlavors

        public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
        Specified by:
        getTransferDataFlavors in interface java.awt.datatransfer.Transferable
      • isDataFlavorSupported

        public boolean isDataFlavorSupported​(java.awt.datatransfer.DataFlavor df)
        Specified by:
        isDataFlavorSupported in interface java.awt.datatransfer.Transferable
      • getTransferData

        public java.lang.Object getTransferData​(java.awt.datatransfer.DataFlavor df)
                                         throws java.awt.datatransfer.UnsupportedFlavorException,
                                                java.io.IOException
        Specified by:
        getTransferData in interface java.awt.datatransfer.Transferable
        Throws:
        java.awt.datatransfer.UnsupportedFlavorException
        java.io.IOException
      • lostOwnership

        public void lostOwnership​(java.awt.datatransfer.Clipboard clpbrd,
                                  java.awt.datatransfer.Transferable t)
        Specified by:
        lostOwnership in interface java.awt.datatransfer.ClipboardOwner
      • getRosterEntries

        public static java.util.ArrayList<RosterEntrygetRosterEntries​(java.awt.datatransfer.Transferable t)
                                                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                                                        java.io.IOException
        Get an ArrayList of RosterEntries from a RosterEntrySelection.
        Parameters:
        t - a Transferable object. This should be a RosterEntrySelection, but for simplicity, will accept any Transferable object.
        Returns:
        the transfered roster entries
        Throws:
        java.awt.datatransfer.UnsupportedFlavorException - if the transferable is incorrect
        java.io.IOException - if unable to transfer the entries