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 Link icon

    • name Link icon

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

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

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

    • AbstractComponent Link icon

      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 Link icon

    • findByName Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      @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 Link icon

      @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 Link icon

      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 Link icon

      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 Link icon

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

      @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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

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

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

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

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

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

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      @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 Link icon

      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 Link icon

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

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

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

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

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

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

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

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

      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 Link icon

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

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

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

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

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

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

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

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

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

      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.