Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PromptFancySelectItem getDefinitionType()
      Finds the PromptFancySelectItem corresponding to the currently selected definition type.
      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.
      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.
      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.
      String getPreviewSchema()
      Gets the generated JSON schema for previewing.
      List<javax.faces.model.SelectItem> getPropertyTypeOptions()  
      String getSchemaTextEditorExtenderOptions()
      Get the options for creating the monaco editor extender that lets the user enter a JSON schema manually.
      boolean isAllowSchemaAdjustments()
      Gets whether schema adjustments are allowed.
      String localizePropertyRequiredDisplayName​(JsonSchemaOutputObjectProperty property)  
      String localizePropertyTypeDisplayName​(JsonSchemaOutputObjectProperty property)  
      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 onConvertToManualInput()
      Callback invoked when the user presses the button to convert configuration to the manual schema input.
      void onConvertToPropertyList()
      Callback invoked when the user presses the button to convert configuration to a list of properties.
      void onConvertToVisualEditor()
      Callback invoked when the user presses the button to convert configuration to the visual editor configuration.
      void onPreview()
      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 setDefinitionType​(PromptFancySelectItem item)
      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 interface javax.faces.component.StateHolder

        isTransient, restoreState, saveState, setTransient
    • Constructor Detail

      • JsonSchemaOutputComponent

        public JsonSchemaOutputComponent()
    • Method Detail

      • 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.
      • 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)