Skip to content

Commit

Permalink
Checks the visual property COLUMN_EDITABLE to provide another way to …
Browse files Browse the repository at this point in the history
…prevent table cells from being edited by the end user.

The "selected" column is no longer editable (end user only).
  • Loading branch information
chrtannus committed Feb 16, 2021
1 parent 8d817fa commit de4266a
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ public void setModel(TableModel dataModel) {
tableColumn.setHeaderRenderer(new BrowserTableHeaderRenderer(serviceRegistrar));
columnModel.addColumn(tableColumn, view.getSUID(), visible, gravity);
}

var view = tableView.getColumnView(CyNetwork.SELECTED);

if (view != null && !tableView.isSet(BasicTableVisualLexicon.COLUMN_EDITABLE))
view.setVisualProperty(BasicTableVisualLexicon.COLUMN_EDITABLE, false);
}

columnModel.reorderColumnsToRespectGravity();
Expand All @@ -208,8 +213,22 @@ public TableCellRenderer getCellRenderer(int row, int column) {
}

@Override
public boolean isCellEditable(final int row, final int column) {
return this.getModel().isCellEditable(convertRowIndexToModel(row), convertColumnIndexToModel(column));
public boolean isCellEditable(int row, int column) {
if (super.isCellEditable(row, column)) {
// Also check the visual property...
if (getModel() instanceof BrowserTableModel) {
var model = (BrowserTableModel) getModel();
var tableView = model.getTableView();
var name = getColumnName(column);
var view = tableView.getColumnView(name);

return view.getVisualProperty(BasicTableVisualLexicon.COLUMN_EDITABLE) == Boolean.TRUE;
} else {
return true;
}
}

return false;
}

@Override
Expand Down

0 comments on commit de4266a

Please sign in to comment.