Class TreeMemory


  • public class TreeMemory
    extends Object
    This singleton class remembers whether or not a TreeItem is expanded. When the tree is refreshed, it remembers, making for a better user experience.
    Author:
    Matt
    • Method Detail

      • getInstance

        public static final TreeMemory getInstance()
      • storeExpanded

        public void storeExpanded​(String treeName,
                                  org.eclipse.swt.widgets.TreeItem treeItem,
                                  boolean expanded)
      • storeExpanded

        public void storeExpanded​(String treeName,
                                  String[] path,
                                  boolean expanded)
      • isExpanded

        public boolean isExpanded​(String treeName,
                                  String[] path)
      • clear

        public void clear()
      • addTreeListener

        public static final org.eclipse.swt.events.TreeListener addTreeListener​(org.eclipse.swt.widgets.Tree tree,
                                                                                String treeName)
        This method creates, adds and returns a tree listener that will keep track of the expanded/collapsed state of the TreeItems. This state will then be stored in the TreeMemory singleton.
        Parameters:
        tree - The tree to add the listener to
        Returns:
        The created/added TreeListener
      • setExpandedFromMemory

        public static void setExpandedFromMemory​(org.eclipse.swt.widgets.Tree tree,
                                                 String treeName)
        Expand of collapse all TreeItems in the complete tree based on the values stored in memory.
        Parameters:
        tree - The tree to format.