Class AbstractComponent<CC extends Component>

java.lang.Object
ch.tocco.nice2.model.form.api.components.AbstractComponent<CC>
All Implemented Interfaces:
Component
Direct Known Subclasses:
AbstractLabeledComponent

@Deprecated public abstract class AbstractComponent<CC extends Component> extends Object implements Component
Deprecated.
Abstract base class for all components, contains the common subset of attributes like "name", "position" etc.

WHEN SUBCLASSING: you need to override mapAllAttributesTo(ch.tocco.nice2.model.form.api.components.Component) and implement newInstanceForCopy(ch.tocco.nice2.model.form.api.components.Component)!

WHEN ADDING NEW ATTRIBUTES here or in subclasses: you need to copy them in mapAllAttributesTo(ch.tocco.nice2.model.form.api.components.Component)!

  • Field Details

    • name

      protected String name
      Deprecated.
      the name of the component
    • extProps

      @Nullable protected @Nullable Map<String,Object> extProps
      Deprecated.
    • attributeProps

      protected Map<String,Object> attributeProps
      Deprecated.
  • Constructor Details

    • AbstractComponent

      protected AbstractComponent(boolean acceptChildren, @Nullable @Nullable Component parent)
      Deprecated.
      Parameters:
      acceptChildren - set this explicit in your constructor. If true, the implementation will accept children, (For exaple an group-component), otherwise not (For example a textfield-component).
      parent - The parent of this component, null if none.
  • Method Details

    • findByName

      public List<Component> findByName(String pattern)
      Deprecated.
      Description copied from interface: Component
      Walks through the component tree and compares the component's name with the pattern.
      Specified by:
      findByName in interface Component
      Parameters:
      pattern - The name of the component we search (regular expressions are supported)
      Returns:
      ordered list of components (flat structure).
    • findFirstByName

      @Nullable public @Nullable Component findFirstByName(String pattern)
      Deprecated.
      Specified by:
      findFirstByName in interface Component
    • findByType

      public List<Component> findByType(Class<? extends Component> type)
      Deprecated.
      //TODO this impl is untested.
      Specified by:
      findByType in interface Component
      Parameters:
      type - component type, eg InputComponent.class
      Returns:
      ordered list of components (flat structure) it may be, that you can access components in the list through the Component.getChildren() method aswell.
    • find

      public List<Component> find(Component.ComponentFilter filter)
      Deprecated.
      Description copied from interface: Component
      Returns all components that match the given filter.

      Iterates the component tree, doing children recursively of each item first.

      Specified by:
      find in interface Component
      Parameters:
      filter - your own component filter
      Returns:
      ordered list of components (flat structure).
    • findFirst

      @Nullable public @Nullable Component findFirst(Component.ComponentFilter filter)
      Deprecated.
      Description copied from interface: Component
      Returns the first component that match the given filter.

      Iterates the component tree, doing children recursively of each item first.

      Specified by:
      findFirst in interface Component
      Parameters:
      filter - your own component filter
    • getParent

      @Nullable public final @Nullable Component getParent()
      Deprecated.
      Description copied from interface: Component
      Every component has a reference to its parent except for the root-components (forms, templates).

      So this condition has to be true:
      for(Compoent child : parent.getChildren())
        assert child.getParent().equals(parent);
      }
      Specified by:
      getParent in interface Component
      Returns:
      null if root-component
      See Also:
    • overrideParent

      public void overrideParent(@Nullable @Nullable Component parent)
      Deprecated.
      Description copied from interface: Component
      Overrides the parent.

      Originally this was not possible, the parent was final. But it is required for dynamically wrapping components in other components, see the table as an example which wraps fields in columns.

      Specified by:
      overrideParent in interface Component
      Parameters:
      parent - The new one.
    • getParentOrEx

      public final Component getParentOrEx()
      Deprecated.
      Description copied from interface: Component
      Returns the parent, or an exception for root components (forms, templates).
      Specified by:
      getParentOrEx in interface Component
      Returns:
      The parent, or an ex if it is null.
      See Also:
    • hasParent

      public final boolean hasParent()
      Deprecated.
      Specified by:
      hasParent in interface Component
      Returns:
      Tells if this component has a parent or not.
      See Also:
    • getForm

      @Nullable public @Nullable Form getForm()
      Deprecated.
      Description copied from interface: Component
      Returns the parent form, if any. This loops all all parents until it either finds a form, or arrives at the top.
      Specified by:
      getForm in interface Component
    • getName

      public final String getName()
      Deprecated.
      Specified by:
      getName in interface Component
      Returns:
      the component's name
    • createCopy

      public final CC createCopy()
      Deprecated.
      Do not remove the final modifier! Instead use the template method property. You need to override newInstanceForCopy(ch.tocco.nice2.model.form.api.components.Component) and mapAllAttributesTo(ch.tocco.nice2.model.form.api.components.Component).
      Specified by:
      createCopy in interface Component
      Returns:
      the copy
    • createCopy

      public final CC createCopy(Component newParent)
      Deprecated.
      Do not remove the final modifier! Instead use the template method property. You need to override newInstanceForCopy(ch.tocco.nice2.model.form.api.components.Component) and mapAllAttributesTo(ch.tocco.nice2.model.form.api.components.Component).
      Specified by:
      createCopy in interface Component
      Parameters:
      newParent - the new parent
      Returns:
      the copy
    • mapAllAttributesTo

      protected void mapAllAttributesTo(Component comp)
      Deprecated.
      Copies the attributes of this component into the passed component.

      This is used to copy the attributes collected by the xml reading process from "general" field tags into datatype-specific customized fields (mapped by FieldComponentConverter). And also for copying instances, kind of like cloning.

      Override this in your subclasses. Also, subclasses are required to let their anchestors do their work using super.copyOtherFields(cpy).

      Parameters:
      comp - The new field into which everything needs to be copied.
    • newInstanceForCopy

      protected abstract CC newInstanceForCopy(Component parent)
      Deprecated.
      Will be called when a copy is requested Component.createCopy()! Create a new instanc of this component, copy the properties and return it. You don't have to copy the properties which are inherited from the abstract implmentation. Only copy the properties from the concrete implementation.

      The parent has to be the parent given in the argument parent

      Parameters:
      parent - the parent to set
      Returns:
      the new instance
    • getType

      public Class<? extends Component> getType()
      Deprecated.
      Specified by:
      getType in interface Component
    • isLeaf

      public final boolean isLeaf()
      Deprecated.
      Description copied from interface: Component
      Tells if this component is at an end of the tree.

      More precise, it means the component has no children. It also returns true if the component is not meant to be a leaf, but happens to have no children, or the children are disabled or something (wrapper). This could even happen to a Form component.

      Specified by:
      isLeaf in interface Component
    • getDisplayType

      public Component.DisplayType getDisplayType()
      Deprecated.
      Specified by:
      getDisplayType in interface Component
    • isForceEditable

      public boolean isForceEditable()
      Deprecated.
      Specified by:
      isForceEditable in interface Component
    • isReplace

      public boolean isReplace()
      Deprecated.
      Specified by:
      isReplace in interface Component
    • getChildren

      public Collection<? extends Component> getChildren()
      Deprecated.
      Previously final, but wanted specialized return type.
      Specified by:
      getChildren in interface Component
      Returns:
      iterator
    • collectDataParts

      public Map<List<String>,Set<String>> collectDataParts()
      Deprecated.
      Specified by:
      collectDataParts in interface Component
    • collectDataParts

      public void collectDataParts(List<String> path, Map<List<String>,Set<String>> collector)
      Deprecated.
      Description copied from interface: Component
      Internal method for recursive loops.
      Specified by:
      collectDataParts in interface Component
      Parameters:
      path - .
      collector - .
    • setChildren

      public final void setChildren(Collection<Component> setChildren)
      Deprecated.
      Description copied from interface: Component
      Set the children explicit
      Specified by:
      setChildren in interface Component
      Parameters:
      setChildren - childern
    • setName

      public void setName(String name)
      Deprecated.
      Specified by:
      setName in interface Component
      Parameters:
      name - name
    • addComponent

      public void addComponent(Component component, int index)
      Deprecated.
      Description copied from interface: Component
      Adds a child component to the child-list of this component at the specified index.
      Specified by:
      addComponent in interface Component
    • addComponent

      public void addComponent(Component component) throws IllegalArgumentException
      Deprecated.
      Not final anymore, at least DefaultTable overrides this.
      Specified by:
      addComponent in interface Component
      Parameters:
      component - Child to add.
      Throws:
      IllegalArgumentException
    • removeComponent

      public final boolean removeComponent(String name)
      Deprecated.
      Description copied from interface: Component
      Removes a component by its name, return false if the component couldn't be found
      Specified by:
      removeComponent in interface Component
      Parameters:
      name - The component-name
    • getChild

      @Nullable public @Nullable Component getChild(String name)
      Deprecated.
      Description copied from interface: Component
      Returns the child with the given name, or null.
      Specified by:
      getChild in interface Component
      Parameters:
      name - The component's name.
    • replaceComponent

      public void replaceComponent(Component oldComponent, Component newComponent)
      Deprecated.
      Description copied from interface: Component
      Replaces oldComponent with newComponent.
      Specified by:
      replaceComponent in interface Component
      Parameters:
      oldComponent - Component to remove.
      newComponent - Component to add (on position of the old one)
    • replaceComponent

      public void replaceComponent(String oldComponentName, Component newComponent)
      Deprecated.
      Specified by:
      replaceComponent in interface Component
    • setDisplayType

      public void setDisplayType(Component.DisplayType displayType)
      Deprecated.
      Specified by:
      setDisplayType in interface Component
    • setForceEditable

      public void setForceEditable(boolean forceEditable)
      Deprecated.
      Specified by:
      setForceEditable in interface Component
    • setReplace

      public void setReplace(boolean replace)
      Deprecated.
      Specified by:
      setReplace in interface Component
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class Object
    • setPosition

      public final void setPosition(Component.Position pos)
      Deprecated.
      Specified by:
      setPosition in interface Component
    • setRelativeToPositionName

      public final void setRelativeToPositionName(String name)
      Deprecated.
      Specified by:
      setRelativeToPositionName in interface Component
    • getPosition

      public final Component.Position getPosition()
      Deprecated.
      Specified by:
      getPosition in interface Component
      Returns:
      the position
    • getRelativeToPositionName

      public final String getRelativeToPositionName()
      Deprecated.
      Description copied from interface: Component
      Get the name of the component this component has its relative-position to.
      Specified by:
      getRelativeToPositionName in interface Component
      Returns:
      name or null.
    • getExtProps

      @Nullable public @Nullable Map<String,Object> getExtProps()
      Deprecated.
      Specified by:
      getExtProps in interface Component
    • setExtProps

      public void setExtProps(Map<String,Object> extProps)
      Deprecated.
      Specified by:
      setExtProps in interface Component
    • getAttributeProps

      @Nullable public @Nullable Map<String,Object> getAttributeProps()
      Deprecated.
      Specified by:
      getAttributeProps in interface Component
    • setAttributeProps

      public void setAttributeProps(Map<String,Object> attributeProps)
      Deprecated.
      Specified by:
      setAttributeProps in interface Component
    • getEventHandler

      public String getEventHandler()
      Deprecated.
      Specified by:
      getEventHandler in interface Component
    • setEventHandler

      public void setEventHandler(@Nullable @Nullable String eventHandler)
      Deprecated.
      Specified by:
      setEventHandler in interface Component
    • equals

      public boolean equals(Object o)
      Deprecated.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Deprecated.
      Overrides:
      hashCode in class Object
    • setScopes

      public void setScopes(Set<String> scopes)
      Deprecated.
      Specified by:
      setScopes in interface Component
      Parameters:
      scopes - No null values, strings in lower case!
    • getScopes

      public Set<String> getScopes()
      Deprecated.
      Description copied from interface: Component
      Returns the scopes as defined in the component, or an empty set if none were defined which means that this component is meant for all scopes.
      Specified by:
      getScopes in interface Component
      Returns:
      Unmodifiable set with the strings in lower case.