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
ConstructorsModifierConstructorDescriptionprotectedALcyDefaultLayerSelectionTransferHandler(ILcdFilter<ILcdLayer> aLayerFilter) Creates a new layer selection transfer handler which allows to import shapes from other formats.protectedALcyDefaultLayerSelectionTransferHandler(ILcdFilter<ILcdLayer> aLayerFilter, boolean aAllowImportShapesFromOtherFormats) Creates a new layer selection transfer handler. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddUndoableListener(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.final booleancanImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView) This method determines whether thisALcyLayerSelectionTransferHandlercan import the givenTransferable.protected abstract TcreateDomainObjectCopy(T aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel) Create a copy ofaDomainObjectfromaSourceModelwhich can be inserted intoaTargetModel.protected abstract TcreateDomainObjectForShape(ILcdShape aShape, ILcdModel aSourceModel, ILcdModel aTargetModel) Creates a new domain object which can be inserted intoaTargetModelwhere the shape of the returned domain object is a copy ofaShape.protected abstract ILcdShapecreateShapeCopy(ILcdShape aShape, ILcdModel aSourceModel) Creates a copy ofaShaperetrieved from a domain object ofaSourceModel, where the copy is defined in the reference ofaSourceModel.final TransferablecreateTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection.final voidexportDone(Transferable aTransferable, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction) This method is called when the export is done.protected final voidfireUndoableHappened(ILcdUndoable aUndoable) Notify all attached listeners ofaUndoable.final ILcdLogListenerGives you the ILcdLogListener that redirects all messages to theILcdLogListeners attached to thisALcyLayerSelectionTransferHandler.intgetSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) This method determines what thisALcyLayerSelectionTransferHandlercan do with the given selection.final booleanimportData(Transferable aTransferable, ILcdLayer aDestinationLayer, ILcdView aDestinationView) Actually imports the data into the destination layers.final voidremoveUndoableListener(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 (ALcyFormatorALcyLspFormat) that plugs in this transfer handler is decorated with a safe guard format wrapper (TLcySafeGuardFormatWrapperorTLcyLspSafeGuardFormatWrapper).
-
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 (ALcyFormatorALcyLspFormat) that plugs in this transfer handler is decorated with a safe guard format wrapper (TLcySafeGuardFormatWrapperorTLcyLspSafeGuardFormatWrapper).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:ALcyLayerSelectionTransferHandlerThis method determines what thisALcyLayerSelectionTransferHandlercan 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 thisALcyLayerSelectionTransferHandlercan only copy the selection.ALcyLayerSelectionTransferHandler.MOVE: indicates thisALcyLayerSelectionTransferHandlercan only move the selection.ALcyLayerSelectionTransferHandler.COPY_OR_MOVE: indicates thisALcyLayerSelectionTransferHandlercan either move or copy the selection.
- Specified by:
getSourceActionsin classALcyLayerSelectionTransferHandler- Parameters:
aSelection- The selection that is to exported.aSourceLayer- TheILcdLayerthat contains aSelection.aSourceView- TheILcdViewthat contains aSelection.- Returns:
- The action that this
ALcyLayerSelectionTransferHandlercan perform on aSelection.
-
createTransferable
public final Transferable createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Description copied from class:ALcyLayerSelectionTransferHandlerCreates the transferable to exportaSelection.- Specified by:
createTransferablein classALcyLayerSelectionTransferHandler- Parameters:
aSelection- The selection that is to exported.aSourceLayer- TheILcdLayerthat contains aSelection.aSourceView- TheILcdViewthat contains aSelection.- Returns:
- The
Transferablethat contains the exported data in various flavors.
-
canImport
public final boolean canImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView) Description copied from class:ALcyLayerSelectionTransferHandlerThis method determines whether thisALcyLayerSelectionTransferHandlercan import the givenTransferable. Typically this method will check if thisALcyLayerSelectionTransferHandlercan do something with one of theDataFlavors contained inaData.- Specified by:
canImportin classALcyLayerSelectionTransferHandler- Parameters:
aFlavors- The available flavors in which the data to import can be represented.aDestinationLayer- TheILcdLayerin which the data should be imported.aDestinationView- TheILcdViewwhich containsaDestinationLayer.- Returns:
trueif thisALcyLayerSelectionTransferHandlercan importaData.
-
importData
public final boolean importData(Transferable aTransferable, ILcdLayer aDestinationLayer, ILcdView aDestinationView) Description copied from class:ALcyLayerSelectionTransferHandlerActually imports the data into the destination layers.- Specified by:
importDatain classALcyLayerSelectionTransferHandler- Parameters:
aTransferable- The data to be imported.aDestinationLayer- TheILcdLayerin which the data should be imported.aDestinationView- TheILcdViewwhich 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:ALcyLayerSelectionTransferHandlerThis method is called when the export is done. Typically in this method you will delete the original objects ifaActionwasMOVE.- Specified by:
exportDonein classALcyLayerSelectionTransferHandler- Parameters:
aTransferable- TheTransferablethat was exported.aSourceLayer- TheILcdLayercontaining the original objects. PossiblynullifaActionisNONE.aSourceView- TheILcdViewcontaining the original objects. PossiblynullifaActionisNONE.aAction- The action that was performed with the transferable.
-
createDomainObjectCopy
protected abstract T createDomainObjectCopy(T aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel) Create a copy of
aDomainObjectfromaSourceModelwhich can be inserted intoaTargetModel.If
aSourceModelandaTargetModelare 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 asaSourceModelwhen copy-pasting elements in the same model.- Returns:
- A copy of
aDomainObject, suitable to be inserted in toaTargetModel. Should never returnnullwhenaSourceModelandaTargetModeluse the same reference. Might returnnullwhen 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
aTargetModelwhere 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
aSourceModelandaTargetModelare 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 whichaShapeis 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
aTargetModelusing a shape based onaShape, ornullwhenaShapecannot 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
aShaperetrieved 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 whichaShapewas derived. This is a model of the format for which this transfer handler is created.- Returns:
- a copy of
aShapedefined in the reference ofaSourceModel. Should never returnnull.
-
getLogListener
Description copied from class:ALcyLayerSelectionTransferHandlerGives you the ILcdLogListener that redirects all messages to theILcdLogListeners attached to thisALcyLayerSelectionTransferHandler. You should use this log listener to provide feedback to Lucy, for instance, when something failed during the importing.- Overrides:
getLogListenerin classALcyLayerSelectionTransferHandler- Returns:
- The
ILcdLogListenerthat redirects all messages to the attachedILcdLogListeners.
-
addUndoableListener
Description copied from interface:ILcdUndoableSourceAdds a listener to this source, so this listener is notified when something undoable has happened.- Specified by:
addUndoableListenerin interfaceILcdUndoableSource- Overrides:
addUndoableListenerin classALcyLayerSelectionTransferHandler- Parameters:
aListener- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSourceRemoves the specified listener so it is no longer notified.- Specified by:
removeUndoableListenerin interfaceILcdUndoableSource- Overrides:
removeUndoableListenerin classALcyLayerSelectionTransferHandler- Parameters:
aListener- The listener to remove.
-
fireUndoableHappened
Description copied from class:ALcyLayerSelectionTransferHandlerNotify all attached listeners ofaUndoable.- Overrides:
fireUndoableHappenedin classALcyLayerSelectionTransferHandler- Parameters:
aUndoable- The undoables of which the listeners should be notified.
-