Class JsonSchemaOutputComponent

java.lang.Object
javax.faces.component.UIComponent
javax.faces.component.UIComponentBase
javax.faces.component.UINamingContainer
de.xima.fc.prompt.service.support.gui.component.JsonSchemaOutputComponent
All Implemented Interfaces:
EventListener, javax.faces.component.NamingContainer, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.component.TransientStateHolder, javax.faces.component.UniqueIdVendor, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder

public class JsonSchemaOutputComponent extends javax.faces.component.UINamingContainer
  • Field Summary

    Fields inherited from class javax.faces.component.UINamingContainer

    COMPONENT_FAMILY, COMPONENT_TYPE, SEPARATOR_CHAR_PARAM_NAME

    Fields inherited from class javax.faces.component.UIComponent

    ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY

    Fields inherited from interface javax.faces.component.NamingContainer

    SEPARATOR_CHAR
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Finds the PromptFancySelectItem corresponding to the currently selected definition type.
    Gets the localized select item options with the possible values for the definition type select field that lets the user choose how they want to define the JSON schema.
    org.primefaces.extensions.model.monacoeditor.EditorOptions
    Gets the EditorOptions for the monaco editor used to edit the JSON example when the user chooses to define the JSON schema by providing a JSON example.
    org.primefaces.extensions.model.monacoeditor.EditorOptions
    Gets the EditorOptions for the monaco editor used to edit the JSON schema when the user chooses to enter a JSON schema manually.
    Gets the generated JSON schema for previewing.
    List<javax.faces.model.SelectItem>
     
    Get the options for creating the monaco editor extender that lets the user enter a JSON schema manually.
    boolean
    Gets whether schema adjustments are allowed.
     
     
    void
    onAddProperty(javax.faces.event.ActionEvent event)
    Callback invoked when the user clicks the "Add Property" button to add a new property to the list of properties.
    void
    Callback invoked when the user presses the button to convert configuration to the manual schema input.
    void
    Callback invoked when the user presses the button to convert configuration to a list of properties.
    void
    Callback invoked when the user presses the button to convert configuration to the visual editor configuration.
    void
    Callback invoked when the user clicks the "Preview" button to preview the generated JSON schema.
    void
    onRemoveProperty(javax.faces.event.ActionEvent event)
    Callback invoked when the user clicks the "Remove" button next to a property in the list of properties.
    void
    onTogglePropertyRequired(javax.faces.event.ActionEvent event)
     
    void
    setAllowSchemaAdjustments(boolean allowSchemaAdjustments)
    Sets whether schema adjustments are allowed.
    void
    Sets the selected task from the given PromptFancySelectItem.

    Methods inherited from class javax.faces.component.UINamingContainer

    createUniqueId, getFamily, getSeparatorChar, visitTree

    Methods inherited from class javax.faces.component.UIComponentBase

    addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent

    Methods inherited from class javax.faces.component.UIComponent

    encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface javax.faces.component.StateHolder

    isTransient, restoreState, saveState, setTransient
  • Constructor Details

    • JsonSchemaOutputComponent

      public JsonSchemaOutputComponent()
  • Method Details

    • getDefinitionType

      public PromptFancySelectItem getDefinitionType()
      Finds the PromptFancySelectItem corresponding to the currently selected definition type.

      Access the cc.attrs.value attribute of the closest TaskComponent component; which must be a JsonSchemaOutput instance. Then, finds the option whose value matches the selected value, and returns that option.

      This is a workaround for the <p:selectOneMenu> component. We want to use a custom UI for each option, but PrimeFaces only makes the select item value available as an EL variable (which is a string). We need to access the entire PromptFancySelectItem that contains the label and description to display.

      Returns:
      The selected PromptFancySelectItem, or null if no option is selected.
    • setDefinitionType

      public void setDefinitionType(PromptFancySelectItem item)
      Sets the selected task from the given PromptFancySelectItem.

      Access the cc.attrs.value attribute of the closest TaskComponent component; which must be a JsonSchemaOutput instance. Then writes the value of the given item to the definition type property.

      This is a workaround for the <p:selectOneMenu> component. We want to use a custom UI for each option, but PrimeFaces only makes the select item value available as an EL variable (which is a string). We need to access the entire PromptFancySelectItem that contains the label and description to display.

      Parameters:
      item - The selected PromptFancySelectItem, or null to clear the selection.
    • getDefinitionTypeOptions

      public List<PromptFancySelectItem> getDefinitionTypeOptions()
      Gets the localized select item options with the possible values for the definition type select field that lets the user choose how they want to define the JSON schema.
      Returns:
      The select item options.
    • getJsonEditorOptionsForExampleInput

      public org.primefaces.extensions.model.monacoeditor.EditorOptions getJsonEditorOptionsForExampleInput()
      Gets the EditorOptions for the monaco editor used to edit the JSON example when the user chooses to define the JSON schema by providing a JSON example.
      Returns:
      The editor options.
    • getJsonEditorOptionsForManualInput

      public org.primefaces.extensions.model.monacoeditor.EditorOptions getJsonEditorOptionsForManualInput()
      Gets the EditorOptions for the monaco editor used to edit the JSON schema when the user chooses to enter a JSON schema manually.
      Returns:
      The editor options.
    • getPreviewSchema

      public String getPreviewSchema()
      Gets the generated JSON schema for previewing. This is set when the user clicks the "Preview" button, see onPreview().
      Returns:
      The generated JSON schema, or null if preview has not been generated yet.
    • getPropertyTypeOptions

      public List<javax.faces.model.SelectItem> getPropertyTypeOptions()
    • getSchemaTextEditorExtenderOptions

      public String getSchemaTextEditorExtenderOptions()
      Get the options for creating the monaco editor extender that lets the user enter a JSON schema manually.
      Returns:
      The options as a serialized JSON string.
    • isAllowSchemaAdjustments

      public boolean isAllowSchemaAdjustments()
      Gets whether schema adjustments are allowed. This is the inverse of the model's forbidSchemaAdjustments property.
      Returns:
      True if schema adjustments are allowed, false if they are forbidden.
    • setAllowSchemaAdjustments

      public void setAllowSchemaAdjustments(boolean allowSchemaAdjustments)
      Sets whether schema adjustments are allowed. This is the inverse of the model's forbidSchemaAdjustments property.
      Parameters:
      allowSchemaAdjustments - True to allow schema adjustments, false to forbid them.
    • localizePropertyRequiredDisplayName

      public String localizePropertyRequiredDisplayName(JsonSchemaOutputObjectProperty property)
    • localizePropertyTypeDisplayName

      public String localizePropertyTypeDisplayName(JsonSchemaOutputObjectProperty property)
    • onAddProperty

      public void onAddProperty(javax.faces.event.ActionEvent event)
      Callback invoked when the user clicks the "Add Property" button to add a new property to the list of properties. Creates a new JsonSchemaOutputObjectProperty instance with default values and adds it to the list of properties in the JsonSchemaOutputByPropertyList instance.
      Parameters:
      event - The action event from the button click.
    • onConvertToManualInput

      public void onConvertToManualInput()
      Callback invoked when the user presses the button to convert configuration to the manual schema input. Extracts the JSON schema from the JsonSchemaOutput instance and sets it as the active configuration.
    • onConvertToPropertyList

      public void onConvertToPropertyList()
      Callback invoked when the user presses the button to convert configuration to a list of properties. Extracts the JSON schema from the JsonSchemaOutput instance, converts it to a list of properties, and sets it as the active configuration.
    • onConvertToVisualEditor

      public void onConvertToVisualEditor()
      Callback invoked when the user presses the button to convert configuration to the visual editor configuration. Extracts the JSON schema from the JsonSchemaOutput instance, converts it the visual editor format, and sets it as the active configuration.
    • onPreview

      public void onPreview()
      Callback invoked when the user clicks the "Preview" button to preview the generated JSON schema. Generates the JSON schema from the current configuration and shows it in a dialog.
    • onRemoveProperty

      public void onRemoveProperty(javax.faces.event.ActionEvent event)
      Callback invoked when the user clicks the "Remove" button next to a property in the list of properties. Removes the property at the current index from the list of properties in the JsonSchemaOutputByPropertyList instance.
      Parameters:
      event - The action event from the button click.
    • onTogglePropertyRequired

      public void onTogglePropertyRequired(javax.faces.event.ActionEvent event)