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
ConstructorDescriptionDefault constructor.Construct aTLcyCompositeLayerSelectionTransferHandler
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayerSelectionTransferHandler
(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler) AddsaLayerSelectionTransferHandler
to the list of handlers.void
addLayerSelectionTransferHandler
(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler, int aPriority) AddsaLayerSelectionTransferHandler
to the list of handlers.boolean
canImport
(DataFlavor[] aFlavors, ILcdLayer aTargetLayer, ILcdView aTargetView) This method determines whether thisALcyLayerSelectionTransferHandler
can import the givenTransferable
.createTransferable
(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection
.void
exportDone
(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction) This method is called when the export is done.getLayerSelectionTransferHandler
(int aIndex) Returns theALcyLayerSelectionTransferHandler
at locationi
.int
Returns the number ofALcyLayerSelectionTransferHandler
objects this manager contains.int
getSourceActions
(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) This method determines what thisALcyLayerSelectionTransferHandler
can do with the given selection.boolean
importData
(Transferable aData, ILcdLayer aTargetLayer, ILcdView aTargetView) Actually imports the data into the destination layers.void
removeLayerSelectionTransferHandler
(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler) RemovesaLayerSelectionTransferHandler
from 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
ALcyLayerSelectionTransferHandler
instances registered to it. If you want to use all registeredALcyLayerSelectionTransferHandler
instances of the Lucy back-end, useTLcyCompositeLayerSelectionTransferHandler(ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeLayerSelectionTransferHandler
Construct a
TLcyCompositeLayerSelectionTransferHandler
working on the Lucy back-endIt will use all
ALcyLayerSelectionTransferHandler
instances registered to the back-end, and adding and/or removingALcyLayerSelectionTransferHandler
s to/from thisALcyLayerSelectionTransferHandler
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeLayerSelectionTransferHandler
which 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
aLayerSelectionTransferHandler
to 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
aLayerSelectionTransferHandler
to the list of handlers.If the constructor specifying an
ILcyLucyEnv
is used, theALcyLayerSelectionTransferHandler
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aLayerSelectionTransferHandler
will only be included in the returned list when the requested class wasALcyLayerSelectionTransferHandler.class
.
Note: if you want to remove the registeredALcyLayerSelectionTransferHandler
afterwards, useremoveLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
and notILcyLucyEnv.removeService(Object)
.Note: when
aLayerSelectionTransferHandler
exports to a customDataFlavor
, ie. aDataFlavor
defined by yourself, the transfer data associated with thisDataFlavor
should 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_DEFAULT
andILcyLucyEnv.PRIORITY_FALLBACK
- Since:
- 2016.0
- See Also:
-
removeLayerSelectionTransferHandler
public void removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler) Removes
aLayerSelectionTransferHandler
from the list of handlers.If the constructor specifying an
ILcyLucyEnv
is used, theALcyLayerSelectionTransferHandler
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeALcyLayerSelectionTransferHandler
instances which were registered using theaddLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
method.- Parameters:
aLayerSelectionTransferHandler
- TheALcyLayerSelectionTransferHandler
to remove.- See Also:
-
getLayerSelectionTransferHandlerCount
public int getLayerSelectionTransferHandlerCount()Returns the number ofALcyLayerSelectionTransferHandler
objects this manager contains.- Returns:
- The number of handlers.
-
getLayerSelectionTransferHandler
Returns theALcyLayerSelectionTransferHandler
at locationi
.- Parameters:
aIndex
- The position of theALcyLayerSelectionTransferHandler
you want to retrieve.- Returns:
- The handler at the specified location.
-
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 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.
-
exportDone
public void exportDone(Transferable aData, 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:
aData
- 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.
-
canImport
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.aTargetLayer
- TheILcdLayer
in which the data should be imported.aTargetView
- TheILcdView
which containsaDestinationLayer
.- Returns:
true
if thisALcyLayerSelectionTransferHandler
can importaData
.
-
importData
Description copied from class:ALcyLayerSelectionTransferHandler
Actually imports the data into the destination layers.- Specified by:
importData
in classALcyLayerSelectionTransferHandler
- Parameters:
aData
- The data to be imported.aTargetLayer
- TheILcdLayer
in which the data should be imported.aTargetView
- TheILcdView
which containsaDestinationLayer
.- Returns:
- Whether or not the import went successfully.
-