Class AbstractEquipmentDatabaseView

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
HHWEquipmentDatabaseView

public abstract class AbstractEquipmentDatabaseView extends IView
A base class for creating an equipment database table that shows all equipment available to the unit and by default includes filters such as an "Energy Weapon" toggle. In addition to the abstract methods, implementing classes may override getUsedButtons() to control the shown filter buttons, shouldShow() to control the equipment filtering when the standard filters are not used, and getVisibleTableColumns() to control the shown columns.
See Also:
  • Field Details

  • Constructor Details

    • AbstractEquipmentDatabaseView

      protected AbstractEquipmentDatabaseView(EntitySource eSource)
  • Method Details

    • getVisibleTableColumns

      protected abstract Collection<Integer> getVisibleTableColumns(boolean tableMode)
      This method is called to find the table columns to display when the table is first displayed and when the Table Column Mode button is pressed. The parameter tableMode changes between true and false for each press of the Table Column Mode button. Note that this method can return any dynamic result but is only called at start (when a new unit is displayed or upon unit reset) and when the Table Column Mode button is pressed.
      Parameters:
      tableMode - indicates which of two table column sets are to be shown. May be ignored, especially if useSwitchTableColumns() is overridden to return false.
      Returns:
      A Collection of columns from EquipmentTableModel that should be shown
    • addEquipment

      protected abstract void addEquipment(megamek.common.equipment.EquipmentType equip, int count)
      Adds the given equipment to the entity a number of times equal to count. When the "Add Multiple" button is not used, count will always be 1. The "Add Multiple" button is only available when useAddMultiple() is overridden to return true. Implementing classes must provide a method that covers all entity types that could be coupled to their view.
    • getUsedButtons

      protected Set<EquipmentDatabaseCategory> getUsedButtons()
      Returns:
      the filter toggles and buttons to be used in this Equipment Database View. By default, this method returns the standard buttons suitable for the entity as defined in EquipmentDatabaseCategory. It may be overridden, e.g. to hide all filter buttons by returning an empty Set. When doing this, shouldShow() should be overridden to prevent the equipment being filtered by the state of the unavailable buttons.
    • useAddMultipleButton

      protected boolean useAddMultipleButton()
      When this returns true, the Add Multiple button is used. This button together with a count JSpinner allows adding multiples of equipment at once. By default, this method returns false.
    • allowAdd

      protected boolean allowAdd()
      This method may be overridden to disallow adding equipment from this database view. By default, it returns true. When it returns true, the "Add" button is shown and adding Equipment with the Enter key is possible. When this returns false, adding equipment to the unit is generally disabled and none of the "Add" buttons is shown. In this case (only), the addEquipment() method can be given an empty method body.
    • useTextFilter

      protected boolean useTextFilter()
      When this returns true, the Text Filter TextField is shown. By default, this method returns true.
    • useSwitchTableColumns

      protected boolean useSwitchTableColumns()
      When this returns true, the "Switch Table Columns" button is shown. By default, this method returns true.
    • setRefresh

      public void setRefresh(RefreshListener newRefresh)
    • refreshTable

      public void refreshTable()
    • shouldShow

      protected boolean shouldShow(megamek.common.equipment.EquipmentType equipment)
      Returns true when the given equipment should show up in the database table. This method checks if the equipment is available to the unit type at all and if the filter toggles and text filter show or hide it. This may be overridden to exclude or include equipment based on other evaluations. For example, by returning true only for equipment that is part of the unit an inventory can be created although this inventory will not show the equipment counts. Another option is to reduce the shown equipment to a predefined warehouse content such as an MHQ Campaign inventory, although here also, an equipment count is (currently) not supported.
      Parameters:
      equipment - The equipment type to be shown or hidden
      Returns:
      True when the equipment should be shown, false otherwise