Class ConfigureTree

All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, TreeExpansionListener, TreeSelectionListener, Scrollable
Direct Known Subclasses:
ExtensionTree

The beating heart of the Editor, this class handles the Configuration Tree that appears in the Configuration window when editing a VASSAL module. Each node in the tree structure is a Configurable object, whose child nodes are obtained via Configurable.getConfigureComponents(). When we're running as the Extension Editor, this is subclassed by ExtensionTree, which overrides some methods to handle extension-specific differences.
See Also:
  • Field Details

    • nodes

    • copyData

      protected DefaultMutableTreeNode copyData
    • cutData

      protected DefaultMutableTreeNode cutData
    • helpWindow

      protected HelpWindow helpWindow
    • editorWindow

      protected EditorWindow editorWindow
    • selected

      protected Configurable selected
    • selectedRow

      protected int selectedRow
    • searchCmd

      protected String searchCmd
    • moveCmd

      protected String moveCmd
    • deleteCmd

      protected String deleteCmd
    • pasteCmd

      protected String pasteCmd
    • copyCmd

      protected String copyCmd
    • cutCmd

      protected String cutCmd
    • helpCmd

      protected String helpCmd
    • propertiesCmd

      protected String propertiesCmd
    • translateCmd

      protected String translateCmd
    • duplicateCmd

      protected String duplicateCmd
    • cutKey

      protected KeyStroke cutKey
    • copyKey

      protected KeyStroke copyKey
    • pasteKey

      protected KeyStroke pasteKey
    • deleteKey

      protected KeyStroke deleteKey
    • moveKey

      protected KeyStroke moveKey
    • searchKey

      protected KeyStroke searchKey
    • helpKey

      protected KeyStroke helpKey
    • propertiesKey

      protected KeyStroke propertiesKey
    • translateKey

      protected KeyStroke translateKey
    • duplicateKey

      protected KeyStroke duplicateKey
    • cutAction

      protected Action cutAction
    • copyAction

      protected Action copyAction
    • pasteAction

      protected Action pasteAction
    • deleteAction

      protected Action deleteAction
    • moveAction

      protected Action moveAction
    • searchAction

      protected Action searchAction
    • propertiesAction

      protected Action propertiesAction
    • translateAction

      protected Action translateAction
    • helpAction

      protected Action helpAction
    • duplicateAction

      protected Action duplicateAction
    • searchDialog

      protected JDialog searchDialog
    • searchField

      protected JTextField searchField
    • searchFiltered

      protected JRadioButton searchFiltered
    • searchAdvanced

      @Deprecated(since="2023-10-17", forRemoval=true) protected JCheckBox searchAdvanced
      Deprecated, for removal: This API element is subject to removal in a future version.
    • chatter

      protected static Chatter chatter
    • additionalComponents

      protected static final List<ConfigureTree.AdditionalComponent> additionalComponents
    • defaultExportExtension

      public static final String defaultExportExtension
      See Also:
    • newNodeSelected

      protected static boolean newNodeSelected
    • lastFoundNode

      protected static DefaultMutableTreeNode lastFoundNode
    • selectedNodeIndex

      protected static int selectedNodeIndex
  • Constructor Details

  • Method Details

    • noHTML

      public static String noHTML(String text)
    • chat

      protected static void chat(String text)
    • getSearchDialog

      protected JDialog getSearchDialog()
    • setSearchDialog

      protected void setSearchDialog(JDialog searchDialog)
    • getSearchField

      protected JTextField getSearchField()
    • setSearchField

      protected void setSearchField(JTextField searchField)
    • setSearchAdvanced

      protected void setSearchAdvanced(JRadioButton searchFiltered)
    • setSearchAdvanced

      @Deprecated(since="2023-10-17", forRemoval=true) protected void setSearchAdvanced(JCheckBox searchAdvanced)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getSearchAdvanced

      @Deprecated(since="2023-10-17", forRemoval=true) protected JCheckBox getSearchAdvanced()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getFrame

      public JFrame getFrame()
    • treeExpanded

      public void treeExpanded(TreeExpansionEvent event)
      Specified by:
      treeExpanded in interface TreeExpansionListener
    • treeCollapsed

      public void treeCollapsed(TreeExpansionEvent event)
      A cell has been collapsed. Reset the edit flag on all the children owned by this node
      Specified by:
      treeCollapsed in interface TreeExpansionListener
      Parameters:
      event - Expansion event
    • buildRenderer

      protected VASSAL.configure.ConfigureTree.Renderer buildRenderer()
    • notifyStateChanged

      protected void notifyStateChanged(boolean changed)
      Tell our enclosing EditorWindow that we are now clean or dirty.
      Parameters:
      changed - true = state is not dirty
    • getTarget

      protected Configurable getTarget(int x, int y)
    • buildTreeNode

      protected DefaultMutableTreeNode buildTreeNode(Configurable c)
    • addAction

      protected void addAction(JPopupMenu menu, Action a)
    • addSubMenu

      protected void addSubMenu(JPopupMenu menu, String name, List<Action> l)
    • buildPopupMenu

      protected JPopupMenu buildPopupMenu(Configurable target)
    • exportTreeBranch

      protected boolean exportTreeBranch(AbstractBuildable target)
    • importTreeBranch

      protected boolean importTreeBranch(Configurable target)
    • buildSearchAction

      protected Action buildSearchAction(Configurable target)
      Returns:
      Search action - runs search dialog box, then searches
    • buildExportTreeAction

      protected Action buildExportTreeAction(Configurable target)
    • buildImportTreeAction

      protected Action buildImportTreeAction(Configurable target)
    • buildMoveAction

      protected Action buildMoveAction(Configurable target)
    • buildCutAction

      protected Action buildCutAction(Configurable target)
    • buildCopyAction

      protected Action buildCopyAction(Configurable target)
    • postPasteFixups

      protected void postPasteFixups(Configurable target)
      If there are items that need to be adjusted after being pasted (to make sure they don't contain illegal values that will be hard to debug later), we can make them here.
      Parameters:
      target - Item we just pasted
    • buildPasteAction

      protected Action buildPasteAction(Configurable target)
    • isValidPasteTarget

      protected boolean isValidPasteTarget(Configurable target, DefaultMutableTreeNode sourceNode)
    • isValidPasteTarget

      protected boolean isValidPasteTarget(Configurable target)
    • convertChild

      protected Configurable convertChild(Configurable parent, Configurable child)
      Some components need to be converted to a new type before insertion. Currently, this is used to allow cut and paste of CardSlots and PieceSlots between Decks and GamePiece Palette components.
      Parameters:
      parent - Parent Configurable
      child - Child Configurable
      Returns:
      new Child
    • isAllowedChildClass

      protected boolean isAllowedChildClass(Configurable parent, Class<?> childClass)
    • updateGpIds

      public void updateGpIds(Configurable c)
      Allocate new PieceSlot Ids to any PieceSlot subcomponents
      Parameters:
      c - Configurable to update
    • buildImportAction

      protected Action buildImportAction(Configurable target)
    • buildImportDeckAction

      protected Action buildImportDeckAction(Configurable target)
    • buildMassPieceLoaderAction

      protected Action buildMassPieceLoaderAction(Configurable target)
    • hasChild

      protected boolean hasChild(Configurable parent, Class<?> childClass)
    • buildAddActionsFor

      protected List<Action> buildAddActionsFor(Configurable target)
    • buildAddActionsFor

      protected List<Action> buildAddActionsFor(Configurable target, List<Action> peerInserts)
    • buildAddAction

      protected Action buildAddAction(Configurable target, Class<? extends Buildable> newConfig)
    • buildAddAction

      protected Action buildAddAction(Configurable target, Class<? extends Buildable> newConfig, String key, int index, Configurable duplicate)
    • buildHelpAction

      protected Action buildHelpAction(Configurable target)
    • buildCloneAction

      protected Action buildCloneAction(Configurable target)
    • getParent

      protected Configurable getParent(DefaultMutableTreeNode targetNode)
    • buildDeleteAction

      protected Action buildDeleteAction(Configurable target)
    • buildEditPiecesAction

      protected Action buildEditPiecesAction(Configurable target)
    • buildOpenPiecesAction

      protected Action buildOpenPiecesAction(Configurable target)
    • buildEditAction

      protected Action buildEditAction(Configurable target)
    • buildTranslateAction

      protected Action buildTranslateAction(Configurable target)
    • canContainGamePiece

      public boolean canContainGamePiece(Configurable target)
    • delete

      protected boolean delete(Configurable target)
      Delete removes an item from the tree but ALSO traverses the tree throwing all the children's children manually out the airlock, one by one. Lest they return and live on as zombies...
    • remove

      protected boolean remove(Configurable parent, Configurable child)
    • insert

      protected boolean insert(Configurable parent, Configurable child, int index)
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • getConfigureName

      public static String getConfigureName(Class<?> c)
      Returns the name of the class for display purposes. Reflection is used to call getConfigureTypeName(), which should be a static method if it exists in the given class. (This is necessary because static methods are not permitted in interfaces.)
      Parameters:
      c - the class whose configure name will be returned
      Returns:
      the configure name of the class
    • getConfigureName

      public static String getConfigureName(Configurable c)
    • importConfigurable

      protected Configurable importConfigurable()
    • maybePopup

      protected void maybePopup(MouseEvent e)
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • getTreeNode

      public DefaultMutableTreeNode getTreeNode(Configurable target)
    • mouseDragged

      public void mouseDragged(MouseEvent evt)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • isMoveAllowed

      public boolean isMoveAllowed(Configurable target)
      Is the Component allowed to be moved?
    • isDeleteAllowed

      protected boolean isDeleteAllowed(Configurable target)
      Is the Component allowed to be deleted? A mandatory component can be deleted if there is more than one of them with the same parent
    • isDuplicateAllowed

      protected boolean isDuplicateAllowed(Configurable target)
      Is the Component allowed to be duplicated?
    • isValidParent

      protected boolean isValidParent(Configurable parent, Configurable child)
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • nodeUpdated

      public void nodeUpdated(Configurable target)
    • jumpToTarget

      public void jumpToTarget(Configurable target)
    • externalInsert

      public void externalInsert(Configurable parent, Configurable child)
      Build an AddAction and execute it to request a new component from the user
      Parameters:
      parent - Target Parent
      child - Type to add
    • getHelpAction

      public Action getHelpAction()
    • populateEditMenu

      public void populateEditMenu(EditorWindow ew)
    • doKeyAction

      protected void doKeyAction(String action)
      Handle main Edit menu selections/accelerators
      Parameters:
      action - Edit command name
    • valueChanged

      public void valueChanged(TreeSelectionEvent e)
      Tree selection changed, record info about the currently selected component
      Specified by:
      valueChanged in interface TreeSelectionListener
    • updateEditMenu

      protected void updateEditMenu()
    • getParent

      protected Configurable getParent(Configurable target)
      Find the parent Configurable of a specified Configurable
      Parameters:
      target - target Configurable
      Returns:
      parent
    • getSearchCmd

      public String getSearchCmd()
    • addAdditionalComponent

      public static void addAdditionalComponent(Class<? extends Buildable> parent, Class<? extends Buildable> child)
      Record additional available components to add to the popup menu.
      Parameters:
      parent - Parent Class
      child - Child Class
    • nodeEdited

      public void nodeEdited(Configurable target)
      Called when the Configurable held by a node has been edited. Set the edit status and re-build the Jtree label
      Parameters:
      target - Edited Configurable
    • checkMinimumIndex

      public int checkMinimumIndex(DefaultMutableTreeNode targetNode, int index)
      Allows ExtensionEditor to override and control what indexes are allowed
    • postInsertProcessing

      protected void postInsertProcessing(Configurable parent, Configurable child)
    • postRemoveProcessing

      protected void postRemoveProcessing(Configurable parent, Configurable child)