public abstract class ALcyLayerSelectionTransferHandler extends Object implements ILcdUndoableSource
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.
Modifier and Type | Field and Description |
---|---|
static int |
COPY
This constant indicates that the
ALcyLayerSelectionTransferHandler can only copy
the selection. |
static int |
COPY_OR_MOVE
This constant indicates that the
ALcyLayerSelectionTransferHandler can either copy
or move the selection. |
static int |
MOVE
This constant indicates that the
ALcyLayerSelectionTransferHandler can only move
the selection. |
static int |
NONE
This constant indicates that the
ALcyLayerSelectionTransferHandler cannot export
the selection. |
Constructor and Description |
---|
ALcyLayerSelectionTransferHandler() |
Modifier and Type | Method and Description |
---|---|
void |
addLogListener(ILcdLogListener aLogListener)
Adds a
ILcdLogListener to this ALcyLayerSelectionTransferHandler . |
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 this
ALcyLayerSelectionTransferHandler can import
the given Transferable . |
abstract Transferable |
createTransferable(ILcdSelection aSelection,
ILcdLayer aSourceLayer,
ILcdView aSourceView)
Creates the transferable to export
aSelection . |
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 of
aUndoable . |
ILcdLogListener |
getLogListener()
Gives you the ILcdLogListener that redirects all messages to the
ILcdLogListener s
attached to this ALcyLayerSelectionTransferHandler . |
abstract int |
getSourceActions(ILcdSelection aSelection,
ILcdLayer aSourceLayer,
ILcdView aSourceView)
This method determines what this
ALcyLayerSelectionTransferHandler can do with the
given selection. |
abstract boolean |
importData(Transferable aData,
ILcdLayer aDestinationLayer,
ILcdView aDestinationView)
Actually imports the data into the destination layers.
|
void |
removeLogListener(ILcdLogListener aLogListener)
Removes the specified
ILcdLogListener to this ALcyLayerSelectionTransferHandler . |
void |
removeUndoableListener(ILcdUndoableListener aListener)
Removes the specified listener so it is no longer notified.
|
public static final int NONE
ALcyLayerSelectionTransferHandler
cannot export
the selection.public static final int COPY
ALcyLayerSelectionTransferHandler
can only copy
the selection.public static final int MOVE
ALcyLayerSelectionTransferHandler
can only move
the selection.public static final int COPY_OR_MOVE
ALcyLayerSelectionTransferHandler
can either copy
or move the selection.public abstract int getSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
ALcyLayerSelectionTransferHandler
can do with the
given selection. The return value should be one of:
NONE
: indicates this transfer handler cannot export the selection.COPY
: indicates this ALcyLayerSelectionTransferHandler
can only copy
the selection.MOVE
: indicates this ALcyLayerSelectionTransferHandler
can only move the selection.COPY_OR_MOVE
: indicates this
ALcyLayerSelectionTransferHandler
can either move or copy the selection.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 abstract Transferable createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView)
aSelection
.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 abstract void exportDone(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction)
aAction
was MOVE
.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 abstract boolean canImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView)
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
.aFlavors
- The available flavors in which the data to import can be represented.aDestinationLayer
- The ILcdLayer
in which the data should be imported.aDestinationView
- The ILcdView
which contains
aDestinationLayer
.true
if this ALcyLayerSelectionTransferHandler
can import
aData
.public abstract boolean importData(Transferable aData, ILcdLayer aDestinationLayer, ILcdView aDestinationView)
aData
- The data to be imported.aDestinationLayer
- The ILcdLayer
in which the data should be imported.aDestinationView
- The ILcdView
which contains
aDestinationLayer
.public final void addLogListener(ILcdLogListener aLogListener)
ILcdLogListener
to this ALcyLayerSelectionTransferHandler
.aLogListener
- The ILcdLogListener
to add to this
ALcyLayerSelectionTransferHandler
.public final void removeLogListener(ILcdLogListener aLogListener)
ILcdLogListener
to this ALcyLayerSelectionTransferHandler
.aLogListener
- The ILcdLogListener
to remove from this
ALcyLayerSelectionTransferHandler
.public ILcdLogListener getLogListener()
ILcdLogListener
s
attached to this ALcyLayerSelectionTransferHandler
. You should use this log
listener to provide feedback to Lucy, for instance, when something failed during the
importing.ILcdLogListener
that redirects all messages to the attached
ILcdLogListener
s.public void addUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
addUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to be notified when something undoable has happened.public void removeUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
removeUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to remove.protected void fireUndoableHappened(ILcdUndoable aUndoable)
aUndoable
.aUndoable
- The undoables of which the listeners should be notified.