Class CustomEditorTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
javax.swing.table.DefaultTableModel
v1.sulphurapi.structure.custom.jtable.CustomEditorTableModel
All Implemented Interfaces:
Serializable, TableModel

public class CustomEditorTableModel extends DefaultTableModel
See Also:
  • Constructor Details

    • CustomEditorTableModel

      public CustomEditorTableModel(CustomTableNode parentNode)
      Constructor for CustomEditorTableModel.
  • Method Details

    • getEditorComponents

      public List<CustomTableRow> getEditorComponents()
    • setEditorComponents

      public void setEditorComponents(ArrayList<CustomTableRow> editorComponents)
    • normalizeModel

      public void normalizeModel()
      Normalizes the model by sorting the rows with non-body cells first and updating the row indices. This method is used to ensure that the table is displayed in a consistent order.
    • clearBodyCells

      public void clearBodyCells()
      Clears the body cells from the editor components. This method filters out all rows that do not start with "body" in the "Source" column.
    • clearParameterCells

      public void clearParameterCells()
      Clears the parameter cells from the editor components. This method filters out all rows that do not start with "body" in the "Source" column.
    • updateSchemaRows

      public void updateSchemaRows(io.swagger.v3.oas.models.media.Schema<?> tableSchema)
      Updates the schema rows in the editor components based on the provided table schema. It clears the existing body cells and adds new rows for each property in the schema. If the schema is null or has no properties, it does nothing.
      Parameters:
      tableSchema - The schema to update the rows with.
    • updateParameterRows

      public void updateParameterRows(ArrayList<io.swagger.v3.oas.models.parameters.Parameter> parameters)
      Updates the parameter rows in the editor components based on the provided list of parameters. It clears the existing parameter cells and adds new rows for each parameter in the list. If the parameters list is null or empty, it does nothing.
      Parameters:
      parameters - The list of parameters to update the rows with.
    • getPositionFromComponent

      public ArrayList<CustomEditorTable.CellPosition> getPositionFromComponent(JComponent component)
      Check the Map to retrieve the position of a specific component comparing the component reference.
      Parameters:
      component - the JComponent to find in the this.activeModel.getEditorComponents() map
      Returns:
      a List of Pair<Integer, Integer> representing the row and column indices of the component
    • setValueAt

      public void setValueAt(Object aValue, int row, int column)
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class DefaultTableModel
    • getParentDialog

      public ObjectDialog getParentDialog()
    • getLazySchemaLoaded

      public Boolean getLazySchemaLoaded()
    • getParentNode

      public CustomTableNode getParentNode()
    • serializeModel

      public org.json.JSONObject serializeModel()
      Serializes the model to a JSONObject. It iterates through the editor components and retrieves the values from the "Parameter" and "Value" columns. If the value is a CustomTableNode, it serializes it to a JSONObject or JSONArray. If the value is a primitive type, it adds it directly to the JSONObject.
      Returns:
      A JSONObject representing the serialized model.