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
-
Field Summary
Fields inherited from class javax.faces.component.UINamingContainer
COMPONENT_FAMILY, COMPONENT_TYPE, SEPARATOR_CHAR_PARAM_NAMEFields 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_KEYFields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFinds thePromptFancySelectItemcorresponding to the currently selected definition type.Gets the localizedselect itemoptions with the possible values for thedefinition typeselect field that lets the user choose how they want to define the JSON schema.org.primefaces.extensions.model.monacoeditor.EditorOptionsGets theEditorOptionsfor 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.EditorOptionsGets theEditorOptionsfor 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.booleanGets whether schema adjustments are allowed.voidonAddProperty(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.voidCallback invoked when the user presses the button to convert configuration to the manual schema input.voidCallback invoked when the user presses the button to convert configuration to a list of properties.voidCallback invoked when the user presses the button to convert configuration to the visual editor configuration.voidCallback invoked when the user clicks the "Preview" button to preview the generated JSON schema.voidonRemoveProperty(javax.faces.event.ActionEvent event) Callback invoked when the user clicks the "Remove" button next to a property in the list of properties.voidonTogglePropertyRequired(javax.faces.event.ActionEvent event) voidsetAllowSchemaAdjustments(boolean allowSchemaAdjustments) Sets whether schema adjustments are allowed.voidSets the selected task from the givenPromptFancySelectItem.Methods inherited from class javax.faces.component.UINamingContainer
createUniqueId, getFamily, getSeparatorChar, visitTreeMethods 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, unsubscribeFromEventMethods 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, setValueExpressionMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.faces.component.StateHolder
isTransient, restoreState, saveState, setTransient
-
Constructor Details
-
JsonSchemaOutputComponent
public JsonSchemaOutputComponent()
-
-
Method Details
-
getDefinitionType
Finds thePromptFancySelectItemcorresponding to the currently selected definition type.Access the
cc.attrs.valueattribute of the closestTaskComponentcomponent; which must be aJsonSchemaOutputinstance. Then, finds theoptionwhosevaluematches 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 entirePromptFancySelectItemthat contains the label and description to display.- Returns:
- The selected
PromptFancySelectItem, ornullif no option is selected.
-
setDefinitionType
Sets the selected task from the givenPromptFancySelectItem.Access the
cc.attrs.valueattribute of the closestTaskComponentcomponent; which must be aJsonSchemaOutputinstance. Then writes thevalueof the given item to thedefinition typeproperty.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 entirePromptFancySelectItemthat contains the label and description to display.- Parameters:
item- The selectedPromptFancySelectItem, ornullto clear the selection.
-
getDefinitionTypeOptions
Gets the localizedselect itemoptions with the possible values for thedefinition typeselect 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 theEditorOptionsfor 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 theEditorOptionsfor the monaco editor used to edit the JSON schema when the user chooses to enter a JSON schema manually.- Returns:
- The editor options.
-
getPreviewSchema
Gets the generated JSON schema for previewing. This is set when the user clicks the "Preview" button, seeonPreview().- Returns:
- The generated JSON schema, or
nullif preview has not been generated yet.
-
getPropertyTypeOptions
-
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'sforbidSchemaAdjustmentsproperty.- 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'sforbidSchemaAdjustmentsproperty.- Parameters:
allowSchemaAdjustments- True to allow schema adjustments, false to forbid them.
-
localizePropertyRequiredDisplayName
-
localizePropertyTypeDisplayName
-
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 newJsonSchemaOutputObjectPropertyinstance with default values and adds it to the list of properties in theJsonSchemaOutputByPropertyListinstance.- 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 theJsonSchemaOutputinstance 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 theJsonSchemaOutputinstance, 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 theJsonSchemaOutputinstance, 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 theJsonSchemaOutputByPropertyListinstance.- Parameters:
event- The action event from the button click.
-
onTogglePropertyRequired
public void onTogglePropertyRequired(javax.faces.event.ActionEvent event)
-