public class TLcyCompositeLayerSelectionTransferHandler extends ALcyLayerSelectionTransferHandler
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
.
TLcyDataTransferManager
COPY, COPY_OR_MOVE, MOVE, NONE
Constructor and Description |
---|
TLcyCompositeLayerSelectionTransferHandler()
Default constructor.
|
TLcyCompositeLayerSelectionTransferHandler(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeLayerSelectionTransferHandler working on the Lucy
back-end |
Modifier and Type | Method and Description |
---|---|
void |
addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler)
Adds
aLayerSelectionTransferHandler to the list of handlers. |
void |
addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler,
int aPriority)
Adds
aLayerSelectionTransferHandler to the list of handlers. |
boolean |
canImport(DataFlavor[] aFlavors,
ILcdLayer aTargetLayer,
ILcdView aTargetView)
This method determines whether this
ALcyLayerSelectionTransferHandler can import
the given Transferable . |
Transferable |
createTransferable(ILcdSelection aSelection,
ILcdLayer aSourceLayer,
ILcdView aSourceView)
Creates the transferable to export
aSelection . |
void |
exportDone(Transferable aData,
ILcdLayer aSourceLayer,
ILcdView aSourceView,
int aAction)
This method is called when the export is done.
|
ALcyLayerSelectionTransferHandler |
getLayerSelectionTransferHandler(int aIndex)
Returns the
ALcyLayerSelectionTransferHandler at location i . |
int |
getLayerSelectionTransferHandlerCount()
Returns the number of
ALcyLayerSelectionTransferHandler objects this manager
contains. |
int |
getSourceActions(ILcdSelection aSelection,
ILcdLayer aSourceLayer,
ILcdView aSourceView)
This method determines what this
ALcyLayerSelectionTransferHandler 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)
Removes
aLayerSelectionTransferHandler from the list of handlers. |
addLogListener, addUndoableListener, fireUndoableHappened, getLogListener, removeLogListener, removeUndoableListener
public TLcyCompositeLayerSelectionTransferHandler()
Default constructor.
The created instance will only work on the ALcyLayerSelectionTransferHandler
instances registered to it. If you want to use all registered ALcyLayerSelectionTransferHandler
instances of the Lucy back-end, use TLcyCompositeLayerSelectionTransferHandler(ILcyLucyEnv)
instead.
public TLcyCompositeLayerSelectionTransferHandler(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeLayerSelectionTransferHandler
working on the Lucy
back-end
It will use all ALcyLayerSelectionTransferHandler
instances registered to the
back-end, and adding and/or removing ALcyLayerSelectionTransferHandler
s to/from
this ALcyLayerSelectionTransferHandler
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, use TLcyCompositeLayerSelectionTransferHandler()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeLayerSelectionTransferHandler()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler)
Adds aLayerSelectionTransferHandler
to the list of handlers.
Equivalent of calling
addLayerSelectionTransferHandler( aLayerSelectionTransferHandler, ILcyLucyEnv.PRIORITY_DEFAULT );
aLayerSelectionTransferHandler
- The handler to add to the list.removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
public void addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler, int aPriority)
Adds aLayerSelectionTransferHandler
to the list of handlers.
If the constructor specifying an ILcyLucyEnv
is used, the
ALcyLayerSelectionTransferHandler
will be registered as a service on the Lucy
back-end (see ILcyLucyEnv.addService(Object, int)
). When calling ILcyLucyEnv.getServices(Class)
afterwards, aLayerSelectionTransferHandler
will only be included in the returned list when the requested class was
ALcyLayerSelectionTransferHandler.class
.
Note: if you want to remove the registered ALcyLayerSelectionTransferHandler
afterwards, use removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
and not ILcyLucyEnv.removeService(Object)
.
Note: when aLayerSelectionTransferHandler
exports to a custom
DataFlavor
, ie. a DataFlavor
defined by yourself, the transfer data
associated with this DataFlavor
should be a ILcyLayerSubsetList
.
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 are
ILcyLucyEnv.PRIORITY_DEFAULT
and ILcyLucyEnv.PRIORITY_FALLBACK
removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
public void removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler)
Removes aLayerSelectionTransferHandler
from the list of handlers.
If the constructor specifying an ILcyLucyEnv
is used, the
ALcyLayerSelectionTransferHandler
will be removed as service from the Lucy
back-end (see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove ALcyLayerSelectionTransferHandler
instances which were registered using the addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
method.
aLayerSelectionTransferHandler
- The ALcyLayerSelectionTransferHandler
to
remove.addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
public int getLayerSelectionTransferHandlerCount()
ALcyLayerSelectionTransferHandler
objects this manager
contains.public ALcyLayerSelectionTransferHandler getLayerSelectionTransferHandler(int aIndex)
ALcyLayerSelectionTransferHandler
at location i
.aIndex
- The position of the ALcyLayerSelectionTransferHandler
you want to
retrieve.public int getSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
ALcyLayerSelectionTransferHandler
ALcyLayerSelectionTransferHandler
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 this ALcyLayerSelectionTransferHandler
can only copy
the selection.ALcyLayerSelectionTransferHandler.MOVE
: indicates this ALcyLayerSelectionTransferHandler
can only move the selection.ALcyLayerSelectionTransferHandler.COPY_OR_MOVE
: indicates this
ALcyLayerSelectionTransferHandler
can either move or copy the selection.getSourceActions
in class ALcyLayerSelectionTransferHandler
aSelection
- The selection that is to exported.aSourceLayer
- The ILcdLayer
that contains aSelection.aSourceView
- The ILcdView
that contains aSelection.ALcyLayerSelectionTransferHandler
can perform on
aSelection.public Transferable createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
ALcyLayerSelectionTransferHandler
aSelection
.createTransferable
in class ALcyLayerSelectionTransferHandler
aSelection
- The selection that is to exported.aSourceLayer
- The ILcdLayer
that contains aSelection.aSourceView
- The ILcdView
that contains aSelection.Transferable
that contains the exported data in various flavors.public void exportDone(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction)
ALcyLayerSelectionTransferHandler
aAction
was MOVE
.exportDone
in class ALcyLayerSelectionTransferHandler
aData
- 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.public boolean canImport(DataFlavor[] aFlavors, ILcdLayer aTargetLayer, ILcdView aTargetView)
ALcyLayerSelectionTransferHandler
ALcyLayerSelectionTransferHandler
can import
the given Transferable
. Typically this method will check if this
ALcyLayerSelectionTransferHandler
can do something with one of the
DataFlavor
s contained in aData
.canImport
in class ALcyLayerSelectionTransferHandler
aFlavors
- The available flavors in which the data to import can be represented.aTargetLayer
- The ILcdLayer
in which the data should be imported.aTargetView
- The ILcdView
which contains
aDestinationLayer
.true
if this ALcyLayerSelectionTransferHandler
can import
aData
.public boolean importData(Transferable aData, ILcdLayer aTargetLayer, ILcdView aTargetView)
ALcyLayerSelectionTransferHandler
importData
in class ALcyLayerSelectionTransferHandler
aData
- The data to be imported.aTargetLayer
- The ILcdLayer
in which the data should be imported.aTargetView
- The ILcdView
which contains
aDestinationLayer
.