Package megameklab.ui.util
Class AbstractCriticalTransferHandler
java.lang.Object
javax.swing.TransferHandler
megameklab.ui.util.AbstractCriticalTransferHandler
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BAASCriticalTransferHandler,BMCriticalTransferHandler,CriticalTransferHandler
This is a base class for some of the transfer handlers used in MML. There is a conflict of targets between unifying
them and keeping them readable because of the different handling the different Entity types require.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.TransferHandler
TransferHandler.DropLocation, TransferHandler.TransferSupport -
Field Summary
FieldsFields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCriticalTransferHandler(EntitySource eSource, RefreshListener refresh) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidchangeMountStatus(megamek.common.equipment.Mounted<?> eq, int location) Moves the given equipment to the given location (removing it from any former location).protected voidchangeMountStatus(megamek.common.equipment.Mounted<?> eq, int location, int secondaryLocation) Moves the given equipment to the given location (removing it from any former location) and secondary location.protected booleanprotected voidCalls for a refresh using the present refresh listener, if any.protected megamek.common.equipment.Mounted<?> getMountedFromTransferable(Transferable transferable) Gets the Mounted equipment from the given transferable.intprotected megamek.common.units.EntitygetUnit()protected booleanisDraggable(megamek.common.equipment.Mounted<?> mounted) Returns true when the given mounted is allowed to be dragged on the present unit type, false otherwise.voidsetRefresh(RefreshListener refresh) Sets a refresh listener to forward refresh calls to.Methods inherited from class javax.swing.TransferHandler
canImport, canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, getVisualRepresentation, importData, importData, setDragImage, setDragImageOffset
-
Field Details
-
eSource
-
refresh
-
-
Constructor Details
-
AbstractCriticalTransferHandler
-
-
Method Details
-
getSourceActions
- Overrides:
getSourceActionsin classTransferHandler
-
changeMountStatus
protected void changeMountStatus(megamek.common.equipment.Mounted<?> eq, int location) Moves the given equipment to the given location (removing it from any former location). Forwards to UnitUtil .changeMountStatus() and calls for a refresh using the present refresh listener, if any.- Parameters:
eq- The Mounted to movelocation- The new location; may be LOC_NONE- See Also:
-
changeMountStatus
protected void changeMountStatus(megamek.common.equipment.Mounted<?> eq, int location, int secondaryLocation) Moves the given equipment to the given location (removing it from any former location) and secondary location. Forwards to UnitUtil.changeMountStatus() and calls for a refresh using the present refresh listener, if any.- Parameters:
eq- The Mounted to movelocation- The new location; may be LOC_NONEsecondaryLocation- The new secondary location- See Also:
-
getUnit
protected megamek.common.units.Entity getUnit()- Returns:
- The unit that is currently edited.
-
setRefresh
Sets a refresh listener to forward refresh calls to. Calls to doRefresh() will use it.- Parameters:
refresh- The new refresh listener
-
doRefresh
protected void doRefresh()Calls for a refresh using the present refresh listener, if any. If no refresh listener has been set, does nothing. -
getMountedFromTransferable
Gets the Mounted equipment from the given transferable. All exceptions are caught and null is returned instead if an exception occurred. This implicitly checks if the String data flavor is supported.- Parameters:
transferable- The Transferable from the present transfer action- Returns:
- The equipment that is being dragged or null in the case of any error
-
isDraggable
protected boolean isDraggable(@Nullable megamek.common.equipment.Mounted<?> mounted) Returns true when the given mounted is allowed to be dragged on the present unit type, false otherwise. Returns false when the given mounted is null.- Parameters:
mounted- The Mounted equipment- Returns:
- True when dragging is allowed, false otherwise
-
doImport
-