!7 beaConcept BInput { S text; toString { ret "[\*id*/] Input " + quote(text); } } beaConcept BOutput { S text; toString { ret "[\*id*/] Output " + quote(text); } } beaConcept BPattern { S text; toString { ret "[\*id*/] " + shortDynName(this) + " " + quote(text); } void reactWith(BInput input) {} @Override Map _fieldMigrations() { ret litmap(pattern := new FieldMigration("text")); } } beaConcept BStarPattern > BPattern { void reactWith(BInput input) { LS mapping = matchesToStringList(flexMatchIC_first(text, input.text)); if (mapping == null) ret; uniqPeer BEAObject(this, type := "match", +input, pattern := this, +mapping); } } beaConcept BAngleVarPattern > BPattern { void reactWith(BInput input) { SS mapping = flexMatchAngleBracketVarsIC_first(text, input.text); if (mapping == null) ret; uniqPeer BEAObject(this, type := "match", +input, pattern := this, +mapping); } } beaConcept BMatch { new Ref pattern; SS mapping; } beaConcept BMatchToScenario { void reactWith(BMatch match) { uniqPeer(BEAObject, this, /*fromReaction_1 := this, fromReaction_2 := match,*/ fromReaction := ll(this, match), type := "scenario", text := mapToLines(match.mapping, (a, b) -> b + " is a " + a)); } } beaConcept BScenarioToOutput { bool canReactWith(BEAObject o) { ret o.typeIs("scenario"); } void reactWith(BEAObject scenario) { uniqPeer(BOutput, this, fromReaction := ll(this, scenario), type := "Output", text := getString text(scenario)); } } cmodule2 > DynCRUD_v2 { S input, output; transient new BEAUtils beaUtils; start { crud.humanizeFieldNames = false; crud.showBackRefs = true; crud.specialFieldsForItem = a -> { MapSO map = litorderedmap(crud.hID, str(a.id)); S j = crud.javaClassDescForItem(a); mapPut(map, "Class/Type", joinUniqueNemptiesCI("/", j, a.type())); ret map; }; thread { uniq BMatchToScenario(); uniq BScenarioToOutput(); uniq BInput(text := "UBports community delivers 'second-largest release of Ubuntu Touch ever'"); //uniq BPattern(text := "* delivers *"); uniq BAngleVarPattern(text := " delivers "); } } visualize { JComponent c = jvsplit(jhsplit(dm_wordWrapTextAreaAsSection input(), dm_wordWrapTextAreaAsSection output()), super.visualize()); tablePopupMenuFirst(table(), (menu, row) -> { BEAObject o = getItem(row); print("Item: " + o); if (o == null) ret; Class targetClass = beaUtils.defaultCustomClass(o); print(+targetClass); if (targetClass != null && targetClass != _getClass(o)) pcall-short { beaUtils.migrateConceptToClass(targetClass, o); addMenuItem(menu, "Convert to " + shortName(targetClass), r { replaceConceptAndUpdateRefs(o, beaUtils.migrateConceptToClass(targetClass, o)); }); } pcall { L partners = filter(list(BEAObject), partner -> o.canReactWith(partner)); if (nempty(partners)) addScrollingSubMenu(menu, "React with", menu2 -> { for (BEAObject p : partners) addMenuItem(menu2, str(p), rThread { call(o, 'reactWith, p); }); }); } }); ret c; } }