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
FieldsModifier and TypeFieldDescriptionstatic final intThis constant indicates that theALcyLayerSelectionTransferHandlercan only copy the selection.static final intThis constant indicates that theALcyLayerSelectionTransferHandlercan either copy or move the selection.static final intThis constant indicates that theALcyLayerSelectionTransferHandlercan only move the selection.static final intThis constant indicates that theALcyLayerSelectionTransferHandlercannot export the selection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddLogListener(ILcdLogListener aLogListener) Adds aILcdLogListenerto thisALcyLayerSelectionTransferHandler.voidaddUndoableListener(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.abstract booleancanImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView) This method determines whether thisALcyLayerSelectionTransferHandlercan import the givenTransferable.abstract TransferablecreateTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection.abstract voidexportDone(Transferable aData, ILcdLayer aSourceLayer, ILcdView aSourceView, int aAction) This method is called when the export is done.protected voidfireUndoableHappened(ILcdUndoable aUndoable) Notify all attached listeners ofaUndoable.Gives you the ILcdLogListener that redirects all messages to theILcdLogListeners attached to thisALcyLayerSelectionTransferHandler.abstract intgetSourceActions(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) This method determines what thisALcyLayerSelectionTransferHandlercan do with the given selection.abstract booleanimportData(Transferable aData, ILcdLayer aDestinationLayer, ILcdView aDestinationView) Actually imports the data into the destination layers.final voidremoveLogListener(ILcdLogListener aLogListener) Removes the specifiedILcdLogListenerto thisALcyLayerSelectionTransferHandler.voidremoveUndoableListener(ILcdUndoableListener aListener) Removes the specified listener so it is no longer notified.
-
Field Details
-
NONE
public static final int NONEThis constant indicates that theALcyLayerSelectionTransferHandlercannot export the selection.- See Also:
-
COPY
public static final int COPYThis constant indicates that theALcyLayerSelectionTransferHandlercan only copy the selection.- See Also:
-
MOVE
public static final int MOVEThis constant indicates that theALcyLayerSelectionTransferHandlercan only move the selection.- See Also:
-
COPY_OR_MOVE
public static final int COPY_OR_MOVEThis constant indicates that theALcyLayerSelectionTransferHandlercan 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 thisALcyLayerSelectionTransferHandlercan do with the given selection. The return value should be one of:NONE: indicates this transfer handler cannot export the selection.COPY: indicates thisALcyLayerSelectionTransferHandlercan only copy the selection.MOVE: indicates thisALcyLayerSelectionTransferHandlercan only move the selection.COPY_OR_MOVE: indicates thisALcyLayerSelectionTransferHandlercan either move or copy the selection.
- 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 abstract Transferable createTransferable(ILcdSelection aSelection, ILcdLayer aSourceLayer, ILcdView aSourceView) Creates the transferable to exportaSelection.- 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 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 ifaActionwasMOVE.- 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
public abstract boolean canImport(DataFlavor[] aFlavors, ILcdLayer aDestinationLayer, ILcdView aDestinationView) This method determines whether thisALcyLayerSelectionTransferHandlercan import the givenTransferable. Typically this method will check if thisALcyLayerSelectionTransferHandlercan do something with one of theDataFlavors contained inaData.- Parameters:
aFlavors- The available flavors in which the data to import can be represented.aDestinationLayer- TheILcdLayerin which the data should be imported.aDestinationView- TheILcdViewwhich containsaDestinationLayer.- Returns:
trueif thisALcyLayerSelectionTransferHandlercan 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- TheILcdLayerin which the data should be imported.aDestinationView- TheILcdViewwhich containsaDestinationLayer.- Returns:
- Whether or not the import went successfully.
-
addLogListener
Adds aILcdLogListenerto thisALcyLayerSelectionTransferHandler.- Parameters:
aLogListener- TheILcdLogListenerto add to thisALcyLayerSelectionTransferHandler.
-
removeLogListener
Removes the specifiedILcdLogListenerto thisALcyLayerSelectionTransferHandler.- Parameters:
aLogListener- TheILcdLogListenerto remove from thisALcyLayerSelectionTransferHandler.
-
getLogListener
Gives you the ILcdLogListener that redirects all messages to theILcdLogListeners attached to thisALcyLayerSelectionTransferHandler. You should use this log listener to provide feedback to Lucy, for instance, when something failed during the importing.- Returns:
- The
ILcdLogListenerthat redirects all messages to the attachedILcdLogListeners.
-
addUndoableListener
Description copied from interface:ILcdUndoableSourceAdds a listener to this source, so this listener is notified when something undoable has happened.- Specified by:
addUndoableListenerin interfaceILcdUndoableSource- Parameters:
aListener- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSourceRemoves the specified listener so it is no longer notified.- Specified by:
removeUndoableListenerin interfaceILcdUndoableSource- Parameters:
aListener- The listener to remove.
-
fireUndoableHappened
Notify all attached listeners ofaUndoable.- Parameters:
aUndoable- The undoables of which the listeners should be notified.
-