Class abstractIconChooserPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, TreeSelectionListener
Direct Known Subclasses:
CamoChooserPanel, PortraitChooserPanel

public abstract class abstractIconChooserPanel extends AbstractPanel implements TreeSelectionListener
An AbstractIconChooser is an abstract panel that is used to select an AbstractIcon from the various potential icons located within the specified AbstractDirectory.
See Also:
  • Field Details

    • treeCategories

      protected JTree treeCategories
    • abstractIconList

      protected AbstractIconList abstractIconList
  • Constructor Details

  • Method Details

    • getOriginalIcon

      @Nullable public AbstractIcon getOriginalIcon()
      Returns:
      the original AbstractIcon, which may be null if there's not an original icon
    • setOriginalIcon

      public void setOriginalIcon(@Nullable AbstractIcon originalIcon)
      Parameters:
      originalIcon - the original AbstractIcon, which may be null if there isn't one or to clear the original AbstractIcon
    • getSplitPane

      public JSplitPane getSplitPane()
    • getTreeCategories

      @Nullable public JTree getTreeCategories()
      Returns:
      the current JTree containing the various applicable categories, which will only be null when initialization of the categories needs to be delayed to the end of initialization. However, all implementations of this must be null protected.
    • setTreeCategories

      public void setTreeCategories(@Nullable JTree treeCategories)
    • getImageList

      public AbstractIconList getImageList()
    • setImageList

      public void setImageList(AbstractIconList abstractIconList)
    • getChkIncludeSubdirectories

      public JCheckBox getChkIncludeSubdirectories()
    • setChkIncludeSubdirectories

      public void setChkIncludeSubdirectories(JCheckBox chkIncludeSubdirectories)
    • initialize

      protected void initialize()
      Description copied from class: AbstractPanel
      This initializes the panel, and must be called by inheriting constructors. This MUST end with a call to setPreferences() for this class to work properly.
      Specified by:
      initialize in class AbstractPanel
    • finalizeInitialization

      protected void finalizeInitialization() throws Exception
      This provides a way to override the end of initialization, which is required for MekHQ's ForcePieceIcons.
      Throws:
      Exception - if there's an issue finishing initialization. Normally this means there's an issue setting the preferences, which normally means that a component has had its name value set.
    • setCustomPreferences

      protected void setCustomPreferences(PreferencesNode preferences) throws Exception
      Description copied from class: AbstractPanel
      Adds custom preferences to the child panel.

      By default, this panel will track no preferences Other preferences can be added by overriding this method.

      Overrides:
      setCustomPreferences in class AbstractPanel
      Parameters:
      preferences - the preference node for this panel
      Throws:
      Exception - if there's an issue initializing the preferences. Normally this means a component has not had its name value set.
    • getDirectory

      @Nullable protected abstract AbstractDirectory getDirectory()
      Returns:
      the directory for the current icon. This should not be null, but there is a low possibility of it occurring if the directory doesn't exist
    • createIcon

      protected abstract AbstractIcon createIcon(String category, String filename)
      Parameters:
      category - the category of the newly created icon
      filename - the filename for the created icon
      Returns:
      the newly created AbstractIcon
    • getSelectedItem

      @Nullable public AbstractIcon getSelectedItem()
      Returns:
      the selected AbstractIcon, which may be null if there is nothing selected
    • clearSelectedItems

      public void clearSelectedItems()
      Clears the selected AbstractIcon(s)
    • getSelectedIndex

      public int getSelectedIndex()
      Returns:
      the index of the selected image
    • refreshDirectory

      public abstract void refreshDirectory()
      This is used to refresh the contents of the directory
    • refreshDirectory

      protected void refreshDirectory(JTree newTree)
      This method is ONLY to be called by those methods overwriting the abstract refreshDirectory above
      Parameters:
      newTree - the new directory tree to use
    • getIcons

      protected List<AbstractIcon> getIcons(String category)
      Called at start and when a new category is selected in the directory tree. Assumes that the root of the path (AbstractIcon.ROOT_CATEGORY) is passed as ""!
      Parameters:
      category - the category to get the items for, in TreePath format
      Returns:
      a list of items that should be shown for the category
    • getSearchedItems

      protected List<AbstractIcon> getSearchedItems(String searchString)
      Called when at least 3 characters are entered into the search bar.
      Parameters:
      searchString - the string to search for
      Returns:
      a list of icons that fit the provided search string
    • setSelection

      protected void setSelection(@Nullable AbstractIcon icon)
      Selects the given category in the tree, updates the shown images to this category, and selects the item given by filename in the image list.
      Parameters:
      icon - the icon to select, which may be null to set nothing as selected
    • valueChanged

      public void valueChanged(TreeSelectionEvent evt)
      Specified by:
      valueChanged in interface TreeSelectionListener