Class ALcyLayerSelectionTransferHandler
- All Implemented Interfaces:
ILcdUndoableSource
- Direct Known Subclasses:
ALcyDefaultLayerSelectionTransferHandler
,TLcyCompositeLayerSelectionTransferHandler
,TLcyGXYAsynchronousLayerSelectionTransferHandler
An ALcyLayerSelectionTransferHandler
is responsible for exporting a selection
from a source layer to various other representations. This exported data can then be imported by
another ALcyLayerSelectionTransferHandler
. A typical example is when a user copies
and pastes domain objects between layers.
The ALcyLayerSelectionTransferHandler
is similar to Swing's
TransferHandler
, in that it wraps the contents of an object in a
Transferable
. Unlike Swing however, an ALcyLayerSelectionTransferHandler
exports the contents of a layer, whereas Swing's TransferHandler
exports the
contents of a JComponent
. For more information about the usage of
ALcyLayerSelectionTransferHandler
, please consult the Lucy Developer Guide.
An ALcyLayerSelectionTransferHandler
has a ILcdLogListener
which can
be used to provide textual feedback to Lucy regarding errors. This ILcdLogListener
is accessible using the getLogListener()
method.
Note that this class implements ILcdUndoableSource
. As such
ILcdUndoableListener
instances can be added to objects of this class. You can notify
the attached listeners of an ILcdUndoable
with the fireUndoableHappened(com.luciad.gui.ILcdUndoable)
method.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
This constant indicates that theALcyLayerSelectionTransferHandler
can only copy the selection.static final int
This constant indicates that theALcyLayerSelectionTransferHandler
can either copy or move the selection.static final int
This constant indicates that theALcyLayerSelectionTransferHandler
can only move the selection.static final int
This constant indicates that theALcyLayerSelectionTransferHandler
cannot export the selection. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addLogListener
(ILcdLogListener aLogListener) Adds aILcdLogListener
to thisALcyLayerSelectionTransferHandler
.void
addUndoableListener
(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.abstract boolean
canImport
(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView) This method determines whether thisALcyLayerSelectionTransferHandler
can import the givenTransferable
.abstract Transferable
createTransferable
(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection
.abstract void
exportDone
(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction) This method is called when the export is done.protected void
fireUndoableHappened
(ILcdUndoable aUndoable) Notify all attached listeners ofaUndoable
.Gives you the ILcdLogListener that redirects all messages to theILcdLogListener
s attached to thisALcyLayerSelectionTransferHandler
.abstract int
getSourceActions
(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) This method determines what thisALcyLayerSelectionTransferHandler
can do with the given selection.abstract boolean
importData
(Transferable aData, ILcdLayer aDestinationLayer, ILcdView aDestinationView) Actually imports the data into the destination layers.final void
removeLogListener
(ILcdLogListener aLogListener) Removes the specifiedILcdLogListener
to thisALcyLayerSelectionTransferHandler
.void
removeUndoableListener
(ILcdUndoableListener aListener) Removes the specified listener so it is no longer notified.
-
Field Details
-
NONE
public static final int NONEThis constant indicates that theALcyLayerSelectionTransferHandler
cannot export the selection.- See Also:
-
COPY
public static final int COPYThis constant indicates that theALcyLayerSelectionTransferHandler
can only copy the selection.- See Also:
-
MOVE
public static final int MOVEThis constant indicates that theALcyLayerSelectionTransferHandler
can only move the selection.- See Also:
-
COPY_OR_MOVE
public static final int COPY_OR_MOVEThis constant indicates that theALcyLayerSelectionTransferHandler
can either copy or move the selection.- See Also:
-
-
Constructor Details
-
ALcyLayerSelectionTransferHandler
public ALcyLayerSelectionTransferHandler()
-
-
Method Details
-
getSourceActions
public abstract int getSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) This method determines what thisALcyLayerSelectionTransferHandler
can do with the given selection. The return value should be one of:NONE
: indicates this transfer handler cannot export the selection.COPY
: indicates thisALcyLayerSelectionTransferHandler
can only copy the selection.MOVE
: indicates thisALcyLayerSelectionTransferHandler
can only move the selection.COPY_OR_MOVE
: indicates thisALcyLayerSelectionTransferHandler
can either move or copy the selection.
- 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 abstract Transferable createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection
.- 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 abstract void exportDone(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction) This method is called when the export is done. Typically in this method you will delete the original objects ifaAction
wasMOVE
.- 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
public abstract boolean canImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView) 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
.- 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 abstract boolean importData(Transferable aData, ILcdLayer aDestinationLayer, ILcdView aDestinationView) Actually imports the data into the destination layers.- Parameters:
aData
- 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.
-
addLogListener
Adds aILcdLogListener
to thisALcyLayerSelectionTransferHandler
.- Parameters:
aLogListener
- TheILcdLogListener
to add to thisALcyLayerSelectionTransferHandler
.
-
removeLogListener
Removes the specifiedILcdLogListener
to thisALcyLayerSelectionTransferHandler
.- Parameters:
aLogListener
- TheILcdLogListener
to remove from thisALcyLayerSelectionTransferHandler
.
-
getLogListener
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.- 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
- 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
- Parameters:
aListener
- The listener to remove.
-
fireUndoableHappened
Notify all attached listeners ofaUndoable
.- Parameters:
aUndoable
- The undoables of which the listeners should be notified.
-