Class ALcyDefaultLayerSelectionTransferHandler<T>
- Type Parameters:
T
- The type of domain object of your format
- All Implemented Interfaces:
ILcdUndoableSource
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
-
Field Summary
Fields inherited from class com.luciad.lucy.datatransfer.ALcyLayerSelectionTransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE
-
Constructor Summary
ModifierConstructorDescriptionprotected
ALcyDefaultLayerSelectionTransferHandler
(ILcdFilter<ILcdLayer> aLayerFilter) Creates a new layer selection transfer handler which allows to import shapes from other formats.protected
ALcyDefaultLayerSelectionTransferHandler
(ILcdFilter<ILcdLayer> aLayerFilter, boolean aAllowImportShapesFromOtherFormats) Creates a new layer selection transfer handler. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addUndoableListener
(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.final boolean
canImport
(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView) This method determines whether thisALcyLayerSelectionTransferHandler
can import the givenTransferable
.protected abstract T
createDomainObjectCopy
(T aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel) Create a copy ofaDomainObject
fromaSourceModel
which can be inserted intoaTargetModel
.protected abstract T
createDomainObjectForShape
(ILcdShape aShape, ILcdModel aSourceModel, ILcdModel aTargetModel) Creates a new domain object which can be inserted intoaTargetModel
where the shape of the returned domain object is a copy ofaShape
.protected abstract ILcdShape
createShapeCopy
(ILcdShape aShape, ILcdModel aSourceModel) Creates a copy ofaShape
retrieved from a domain object ofaSourceModel
, where the copy is defined in the reference ofaSourceModel
.final Transferable
createTransferable
(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection
.final void
exportDone
(Transferable aTransferable, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction) This method is called when the export is done.protected final void
fireUndoableHappened
(ILcdUndoable aUndoable) Notify all attached listeners ofaUndoable
.final ILcdLogListener
Gives you the ILcdLogListener that redirects all messages to theILcdLogListener
s attached to thisALcyLayerSelectionTransferHandler
.int
getSourceActions
(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) This method determines what thisALcyLayerSelectionTransferHandler
can do with the given selection.final boolean
importData
(Transferable aTransferable, ILcdLayer aDestinationLayer, ILcdView aDestinationView) Actually imports the data into the destination layers.final void
removeUndoableListener
(ILcdUndoableListener aListener) Removes the specified listener so it is no longer notified.Methods inherited from class com.luciad.lucy.datatransfer.ALcyLayerSelectionTransferHandler
addLogListener, removeLogListener
-
Constructor Details
-
ALcyDefaultLayerSelectionTransferHandler
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 benull
, but in that case you have to ensure that the format (ALcyFormat
orALcyLspFormat
) that plugs in this transfer handler is decorated with a safe guard format wrapper (TLcySafeGuardFormatWrapper
orTLcyLspSafeGuardFormatWrapper
).
-
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 benull
, but in that case you have to ensure that the format (ALcyFormat
orALcyLspFormat
) that plugs in this transfer handler is decorated with a safe guard format wrapper (TLcySafeGuardFormatWrapper
orTLcyLspSafeGuardFormatWrapper
).aAllowImportShapesFromOtherFormats
- Whenfalse
, 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
Description copied from class:ALcyLayerSelectionTransferHandler
This method determines what thisALcyLayerSelectionTransferHandler
can do with the given selection. The return value should be one of:ALcyLayerSelectionTransferHandler.NONE
: indicates this transfer handler cannot export the selection.ALcyLayerSelectionTransferHandler.COPY
: indicates thisALcyLayerSelectionTransferHandler
can only copy the selection.ALcyLayerSelectionTransferHandler.MOVE
: indicates thisALcyLayerSelectionTransferHandler
can only move the selection.ALcyLayerSelectionTransferHandler.COPY_OR_MOVE
: indicates thisALcyLayerSelectionTransferHandler
can either move or copy the selection.
- Specified by:
getSourceActions
in classALcyLayerSelectionTransferHandler
- Parameters:
aSelection
- The selection that is to exported.aSourceLayer
- TheILcdLayer
that contains aSelection.aSourceView
- TheILcdView
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 exportaSelection
.- Specified by:
createTransferable
in classALcyLayerSelectionTransferHandler
- Parameters:
aSelection
- The selection that is to exported.aSourceLayer
- TheILcdLayer
that contains aSelection.aSourceView
- TheILcdView
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 thisALcyLayerSelectionTransferHandler
can import the givenTransferable
. Typically this method will check if thisALcyLayerSelectionTransferHandler
can do something with one of theDataFlavor
s contained inaData
.- Specified by:
canImport
in classALcyLayerSelectionTransferHandler
- Parameters:
aFlavors
- The available flavors in which the data to import can be represented.aDestinationLayer
- TheILcdLayer
in which the data should be imported.aDestinationView
- TheILcdView
which containsaDestinationLayer
.- Returns:
true
if thisALcyLayerSelectionTransferHandler
can importaData
.
-
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 classALcyLayerSelectionTransferHandler
- Parameters:
aTransferable
- The data to be imported.aDestinationLayer
- TheILcdLayer
in which the data should be imported.aDestinationView
- TheILcdView
which containsaDestinationLayer
.- 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 ifaAction
wasMOVE
.- Specified by:
exportDone
in classALcyLayerSelectionTransferHandler
- Parameters:
aTransferable
- TheTransferable
that was exported.aSourceLayer
- TheILcdLayer
containing the original objects. Possiblynull
ifaAction
isNONE
.aSourceView
- TheILcdView
containing the original objects. Possiblynull
ifaAction
isNONE
.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
fromaSourceModel
which can be inserted intoaTargetModel
.If
aSourceModel
andaTargetModel
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 containingaDomainObject
. 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 asaSourceModel
when copy-pasting elements in the same model.- Returns:
- A copy of
aDomainObject
, suitable to be inserted in toaTargetModel
. Should never returnnull
whenaSourceModel
andaTargetModel
use the same reference. Might returnnull
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 (seegetLogListener()
).
-
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 ofaShape
.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 ofaShape
. The returned domain object should not useaShape directly
, as that shape is part of (a domain object of)aSourceModel
.If
aSourceModel
andaTargetModel
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 whichaShape
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 onaShape
, ornull
whenaShape
cannot be converted to a valid domain object foraTargetModel
. In that case, the implementation of this method can decide to log a fail message before returning (seegetLogListener()
).
-
createShapeCopy
Creates a copy of
aShape
retrieved from a domain object ofaSourceModel
, where the copy is defined in the reference ofaSourceModel
.- Parameters:
aShape
- The shape.aSourceModel
- The model containing the domain object of whichaShape
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 ofaSourceModel
. Should never returnnull
.
-
getLogListener
Description copied from class:ALcyLayerSelectionTransferHandler
Gives you the ILcdLogListener that redirects all messages to theILcdLogListener
s attached to thisALcyLayerSelectionTransferHandler
. You should use this log listener to provide feedback to Lucy, for instance, when something failed during the importing.- Overrides:
getLogListener
in classALcyLayerSelectionTransferHandler
- Returns:
- The
ILcdLogListener
that redirects all messages to the attachedILcdLogListener
s.
-
addUndoableListener
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 interfaceILcdUndoableSource
- Overrides:
addUndoableListener
in classALcyLayerSelectionTransferHandler
- Parameters:
aListener
- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSource
Removes the specified listener so it is no longer notified.- Specified by:
removeUndoableListener
in interfaceILcdUndoableSource
- Overrides:
removeUndoableListener
in classALcyLayerSelectionTransferHandler
- Parameters:
aListener
- The listener to remove.
-
fireUndoableHappened
Description copied from class:ALcyLayerSelectionTransferHandler
Notify all attached listeners ofaUndoable
.- Overrides:
fireUndoableHappened
in classALcyLayerSelectionTransferHandler
- Parameters:
aUndoable
- The undoables of which the listeners should be notified.
-