Class ComplexFormBuilder

java.lang.Object
com.jbstrap.ui.components.form.builders.ComplexFormBuilder
All Implemented Interfaces:
BlockedForm, ColumnedForm, ComplexForm, TabbedForm, FormBuilder

public class ComplexFormBuilder extends Object implements FormBuilder, BlockedForm, TabbedForm, ColumnedForm, ComplexForm

Complex form builder class

With the use of this builder class, a complex form can be built. The form can have tabs, blocks and columns. The hierarchy of the items can also be set. The form items will always be displayed in the bottom level element of the hierarchy. The look of the form will depend on the hierarchy types, that can be the following:

  • ComplexBuilderHierarchy.TAB_BLOCK_COLUMN
    This is the default display hierarchy. The tabs will be on the top-level, which means that there will be tab labels on the top, that the user can click on, to change tabs and their contents. By default, the first tab, and its contents, are displayed.
    The next level is the blocks, which will have the width to fill out the tab. The columns will be within these blocks, also having the width, to fill out the block. The individual form items will be displayed in these columns, with the width of the columns, under each other.
  • ComplexBuilderHierarchy.TAB_COLUMN_BLOCK
    In this hierarchy, the tabs will be on the top-level, which means that there will be tab labels on the top, that the user can click on, to change tabs and their contents. By default, the first tab, and its contents, are displayed.
    The next level is the column, which will have uniform width, so the columns together will have the width of the tab. The next level is the blocks, which will fill out the columns, and within the blocks, the form items will be displayed.
  • ComplexBuilderHierarchy.BLOCK_COLUMN_TAB
    In this hierarchy, the blocks will be on the top-level. The blocks will be under each other, with the width of the form. The columns will be within the blocks, having the width to fill out the block. The tabs will be within the columns, with the tab labels visible. The tabs will have the same width as the columns. The form items will be within the tabs, under each other.
  • ComplexBuilderHierarchy.BLOCK_TAB_COLUMN
    In this hierarchy, the blocks will be on the top level. The blocks will be under each other, with the width of the form. The tabs will be within the blocks, with the tab labels. The first tab and its contents are displayed. The tabs will have the width of the block. The next level is the column, which will have uniform width, so the columns together will have the width of the tab. The form items will be inside the columns, and they will have the width of the columns, under each other.
  • ComplexBuilderHierarchy.COLUMN_BLOCK_TAB
    In this hierarchy the columns will be on the top-level. The columns will have the width of the form, and they will fill out the form. The next level is the blocks, which will fill out the columns. The tabs will be within the blocks, with the tab labels. The first tab and its contents are displayed. The tabs will have the width of the block. The form items will be within the tabs, under each other.
  • ComplexBuilderHierarchy.COLUMN_TAB_BLOCK
    In this hierarchy the columns will be on the top-level. The columns will have the width of the form, and they will fill out the form. The tabs will be within the columns, with the tab labels visible. The tabs will have the same width as the columns. The next level is the blocks, which will fill out the columns, and within the blocks, the form items will be displayed.

The tabs, columns and blocks that are to be used must be created, through the form component, before it is drawn, by using the Form.addTabPage(String, Icon, String), Form.addBlock(String, String) or Form.addColumn(String) methods.

For the form to be displayed properly, the items must be parameterized correctly, by specifying their placements. This can be done by specifying it directly through code using the form item parameters, or by using the DataDescriptor column's column parameters. These parameters must be specified, so that the form items can be displayed.

Since:
4.0
Author:
JBStrap
See Also:
  • Constructor Details

    • ComplexFormBuilder

      public ComplexFormBuilder()
  • Method Details

    • createTabpage

      public final TabPage createTabpage(String name, Icon icon, String title)
      Creates a tab page, with the specified name, icon and label
      Specified by:
      createTabpage in interface TabbedForm
      Parameters:
      name - The name of the tab, must be unique within the form
      icon - The tab icon. The usable icons can be found in the Icon enum. If null, no icon will be used.
      title - The tab title. If null, none will be used.
      Returns:
      The created component
      Throws:
      NullPointerException - If the name is null
    • getTabpage

      public TabPage getTabpage(String name)
      Gets the tab page component, specified by its name
      Specified by:
      getTabpage in interface TabbedForm
      Parameters:
      name - The name of the tab
      Returns:
      The tabpage with the specified name or null, if not found
    • createBlock

      public final FormBlock createBlock(String name, String title)
      Creates a form block component, with the specified name and title
      Specified by:
      createBlock in interface BlockedForm
      Parameters:
      name - The name of the block, must be unique within the form
      title - The title of form block. If null, no title will be used
      Returns:
      The created form block component
      Throws:
      NullPointerException - If the name is null
    • getBlock

      public FormBlock getBlock(String name)
      Gets the block component, specified by its name
      Specified by:
      getBlock in interface BlockedForm
      Parameters:
      name - The name of the block
      Returns:
      The block with the specified name or null, if not found
    • createColumn

      public final FormColumn createColumn(String name)
      Creates a column with the specified name
      Specified by:
      createColumn in interface ColumnedForm
      Parameters:
      name - The name of the column, must be unique within the form
      Returns:
      The created form column component
      Throws:
      NullPointerException - If the name is null
    • getColumn

      public FormColumn getColumn(String name)
      Gets the column component, specified by its name
      Specified by:
      getColumn in interface ColumnedForm
      Parameters:
      name - The name of the column
      Returns:
      The column with the specified name or null if not found
    • setTabType

      public void setTabType(TabType tabType)
      Sets the tab type to be used on the form. By default the TabType.DEFAULT type is used
      Specified by:
      setTabType in interface TabbedForm
      Parameters:
      tabType - The tab type. The usable types can be found in the TabType enum
    • setHierarchy

      public void setHierarchy(ComplexBuilderHierarchy hierachia)
      Sets the hierarchy to be used by the form. The default hierarchy is the ComplexBuilderHierarchy.TAB_BLOCK_COLUMN.
      Specified by:
      setHierarchy in interface ComplexForm
      Parameters:
      hierachia - The hierarchy type to be used. The usable types can be found in the ComplexBuilderHierarchy enum
    • getHierarchy

      public ComplexBuilderHierarchy getHierarchy()
      Gets the hierarchy used by the form builder
      Specified by:
      getHierarchy in interface ComplexForm
      Returns:
      The hierarchy type
    • buildForm

      public Component<?> buildForm(List<FormItem<?,?>> formItems)
      Description copied from interface: FormBuilder
      Builds a form
      Specified by:
      buildForm in interface FormBuilder
      Parameters:
      formItems - A list containing the form items
      Returns:
      The built form content