Ejemplo n.º 1
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            string        rootName = string.Format("Domain template-{0}", ctrl.Trees.Count + 1);
            IDecisionTree tree     = IApplicationInterface.NewDescisionTree(rootName);

            IBaseNode dataObjects = tree.CreateNewNode(eNodeType.DataObjects, null, Constants.DataNodesTreeName);

            tree.RootNode.AddNode(dataObjects);

            IBaseNode dataSources = tree.CreateNewNode(eNodeType.DataSources, null, Constants.DataSourcesTreeName);

            tree.RootNode.AddNode(dataSources);

            ctrl.AddTree(tree);
        }
Ejemplo n.º 2
0
        private void AddBulkAssignments()
        {
            IBaseNode     currentNode = TreeNodeAsBaseNode(tvDecisionTree.SelectedNode);
            IDecisionTree tree        = currentNode.Tree;

            if (tree != null)
            {
                BulkExpressionForm frm = new BulkExpressionForm(tree.RootNode.GetNode(eNodeType.VariableDefinitions));
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    foreach (IVariableDef assignment in frm.SelectedValues)
                    {
                        IBaseNode newNode = tree.CreateNewNode(eNodeType.Expression, currentNode, assignment.Value);
                        if (assignment.Parent != null && assignment.Parent.NodeType == eNodeType.DomainObject)
                        {
                            (newNode as IExpression).Domain = assignment.Parent as IDomainObject;
                        }

                        (newNode as IExpression).Variable = assignment;

                        newNode.Updated += Node_Updated;

                        TreeNode node = modelGUIConfig.BaseNodeAsTreeNode(newNode);

                        tvDecisionTree.SelectedNode.Nodes.Add(node);
                        tvDecisionTree.SelectedNode.Expand();
                    }
                }
            }

            App.SelectedTree = tree;
        }
Ejemplo n.º 3
0
        private void AddBulkBranches()
        {
            IBaseNode     currentNode = TreeNodeAsBaseNode(tvDecisionTree.SelectedNode);
            IDecisionTree tree        = currentNode.Tree;

            if (tree != null)
            {
                BulkBranchForm frm = new sakwa.BulkBranchForm(tree.RootNode.GetNode(eNodeType.VariableDefinitions));
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    string[] elems = frm.SelectedValues;
                    foreach (string elem in elems)
                    {
                        IBaseNode newNode = tree.CreateNewNode(eNodeType.Branch, currentNode, elem);
                        newNode.Updated += Node_Updated;

                        TreeNode node = modelGUIConfig.BaseNodeAsTreeNode(newNode);

                        tvDecisionTree.SelectedNode.Nodes.Add(node);
                        tvDecisionTree.SelectedNode.Expand();
                    }
                }
            }

            App.SelectedTree = tree;
        }
Ejemplo n.º 4
0
        private void AddNode(eNodeType nodeType)
        {
            IBaseNode     currentNode = TreeNodeAsBaseNode(tvDecisionTree.SelectedNode);
            IDecisionTree tree        = currentNode.Tree;

            if (tree != null)
            {
                IBaseNode newNode = tree.CreateNewNode(nodeType, currentNode);
                newNode.Updated += Node_Updated;
                if (newNode.NodeType == eNodeType.VarDefinition)
                {
                    (newNode as IVariableDef).VariableTypeChanged += VariableTypeChanged;
                }

                if (newNode.NodeType == eNodeType.DomainObject)
                {
                    (newNode as IDomainObject).UpdatedAndRefresh += UpdateAdRefresh;
                }

                TreeNode node = modelGUIConfig.BaseNodeAsTreeNode(newNode);

                tvDecisionTree.SelectedNode.Nodes.Add(node);
                tvDecisionTree.SelectedNode.Expand();
                tvDecisionTree.SelectedNode = node;
            }

            App.SelectedTree = tree;
        }
