Class ALcyLayerSelectionTransferHandler

java.lang.Object
com.luciad.lucy.datatransfer.ALcyLayerSelectionTransferHandler
All Implemented Interfaces:
ILcdUndoableSource
Direct Known Subclasses:
ALcyDefaultLayerSelectionTransferHandler, TLcyCompositeLayerSelectionTransferHandler, TLcyGXYAsynchronousLayerSelectionTransferHandler

public abstract class ALcyLayerSelectionTransferHandler extends Object implements ILcdUndoableSource

An ALcyLayerSelectionTransferHandler is responsible for exporting a selection from a source layer to various other representations. This exported data can then be imported by another ALcyLayerSelectionTransferHandler. A typical example is when a user copies and pastes domain objects between layers.

The ALcyLayerSelectionTransferHandler is similar to Swing's TransferHandler, in that it wraps the contents of an object in a Transferable. Unlike Swing however, an ALcyLayerSelectionTransferHandler exports the contents of a layer, whereas Swing's TransferHandler exports the contents of a JComponent. For more information about the usage of ALcyLayerSelectionTransferHandler, please consult the Lucy Developer Guide.

An ALcyLayerSelectionTransferHandler has a ILcdLogListener which can be used to provide textual feedback to Lucy regarding errors. This ILcdLogListener is accessible using the getLogListener() method.

Note that this class implements ILcdUndoableSource. As such ILcdUndoableListener instances can be added to objects of this class. You can notify the attached listeners of an ILcdUndoable with the fireUndoableHappened(com.luciad.gui.ILcdUndoable) method.

  • Field Details

    • NONE

      public static final int NONE
      This constant indicates that the ALcyLayerSelectionTransferHandler cannot export the selection.
      See Also:
    • COPY

      public static final int COPY
      This constant indicates that the ALcyLayerSelectionTransferHandler can only copy the selection.
      See Also:
    • MOVE

      public static final int MOVE
      This constant indicates that the ALcyLayerSelectionTransferHandler can only move the selection.
      See Also:
    • COPY_OR_MOVE

      public static final int COPY_OR_MOVE
      This constant indicates that the ALcyLayerSelectionTransferHandler can either copy or move the selection.
      See Also:
  • Constructor Details

    • ALcyLayerSelectionTransferHandler

      public ALcyLayerSelectionTransferHandler()
  • Method Details

    • getSourceActions

      public abstract int getSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
      This method determines what this ALcyLayerSelectionTransferHandler can do with the given selection. The return value should be one of:
      • NONE: indicates this transfer handler cannot export the selection.
      • COPY: indicates this ALcyLayerSelectionTransferHandler can only copy the selection.
      • MOVE: indicates this ALcyLayerSelectionTransferHandler can only move the selection.
      • COPY_OR_MOVE: indicates this ALcyLayerSelectionTransferHandler can either move or copy the selection.
      Parameters:
      aSelection - The selection that is to exported.
      aSourceLayer - The ILcdLayer that contains aSelection.
      aSourceView - The ILcdView that contains aSelection.
      Returns:
      The action that this ALcyLayerSelectionTransferHandler can perform on aSelection.
    • createTransferable

      public abstract Transferable createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
      Creates the transferable to export aSelection.
      Parameters:
      aSelection - The selection that is to exported.
      aSourceLayer - The ILcdLayer that contains aSelection.
      aSourceView - The ILcdView that contains aSelection.
      Returns:
      The Transferable that contains the exported data in various flavors.
    • exportDone

      public abstract void exportDone(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction)
      This method is called when the export is done. Typically in this method you will delete the original objects if aAction was MOVE.
      Parameters:
      aData - The Transferable that was exported.
      aSourceLayer - The ILcdLayer containing the original objects. Possibly null if aAction is NONE.
      aSourceView - The ILcdView containing the original objects. Possibly null if aAction is NONE.
      aAction - The action that was performed with the transferable.
    • canImport

      public abstract boolean canImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView)
      This method determines whether this ALcyLayerSelectionTransferHandler can import the given Transferable. Typically this method will check if this ALcyLayerSelectionTransferHandler can do something with one of the DataFlavors contained in aData.
      Parameters:
      aFlavors - The available flavors in which the data to import can be represented.
      aDestinationLayer - The ILcdLayer in which the data should be imported.
      aDestinationView - The ILcdView which contains aDestinationLayer.
      Returns:
      true if this ALcyLayerSelectionTransferHandler can import aData.
    • importData

      public abstract boolean importData(Transferable aData, ILcdLayer aDestinationLayer, ILcdView aDestinationView)
      Actually imports the data into the destination layers.
      Parameters:
      aData - The data to be imported.
      aDestinationLayer - The ILcdLayer in which the data should be imported.
      aDestinationView - The ILcdView which contains aDestinationLayer.
      Returns:
      Whether or not the import went successfully.
    • addLogListener

      public final void addLogListener(ILcdLogListener aLogListener)
      Adds a ILcdLogListener to this ALcyLayerSelectionTransferHandler.
      Parameters:
      aLogListener - The ILcdLogListener to add to this ALcyLayerSelectionTransferHandler.
    • removeLogListener

      public final void removeLogListener(ILcdLogListener aLogListener)
      Removes the specified ILcdLogListener to this ALcyLayerSelectionTransferHandler.
      Parameters:
      aLogListener - The ILcdLogListener to remove from this ALcyLayerSelectionTransferHandler.
    • getLogListener

      public ILcdLogListener getLogListener()
      Gives you the ILcdLogListener that redirects all messages to the ILcdLogListeners attached to this ALcyLayerSelectionTransferHandler. You should use this log listener to provide feedback to Lucy, for instance, when something failed during the importing.
      Returns:
      The ILcdLogListener that redirects all messages to the attached ILcdLogListeners.
    • addUndoableListener

      public void addUndoableListener(ILcdUndoableListener aListener)
      Description copied from interface: ILcdUndoableSource
      Adds a listener to this source, so this listener is notified when something undoable has happened.
      Specified by:
      addUndoableListener in interface ILcdUndoableSource
      Parameters:
      aListener - The listener to be notified when something undoable has happened.
    • removeUndoableListener

      public void removeUndoableListener(ILcdUndoableListener aListener)
      Description copied from interface: ILcdUndoableSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeUndoableListener in interface ILcdUndoableSource
      Parameters:
      aListener - The listener to remove.
    • fireUndoableHappened

      protected void fireUndoableHappened(ILcdUndoable aUndoable)
      Notify all attached listeners of aUndoable.
      Parameters:
      aUndoable - The undoables of which the listeners should be notified.