Class TLcyCompositeLayerSelectionTransferHandler
- All Implemented Interfaces:
ILcdUndoableSource
Composite implementation of ALcyLayerSelectionTransferHandler according
to the composite design pattern.
When creating a new TLcyCompositeLayerSelectionTransferHandler using the default
constructor (see TLcyCompositeLayerSelectionTransferHandler()), the created instance will
only work on/with the ALcyLayerSelectionTransferHandlers registered
on this composite instance (see addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
and removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)).
When creating a new TLcyCompositeLayerSelectionTransferHandler using the constructor
specifying an ILcyLucyEnv instance (see TLcyCompositeLayerSelectionTransferHandler(com.luciad.lucy.ILcyLucyEnv), the created instance will
work on the Lucy back-end services. It will use
all registered ALcyLayerSelectionTransferHandler instances of the
Lucy back-end, adding and/or removing an ALcyLayerSelectionTransferHandler will
add/remove the ALcyLayerSelectionTransferHandler as service from Lucy, ... .
For example adding and/or removing a Transferable using the back-end based implementation
can be done by creating a new instance of this class:
//Create a new instance whenever you need it.
TLcyCompositeLayerSelectionTransferHandler handler = new TLcyCompositeLayerSelectionTransferHandler( aLucyEnv );
//add and remove a handler
handler.addLayerSelectionTransferHandler( aLayerSelectionTransferHandler );
handler.removeLayerSelectionTransferHanlder( anotherLayerSelectionTransferHandler );
//There is no need to keep a reference to the composite instance, you can create a new one
//the next time you would need it
handler = null;
The same result can be obtained by using the back-end services directly:
//Suppose we have a reference to the back-end
ILcyLucyEnv backEnd;
//add and remove a handler
backEnd.addService( aLayerSelectionTransferHandler );
backEnd.removeService( anotherLayerSelectionTransferHandler );
Note: there is a restriction on the ALcyLayerSelectionTransferHandler
instances which are added to this TLcyCompositeLayerSelectionTransferHandler, or
which are registered directly as service on the Lucy back-end. When the
ALcyLayerSelectionTransferHandler exports to a custom DataFlavor, ie. a
DataFlavor defined by yourself, the transfer data associated with this DataFlavor
should be a ILcyLayerSubsetList.
- See Also:
-
Field Summary
Fields inherited from class com.luciad.lucy.datatransfer.ALcyLayerSelectionTransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Construct aTLcyCompositeLayerSelectionTransferHandlerworking on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler) AddsaLayerSelectionTransferHandlerto the list of handlers.voidaddLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler, int aPriority) AddsaLayerSelectionTransferHandlerto the list of handlers.booleancanImport(DataFlavor[] aFlavors, ILcdLayer aTargetLayer, ILcdView aTargetView) This method determines whether thisALcyLayerSelectionTransferHandlercan import the givenTransferable.createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection.voidexportDone(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction) This method is called when the export is done.getLayerSelectionTransferHandler(int aIndex) Returns theALcyLayerSelectionTransferHandlerat locationi.intReturns the number ofALcyLayerSelectionTransferHandlerobjects this manager contains.intgetSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) This method determines what thisALcyLayerSelectionTransferHandlercan do with the given selection.booleanimportData(Transferable aData, ILcdLayer aTargetLayer, ILcdView aTargetView) Actually imports the data into the destination layers.voidremoveLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler) RemovesaLayerSelectionTransferHandlerfrom the list of handlers.Methods inherited from class com.luciad.lucy.datatransfer.ALcyLayerSelectionTransferHandler
addLogListener, addUndoableListener, fireUndoableHappened, getLogListener, removeLogListener, removeUndoableListener
-
Constructor Details
-
TLcyCompositeLayerSelectionTransferHandler
public TLcyCompositeLayerSelectionTransferHandler()Default constructor.
The created instance will only work on the
ALcyLayerSelectionTransferHandlerinstances registered to it. If you want to use all registeredALcyLayerSelectionTransferHandlerinstances of the Lucy back-end, useTLcyCompositeLayerSelectionTransferHandler(ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeLayerSelectionTransferHandler
Construct a
TLcyCompositeLayerSelectionTransferHandlerworking on the Lucy back-endIt will use all
ALcyLayerSelectionTransferHandlerinstances registered to the back-end, and adding and/or removingALcyLayerSelectionTransferHandlers to/from thisALcyLayerSelectionTransferHandlerwill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeLayerSelectionTransferHandlerwhich does not use the back-end, useTLcyCompositeLayerSelectionTransferHandler()instead.- Parameters:
aLucyEnv- The Lucy back-end.- See Also:
-
-
Method Details
-
addLayerSelectionTransferHandler
public void addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler) Adds
aLayerSelectionTransferHandlerto the list of handlers.Equivalent of calling
addLayerSelectionTransferHandler( aLayerSelectionTransferHandler, ILcyLucyEnv.PRIORITY_DEFAULT );- Parameters:
aLayerSelectionTransferHandler- The handler to add to the list.- See Also:
-
addLayerSelectionTransferHandler
public void addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler, int aPriority) Adds
aLayerSelectionTransferHandlerto the list of handlers.If the constructor specifying an
ILcyLucyEnvis used, theALcyLayerSelectionTransferHandlerwill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)). When callingILcyLucyEnv.getServices(Class)afterwards,aLayerSelectionTransferHandlerwill only be included in the returned list when the requested class wasALcyLayerSelectionTransferHandler.class.
Note: if you want to remove the registeredALcyLayerSelectionTransferHandlerafterwards, useremoveLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)and notILcyLucyEnv.removeService(Object).Note: when
aLayerSelectionTransferHandlerexports to a customDataFlavor, ie. aDataFlavordefined by yourself, the transfer data associated with thisDataFlavorshould be aILcyLayerSubsetList.- Parameters:
aLayerSelectionTransferHandler- The handler to add to the list.aPriority- The priority for the instance. Lower values mean higher priorities. Services with higher priority appear earlier in the list of results. Common values areILcyLucyEnv.PRIORITY_DEFAULTandILcyLucyEnv.PRIORITY_FALLBACK- Since:
- 2016.0
- See Also:
-
removeLayerSelectionTransferHandler
public void removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler) Removes
aLayerSelectionTransferHandlerfrom the list of handlers.If the constructor specifying an
ILcyLucyEnvis used, theALcyLayerSelectionTransferHandlerwill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeALcyLayerSelectionTransferHandlerinstances which were registered using theaddLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)method.- Parameters:
aLayerSelectionTransferHandler- TheALcyLayerSelectionTransferHandlerto remove.- See Also:
-
getLayerSelectionTransferHandlerCount
public int getLayerSelectionTransferHandlerCount()Returns the number ofALcyLayerSelectionTransferHandlerobjects this manager contains.- Returns:
- The number of handlers.
-
getLayerSelectionTransferHandler
Returns theALcyLayerSelectionTransferHandlerat locationi.- Parameters:
aIndex- The position of theALcyLayerSelectionTransferHandleryou want to retrieve.- Returns:
- The handler at the specified location.
-
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 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.
-
exportDone
public void exportDone(Transferable aData, 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:
aData- TheTransferablethat was exported.aSourceLayer- TheILcdLayercontaining the original objects. PossiblynullifaActionisNONE.aSourceView- TheILcdViewcontaining the original objects. PossiblynullifaActionisNONE.aAction- The action that was performed with the transferable.
-
canImport
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.aTargetLayer- TheILcdLayerin which the data should be imported.aTargetView- TheILcdViewwhich containsaDestinationLayer.- Returns:
trueif thisALcyLayerSelectionTransferHandlercan importaData.
-
importData
Description copied from class:ALcyLayerSelectionTransferHandlerActually imports the data into the destination layers.- Specified by:
importDatain classALcyLayerSelectionTransferHandler- Parameters:
aData- The data to be imported.aTargetLayer- TheILcdLayerin which the data should be imported.aTargetView- TheILcdViewwhich containsaDestinationLayer.- Returns:
- Whether or not the import went successfully.
-