Пример #1
0
        //
        // Identifiable
        //

        public void DisplayOrEditEntityIdentifiable(StackPanel 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[1][0], levelColors[1][1]);

            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();
                return(new ModifyRepo.LambdaActionRedrawEntity());
            }))
            {
                this.AddKeyValueRef(
                    stack, "idType", identifiable, ref identifiable.identification.idType, null, repo,
                    v =>
                {
                    identifiable.identification.idType = v as string;
                    return(new ModifyRepo.LambdaActionNone());
                },
                    comboBoxItems: AdminShell.Key.IdentifierTypeNames);

                this.AddKeyValueRef(
                    stack, "id", identifiable, ref identifiable.identification.id, null, repo,
                    v => { identifiable.identification.id = v as string; return(new ModifyRepo.LambdaActionNone()); },
                    auxButtonTitles: DispEditInjectAction.GetTitles(new[] { "Generate" }, injectToId),
                    auxButtonLambda: (i) =>
                {
                    if (i == 0)
                    {
                        identifiable.identification.idType = AdminShell.Identification.IRI;
                        identifiable.identification.id     = Options.Curr.GenerateIdAccordingTemplate(
                            templateForIdString);
                        return(new ModifyRepo.LambdaActionRedrawAllElements(nextFocus: identifiable));
                    }
                    if (i >= 1)
                    {
                        var la = injectToId?.auxLambda?.Invoke(i - 1);
                        return(la);
                    }
                    return(new ModifyRepo.LambdaActionNone());
                });
            }

            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();
                return(new ModifyRepo.LambdaActionRedrawEntity());
            }))
            {
                this.AddKeyValueRef(
                    stack, "version", identifiable.administration, ref identifiable.administration.version,
                    null, repo,
                    v =>
                {
                    identifiable.administration.version = v as string;
                    return(new ModifyRepo.LambdaActionNone());
                });

                this.AddKeyValueRef(
                    stack, "revision", identifiable.administration, ref identifiable.administration.revision,
                    null, repo,
                    v =>
                {
                    identifiable.administration.revision = v as string;
                    return(new ModifyRepo.LambdaActionNone());
                });
            }
        }
Пример #2
0
        //
        // Referable
        //

        public void DisplayOrEditEntityReferable(StackPanel 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[1][0], levelColors[1][1]);

            // members
            this.AddHintBubble(stack, hintMode, new[] {
                new HintCheck(() => { return(referable.idShort == null || referable.idShort.Length < 1); },
                              "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));
                },
                    "idShort shall only feature letters, digits, underscore ('_'); " +
                    "starting mandatory with a letter..")
            });
            this.AddKeyValueRef(
                stack, "idShort", referable, ref referable.idShort, null, repo,
                v => { referable.idShort = v as string; return(new ModifyRepo.LambdaActionNone()); },
                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; return(new ModifyRepo.LambdaActionNone()); },
                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 ModifyRepo.LambdaActionRedrawEntity());
            }))
            {
                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);
            }
        }