Class abstractIconChooserPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
megamek.client.ui.panels.abstractPanels.AbstractPanel
megamek.client.ui.panels.abstractPanels.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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsFields inherited from class megamek.client.ui.panels.abstractPanels.AbstractPanel
resourcesFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedabstractIconChooserPanel(JFrame frame, String name, JTree tree, AbstractIcon icon) protectedabstractIconChooserPanel(JFrame frame, String name, JTree tree, AbstractIcon icon, boolean initialize) -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the selected AbstractIcon(s)protected abstract AbstractIconcreateIcon(String category, String filename) protected voidThis provides a way to override the end of initialization, which is required for MekHQ's ForcePieceIcons.protected abstract AbstractDirectoryprotected List<AbstractIcon> Called at start and when a new category is selected in the directory tree.protected List<AbstractIcon> getSearchedItems(String searchString) Called when at least 3 characters are entered into the search bar.intprotected voidThis initializes the panel, and must be called by inheriting constructors.abstract voidThis is used to refresh the contents of the directoryprotected voidrefreshDirectory(JTree newTree) This method is ONLY to be called by those methods overwriting the abstract refreshDirectory abovevoidsetChkIncludeSubdirectories(JCheckBox chkIncludeSubdirectories) protected voidsetCustomPreferences(PreferencesNode preferences) Adds custom preferences to the child panel.voidsetImageList(AbstractIconList abstractIconList) voidsetOriginalIcon(AbstractIcon originalIcon) protected voidsetSelection(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.voidsetTreeCategories(JTree treeCategories) voidMethods inherited from class megamek.client.ui.panels.abstractPanels.AbstractPanel
getFrame, setPreferences, setPreferencesMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
treeCategories
-
abstractIconList
-
-
Constructor Details
-
abstractIconChooserPanel
-
abstractIconChooserPanel
-
-
Method Details
-
getOriginalIcon
- Returns:
- the original AbstractIcon, which may be null if there's not an original icon
-
setOriginalIcon
- Parameters:
originalIcon- the original AbstractIcon, which may be null if there isn't one or to clear the original AbstractIcon
-
getSplitPane
-
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
-
getImageList
-
setImageList
-
getChkIncludeSubdirectories
-
setChkIncludeSubdirectories
-
initialize
protected void initialize()Description copied from class:AbstractPanelThis 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:
initializein classAbstractPanel
-
finalizeInitialization
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
Description copied from class:AbstractPanelAdds custom preferences to the child panel.By default, this panel will track no preferences Other preferences can be added by overriding this method.
- Overrides:
setCustomPreferencesin classAbstractPanel- 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
- 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
- Parameters:
category- the category of the newly created iconfilename- the filename for the created icon- Returns:
- the newly created 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
This method is ONLY to be called by those methods overwriting the abstract refreshDirectory above- Parameters:
newTree- the new directory tree to use
-
getIcons
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
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
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
- Specified by:
valueChangedin interfaceTreeSelectionListener
-