Exemplo n.º 1
0
        private void buttonInsert_Click(object sender, EventArgs e)
        {
            DocDefinition docBase       = this.m_base;
            DocDefinition docDefinition = null;


            // for now, clear it -- future: allow incremental replacement

            CvtValuePath valuepathouter = null;
            CvtValuePath valuepathinner = null;

            // keep building
            while (docBase != null)
            {
                using (FormSelectEntity formEntity = new FormSelectEntity(docBase, docDefinition, this.m_project, SelectDefinitionOptions.Entity | SelectDefinitionOptions.Type))
                {
                    if (formEntity.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && formEntity.SelectedEntity != null)
                    {
                        CvtValuePath valuepath = null;
                        if (formEntity.SelectedEntity is DocEntity)
                        {
                            using (FormSelectAttribute formAttribute = new FormSelectAttribute((DocEntity)formEntity.SelectedEntity, this.m_project, null, false))
                            {
                                if (formAttribute.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && formAttribute.SelectedAttribute != null)
                                {
                                    string item = null;
                                    switch (formAttribute.SelectedAttribute.GetAggregation())
                                    {
                                    case DocAggregationEnum.SET:
                                        // if set collection, then qualify by name
                                        // future: more intelligent UI for picking property sets, properties
                                        using (FormSelectItem formItem = new FormSelectItem())
                                        {
                                            if (formItem.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                                            {
                                                item = formItem.Item;
                                            }
                                        }
                                        break;

                                    case DocAggregationEnum.LIST:
                                        // if list collection, then qualify by index
                                        // future: more intelligent UI for picking list indices
                                        using (FormSelectItem formItem = new FormSelectItem())
                                        {
                                            if (formItem.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                                            {
                                                item = formItem.Item;
                                            }
                                        }
                                        break;
                                    }

                                    // now add entry to listview
                                    valuepath = new CvtValuePath(formEntity.SelectedEntity, formAttribute.SelectedAttribute, item, null);

                                    if (valuepathinner != null)
                                    {
                                        valuepathinner.InnerPath = valuepath;
                                    }
                                    valuepathinner = valuepath;

                                    if (valuepathouter == null)
                                    {
                                        valuepathouter = valuepath;
                                    }

                                    // drill in
                                    if (this.m_map.ContainsKey(formAttribute.SelectedAttribute.DefinedType))
                                    {
                                        docBase = this.m_map[formAttribute.SelectedAttribute.DefinedType] as DocDefinition;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        else if (formEntity.SelectedEntity is DocType)
                        {
                            valuepath = new CvtValuePath(formEntity.SelectedEntity, null, null, null);

                            if (valuepathinner != null)
                            {
                                valuepathinner.InnerPath = valuepath;
                            }
                            valuepathinner = valuepath;

                            if (valuepathouter == null)
                            {
                                valuepathouter = valuepath;
                            }

                            docBase = null;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            this.LoadValuePath(valuepathouter);
        }
Exemplo n.º 2
0
        private void buttonViewXsdAttribute_Click(object sender, EventArgs e)
        {
            using (FormSelectEntity form = new FormSelectEntity(null, null, this.m_project, SelectDefinitionOptions.Entity))
            {
                if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && form.SelectedEntity is DocEntity)
                {
                    using(FormSelectAttribute formAttr = new FormSelectAttribute((DocEntity)form.SelectedEntity, this.m_project, null, false))
                    {
                        if(formAttr.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                        {
                            DocXsdFormat docFormat = new DocXsdFormat();
                            docFormat.Entity = form.SelectedEntity.Name;
                            docFormat.Attribute = formAttr.SelectedAttribute.Name;

                            DocModelView docView = (DocModelView)this.m_target;
                            docView.XsdFormats.Add(docFormat);

                            ListViewItem lvi = new ListViewItem();
                            lvi.Tag = docFormat;
                            lvi.Text = docFormat.Entity;
                            lvi.SubItems.Add(docFormat.Attribute);
                            lvi.SubItems.Add(docFormat.XsdFormat.ToString());
                            lvi.SubItems.Add(docFormat.XsdTagless.ToString());

                            this.listViewViewXsd.Items.Add(lvi);

                            lvi.Selected = true;
                        }
                    }
                }
            }

        }
Exemplo n.º 3
0
 private void buttonAttributeInverse_Click(object sender, EventArgs e)
 {
     DocAttribute docAttr = (DocAttribute)this.m_target;
     DocObject docEntity = null;
     if (this.m_map.TryGetValue(docAttr.DefinedType, out docEntity) && docEntity is DocEntity)
     {
         using(FormSelectAttribute form = new FormSelectAttribute((DocEntity)docEntity, this.m_project, null, false))
         {
             if(form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
             {
                 if (form.SelectedAttribute != null)
                 {
                     docAttr.Inverse = form.SelectedAttribute.Name;
                     this.textBoxAttributeInverse.Text = docAttr.Inverse;
                 }
                 else
                 {
                     docAttr.Inverse = null;
                     this.textBoxAttributeInverse.Text = String.Empty;
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        public void DoInsert()
        {
            if (this.m_template == null)
            {
                return;
            }

            if (this.treeViewTemplate.Nodes.Count == 0)
            {
                DocEntity docEntityBase = null;
                if (this.m_parent is DocTemplateDefinition)
                {
                    string classname = ((DocTemplateDefinition)this.m_parent).Type;
                    docEntityBase = this.m_project.GetDefinition(classname) as DocEntity;
                }

                // get selected entity
                DocEntity docEntityThis = this.m_project.GetDefinition(this.m_template.Type) as DocEntity;

                using (FormSelectEntity form = new FormSelectEntity(docEntityBase, docEntityThis, this.m_project, SelectDefinitionOptions.Entity))
                {
                    DialogResult res = form.ShowDialog(this);
                    if (res == DialogResult.OK && form.SelectedEntity != null)
                    {
                        this.m_template.Type = form.SelectedEntity.Name;
                        this.LoadTemplateGraph();
                        this.ContentChanged(this, EventArgs.Empty);
                    }
                }

                return;
            }

            if (this.m_attribute != null && !String.IsNullOrEmpty(this.m_attribute.DefinedType))
            {
                DocTemplateDefinition docTemplate  = this.m_template;
                DocAttribute          docAttribute = this.m_attribute;

                string entityname = null;
                switch (this.m_attribute.DefinedType)
                {
                case "BOOLEAN":
                case "LOGICAL":
                case "BINARY":
                case "STRING":
                case "REAL":
                case "INTEGER":
                case "NUMBER":
                    entityname = this.m_attribute.DefinedType;
                    break;

                default:
                {
                    // qualify schema
                    DocObject docobj = null;

                    if (!String.IsNullOrEmpty(this.m_template.Code))
                    {
                        foreach (DocSection docSection in this.m_project.Sections)
                        {
                            foreach (DocSchema docSchema in docSection.Schemas)
                            {
                                if (docSchema.Name.Equals(this.m_template.Code, StringComparison.OrdinalIgnoreCase))
                                {
                                    docobj = docSchema.GetDefinition(docAttribute.DefinedType);
                                    break;
                                }
                            }
                        }
                    }

                    if (docobj == null)
                    {
                        docobj = this.m_project.GetDefinition(docAttribute.DefinedType);
                    }

                    using (FormSelectEntity form = new FormSelectEntity((DocDefinition)docobj, null, this.m_project, SelectDefinitionOptions.Entity | SelectDefinitionOptions.Type))
                    {
                        DialogResult res = form.ShowDialog(this);
                        if (res == DialogResult.OK && form.SelectedEntity != null)
                        {
                            entityname = form.SelectedEntity.Name;
                        }
                    }
                    break;
                }
                }

                if (entityname != null)
                {
                    // get or add attribute rule
                    TreeNode tn = this.treeViewTemplate.SelectedNode;
                    DocModelRuleAttribute docRuleAtt = null;
                    if (this.treeViewTemplate.SelectedNode.Tag is DocModelRuleAttribute)
                    {
                        docRuleAtt = (DocModelRuleAttribute)this.treeViewTemplate.SelectedNode.Tag;
                    }
                    else
                    {
                        docRuleAtt      = new DocModelRuleAttribute();
                        docRuleAtt.Name = docAttribute.Name;

                        if (this.treeViewTemplate.SelectedNode.Tag is DocModelRuleEntity)
                        {
                            DocModelRuleEntity docRuleEnt = (DocModelRuleEntity)this.treeViewTemplate.SelectedNode.Tag;
                            docRuleEnt.Rules.Add(docRuleAtt);
                        }
                        else if (this.treeViewTemplate.SelectedNode.Tag is DocTemplateDefinition)
                        {
                            docTemplate.Rules.Add(docRuleAtt);
                        }

                        tn = this.LoadTemplateGraph(tn, docRuleAtt);
                    }

                    // get and add entity rule
                    DocModelRuleEntity docRuleEntity = new DocModelRuleEntity();
                    docRuleEntity.Name = entityname;
                    docRuleAtt.Rules.Add(docRuleEntity);
                    this.treeViewTemplate.SelectedNode = this.LoadTemplateGraph(tn, docRuleEntity);

                    // copy to child templates
                    docTemplate.PropagateRule(this.treeViewTemplate.SelectedNode.FullPath);

                    this.m_selection = docRuleEntity;
                    this.ContentChanged(this, EventArgs.Empty);
                    this.SelectionChanged(this, EventArgs.Empty);
                }
            }
            else
            {
                // pick attribute, including attribute that may be on subtype
                DocModelRule rule = null;
                if (this.treeViewTemplate.SelectedNode != null)
                {
                    rule = this.treeViewTemplate.SelectedNode.Tag as DocModelRule;
                }

                //if (rule == null)
                //   return;

                DocTemplateDefinition docTemplate = (DocTemplateDefinition)this.m_template;

                string typename = null;
                if (rule is DocModelRuleEntity)
                {
                    DocModelRuleEntity docRuleEntity = (DocModelRuleEntity)rule;
                    typename = docRuleEntity.Name;
                }
                else
                {
                    // get applicable entity of target (or parent entity rule)
                    typename = docTemplate.Type;
                }

                DocEntity docEntity = this.m_project.GetDefinition(typename) as DocEntity;
                if (docEntity == null)
                {
                    // launch dialog for constraint
                    using (FormConstraint form = new FormConstraint())
                    {
                        DialogResult res = form.ShowDialog(this);
                        if (res == DialogResult.OK)
                        {
                            DocModelRuleConstraint docRuleConstraint = new DocModelRuleConstraint();
                            rule.Rules.Add(docRuleConstraint);
                            docRuleConstraint.Description = form.Expression;
                            docRuleConstraint.Name        = form.Expression; // for viewing

                            this.treeViewTemplate.SelectedNode = this.LoadTemplateGraph(this.treeViewTemplate.SelectedNode, docRuleConstraint);

                            // copy to child templates
                            docTemplate.PropagateRule(this.treeViewTemplate.SelectedNode.FullPath);
                        }
                    }
                }
                else
                {
                    // launch dialog to pick attribute of entity
                    using (FormSelectAttribute form = new FormSelectAttribute(docEntity, this.m_project, null, true))
                    {
                        DialogResult res = form.ShowDialog(this);
                        if (res == DialogResult.OK && form.Selection != null)
                        {
                            // then add and update tree
                            DocModelRuleAttribute docRuleAttr = new DocModelRuleAttribute();
                            docRuleAttr.Name = form.Selection;
                            if (rule != null)
                            {
                                rule.Rules.Add(docRuleAttr);
                            }
                            else
                            {
                                docTemplate.Rules.Add(docRuleAttr);
                            }
                            this.treeViewTemplate.SelectedNode = this.LoadTemplateGraph(this.treeViewTemplate.SelectedNode, docRuleAttr);

                            // copy to child templates
                            docTemplate.PropagateRule(this.treeViewTemplate.SelectedNode.FullPath);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void DoInsert()
        {
            if (this.m_template == null)
                return;

            if (this.treeViewTemplate.Nodes.Count == 0)
            {
                DocEntity docEntityBase = null;
                if (this.m_parent is DocTemplateDefinition)
                {
                    string classname = ((DocTemplateDefinition)this.m_parent).Type;
                    docEntityBase = this.m_project.GetDefinition(classname) as DocEntity;
                }

                // get selected entity
                DocEntity docEntityThis = this.m_project.GetDefinition(this.m_template.Type) as DocEntity;

                using (FormSelectEntity form = new FormSelectEntity(docEntityBase, docEntityThis, this.m_project, SelectDefinitionOptions.Entity))
                {
                    DialogResult res = form.ShowDialog(this);
                    if (res == DialogResult.OK && form.SelectedEntity != null)
                    {
                        this.m_template.Type = form.SelectedEntity.Name;
                        this.LoadTemplateGraph();
                        this.ContentChanged(this, EventArgs.Empty);
                    }
                }

                return;
            }

            if (this.m_attribute != null && !String.IsNullOrEmpty(this.m_attribute.DefinedType))
            {
                DocTemplateDefinition docTemplate = this.m_template;
                DocAttribute docAttribute = this.m_attribute;

                string entityname = null;
                switch (this.m_attribute.DefinedType)
                {
                    case "BOOLEAN":
                    case "LOGICAL":
                    case "BINARY":
                    case "STRING":
                    case "REAL":
                    case "INTEGER":
                    case "NUMBER":
                        entityname = this.m_attribute.DefinedType;
                        break;

                    default:
                        {
                            // qualify schema
                            DocObject docobj = null;

                            if (!String.IsNullOrEmpty(this.m_template.Code))
                            {
                                foreach(DocSection docSection in this.m_project.Sections)
                                {
                                    foreach (DocSchema docSchema in docSection.Schemas)
                                    {
                                        if (docSchema.Name.Equals(this.m_template.Code, StringComparison.OrdinalIgnoreCase))
                                        {
                                            docobj = docSchema.GetDefinition(docAttribute.DefinedType);
                                            break;
                                        }
                                    }
                                }
                            }

                            if (docobj == null)
                            {
                                docobj = this.m_project.GetDefinition(docAttribute.DefinedType);
                            }

                            using (FormSelectEntity form = new FormSelectEntity((DocDefinition)docobj, null, this.m_project, SelectDefinitionOptions.Entity | SelectDefinitionOptions.Type))
                            {
                                DialogResult res = form.ShowDialog(this);
                                if (res == DialogResult.OK && form.SelectedEntity != null)
                                {
                                    entityname = form.SelectedEntity.Name;
                                }
                            }
                            break;
                        }
                }

                if (entityname != null)
                {
                    // get or add attribute rule
                    TreeNode tn = this.treeViewTemplate.SelectedNode;
                    DocModelRuleAttribute docRuleAtt = null;
                    if (this.treeViewTemplate.SelectedNode.Tag is DocModelRuleAttribute)
                    {
                        docRuleAtt = (DocModelRuleAttribute)this.treeViewTemplate.SelectedNode.Tag;
                    }
                    else
                    {
                        docRuleAtt = new DocModelRuleAttribute();
                        docRuleAtt.Name = docAttribute.Name;

                        if (this.treeViewTemplate.SelectedNode.Tag is DocModelRuleEntity)
                        {
                            DocModelRuleEntity docRuleEnt = (DocModelRuleEntity)this.treeViewTemplate.SelectedNode.Tag;
                            docRuleEnt.Rules.Add(docRuleAtt);
                        }
                        else if (this.treeViewTemplate.SelectedNode.Tag is DocTemplateDefinition)
                        {
                            docTemplate.Rules.Add(docRuleAtt);
                        }

                        tn = this.LoadTemplateGraph(tn, docRuleAtt);
                    }

                    // get and add entity rule
                    DocModelRuleEntity docRuleEntity = new DocModelRuleEntity();
                    docRuleEntity.Name = entityname;
                    docRuleAtt.Rules.Add(docRuleEntity);
                    this.treeViewTemplate.SelectedNode = this.LoadTemplateGraph(tn, docRuleEntity);

                    // copy to child templates
                    docTemplate.PropagateRule(this.treeViewTemplate.SelectedNode.FullPath);

                    this.m_selection = docRuleEntity;
                    this.ContentChanged(this, EventArgs.Empty);
                    this.SelectionChanged(this, EventArgs.Empty);
                }
            }
            else
            {
                // pick attribute, including attribute that may be on subtype
                DocModelRule rule = null;
                if (this.treeViewTemplate.SelectedNode != null)
                {
                    rule = this.treeViewTemplate.SelectedNode.Tag as DocModelRule;
                }

                //if (rule == null)
                //   return;

                DocTemplateDefinition docTemplate = (DocTemplateDefinition)this.m_template;

                string typename = null;
                if (rule is DocModelRuleEntity)
                {
                    DocModelRuleEntity docRuleEntity = (DocModelRuleEntity)rule;
                    typename = docRuleEntity.Name;
                }
                else
                {
                    // get applicable entity of target (or parent entity rule)
                    typename = docTemplate.Type;
                }

                DocEntity docEntity = this.m_project.GetDefinition(typename) as DocEntity;
                if (docEntity == null)
                {
            #if false // constraints now edited at operations
                    // launch dialog for constraint
                    using (FormConstraint form = new FormConstraint())
                    {
                        DialogResult res = form.ShowDialog(this);
                        if (res == DialogResult.OK)
                        {
                            DocModelRuleConstraint docRuleConstraint = new DocModelRuleConstraint();
                            rule.Rules.Add(docRuleConstraint);
                            docRuleConstraint.Description = form.Expression;
                            docRuleConstraint.Name = form.Expression; // for viewing

                            this.treeViewTemplate.SelectedNode = this.LoadTemplateGraph(this.treeViewTemplate.SelectedNode, docRuleConstraint);

                            // copy to child templates
                            docTemplate.PropagateRule(this.treeViewTemplate.SelectedNode.FullPath);
                        }
                    }
            #endif
                }
                else
                {
                    // launch dialog to pick attribute of entity
                    using (FormSelectAttribute form = new FormSelectAttribute(docEntity, this.m_project, null, true))
                    {
                        DialogResult res = form.ShowDialog(this);
                        if (res == DialogResult.OK && form.Selection != null)
                        {
                            // then add and update tree
                            DocModelRuleAttribute docRuleAttr = new DocModelRuleAttribute();
                            docRuleAttr.Name = form.Selection;
                            if (rule != null)
                            {
                                rule.Rules.Add(docRuleAttr);
                            }
                            else
                            {
                                docTemplate.Rules.Add(docRuleAttr);
                            }
                            this.treeViewTemplate.SelectedNode = this.LoadTemplateGraph(this.treeViewTemplate.SelectedNode, docRuleAttr);

                            // copy to child templates
                            docTemplate.PropagateRule(this.treeViewTemplate.SelectedNode.FullPath);
                        }
                    }
                }

            }
        }
Exemplo n.º 6
0
        private void buttonInsert_Click(object sender, EventArgs e)
        {
            DocDefinition docBase = this.m_base;
            DocDefinition docDefinition = null;

            // for now, clear it -- future: allow incremental replacement

            CvtValuePath valuepathouter = null;
            CvtValuePath valuepathinner = null;

            // keep building
            while (docBase != null)
            {
                using (FormSelectEntity formEntity = new FormSelectEntity(docBase, docDefinition, this.m_project, SelectDefinitionOptions.Entity | SelectDefinitionOptions.Type))
                {
                    if (formEntity.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && formEntity.SelectedEntity != null)
                    {
                        CvtValuePath valuepath = null;
                        if (formEntity.SelectedEntity is DocEntity)
                        {
                            using (FormSelectAttribute formAttribute = new FormSelectAttribute((DocEntity)formEntity.SelectedEntity, this.m_project, null, false))
                            {
                                if (formAttribute.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && formAttribute.SelectedAttribute != null)
                                {
                                    string item = null;
                                    switch (formAttribute.SelectedAttribute.GetAggregation())
                                    {
                                        case DocAggregationEnum.SET:
                                            // if set collection, then qualify by name
                                            // future: more intelligent UI for picking property sets, properties
                                            using (FormSelectItem formItem = new FormSelectItem())
                                            {
                                                if (formItem.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                                                {
                                                    item = formItem.Item;
                                                }
                                            }
                                            break;

                                        case DocAggregationEnum.LIST:
                                            // if list collection, then qualify by index
                                            // future: more intelligent UI for picking list indices
                                            using (FormSelectItem formItem = new FormSelectItem())
                                            {
                                                if (formItem.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                                                {
                                                    item = formItem.Item;
                                                }
                                            }
                                            break;
                                    }

                                    // now add entry to listview
                                    valuepath = new CvtValuePath(formEntity.SelectedEntity, formAttribute.SelectedAttribute, item, null);

                                    if (valuepathinner != null)
                                    {
                                        valuepathinner.InnerPath = valuepath;
                                    }
                                    valuepathinner = valuepath;

                                    if (valuepathouter == null)
                                    {
                                        valuepathouter = valuepath;
                                    }

                                    // drill in
                                    if (this.m_map.ContainsKey(formAttribute.SelectedAttribute.DefinedType))
                                    {
                                        docBase = this.m_map[formAttribute.SelectedAttribute.DefinedType] as DocDefinition;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }

                        }
                        else if (formEntity.SelectedEntity is DocType)
                        {
                            valuepath = new CvtValuePath(formEntity.SelectedEntity, null, null, null);

                            if (valuepathinner != null)
                            {
                                valuepathinner.InnerPath = valuepath;
                            }
                            valuepathinner = valuepath;

                            if (valuepathouter == null)
                            {
                                valuepathouter = valuepath;
                            }

                            docBase = null;
                        }

                    }
                    else
                    {
                        break;
                    }

                }
            }

            this.LoadValuePath(valuepathouter);
        }