Ejemplo n.º 5
0
        private void LoadFile(string fileName)
        {
            LastUsedFolder = fileName;
            IDecisionTree tree        = IApplicationInterface.NewDescisionTree();
            IPersistence  persistence = new XmlPersistenceImpl(fileName);

            if (tree.Load(persistence, fileName))
            {
                if (tree.RootNode.GetNode(eNodeType.DataObjects) == null)
                {
                    IBaseNode dataObjects = tree.CreateNewNode(eNodeType.DataObjects, null, Constants.DataNodesTreeName);
                    tree.RootNode.AddNode(dataObjects);
                }

                if (tree.RootNode.GetNode(eNodeType.DataSources) == null)
                {
                    IBaseNode dataSources = tree.CreateNewNode(eNodeType.DataSources, null, Constants.DataSourcesTreeName);
                    tree.RootNode.AddNode(dataSources);
                }

                ctrl.AddTree(tree);
                IApplicationInterface.StatusLine = string.Format("Opened {0} from disk", Path.GetFileName(fileName)) + UI_Constants.ZoomPanHint;
            }
        }
Ejemplo n.º 6
0
        private void ShowTemplatePreview()
        {
            tvTemplate.Nodes.Clear();
            IDecisionTree tree = App.NewDescisionTree();

            IBaseNode baseNode = tree.CreateNewNode(eNodeType.Root, null, "Domain template");
            TreeNode  rootNode = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            modelGUIConfig.ConfigureTreeNode(rootNode);
            tvTemplate.Nodes.Add(modelGUIConfig.ConfigureTreeNode(rootNode));

            baseNode = tree.CreateNewNode(eNodeType.DataObjects, null, "Data objects");
            TreeNode dataobjs = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            rootNode.Nodes.Add(modelGUIConfig.ConfigureTreeNode(dataobjs));

            baseNode = tree.CreateNewNode(eNodeType.DataObject, null, "Data object");
            TreeNode node = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            dataobjs.Nodes.Add(modelGUIConfig.ConfigureTreeNode(node));

            baseNode = tree.CreateNewNode(eNodeType.DataSources, null, "Data sources");
            TreeNode dataSources = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            rootNode.Nodes.Add(modelGUIConfig.ConfigureTreeNode(dataSources));

            baseNode = tree.CreateNewNode(eNodeType.DataSource, null, "Data source");
            TreeNode dataSource = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            dataSources.Nodes.Add(modelGUIConfig.ConfigureTreeNode(dataSource));

            baseNode = tree.CreateNewNode(eNodeType.DataDefinition, null, "Data definition");
            node     = modelGUIConfig.BaseNodeAsTreeNode(baseNode);
            dataSource.Nodes.Add(modelGUIConfig.ConfigureTreeNode(node));

            tvTemplate.ExpandAll();
        }
Ejemplo n.º 7
0
        private void ShowModelPreview()
        {
            tvModel.Nodes.Clear();
            IDecisionTree tree = App.NewDescisionTree();

            IBaseNode baseNode = tree.CreateNewNode(eNodeType.Root, null, "Decision model");
            TreeNode  rootNode = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            modelGUIConfig.ConfigureTreeNode(rootNode);
            tvModel.Nodes.Add(modelGUIConfig.ConfigureTreeNode(rootNode));

            baseNode = tree.CreateNewNode(eNodeType.VariableDefinitions, null, "Variable definitions");
            TreeNode vars = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            rootNode.Nodes.Add(modelGUIConfig.ConfigureTreeNode(vars));

            baseNode = tree.CreateNewNode(eNodeType.VarDefinition, null, "Variable definition");
            TreeNode node = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            vars.Nodes.Add(modelGUIConfig.ConfigureTreeNode(node));

            baseNode = tree.CreateNewNode(eNodeType.DomainObject, null, "Domain object");
            TreeNode decision = modelGUIConfig.BaseNodeAsTreeNode(baseNode);

            vars.Nodes.Add(modelGUIConfig.ConfigureTreeNode(decision));


            baseNode = tree.CreateNewNode(eNodeType.Expression, null, "Expression");
            node     = modelGUIConfig.BaseNodeAsTreeNode(baseNode);
            rootNode.Nodes.Add(modelGUIConfig.ConfigureTreeNode(node));

            baseNode = tree.CreateNewNode(eNodeType.Branch, null, "Branch");
            node     = modelGUIConfig.BaseNodeAsTreeNode(baseNode);
            rootNode.Nodes.Add(modelGUIConfig.ConfigureTreeNode(node));

            tvModel.ExpandAll();
        }