Module org.autogui

Class GuiReprAction

java.lang.Object
org.autogui.base.mapping.GuiReprAction
All Implemented Interfaces:
GuiRepresentation

public class GuiReprAction extends Object implements GuiRepresentation
The abstract action component for an action
     @GuiIncluded
     public class C {
         ...
         @GuiIncluded
         public void action() {
             ...
         }
     }
 
an action can be selection-updater by attaching GuiListSelectionUpdater
  • Constructor Details

    • GuiReprAction

      public GuiReprAction()
  • Method Details

    • match

      public boolean match(GuiMappingContext context)
      Description copied from interface: GuiRepresentation
      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 *
      Specified by:
      match in interface GuiRepresentation
      Parameters:
      context - the context of the repr.
      Returns:
      the matching result
    • checkAndUpdateSource

      public boolean checkAndUpdateSource(GuiMappingContext context)
      Description copied from interface: GuiRepresentation
      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.
      Specified by:
      checkAndUpdateSource in interface GuiRepresentation
      Parameters:
      context - the context of the repr.
      Returns:
      the representation is updated or not
    • executeAction

      public Object executeAction(GuiMappingContext context, GuiReprValue.ObjectSpecifier targetSpecifier)
      the action executor relying on GuiMappingContext.execute(Callable). the target is obtained from the parent context
      Parameters:
      context - the context
      targetSpecifier - the specifier of the target
      Returns:
      result of method execution or null
    • executeActionForTargets

      public List<Object> executeActionForTargets(GuiMappingContext context, List<?> targets)
      the action executor relying on GuiMappingContext.execute(Callable).
      Parameters:
      context - the context
      targets - the targets
      Returns:
      results of each execution, might include null elements. if some execution cause an exception, partially constructed results will be returned
    • toJson

      public Object toJson(GuiMappingContext context, Object source)
      Description copied from interface: GuiRepresentation
      convert the source into JSON format
      Specified by:
      toJson in interface GuiRepresentation
      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

      public Object fromJson(GuiMappingContext context, Object target, Object json)
      Description copied from interface: GuiRepresentation
      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 GuiRepresentation.isJsonSetter().
      Specified by:
      fromJson in interface GuiRepresentation
      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.
    • isSelectionAction

      public boolean isSelectionAction(GuiMappingContext context)
      Parameters:
      context - the context of the action
      Returns:
      true if the target method has the annotation GuiListSelectionCallback
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isSelectionChangeAction

      public boolean isSelectionChangeAction(GuiMappingContext context, GuiMappingContext tableContext)
      Parameters:
      context - the context of the action
      tableContext - the table context in order to obtain the element-type of the list
      Returns:
      the target method returns a list of the element-type List<E> and has the annotation GuiListSelectionUpdater
    • isSelectionChangeRowIndicesAction

      public boolean isSelectionChangeRowIndicesAction(GuiMappingContext context, GuiMappingContext tableContext)
      checking an action can be a selection updater for a table
      Parameters:
      context - the action context
      tableContext - the linked table-context
      Returns:
      true if the target action returning List<Integer> with GuiListSelectionUpdater.index()=true and the parent of tableContext is target of the action (specified by GuiListSelectionUpdater.target() or the method name "select...")
      Since:
      1.5
    • isSelectionChangeRowAndColumnIndicesAction

      public boolean isSelectionChangeRowAndColumnIndicesAction(GuiMappingContext context, GuiMappingContext tableContext)
      checking an action can be a selection updater for a table
      Parameters:
      context - the action context
      tableContext - the linked table-context
      Returns:
      true if the target action returning List<int[]> with GuiListSelectionUpdater with index=true, and the parent of tableContext is target of the action (specified by GuiListSelectionUpdater.target() or the method name "select...")
      Since:
      1.5