Module org.autogui

Interface GuiRepresentation

All Known Implementing Classes:
GuiReprAction, GuiReprActionList, GuiReprCollectionElement, GuiReprCollectionTable, GuiReprEmbeddedComponent, GuiRepresentation.GuiReprNone, GuiReprObjectPane, GuiReprObjectTabbedPane, GuiReprPropertyPane, GuiReprSet, GuiReprValue, GuiReprValueBooleanCheckBox, GuiReprValueDocumentEditor, GuiReprValueEnumComboBox, GuiReprValueFilePathField, GuiReprValueImagePane, GuiReprValueLabel, GuiReprValueNumberSpinner, GuiReprValueStringField

public interface GuiRepresentation
abstract GUI component: most methods of the interface always take a GuiMappingContext, this is because an instance of the interface might be a singleton instance.
  • Field Details

  • Method Details

    • match

      boolean match(GuiMappingContext context)
      match the representation with the typeElement of the context, and if succeeded, it sets this representation to the context, and it might create sub-contexts for recursive matches *
      Parameters:
      context - the context of the repr.
      Returns:
      the matching result
    • matchAndSetNotifiersAsInit

      default boolean matchAndSetNotifiersAsInit(GuiMappingContext context)
      Parameters:
      context - the context of the repr.
      Returns:
      the matching result
      Since:
      1.2
    • setNotifiersTree

      default void setNotifiersTree(GuiMappingContext context)
      sets notifiers for the entire tree by GuiMappingContext.setNotifiers(Object)
      Parameters:
      context - the context of the repr.
      Since:
      1.2
    • checkAndUpdateSource

      boolean checkAndUpdateSource(GuiMappingContext context)
      invoke the associated method and check the returned value whether it is updated or not. if updated, set the source of context to the value. This is non-recursive operation; GuiMappingContext recursively calls this method. The source of parent is already updated by the order of the calls.
      Parameters:
      context - the context of the repr.
      Returns:
      the representation is updated or not
    • continueCheckAndUpdateSourceForChildren

      default boolean continueCheckAndUpdateSourceForChildren(GuiMappingContext context, boolean parentUpdate)
    • toJsonWithNamed

      default Object toJsonWithNamed(GuiMappingContext context, Object source)
      the source might be a GuiReprValue.NamedValue, then it unwraps the named value, calls toJson(GuiMappingContext, Object), and it returns Map with the name. otherwise, it simply calls toJson and returns the result.
      Parameters:
      context - context of the repr.
      source - the source of returned JSON
      Returns:
      JSON object
    • fromJsonWithNamed

      default Object fromJsonWithNamed(GuiMappingContext context, Object target, Object json)
      Parameters:
      context - the context of the repr. In most cases, the type of the context will be a property.
      target - the target object. if it is GuiReprValue.NamedValue, then it obtains the value. nullable
      json - a Map with containing an entry for the name of the context
      Returns:
      the returned value fromJson(GuiMappingContext, Object, Object). if the target is a NamedValue, the returned value will also be a NamedValue.
    • toJson

      Object toJson(GuiMappingContext context, Object source)
      convert the source into JSON format
      Parameters:
      context - a context holds the representation
      source - the converted object
      Returns:
      JSON objects representing the source; String, Number, Boolean, List, Map or null
    • fromJson

      Object fromJson(GuiMappingContext context, Object target, Object json)
      create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents. the behavior can be varied by each representation, confirmed by isJsonSetter().
      Parameters:
      context - a context holds the representation
      target - the target object or null
      json - JSON objects representing the target String, Number, Boolean, List, Map or null
      Returns:
      created object from the json, target if provided, or null.
    • isJsonSetter

      default boolean isJsonSetter()
      Returns:
      true means fromJson(GuiMappingContext, Object, Object) takes a target object and set json properties to the target. otherwise, the method will return a new value, thus the target can be null
    • toHumanReadableString

      default String toHumanReadableString(GuiMappingContext context, Object source)
      method for constructing "toString" copy operations: the returned string will be separated by tabs and new-lines
      Parameters:
      context - the context of the repr.
      source - converted to string
      Returns:
      a string representation of the source
    • fromHumanReadableString

      default Object fromHumanReadableString(GuiMappingContext context, String str)
    • getDefaultSet

      static GuiReprSet getDefaultSet()
      Returns:
      the set of default representations. it does not include swing-based representations. Instead, GuiSwingMapperSet includes all representations.
    • createCollectionElement

      static GuiReprCollectionElement createCollectionElement(GuiRepresentation owner)
      Parameters:
      owner - the owner which can contains the returned repr itself
      Returns:
      new representation
      Since:
      1.7
    • createValueBooleanCheckBox

      static GuiReprValueBooleanCheckBox createValueBooleanCheckBox()
      Returns:
      new representation
      Since:
      1.7
    • createValueEnumComboBox

      static GuiReprValueEnumComboBox createValueEnumComboBox()
      Returns:
      new representation
      Since:
      1.7
    • createValueFilePathField

      static GuiReprValueFilePathField createValueFilePathField()
      Returns:
      new representation
      Since:
      1.7
    • createValueNumberSpinner

      static GuiReprValueNumberSpinner createValueNumberSpinner()
      Returns:
      new representation wihtout a number-type; GuiReprValueNumberSpinner.match(GuiMappingContext) can determine the number-type from the type of the given context. Also GuiReprValueNumberSpinner.createNumberSpinner(GuiReprValueNumberSpinner.NumberType) can re-create with concretizing the number-type.
      Since:
      1.7
      See Also:
    • createValueNumberSpinner

      static GuiReprValueNumberSpinner createValueNumberSpinner(GuiReprValueNumberSpinner.NumberType numType)
      Parameters:
      numType - the number-type defined in GuiReprValueNumberSpinner, like GuiReprValueNumberSpinner.INT
      Returns:
      new representation with the number-type
    • createValueStringField

      static GuiReprValueStringField createValueStringField()
      Returns:
      new representation
      Since:
      1.7
    • createCollectionTable

      static GuiReprCollectionTable createCollectionTable(GuiRepresentation owner)
      Parameters:
      owner - the owner which can contains the returned repr itself
      Returns:
      new representation
      Since:
      1.7
    • createObjectTabbedPane

      static GuiReprObjectTabbedPane createObjectTabbedPane(GuiRepresentation owner)
      Parameters:
      owner - the owner which can contains the returned repr itself
      Returns:
      new representation
      Since:
      1.7
    • createObjectPane

      static GuiReprObjectPane createObjectPane(GuiRepresentation owner)
      Parameters:
      owner - the owner which can contains the returned repr itself
      Returns:
      new representation
      Since:
      1.7
    • createPropertyPane

      static GuiReprPropertyPane createPropertyPane(GuiRepresentation owner)
      Parameters:
      owner - the owner which can contains the returned repr itself
      Returns:
      new representation
      Since:
      1.7
    • createAction

      static GuiReprAction createAction()
      Returns:
      new representation
      Since:
      1.7
    • createActionList

      static GuiReprActionList createActionList()
      Returns:
      new representation
      Since:
      1.7
    • createValueLabel

      static GuiReprValueLabel createValueLabel()
      Returns:
      new representation
      Since:
      1.7
    • createValue

      static GuiReprValue createValue()
      the repr type is abstract for any values and it will not be directly included in the default set.
      Returns:
      new representation
      Since:
      1.7
    • toStringHeader

      default String toStringHeader()
    • isTaskRunnerUsedFor

      default boolean isTaskRunnerUsedFor(Supplier<?> task)
      Parameters:
      task - the tested task
      Returns:
      true if the task can be executed under the task-runner of a context. the method can be used for the cases that the task is dispatched to a custom task-runner mechanism
    • shutdown

      default void shutdown(GuiMappingContext context, Object target)
      do shutting-down process if the target object is an AutoCloseable.
      Parameters:
      context - the context of the repr.
      target - the target object, obtained from source value of the context