switchable S caseID; switchable float tableFontSize = 0; // 0 for default transient Concepts cc = db_mainConcepts(); transient Class<A> conceptClass; transient SimpleCRUD_v2<A> crud; transient bool addCountToName = true, addCountToName_installed; transient bool useInternalFramesForForms = true; void start_DynCRUD { ifndef NoMainConcepts // set flag to save space if (cc == db_mainConcepts()) dbWithCase(caseID); // So we can do stuff in overridden start methods endifndef crud = makeCRUD(); // so we can customize early if (addCountToName) addCountToName(); } JComponent visualizeWithCountInTab() { JComponent c = visualize(); bindToComponent(table(), r updateTabTitle); onConceptChange(cc, r updateTabTitle); ret c; } void updateTabTitle { updateEnclosingTabTitleWithCount(table(), conceptCount()); } visualize { if (crud == null) start_DynCRUD(); if (useInternalFramesForForms) crud.showAForm = (title, parts) -> { //formLayouter1_yPlus = 35; JComponent form = makeForm_customLayout_b(true, formLayouter1b(), parts); dm_showExtraFrame(title, withRightAndBottomMargin(form), /*usePreferredSizeInitially := true*/); ret form; }; crud.idWidth = 0; crud.tableFontSize = zeroToNull(tableFontSize); ret withMargin(crud.make_dontStartBots()); } SimpleCRUD_v2<A> makeCRUD() { ret SimpleCRUD_v2<A>(cc, conceptClass); } JTable table() { ret crud?.table; } A selected() { ret crud?.selectedConcept(); } A getItem(int row) { ret crud?.getItem(row); } // call these in visualize() only (after calling super.visualize()) void addButton(JComponent button) { if (crud != null) addComponent(crud.buttons, button); } void addButton(S name, Runnable action) { addButton(jbutton(name, action)); } void addSelectionDependentButton(S name, O action) { addButton(tableDependentButton(table(), name, toRunnable(action))); } void makeSortable() { // broken? addRowSorter(table()); rowSorter_setComparatorForAllColumns(table(), alphaNumComparator()); } S searchTerm() { ret crud == null || crud.tableSearcher == null ? null : gtt(crud.tableSearcher.tfInput); } void addCountToName { if (addCountToName_installed) ret; addCountToName_installed = true; onConceptChangeAndNow(cc, rEnter { setModuleName(dm_originalModuleName() + " (" + nObjects(conceptCount()) + ")") }); } Concepts conceptsObject() { ret crud.concepts; } // overwrite for compact modules to work <B extends Concept> L<B> list(Class<B> c) { ret conceptsObject().list(c); } <B extends Concept> L<B> list(Concepts cc, Class<B> c) { ret cc.list(c); } // API L<A> concepts() enter { ret list(conceptClass); } L<A> data() { ret concepts(); } L<A> list() { ret concepts(); } L<Concept> conceptsOfType(S type) enter { ret conceptsObject().list(type); } // TODO: use index L<Concept> conceptsOfTypeWhere(S type, O[] params) enter { ret filterConcepts(conceptsOfType(type), params); } int conceptCount() enter { ret countConcepts(cc, conceptClass); } void deleteAll() enter { deleteConcepts(cc, conceptClass); } void addDialog() enter { crud.newConcept(); } A uniqConcept(O... params) { ret uniq_sync(cc, conceptClass, params); } Pair<A, Bool> uniqConcept2(O... params) { ret uniq2_sync(cc, conceptClass, params); } int cset(Concept c, O... values) { ret _cset(c, values); }
Began life as a copy of #1026525
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030727 |
Snippet name: | DynCRUD Include v2 |
Eternal ID of this version: | #1030727/25 |
Text MD5: | 1b0bedcd332f4a85752194c6510aa160 |
Author: | stefan |
Category: | javax / db / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-07 17:07:49 |
Source code size: | 3477 bytes / 123 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 282 / 566 |
Version history: | 24 change(s) |
Referenced in: | #1030728 - DynCRUD_v2 - CRUD as Dyn Module |