Klasse FormBuilder

java.lang.Object
uibooster.model.FormBuilder
Bekannte direkte Unterklassen:
FormBuilderElementTyped, RowFormBuilder

public class FormBuilder extends Object
  • Konstruktordetails

  • Methodendetails

    • addText

      public FormBuilderElementTyped<String> addText(String label)
      Adds an input text field to the form.
      Parameter:
      label - expects the label for this input element
    • addText

      public FormBuilderElementTyped<String> addText(String label, String initialText)
      Adds an input text field to the form with an initial text.
      Parameter:
      label - expects the label for this input element
      initialText - expects a text which will be set into the text field
    • addText

      public FormBuilderElementTyped<String> addText(String label, String initialText, boolean readonly)
      Adds an input text field to the form with an initial text.
      Parameter:
      label - expects the label for this input element
      initialText - expects a text which will be set into the text field.
      readonly - if readonly is set to true, the input field is not changable for the user
    • addTextArea

      public FormBuilderElementTyped<String> addTextArea(String label)
      Adds an input text area with 3 lines to the form.
      Parameter:
      label - expects the label for this input element
    • addTextArea

      public FormBuilderElementTyped<String> addTextArea(String label, int rows)
      Adds an input text area with specified number of lines to the form.
      Parameter:
      label - expects the label for this input element
      rows - expects the number of lines
    • addTextArea

      public FormBuilderElementTyped<String> addTextArea(String label, String initialText)
      Adds an input text area with 3 lines to the form and an initial text.
      Parameter:
      label - expects the label for this input element
      initialText - expects a text which will be set into the text area
    • addTextArea

      public FormBuilderElementTyped<String> addTextArea(String label, int rows, String initialText)
      Adds an input text area with specified number of lines to the form and an initial text.
      Parameter:
      label - expects the label for this input element
      rows - expects the number of lines
      initialText - expects a text which will be set into the text area
    • addTextArea

      public FormBuilderElementTyped<String> addTextArea(String label, int rows, String initialText, boolean readonly)
      Adds an input text area with specified number of lines to the form and an initial text.
      Parameter:
      label - expects the label for this input element
      rows - expects the number of lines
      initialText - expects a text which will be set into the text area
      readonly - if readonly is set to true, the input field is not changable for the user
    • addSelection

      public FormBuilderElementTyped<String> addSelection(String label, List<String> possibilities)
      Adds a selection list to the form, which allows to choose one option.
      Parameter:
      label - expects the label for this input element
      possibilities - expects a list of possible texts options
    • addSelection

      public FormBuilderElementTyped<String> addSelection(String label, String... possibilities)
      Adds a selection list to the form, which allows to choose one option.
      Parameter:
      label - expects the label for this input element
      possibilities - expects a list of possible texts options
      Gibt zurück:
    • addSelectionWithCheckboxes

      public FormBuilderElementTyped<String> addSelectionWithCheckboxes(String label, List<String> possibilities)
      Adds a selection with checkboxes to the form, which allows to choose multiple options.
      Parameter:
      label - expects the label for this input element
      possibilities - expects a list of possible texts options
    • addSelectionWithCheckboxes

      public FormBuilderElementTyped<String> addSelectionWithCheckboxes(String label, List<String> possibilities, List<String> initialSelectedPossibilities)
      Adds a selection with checkboxes to the form, which allows to choose multiple options.
      Parameter:
      label - expects the label for this input element
      possibilities - expects a list of possible texts options
      initialSelectedPossibilities - expects the initial
    • addSelectionWithCheckboxes

      public FormBuilderElementTyped<String> addSelectionWithCheckboxes(String label, String... possibilities)
      Adds a selection with checkboxes to the form, which allows to choose multiple options.
      Parameter:
      label - expects the label for this input element
      possibilities - expects a list of possible texts options
    • addCustomElement

      public <T> FormBuilderElementTyped<T> addCustomElement(FormElement<T> element)
      Adds the given self implemented FormElement to the form.
      Parameter:
      element - expects an implementation of FormElement
    • addLabel

      public FormBuilderElementTyped<String> addLabel(String label)
      Adds just a label to the form.
      Parameter:
      label - expects the label
    • addButton

      public FormBuilderElementTyped<String> addButton(String buttonLabel, Runnable onClick)
      Adds a button to the form.
      Parameter:
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
    • addButton

      public FormBuilderElementTyped<String> addButton(String buttonLabel, ButtonClickListener onClick)
      Adds a button to the form.
      Parameter:
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
    • addButton

      public FormBuilderElementTyped<String> addButton(String buttonLabel, ButtonClickListener onClick, Color backgroundColor)
      Adds a button to the form.
      Parameter:
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
      backgroundColor - expects a color for the tint of this button background
    • addButton

      public FormBuilderElementTyped<String> addButton(String buttonLabel, ButtonClickListener onClick, Color backgroundColor, Color textColor)
      Adds a button to the form.
      Parameter:
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
      backgroundColor - expects a color for the tint of this button background
      textColor - expects a color for the text in this button
    • addButton

      public FormBuilderElementTyped<String> addButton(String label, String buttonLabel, Runnable onClick)
      Adds a button to the form.
      Parameter:
      label - expects the label for this input element
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
    • addButton

      public FormBuilderElementTyped<String> addButton(String label, String buttonLabel, ButtonClickListener onClick)
      Adds a button to the form.
      Parameter:
      label - expects the label for this input element
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
    • addButton

      public FormBuilderElementTyped<String> addButton(String label, String buttonLabel, ButtonClickListener onClick, Color backgroundColor, Color textColor)
      Adds a button to the form.
      Parameter:
      label - expects the label for this input element
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
      backgroundColor - expects a color for the tint of this button background
      textColor - expects a color for the text in this button
    • addButton

      public FormBuilderElementTyped<String> addButton(String label, String buttonLabel, ButtonClickListener onClick, Color backgroundColor)
      Adds a button to the form.
      Parameter:
      label - expects the label for this input element
      buttonLabel - expects the text which is shown on the button
      onClick - expects an implementation of Runnable, which is executed when the button is clicked
      backgroundColor - expects a color for the tint of this button background
    • addProgress

      public FormBuilderElementTyped<Integer> addProgress(String label, int min, int max, int initial)
      Adds a progress bar to the form.
      Parameter:
      label - expects the label for this input element
      min - expects the minimum value of the progress bar
      max - expects the maximum value of the progress bar
      initial - expects the current value of the progress bar
    • addSlider

      public FormBuilderElementTyped<Integer> addSlider(String label, int min, int max, int init, int majorTick, int minorTick)
      Adds a slider to the form, which allows to choose a value in between some bounds.
      Parameter:
      label - expects the label for this input element
      min - expects the minimum value of the slider
      max - expects the maximum value of the slider
      init - expects the current value of the slider
      majorTick - expects the step size for the bigger major tick
      minorTick - expects the step size for the smaller minor tick
    • addDatePicker

      public FormBuilderElementTyped<Date> addDatePicker(String label)
      Adds a date picker to the form.
      Parameter:
      label - expects the label for this input element
    • addColorPicker

      public FormBuilderElementTyped<Color> addColorPicker(String label)
      Adds a color picker to the form.
      Parameter:
      label - expects the label for this input element
    • addColorPicker

      public FormBuilderElementTyped<Color> addColorPicker(String label, Color initialColor)
      Adds a color picker to the form.
      Parameter:
      label - expects the label for this input element
      initialColor - expects a color which is set to the picker as default
    • addFontChooser

      public FormBuilderElementTyped<Font> addFontChooser(String label)
      Adds a font chooser to the form.
      Parameter:
      label - expects the label for this input element
    • addFontChooser

      public FormBuilderElementTyped<Font> addFontChooser(String label, Font initialFont)
      Adds a font chooser to the form.
      Parameter:
      label - expects the label for this input element
      initialFont - expects a font which is set to the chooser as default
    • addMultipleSelection

      public FormBuilderElementTyped<List<String>> addMultipleSelection(String label, String... elements)
      Adds a scrollable and searchable list of elements to the form, which allows to choose multiple elements.
      Parameter:
      label - expects the label for this input element
      elements - expects a list of options as text
    • addMultipleSelection

      public FormBuilderElementTyped<List<String>> addMultipleSelection(String label, boolean hideFilter, String... elements)
      Adds a scrollable and searchable list of elements to the form, which allows to choose multiple elements.
      Parameter:
      label - expects the label for this input element
      hideFilter - if set to true, the input text field for the search will be not shown
      elements - expects a list of options as text
    • addMultipleSelection

      public FormBuilderElementTyped<List<String>> addMultipleSelection(String label, List<String> elements)
      Adds a scrollable and searchable list of elements to the form, which allows to choose multiple elements.
      Parameter:
      label - expects the label for this input element
      elements - expects a list of options as text
    • addMultipleSelection

      public FormBuilderElementTyped<List<String>> addMultipleSelection(String label, boolean hideFilter, List<String> elements)
      Adds a scrollable and searchable list of elements to the form, which allows to choose multiple elements.
      Parameter:
      label - expects the label for this input element
      hideFilter - if set to true, the input text field for the search will be not shown
      elements - expects a list of options as text
    • addList

      public FormBuilderElementTyped<ListElement> addList(String label, ListElement... elements)
      Adds a list with more complex elements to the form.
      Parameter:
      label - expects the label for this input element
      elements - expects a list of objects with type ListElement
    • addTable

      public FormBuilderElementTyped<TableData> addTable(String label, List<String> header, String[][] data, boolean isEditable)
      Adds table with custom data to the form.
      Parameter:
      label - expects the label for this input element
      header - expects a list of column names
      data - expects the data as two-dimensional array of Strings. It has to match with the number of column names
      isEditable - true if the data should changeable by the user, otherwise set false for immutable data
    • addTable

      public FormBuilderElementTyped<TableData> addTable(String label, List<String> header, String[][] data)
      Adds an editable table with custom data to the form.
      Parameter:
      label - expects the label for this input element
      header - expects a list of column names
      data - expects the data as two-dimensional array of Strings. It has to match with the number of column names
    • addImage

      public FormBuilderElementTyped<String> addImage(String imagePath)
      Adds an image to the form.
      Parameter:
      imagePath - expects the path to the image file
    • addImageCentered

      public FormBuilder addImageCentered(String imagePath)
      Adds an image centered to the form.
      Parameter:
      imagePath - expects the path to the image file
    • addImage

      public FormBuilderElementTyped<String> addImage(String label, String imagePath, boolean centered)
      Adds an image to the form.
      Parameter:
      label - expects the label for this input element
      imagePath - expects the path to the image file
      centered - true if the image should be centered, false it's aligned to the left
    • addCheckbox

      public FormBuilderElementTyped<Boolean> addCheckbox(String label)
      Adds true/false option as checkbox to the form.
      Parameter:
      label - expects a text which is displayed next to the checkbox
    • addCheckbox

      public FormBuilderElementTyped<Boolean> addCheckbox(String headline, String label)
      Adds true/false option as checkbox to the form.
      Parameter:
      headline - expects a text for this input element, which is displayed over the input element
      label - expects a text which is displayed next to the checkbox
    • addCheckbox

      public FormBuilderElementTyped<Boolean> addCheckbox(String headline, String label, boolean initialValue)
      Adds true/false option as checkbox to the form.
      Parameter:
      headline - expects a text for this input element, which is displayed over the input element
      label - expects a text which is displayed next to the checkbox
      initialValue - executes a value which is set up for the checkbox
    • addCheckbox

      public FormBuilderElementTyped<Boolean> addCheckbox(String label, boolean initialValue)
      Adds true/false option as checkbox to the form.
      Parameter:
      label - expects a text which is displayed next to the checkbox
      initialValue - executes a value which is set up for the checkbox
    • addHtmlText

      public FormBuilderElementTyped<String> addHtmlText(String label, String htmlContent)
      Adds a html interpreted text to the form. It supports HTML 3.2
      Parameter:
      label - expects the label for this input element
      htmlContent - expected html content
    • addHtmlText

      public FormBuilderElementTyped<String> addHtmlText(String label, String htmlContent, int width, int height)
      Adds a html interpreted text to the form. It supports HTML 3.2
      Parameter:
      label - expects the label for this input element
      htmlContent - expects html content
      width - expects the width in pixel which the component has to used preferred
      height - expects the height in pixel which the component has to used preferred
    • setChangeListener

      public FormBuilder setChangeListener(FormElementChangeListener onChange)
      Defines a listener which detects all changes in this form. It allows to react to different events for the added form elements.
      Parameter:
      onChange - expects an implementation of FormElementChangeListener
    • setCloseListener

      public FormBuilder setCloseListener(FormCloseListener closeListener)
      Defines a listener which detects the closing of the window of form. It allows to react on f.e. exit
      Parameter:
      closeListener - expects an implementation of FormElementCloseListener
    • setInitListener

      public FormBuilder setInitListener(FormInitializedListener formInitializedListener)
      Defines a listener which is called onced after the creation of the form.
      Parameter:
      formInitializedListener - expects an implementation of FormInitializedListener
    • setMargin

      public FormBuilder setMargin(int elementLeft, int elementTop, int elementRight, int elementBottom)
      Defines a margin for the lastly added element to set the space around this element in pixel. If setMargin is called before any element is added the given margin will set as default values for upcoming elements.
      Parameter:
      elementLeft - expects a margin space to the left in pixel
      elementTop - expects a margin space to top in pixel
      elementRight - expects a margin space to the right in pixel
      elementBottom - expects a margin space to bottom in pixel
    • andWindow

      public WindowSetting andWindow()
      Allows to define some settings for the created window of the form. The settings have to be closed with save()-method
    • show

      public Form show()
      Creates the previous defined form as blocking dialog and shows the window. It blocks the process until the window is closed. After that it returns the user input as Form.
      Gibt zurück:
      an object with the user filled data
    • run

      public Form run()
      Creates the previous defined form as non-blocking dialog and shows the window. The window is started in a new thread and allows to run the following code. It returns an object which is synchronized with the form. This form-object contains every user input as long as the dialog runs.
      Gibt zurück:
      an object which allows access to the user filled data.
    • startRow

      public RowFormBuilder startRow()
      Starts a new row to set multiple elements next to each other. It allows to set elements in the same row. The row has to end with the endRow()-method.
    • startRow

      public RowFormBuilder startRow(int hGap, int vGap)
      Starts a new row to set multiple elements next to each other. It allows to set elements in the same row. The row has to end with the endRow()-method. The gap params allow to set some space for the row in horizontal and vertical direction.
      Parameter:
      hGap - expects a space in horizontal direction in pixel. The space is the sum of left und right spacing.
      vGap - expects a space in vertical direction in pixel. The space is the sum of left und right spacing.
    • startRow

      public RowFormBuilder startRow(int elementLeft, int elementTop, int elementRight, int elementBottom)
      Starts a new row to set multiple elements next to each other. It allows to set elements in the same row. The row has to end with the endRow()-method. The margin defines the space around this row in pixel.
      Parameter:
      elementLeft - expects a margin space to the left in pixel
      elementTop - expects a margin space to top in pixel
      elementRight - expects a margin space to the right in pixel
      elementBottom - expects a margin space to bottom in pixel
    • startRow

      public RowFormBuilder startRow(String label)
      Starts a new row to set multiple elements next to each other. It allows to set elements in the same row. The row has to end with the endRow()-method.
      Parameter:
      label - expects the label for this input element
    • startRow

      public RowFormBuilder startRow(String label, int hGap, int vGap)
      Starts a new row to set multiple elements next to each other. It allows to set elements in the same row. The row has to end with the endRow()-method. The gap params allow to set some space for the row in horizontal and vertical direction.
      Parameter:
      label - expects the label for this input element
      hGap - expects a space in horizontal direction in pixel. The space is the sum of left und right spacing.
      vGap - expects a space in vertical direction in pixel. The space is the sum of left und right spacing.
    • startRow

      public RowFormBuilder startRow(String label, int elementLeft, int elementTop, int elementRight, int elementBottom)
      Starts a new row to set multiple elements next to each other. It allows to set elements in the same row. The row has to end with the endRow()-method. The margin defines the space around this row in pixel.
      Parameter:
      label - expects the label for this input element
      elementLeft - expects a margin space to the left in pixel
      elementTop - expects a margin space to top in pixel
      elementRight - expects a margin space to the right in pixel
      elementBottom - expects a margin space to bottom in pixel
    • endRow

      public FormBuilder endRow()
      Stops the current created row. It has to be used after startRow()-method.