@Override
public Component prepareEditor(TableCellEditor editor, int row, int column) {
Component component = super.prepareEditor(editor, row, column);
if (getColumnClass(column) == ParameterStyle.class) {
RestParamProperty parameter = paramsTableModel.getParameterAt(row);
JComboBox comboBox = (JComboBox) ((DefaultCellEditor) editor).getComponent();
comboBox.setModel(getStylesForLocation(parameter.getParamLocation()));
super.prepareEditor(editor, row, column);
}
if (getColumnClass(column) == ParamLocation.class) {
RestParamProperty parameter = paramsTableModel.getParameterAt(row);
JComboBox comboBox = (JComboBox) ((DefaultCellEditor) editor).getComponent();
comboBox.setModel(getLocationForParameter(parameter.getStyle()));
super.prepareEditor(editor, row, column);
}
return component;
}
};
paramsTable.setName(REST_PARAMS_TABLE);
paramsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
if (showDefaultParamsButton) {
defaultParamsAction = new UseDefaultParamsAction();
}
movePropertyDownAction = new MovePropertyDownAction(paramsTable, params, "Moves selected parameter down one row");
movePropertyUpAction = new MovePropertyUpAction(paramsTable, params, "Moves selected parameter up one row");
if (showEditableButtons) {
initEditableButtons();
}
paramsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
paramsTable.setDefaultEditor(ParameterStyle.class, new DefaultCellEditor(
new JComboBox(getStylesForLocation(ParamLocation.RESOURCE))));
paramsTable.setDefaultEditor(ParamLocation.class, new DefaultCellEditor(
new JComboBox(ParamLocation.values())));
// Workaround: for some reason the lower part of text gets clipped on some platforms
paramsTable.setRowHeight(25);
paramsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int selectedRow = paramsTable.getSelectedRow();
if (showEditableButtons) {
removeParamAction.setEnabled(selectedRow != -1);
}
if (showDefaultParamsButton) {
defaultParamsAction.setEnabled(paramsTable.getRowCount() > 0);
}
movePropertyDownAction.setEnabled(selectedRow < paramsTable.getRowCount() - 1);
movePropertyUpAction.setEnabled(selectedRow > 0);
if (selectedRow != -1) {
RestParamProperty selectedParameter = getSelectedParameter();
if (paramDetailsModel != null) {
updateDetailsFormWith(selectedParameter);
detailsForm.setEnabled(true);
}
} else {