Class AbstractCriticalTransferHandler

java.lang.Object
javax.swing.TransferHandler
megameklab.ui.util.AbstractCriticalTransferHandler
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BAASCriticalTransferHandler, BMCriticalTransferHandler, CriticalTransferHandler

public class AbstractCriticalTransferHandler extends TransferHandler
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:
  • Field Details

  • Constructor Details

  • Method Details

    • getSourceActions

      public int getSourceActions(JComponent c)
      Overrides:
      getSourceActions in class TransferHandler
    • 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 move
      location - 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 move
      location - The new location; may be LOC_NONE
      secondaryLocation - The new secondary location
      See Also:
    • getUnit

      protected megamek.common.units.Entity getUnit()
      Returns:
      The unit that is currently edited.
    • setRefresh

      public void setRefresh(RefreshListener refresh)
      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

      protected megamek.common.equipment.Mounted<?> getMountedFromTransferable(Transferable transferable)
      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

      protected boolean doImport(megamek.common.equipment.Mounted<?> mounted, Component target)