Class PreferenceNode

  • All Implemented Interfaces:
    IPreferenceNode

    public class PreferenceNode
    extends java.lang.Object
    implements IPreferenceNode
    A concrete implementation of a node in a preference dialog tree. This class also supports lazy creation of the node's preference page.
    • Constructor Summary

      Constructors 
      Constructor Description
      PreferenceNode​(java.lang.String id)
      Creates a new preference node with the given id.
      PreferenceNode​(java.lang.String id, java.lang.String label, ImageDescriptor image, java.lang.String className)
      Creates a preference node with the given id, label, and image, and lazily-loaded preference page.
      PreferenceNode​(java.lang.String id, IPreferencePage preferencePage)
      Creates a preference node with the given id and preference page.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(IPreferenceNode node)
      Adds the given preference node as a subnode of this preference node.
      void createPage()
      Creates the preference page for this node.
      void disposeResources()
      Release the page managed by this node, and any SWT resources held onto by this node (Images, Fonts, etc).
      IPreferenceNode findSubNode​(java.lang.String id)
      Returns the subnode of this contribution node with the given node id.
      java.lang.String getId()
      Returns the id of this contribution node.
      protected ImageDescriptor getImageDescriptor()
      Returns the image descriptor for this node.
      Image getLabelImage()
      Returns the image used to present this node in a preference dialog.
      java.lang.String getLabelText()
      Returns the text label used to present this node in a preference dialog.
      IPreferencePage getPage()
      Returns the preference page for this node.
      IPreferenceNode[] getSubNodes()
      Returns an iterator over the subnodes (immediate children) of this contribution node.
      IPreferenceNode remove​(java.lang.String id)
      Removes the subnode of this preference node with the given node id.
      boolean remove​(IPreferenceNode node)
      Removes the given preference node from the list of subnodes (immediate children) of this node.
      void setPage​(IPreferencePage newPage)
      Set the current page to be newPage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PreferenceNode

        public PreferenceNode​(java.lang.String id)
        Creates a new preference node with the given id. The new node has no subnodes.
        Parameters:
        id - the node id
      • PreferenceNode

        public PreferenceNode​(java.lang.String id,
                              java.lang.String label,
                              ImageDescriptor image,
                              java.lang.String className)
        Creates a preference node with the given id, label, and image, and lazily-loaded preference page. The preference node assumes (sole) responsibility for disposing of the image; this will happen when the node is disposed.
        Parameters:
        id - the node id
        label - the label used to display the node in the preference dialog's tree
        image - the image displayed left of the label in the preference dialog's tree, or null if none
        className - the class name of the preference page; this class must implement IPreferencePage
      • PreferenceNode

        public PreferenceNode​(java.lang.String id,
                              IPreferencePage preferencePage)
        Creates a preference node with the given id and preference page. The title of the preference page is used for the node label. The node will not have an image.
        Parameters:
        id - the node id
        preferencePage - the preference page
    • Method Detail

      • add

        public void add​(IPreferenceNode node)
        Description copied from interface: IPreferenceNode
        Adds the given preference node as a subnode of this preference node.
        Specified by:
        add in interface IPreferenceNode
        Parameters:
        node - the node to add
      • disposeResources

        public void disposeResources()
        Description copied from interface: IPreferenceNode
        Release the page managed by this node, and any SWT resources held onto by this node (Images, Fonts, etc). Note that nodes are reused so this is not a call to dispose the node itself.
        Specified by:
        disposeResources in interface IPreferenceNode
      • findSubNode

        public IPreferenceNode findSubNode​(java.lang.String id)
        Description copied from interface: IPreferenceNode
        Returns the subnode of this contribution node with the given node id.
        Specified by:
        findSubNode in interface IPreferenceNode
        Parameters:
        id - the preference node id
        Returns:
        the subnode, or null if none
      • getId

        public java.lang.String getId()
        Description copied from interface: IPreferenceNode
        Returns the id of this contribution node. This id identifies a contribution node relative to its parent.
        Specified by:
        getId in interface IPreferenceNode
        Returns:
        the node id
      • getImageDescriptor

        protected ImageDescriptor getImageDescriptor()
        Returns the image descriptor for this node.
        Returns:
        the image descriptor
      • getLabelImage

        public Image getLabelImage()
        Description copied from interface: IPreferenceNode
        Returns the image used to present this node in a preference dialog.
        Specified by:
        getLabelImage in interface IPreferenceNode
        Returns:
        the image for this node, or null if there is no image for this node
      • getLabelText

        public java.lang.String getLabelText()
        Description copied from interface: IPreferenceNode
        Returns the text label used to present this node in a preference dialog.
        Specified by:
        getLabelText in interface IPreferenceNode
        Returns:
        the text label for this node, or null if there is no label for this node
      • getSubNodes

        public IPreferenceNode[] getSubNodes()
        Description copied from interface: IPreferenceNode
        Returns an iterator over the subnodes (immediate children) of this contribution node.
        Specified by:
        getSubNodes in interface IPreferenceNode
        Returns:
        an IPreferenceNode array containing the child nodes
      • remove

        public IPreferenceNode remove​(java.lang.String id)
        Description copied from interface: IPreferenceNode
        Removes the subnode of this preference node with the given node id.
        Specified by:
        remove in interface IPreferenceNode
        Parameters:
        id - the subnode id
        Returns:
        the removed subnode, or null if none
      • remove

        public boolean remove​(IPreferenceNode node)
        Description copied from interface: IPreferenceNode
        Removes the given preference node from the list of subnodes (immediate children) of this node.
        Specified by:
        remove in interface IPreferenceNode
        Parameters:
        node - the node to remove
        Returns:
        true if the node was removed, and false otherwise
      • setPage

        public void setPage​(IPreferencePage newPage)
        Set the current page to be newPage.
        Parameters:
        newPage - page to set