Package jmri.util.datatransfer
Class RosterEntrySelection
- java.lang.Object
-
- jmri.util.datatransfer.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 Summary
Fields Modifier and Type Field Description static java.awt.datatransfer.DataFlavor
rosterEntryFlavor
-
Constructor Summary
Constructors Constructor Description RosterEntrySelection(java.util.ArrayList<java.lang.String> rosterEntries)
Create the transferable.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RosterEntrySelection
createRosterEntrySelection(java.util.ArrayList<RosterEntry> rosterEntries)
Create a transferable with a list of RosterEntries.static java.util.ArrayList<RosterEntry>
getRosterEntries(java.awt.datatransfer.Transferable t)
Get an ArrayList of RosterEntries from a RosterEntrySelection.java.lang.Object
getTransferData(java.awt.datatransfer.DataFlavor df)
java.awt.datatransfer.DataFlavor[]
getTransferDataFlavors()
boolean
isDataFlavorSupported(java.awt.datatransfer.DataFlavor df)
void
lostOwnership(java.awt.datatransfer.Clipboard clpbrd, java.awt.datatransfer.Transferable t)
-
-
-
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 interfacejava.awt.datatransfer.Transferable
-
isDataFlavorSupported
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor df)
- Specified by:
isDataFlavorSupported
in interfacejava.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 interfacejava.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 interfacejava.awt.datatransfer.ClipboardOwner
-
getRosterEntries
public static java.util.ArrayList<RosterEntry> getRosterEntries(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 incorrectjava.io.IOException
- if unable to transfer the entries
-
-