Class CustomEditorTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
javax.swing.table.DefaultTableModel
v1.sulphurapi.structure.custom.jtable.CustomEditorTableModel
- All Implemented Interfaces:
Serializable
,TableModel
- See Also:
-
Field Summary
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionCustomEditorTableModel
(CustomTableNode parentNode) Constructor for CustomEditorTableModel. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the body cells from the editor components.void
Clears the parameter cells from the editor components.getPositionFromComponent
(JComponent component) Check the Map to retrieve the position of a specific component comparing the component reference.void
Normalizes the model by sorting the rows with non-body cells first and updating the row indices.org.json.JSONObject
Serializes the model to a JSONObject.void
setEditorComponents
(ArrayList<CustomTableRow> editorComponents) void
setValueAt
(Object aValue, int row, int column) 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.void
updateSchemaRows
(io.swagger.v3.oas.models.media.Schema<?> tableSchema) Updates the schema rows in the editor components based on the provided table schema.Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getColumnName, getDataVector, getRowCount, getValueAt, insertRow, insertRow, isCellEditable, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
-
Constructor Details
-
CustomEditorTableModel
Constructor for CustomEditorTableModel.
-
-
Method Details
-
getEditorComponents
-
setEditorComponents
-
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
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
- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classDefaultTableModel
-
getParentDialog
-
getLazySchemaLoaded
-
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.
-