// // Identifiable // public void DisplayOrEditEntityIdentifiable(AnyUiStackPanel stack, AdminShell.Identifiable identifiable, string templateForIdString, DispEditInjectAction injectToId = null, bool checkForIri = true) { // access if (stack == null || identifiable == null) { return; } // members this.AddGroup(stack, "Identifiable:", levelColors.SubSection); this.AddHintBubble(stack, hintMode, new[] { new HintCheck( () => { return(identifiable.identification == null); }, "Providing a worldwide unique identification is mandatory.", breakIfTrue: true), new HintCheck( () => { return(checkForIri && identifiable.identification.idType != AdminShell.Identification.IRI); }, "Check if identification type is correct. Use of IRIs is usual here.", severityLevel: HintCheck.Severity.Notice), new HintCheck( () => { return(identifiable.identification.id.Trim() == ""); }, "Identification id shall not be empty. You could use the 'Generate' button in order to " + "generate a worldwide unique id. " + "The template of this id could be set by commandline arguments.") }); if (this.SafeguardAccess( stack, repo, identifiable.identification, "identification:", "Create data element!", v => { identifiable.identification = new AdminShell.Identification(); this.AddDiaryEntry(identifiable, new DiaryEntryStructChange()); return(new AnyUiLambdaActionRedrawEntity()); })) { this.AddKeyValueRef( stack, "idType", identifiable, ref identifiable.identification.idType, null, repo, v => { var dr = new DiaryReference(identifiable); identifiable.identification.idType = v as string; this.AddDiaryEntry(identifiable, new DiaryEntryStructChange(), diaryReference: dr); return(new AnyUiLambdaActionNone()); }, comboBoxItems: AdminShell.Key.IdentifierTypeNames); this.AddKeyValueRef( stack, "id", identifiable, ref identifiable.identification.id, null, repo, v => { var dr = new DiaryReference(identifiable); identifiable.identification.id = v as string; this.AddDiaryEntry(identifiable, new DiaryEntryStructChange(), diaryReference: dr); return(new AnyUiLambdaActionNone()); }, auxButtonTitles: DispEditInjectAction.GetTitles(new[] { "Generate" }, injectToId), auxButtonLambda: (i) => { if (i == 0) { var dr = new DiaryReference(identifiable); identifiable.identification.idType = AdminShell.Identification.IRI; identifiable.identification.id = AdminShellUtil.GenerateIdAccordingTemplate( templateForIdString); this.AddDiaryEntry(identifiable, new DiaryEntryStructChange(), diaryReference: dr); return(new AnyUiLambdaActionRedrawAllElements(nextFocus: identifiable)); } if (i >= 1) { var la = injectToId?.auxLambda?.Invoke(i - 1); return(la); } return(new AnyUiLambdaActionNone()); }); } this.AddHintBubble(stack, hintMode, new[] { new HintCheck( () => { return(identifiable.administration == null); }, "Check if providing admistrative information on version/ revision would be useful. " + "This allows for better version management.", breakIfTrue: true, severityLevel: HintCheck.Severity.Notice), new HintCheck( () => { return(identifiable.administration.version.Trim() == "" || identifiable.administration.revision.Trim() == ""); }, "Admistrative information fields should not be empty.", severityLevel: HintCheck.Severity.Notice) }); if (this.SafeguardAccess( stack, repo, identifiable.administration, "administration:", "Create data element!", v => { identifiable.administration = new AdminShell.Administration(); this.AddDiaryEntry(identifiable, new DiaryEntryStructChange()); return(new AnyUiLambdaActionRedrawEntity()); })) { this.AddKeyValueRef( stack, "version", identifiable.administration, ref identifiable.administration.version, null, repo, v => { identifiable.administration.version = v as string; this.AddDiaryEntry(identifiable, new DiaryEntryStructChange()); return(new AnyUiLambdaActionNone()); }); this.AddKeyValueRef( stack, "revision", identifiable.administration, ref identifiable.administration.revision, null, repo, v => { identifiable.administration.revision = v as string; this.AddDiaryEntry(identifiable, new DiaryEntryStructChange()); return(new AnyUiLambdaActionNone()); }); } }
// // Referable // public void DisplayOrEditEntityReferable(AnyUiStackPanel stack, AdminShell.Referable referable, DispEditInjectAction injectToIdShort = null, HintCheck[] addHintsCategory = null, bool categoryUsual = false) { // access if (stack == null || referable == null) { return; } // members this.AddGroup(stack, "Referable:", levelColors.SubSection); // members this.AddHintBubble(stack, hintMode, new[] { new HintCheck(() => { return(referable.idShort == null || referable.idShort.Length < 1); }, "The idShort is meanwhile mandatory for all Referables. It is a short, " + "unique identifier that is unique just in its context, its name space. ", breakIfTrue: true), new HintCheck( () => { if (referable.idShort == null) { return(false); } return(!AdminShellUtil.ComplyIdShort(referable.idShort)); }, "The idShort shall only feature letters, digits, underscore ('_'); " + "starting mandatory with a letter."), new HintCheck( () => { return(true == referable.idShort?.Contains("---")); }, "The idShort contains 3 dashes. Probably, the entitiy was auto-named " + "to keep it unqiue because of an operation such a copy/ paste.", severityLevel: HintCheck.Severity.Notice) }); this.AddKeyValueRef( stack, "idShort", referable, ref referable.idShort, null, repo, v => { var dr = new DiaryReference(referable); referable.idShort = v as string; this.AddDiaryEntry(referable, new DiaryEntryStructChange(), diaryReference: dr); return(new AnyUiLambdaActionNone()); }, auxButtonTitles: DispEditInjectAction.GetTitles(null, injectToIdShort), auxButtonToolTips: DispEditInjectAction.GetToolTips(null, injectToIdShort), auxButtonLambda: injectToIdShort?.auxLambda ); if (!categoryUsual) { this.AddHintBubble( stack, hintMode, new HintCheck(() => { return(referable.category != null && referable.category.Trim().Length >= 1); }, "The use of category is unusual here.", severityLevel: HintCheck.Severity.Notice)); } this.AddHintBubble(stack, hintMode, this.ConcatHintChecks(null, addHintsCategory)); this.AddKeyValueRef( stack, "category", referable, ref referable.category, null, repo, v => { referable.category = v as string; this.AddDiaryEntry(referable, new DiaryEntryStructChange()); return(new AnyUiLambdaActionNone()); }, comboBoxItems: AdminShell.Referable.ReferableCategoryNames, comboBoxIsEditable: true); this.AddHintBubble( stack, hintMode, new[] { new HintCheck( () => { return(referable.description == null || referable.description.langString == null || referable.description.langString.Count < 1); }, "The use of an description is recommended to allow the consumer of an Referable " + "to understand the nature of it.", breakIfTrue: true, severityLevel: HintCheck.Severity.Notice), new HintCheck( () => { return(referable.description.langString.Count < 2); }, "Consider having description in multiple langauges.", severityLevel: HintCheck.Severity.Notice) }); if (this.SafeguardAccess(stack, repo, referable.description, "description:", "Create data element!", v => { referable.description = new AdminShell.Description(); return(new AnyUiLambdaActionRedrawEntity()); })) { this.AddHintBubble( stack, hintMode, new HintCheck( () => { return(referable.description.langString == null || referable.description.langString.Count < 1); }, "Please add some descriptions in your main languages here to help consumers " + "of your Administration shell to understand your intentions.")); this.AddKeyListLangStr(stack, "description", referable.description.langString, repo, relatedReferable: referable); } }