/// <summary>
        /// データベースプロパティ変更時処理。
        /// </summary>
        /// <param name="parameters">パラメータ。</param>
        private void ChangeDatabaseProperty(KeyValueMap parameters)
        {
            DatabaseDefinition definition = parameters["Definition"];
            String name = parameters["Name"];
            dynamic value = parameters["Value"];
            dynamic oldValue = parameters["oldValue"];

            var validator = new DatabaseDefinitionValidator(Message, Project, definition);
            ProvidedMessage result;
            if (value != null) value = ((string)value).Trim();

            switch (name)
            {
                case "Name":
                    result = validator.ValidateName(value);
                    if (result != null)
                    {
                        InvokeMessage(result);

                        return;
                    }

                    definition.Name = value;

                    break;
                default:
                    throw new NotImplementedException();
            }

            if (!SaveProject()) return;
            RefreshDatabaseNode(definition);
        }
        /// <summary>
        /// データベースノードの名称変更を行う。
        /// </summary>
        /// <param name="parameters">パラメータ。</param>
        private void RenameDatabaseNode(KeyValueMap parameters)
        {
            parameters["Result"] = false;
            DatabaseTreeNode node = parameters["Node"];
            string label = parameters["Label"];

            if (label == null) return;

            label = label.TrimEnd();

            DatabaseDefinition definition = (DatabaseDefinition)node.Tag;
            string oldName = definition.Name;

            if (label == oldName) return;

            var validator = new DatabaseDefinitionValidator(Message, Project, definition);
            ProvidedMessage result;

            // データベース名
            result = validator.ValidateName(label);
            if (result != null)
            {
                InvokeMessage(result);

                return;
            }

            definition.Name = label;

            RenameDatabaseDefinition(
                new KeyValueMap()
                {
                    {"Definition", definition},
                    {"OldName", oldName}
                }
            );

            if (!SaveProject()) return;

            RefreshObjectDefinition();
            parameters["Result"] = true;
        }
Пример #3
0
        /// <summary>
        /// 画面項目の入力チェックを行う。
        /// </summary>
        /// <returns>入力チェックOK時はtrue。</returns>
        private bool ValidateInput()
        {
            ctlName.Text = ctlName.Text.TrimEnd();
            ctlFile.Text = ctlFile.Text.TrimEnd();

            var message = GetMessageProvider();
            var validator = new DatabaseDefinitionValidator(message, Project, Definition);
            ProvidedMessage result;

            // データベース名
            result = validator.ValidateName(ctlName.Text);
            if (result != null)
            {
                ActiveControl = ctlName;
                InvokeMessage(result);

                return false;
            }

            // データベースファイル名
            var file = ctlFile.Text;
            result = validator.ValidateFile(ref file);
            ctlFile.Text = file;

            if (result != null)
            {
                ActiveControl = ctlFile;
                InvokeMessage(result);

                return false;
            }

            if (Definition != null)
            {
                if (Definition.File.ToLower() != ctlFile.Text.ToLower())
                {
                    var fullPath = Path.GetFullPath(Path.Combine(Project.DataFolderFullPath, ctlFile.Text));
                    if (File.Exists(fullPath))
                    {
                        if (ProvideMessage("DatabaseDefinition.Validation.File.Exists.Confirm") != DialogResult.Yes)
                        {
                            return false;
                        }
                    }
                }
            }

            // クラス
            if (ctlDataClass.Enabled)
            {
                string fullName = null;
                if (ctlDataClass.SelectedValue is ClassDefinition)
                {
                    fullName = ((ClassDefinition)ctlDataClass.SelectedValue).FullName;
                }
                else if (ctlDataClass.SelectedValue is RubyClassDefinition)
                {
                    fullName = ((RubyClassDefinition)ctlDataClass.SelectedValue).FullName;
                }

                result = validator.ValidateDataClass(fullName);
                if (result != null)
                {
                    ActiveControl = ctlDataClass;
                    InvokeMessage(result);

                    return false;
                }
            }

            // エディタ
            result = validator.ValidateEditorType((string)ctlEditorType.SelectedValue);
            if (result != null)
            {
                ActiveControl = ctlEditorType;
                InvokeMessage(result);

                return false;
            }

            return true;
        }