!7
abstract sclass DynCRUD extends DynModule {
transient Class conceptClass;
transient SimpleCRUD crud;
*() {}
*(Class *conceptClass) {}
start {
db(); // So we can do stuff in overridden start methods
}
visualize {
makeConceptsTable_idWidth = 0;
if (crud == null) crud = makeCRUD();
showConceptsTable_afterUpdate.set(voidfunc(JTable t) {
int n = tableColumnCount(t);
for i to n:
setColumnName(t, i, i == 0 ? "" : humanizeFormLabel(getColumnName(t, i)));
});
ret withMargin(crud.make());
}
SimpleCRUD makeCRUD() {
ret SimpleCRUD(conceptClass);
}
JTable table() { ret crud == null ? null : crud.table; }
A selected() { ret crud == null ? null : crud.selectedConcept(); }
void addButton(JComponent button) {
if (crud != null) addComponent(crud.buttons, button);
}
void addButton(S name, O action) { addButton(jbutton(name, action)); }
void makeSortable() { // broken?
addRowSorter(table());
rowSorter_setComparatorForAllColumns(table(), alphaNumComparator());
}
S searchTerm() {
ret crud == null || crud.tableSearcher == null ? null : gtt(crud.tableSearcher.tfInput);
}
}