// optional parameters static ThreadLocal> showConceptsTable_dropFields = new ThreadLocal; static new ThreadLocal showConceptsTable_postProcess; // func(L) -> L static new ThreadLocal showConceptsTable_afterUpdate; // voidfunc(JTable) static int makeConceptsTable_idWidth = 30; static JTable showConceptsTable(Class c) { JTable table = makeConceptsTable(c); showFrame(plural(shortClassName(c)), table); ret table; } static JTable makeConceptsTable(final Class c) { L dropFields = getAndClearThreadLocal(showConceptsTable_dropFields); fO pp = getAndClearThreadLocal(showConceptsTable_postProcess); fO afterUpdate = optParam(showConceptsTable_afterUpdate); final L fields = listMinusList(concatLists(ll("id"), conceptFieldsInOrder(c)), dropFields); final JTable table = sexyTable(); tablePopupMenu(table, voidfunc(JPopupMenu menu, final int row) { addMenuItem(menu, "Delete", r { final long id = toLong(getTableCell(table, row, 0)); withDBLock(r { deleteConcept(id) }); }); }); awtOnConceptChanges(table, r { //print("Updating concept table"); new L data; for (final Concept cc : list(c)) data.add(map(func(S field) { renderForTable(cget(cc, field)) }, fields)); data = (L) postProcess(pp, data); fillTableWithData(table, data, fields); tcm.getColumnModel().getColumn(0).setPreferredWidth(makeConceptsTable_idWidth); pcallF(afterUpdate, table); }, true); ret table; } // f takes a concept and makes a map for display static JTable makeConceptsTable(final Class cClass, final O f) { if (f == null) ret makeConceptsTable(cClass); fO pp = optParam(showConceptsTable_postProcess); fO afterUpdate = optParam(showConceptsTable_afterUpdate); final JTable table = sexyTable(); awtOnConceptChanges(table, 1000, r { new L data; for (A c : list(cClass)) addIfNotNull(data, (Map) pcallF(f, c)); data = (L) postProcess(pp, data); dataToTable_uneditable(data, table); tcm.getColumnModel().getColumn(0).setPreferredWidth(makeConceptsTable_idWidth); pcallF(afterUpdate, table); }); ret table; } static JTable showConceptsTable(final Class c, final O f) { JTable table = makeConceptsTable(c, f); showFrame(plural(shortClassName(c)), table); ret table; } static JTable showConceptsTable(S title, Class cClass, O f) { ret setFrameTitle(title, showConceptsTable(cClass, f)); }