Class ALcyDefaultLayerSelectionTransferHandler<T>

java.lang.Object
com.luciad.lucy.datatransfer.ALcyLayerSelectionTransferHandler
com.luciad.lucy.datatransfer.ALcyDefaultLayerSelectionTransferHandler<T>
Type Parameters:
T - The type of domain object of your format
All Implemented Interfaces:
ILcdUndoableSource

public abstract class ALcyDefaultLayerSelectionTransferHandler<T> extends ALcyLayerSelectionTransferHandler

An abstract extension of ALcyLayerSelectionTransferHandler which adds support to copy domain objects between models of the same format and optionally to import shapes from another format.

This class does not support a partial copy. When multiple objects are copied or moved in one go, the operation will only take place when all objects can be copied or moved.

Since:
2016.1
  • Constructor Details

    • ALcyDefaultLayerSelectionTransferHandler

      protected ALcyDefaultLayerSelectionTransferHandler(ILcdFilter<ILcdLayer> aLayerFilter)
      Creates a new layer selection transfer handler which allows to import shapes from other formats.
      Parameters:
      aLayerFilter - Filter which only accepts layers of the format for which this transfer handler is created. Might be null, but in that case you have to ensure that the format (ALcyFormat or ALcyLspFormat) that plugs in this transfer handler is decorated with a safe guard format wrapper (TLcySafeGuardFormatWrapper or TLcyLspSafeGuardFormatWrapper).
    • ALcyDefaultLayerSelectionTransferHandler

      protected ALcyDefaultLayerSelectionTransferHandler(ILcdFilter<ILcdLayer> aLayerFilter, boolean aAllowImportShapesFromOtherFormats)
      Creates a new layer selection transfer handler.
      Parameters:
      aLayerFilter - Filter which only accepts layers of the format for which this transfer handler is created. Might be null, but in that case you have to ensure that the format (ALcyFormat or ALcyLspFormat) that plugs in this transfer handler is decorated with a safe guard format wrapper (TLcySafeGuardFormatWrapper or TLcyLspSafeGuardFormatWrapper).
      aAllowImportShapesFromOtherFormats - When false, this transfer handler will only allow to copy or move domain objects between models of the same format. It will no longer try to import shapes from another format.
  • Method Details

    • getSourceActions

      public int getSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
      Description copied from class: ALcyLayerSelectionTransferHandler
      This method determines what this ALcyLayerSelectionTransferHandler can do with the given selection. The return value should be one of:
      Specified by:
      getSourceActions in class ALcyLayerSelectionTransferHandler
      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 final Transferable createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
      Description copied from class: ALcyLayerSelectionTransferHandler
      Creates the transferable to export aSelection.
      Specified by:
      createTransferable in class ALcyLayerSelectionTransferHandler
      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.
    • canImport

      public final boolean canImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView)
      Description copied from class: ALcyLayerSelectionTransferHandler
      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.
      Specified by:
      canImport in class ALcyLayerSelectionTransferHandler
      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 final boolean importData(Transferable aTransferable, ILcdLayer aDestinationLayer, ILcdView aDestinationView)
      Description copied from class: ALcyLayerSelectionTransferHandler
      Actually imports the data into the destination layers.
      Specified by:
      importData in class ALcyLayerSelectionTransferHandler
      Parameters:
      aTransferable - 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.
    • exportDone

      public final void exportDone(Transferable aTransferable, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction)
      Description copied from class: ALcyLayerSelectionTransferHandler
      This method is called when the export is done. Typically in this method you will delete the original objects if aAction was MOVE.
      Specified by:
      exportDone in class ALcyLayerSelectionTransferHandler
      Parameters:
      aTransferable - 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.
    • createDomainObjectCopy

      protected abstract T createDomainObjectCopy(T aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel)

      Create a copy of aDomainObject from aSourceModel which can be inserted into aTargetModel.

      If aSourceModel and aTargetModel are using different references, it is up to this method to perform the necessary conversions.

      Parameters:
      aDomainObject - The domain object that must be copied.
      aSourceModel - The model containing aDomainObject. This is a model of the format for which this transfer handler is created.
      aTargetModel - The model in which the returned copy might be inserted. This is a model of the format for which this transfer handler is created, possibly even the same instance as aSourceModel when copy-pasting elements in the same model.
      Returns:
      A copy of aDomainObject, suitable to be inserted in to aTargetModel. Should never return null when aSourceModel and aTargetModel use the same reference. Might return null when the domain object is not supported in the target reference. In that case, the implementation of this method can decide to log a fail message before returning (see getLogListener()).
    • createDomainObjectForShape

      protected abstract T createDomainObjectForShape(ILcdShape aShape, ILcdModel aSourceModel, ILcdModel aTargetModel)

      Creates a new domain object which can be inserted into aTargetModel where the shape of the returned domain object is a copy of aShape.

      This method will be called when importing shapes from a different format into aTargetModel. It is the responsibility of this method to create a domain object for that shape, and ensure that the shape of the returned domain object is a copy of aShape. The returned domain object should not use aShape directly, as that shape is part of (a domain object of) aSourceModel.

      If aSourceModel and aTargetModel are using different references, it is up to this method to perform the necessary conversions.

      This method will only be called when the transfer handler allows to import shapes from other formats (see ALcyDefaultLayerSelectionTransferHandler(ILcdFilter, boolean)).

      Parameters:
      aShape - The shape.
      aSourceModel - The model from which aShape is obtained. This might be a model from another format.
      aTargetModel - The model in which the returned domain object might be inserted. This is a model of the format for which this transfer handler is created.
      Returns:
      a domain object for aTargetModel using a shape based on aShape, or null when aShape cannot be converted to a valid domain object for aTargetModel. In that case, the implementation of this method can decide to log a fail message before returning (see getLogListener()).
    • createShapeCopy

      protected abstract ILcdShape createShapeCopy(ILcdShape aShape, ILcdModel aSourceModel)

      Creates a copy of aShape retrieved from a domain object of aSourceModel, where the copy is defined in the reference of aSourceModel.

      Parameters:
      aShape - The shape.
      aSourceModel - The model containing the domain object of which aShape was derived. This is a model of the format for which this transfer handler is created.
      Returns:
      a copy of aShape defined in the reference of aSourceModel. Should never return null.
    • getLogListener

      public final ILcdLogListener getLogListener()
      Description copied from class: ALcyLayerSelectionTransferHandler
      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.
      Overrides:
      getLogListener in class ALcyLayerSelectionTransferHandler
      Returns:
      The ILcdLogListener that redirects all messages to the attached ILcdLogListeners.
    • addUndoableListener

      public final 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
      Overrides:
      addUndoableListener in class ALcyLayerSelectionTransferHandler
      Parameters:
      aListener - The listener to be notified when something undoable has happened.
    • removeUndoableListener

      public final 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
      Overrides:
      removeUndoableListener in class ALcyLayerSelectionTransferHandler
      Parameters:
      aListener - The listener to remove.
    • fireUndoableHappened

      protected final void fireUndoableHappened(ILcdUndoable aUndoable)
      Description copied from class: ALcyLayerSelectionTransferHandler
      Notify all attached listeners of aUndoable.
      Overrides:
      fireUndoableHappened in class ALcyLayerSelectionTransferHandler
      Parameters:
      aUndoable - The undoables of which the listeners should be notified.