Class AbstractComponent

java.lang.Object
com.groiss.gui.AbstractComponent
All Implemented Interfaces:
Component, Serializable, Cloneable
Direct Known Subclasses:
AbstractContainer, Checkbox, ComparableComponent, FileChooser, Image, Link, RadioButton, RadioGroup, SelectList, SubmitButton, Text, Textarea, Textfield

public abstract class AbstractComponent extends Object implements Component
abstract implementation of the component interface with some common code for subclasses
See Also:
  • Field Details

  • Constructor Details

    • AbstractComponent

      public AbstractComponent()
    • AbstractComponent

      public AbstractComponent(Element root)
      constructs a new component from an existing JDOM the root element must have an id attribute
      Parameters:
      root - - the root JDOM element
    • AbstractComponent

      public AbstractComponent(String name, String id, String className)
      constructs a new empty component and creates an internal JDOM that consists of an empty root element
      Parameters:
      name - - the name of the root element
      id - - the id of the component
      className - - the name of the component class
    • AbstractComponent

      public AbstractComponent(String name)
  • Method Details

    • init

      public void init(Element element)
      Initialize the component with a jdom-tree.
      Specified by:
      init in interface Component
      Parameters:
      element - - the root-element of the tree, must not be null
    • init

      public void init(String name)
    • init

      public void init(String name, String id, String className)
      initialize the component with an new jdom-tree
      Specified by:
      init in interface Component
      Parameters:
      name - - the name of the root-element of the tree, must not be null
      id - - the id of the component
      className - - the name of the component class
    • setAttribute

      public Component setAttribute(String name, String value)
      sets the attribute to the component
      Specified by:
      setAttribute in interface Component
      Parameters:
      name - - the name of the attribute
      value - - the value of the attribute
      Returns:
      the updated component
    • getAttribute

      public String getAttribute(String name)
      returs the value of an attribute
      Specified by:
      getAttribute in interface Component
      Parameters:
      name - - the name of the attribute
      Returns:
      - the value of the attribute
    • removeAttribute

      public boolean removeAttribute(String name)
      Remove the attribute from the component.
      Specified by:
      removeAttribute in interface Component
      Parameters:
      name - - the name of the attribute
      Returns:
      - true, if the attribute was found
    • setActionListener

      public void setActionListener(String event, String action)
      Sets the action to an event. A synonym to setAttribute.
      Specified by:
      setActionListener in interface Component
      Parameters:
      event - the event to listen
      action - the action to perform
    • setId

      public void setId(String id)
      set the unique identifier to a given value. Handle with care!
      Specified by:
      setId in interface Component
      Parameters:
      id - the new id of this component
    • getId

      public String getId()
      Specified by:
      getId in interface Component
      Returns:
      - the unique identifier of the component
    • setName

      public void setName(String name)
      set the name to a given value.
      Specified by:
      setName in interface Component
      Parameters:
      name - - the new name of this component
    • getName

      public String getName()
      Specified by:
      getName in interface Component
      Returns:
      - the name of the component
    • setRootName

      public void setRootName(String name)
      set the name of the root element to a given value.
      Parameters:
      name - - the new name of the root element
    • getRootName

      public String getRootName()
      Returns:
      - the name of the root element
    • setLabel

      public void setLabel(Label c)
      sets the label component
      Specified by:
      setLabel in interface Component
      Parameters:
      c - - the label component
    • getLabel

      public Label getLabel()
      Specified by:
      getLabel in interface Component
      Returns:
      - the label component of the component
    • setParentElement

      public void setParentElement(Element parent)
      sets the parent element of the components root
      Specified by:
      setParentElement in interface Component
      Parameters:
      parent - - the parent element
    • getParentElement

      public Element getParentElement()
      Specified by:
      getParentElement in interface Component
      Returns:
      - the parent element of the components root
    • setParent

      public void setParent(Container parent)
      sets the parent container
      Specified by:
      setParent in interface Component
      Parameters:
      parent - - the parent container
    • getParent

      public Container getParent()
      Specified by:
      getParent in interface Component
      Returns:
      - the parent container
    • setViewMode

      public void setViewMode(short mode)
      sets the viewMode
      Specified by:
      setViewMode in interface Component
      Parameters:
      mode - - the new viewMode
    • getViewMode

      public short getViewMode()
      Specified by:
      getViewMode in interface Component
      Returns:
      - the viewMode of the component
    • setBrowserMode

      public void setBrowserMode(short mode)
      sets the browserMode
      Specified by:
      setBrowserMode in interface Component
      Parameters:
      mode - - the new browserMode
    • getBrowserMode

      public short getBrowserMode()
      Specified by:
      getBrowserMode in interface Component
      Returns:
      - the browserMode of the component
    • setStyle

      public void setStyle(String style)
      Set the style
      Specified by:
      setStyle in interface Component
      Parameters:
      style - - the new style
    • getStyle

      public String getStyle()
      Specified by:
      getStyle in interface Component
      Returns:
      - the style of the component
    • show

      public String show()
      Description copied from interface: Component
      method for rendering the component as string
      Specified by:
      show in interface Component
      Returns:
      - the rendered component as String
    • show

      public void show(PrintWriter pw)
      prints the rendered component to a PrintWriter
      Specified by:
      show in interface Component
      Parameters:
      pw - - the Printwriter
    • toString

      public String toString()
      Returns the classname followed by a colon and the title attribute. The string representation is sometimes used for sorting, e.g. TableRenderer.
      Specified by:
      toString in interface Component
      Overrides:
      toString in class Object
      Returns:
      - the rendered component as string
    • clone

      public Object clone()
      returns a copy of the Component object
      Specified by:
      clone in interface Component
      Overrides:
      clone in class Object
      Returns:
      the Component clone
    • getRoot

      public Element getRoot()
      returns the root element of the internal JDOM
      Specified by:
      getRoot in interface Component
      Returns:
      the root element
    • setContent

      public void setContent(Object o)
      sets the content of the component
      Specified by:
      setContent in interface Component
      Parameters:
      o - any object where the string representation is used for rendering
    • getContent

      public Object getContent()
      Specified by:
      getContent in interface Component
      Returns:
      the content object of the component
    • setNewLines

      @Deprecated public void setNewLines(boolean val)
      Deprecated.
      method does nothing
      Parameters:
      val - - boolean value
    • setEncoding

      @Deprecated public void setEncoding(boolean val)
      Deprecated.
      method does nothing
      Parameters:
      val - - boolean value
    • setExpandEmptyElements

      @Deprecated public void setExpandEmptyElements(boolean val)
      Deprecated.
      method does nothing
      Parameters:
      val - - boolean value
    • setIndenting

      @Deprecated public void setIndenting(boolean val)
      Deprecated.
      method does nothing
      Parameters:
      val - - boolean value
    • create

      public static Component create(Element root)
      Create element from dom
      Parameters:
      root - - the root JDOM element
      Returns:
      the new component
    • toggleClass

      public Component toggleClass(String clazz, boolean add)
      Description copied from interface: Component
      remove or add the given CSS class(es) from the list of existing CSS-classes depending on a condition
      Specified by:
      toggleClass in interface Component
      Parameters:
      clazz - blank separated list of CSS classes to be added/removed
      add - - condition to add (true) or remove (false) the classes
      Returns:
      the current CSS classes
    • addClass

      public Component addClass(String clazz)
      Description copied from interface: Component
      add the given CSS class(es) to the list of existing CSS-classes
      Specified by:
      addClass in interface Component
      Parameters:
      clazz - blank separated list of CSS classes to be added
      Returns:
      the current CSS classes
    • removeClass

      public Component removeClass(String clazz)
      Description copied from interface: Component
      remove the given CSS class(es) from the list of existing CSS-classes
      Specified by:
      removeClass in interface Component
      Parameters:
      clazz - blank separated list of CSS classes to be removed
      Returns:
      the current CSS classes
    • setClass

      public Component setClass(String clazz)
      Description copied from interface: Component
      set the CSS-class attribute to the given value
      Specified by:
      setClass in interface Component
      Parameters:
      clazz - blank separated list of CSS classes to be assigned
      Returns:
      the current CSS classes