예제 #1
0
 public HierarchyRow[] GetHierarchyChildRows(string relationName)
 {
     DataRow[]      children      = GetChildRows(relationName);
     HierarchyRow[] typedChildren = new HierarchyRow[children.Length];
     for (int i = 0; i < children.Length; i++)
     {
         typedChildren[i] = (HierarchyRow)(children[i]);
     }
     return(typedChildren);
 }
예제 #2
0
 private void AddSubmenuForItem(HierarchyRow row, WC.MenuItem item)
 {
     DataRow[]   children = row.GetChildRows("Hierarchy");
     WC.MenuItem childItem;
     foreach (HierarchyRow child in children)
     {
         childItem = new WC.MenuItem(child.Caption, null, null, "/" +
                                     ((CE.GlobalState == GlobalState.Administer) ? "admin/" : "architect/show/") +
                                     CE.project.Name + "/" +
                                     child.NavId.ToString());
         item.ChildItems.Add(childItem);
         AddSubmenuForItem(child, childItem);
     }
 }
예제 #3
0
        public override void InventData()
        {
            Random rnd = new Random((Int32)(DateTime.Now.Ticks % 10000000));

            data.DataSet.EnforceConstraints = false;
            data.Rows.Clear();
            data.DataSet.EnforceConstraints = true;
            int n = rnd.Next() % 10 + 10;
            HierarchyNavTable hierarchy = (HierarchyNavTable)(data);

            for (int i = 0; i < n; i++) // generate a random tree - each node picks a parent or no parent with equal chance
            {
                HierarchyRow r = (HierarchyRow)hierarchy.NewRow();
                r.Id       = i + 1;
                r.ParentId = rnd.Next() % (i + 1);
                if ((int)(r.ParentId) == 0)
                {
                    r.ParentId = null;
                }
                r.Caption = NLipsum.Core.LipsumGenerator.Generate(1, NLipsum.Core.Features.Words, "{0}", NLipsum.Core.Lipsums.LeMasque);
                r.NavId   = r.Id;
                data.Rows.Add(r);
            }
        }
예제 #4
0
 public void Remove(HierarchyRow row)
 {
     Rows.Remove(row);
 }
예제 #5
0
 public void Add(HierarchyRow row)
 {
     Rows.Add(row);
 }
예제 #6
0
 public HierarchyRow[] GetHierarchyChildRows(string relationName)
 {
     DataRow[] children = GetChildRows(relationName);
     HierarchyRow[] typedChildren = new HierarchyRow[children.Length];
     for (int i = 0; i < children.Length; i++) {
         typedChildren[i] = (HierarchyRow)(children[i]);
     }
     return typedChildren;
 }
예제 #7
0
        /// <summary>
        /// get both edit and summary panel proposal for editable tables
        /// and create base Panel with MenuDrop field for each editable table
        /// with 2 children pointing to insert action and summary table view;
        /// also saves it to systemDB, because it needs the panelIDs to
        /// build navigation upon them.
        /// The proposal should always pass proposal check.
        ///
        /// Presenter must have sent a request banning others from initiating a proposal
        /// the whole proposal happens in a transaction
        /// </summary>
        /// <returns>Panel</returns>
        public Panel propose()
        {
            systemDriver.BeginTransaction();

            List <string> tables       = stats.Tables;
            List <Panel>  baseChildren = new List <Panel>();

            HierarchyNavTable basePanelHierarchy = new HierarchyNavTable();

            foreach (string tableName in tables)
            {
                if (excludedTables.Contains(tableName))
                {
                    continue;
                }
                //Notice(this, new ArchitectNoticeEventArgs("Exploring table \"" + tableName + "\"..."));
                Panel editPanel = ProposeForTable(tableName);
                if (editPanel != null)
                {      // editable panel available - add summary panel
                    Panel summaryPanel = proposeSummaryPanel(tableName);

                    foreach (Control c in summaryPanel.controls)        // simlified for now
                    {
                        c.targetPanel = editPanel;
                    }
                    foreach (Control c in editPanel.controls)
                    {
                        c.targetPanel = summaryPanel;
                    }

                    editPanel.panelName    = "Editation of " + tableName;
                    summaryPanel.panelName = "Summary of " + tableName;
                    baseChildren.Add(editPanel);
                    baseChildren.Add(summaryPanel);

                    HierarchyRow tableRow        = (HierarchyRow)basePanelHierarchy.NewRow();
                    HierarchyRow tableEditRow    = (HierarchyRow)basePanelHierarchy.NewRow();
                    HierarchyRow tableSummaryRow = (HierarchyRow)basePanelHierarchy.NewRow();
                    tableRow.ParentId        = null;
                    tableSummaryRow.ParentId = tableRow.Id;
                    tableEditRow.ParentId    = tableRow.Id;
                    tableRow.NavId           = null;

                    tableRow.Caption        = tableName;
                    tableEditRow.Caption    = "Add";
                    tableSummaryRow.Caption = "Browse";

                    basePanelHierarchy.Add(tableRow);
                    basePanelHierarchy.Add(tableEditRow);
                    basePanelHierarchy.Add(tableSummaryRow);
                }
            }

            Panel basePanel = new Panel(null, 0, PanelTypes.MenuDrop,
                                        baseChildren, null, null, null);

            basePanel.panelName      = "Main page";
            basePanel.isBaseNavPanel = true;
            systemDriver.AddPanel(basePanel);

            TreeControl basePanelTreeControl = new TreeControl(basePanel.panelId, basePanelHierarchy,
                                                               "Id", "ParentId", "Caption", UserAction.View);

            basePanelTreeControl.navThroughPanels = true;

            // navId for menu items
            for (int i = 0; i < basePanel.children.Count / 2; i++) // ad hoc beyond sense
            {
                basePanelHierarchy.Rows[i * 3]["NavId"]     = basePanel.children[2 * i].panelId;
                basePanelHierarchy.Rows[i * 3 + 1]["NavId"] = basePanel.children[2 * i].panelId;
                basePanelHierarchy.Rows[i * 3 + 2]["NavId"] = basePanel.children[2 * i + 1].panelId;
            }


            List <Control> addedList = new List <Control>();

            addedList.Add(basePanelTreeControl);
            basePanel.AddControls(addedList);
            systemDriver.AddControl(basePanelTreeControl);

            systemDriver.IncreaseVersionNumber();
            systemDriver.CommitTransaction();
            return(basePanel);
        }
예제 #8
0
 private void AddSubmenuForItem(HierarchyRow row, WC.MenuItem item)
 {
     DataRow[] children = row.GetChildRows("Hierarchy");
     WC.MenuItem childItem;
     foreach (HierarchyRow child in children)
     {
         childItem = new WC.MenuItem(child.Caption, null, null, "/" +
                 ((CE.GlobalState == GlobalState.Administer) ? "admin/" : "architect/show/") +
                 CE.project.Name + "/" +
                 child.NavId.ToString());
         item.ChildItems.Add(childItem);
         AddSubmenuForItem(child, childItem);
     }
 }
예제 #9
0
        /// <summary>
        /// called upon building the TreeView from the hierarchy table - creates a new Treenode and sets its parent to the "itme"
        /// </summary>
        /// <param name="row"></param>
        /// <param name="item"></param>
        private void AddSubtreeForItem(HierarchyRow row, WC.TreeNode item)
        {
            HierarchyRow[] children = row.GetHierarchyChildRows("Hierarchy");

            WC.TreeNode childItem;
            foreach (HierarchyRow child in children)
            {
                childItem = new WC.TreeNode(child.Caption, child.Id.ToString());
                item.ChildNodes.Add(childItem);
                AddSubtreeForItem(child, childItem);
            }
        }
예제 #10
0
        public HierarchyRow GetNewRow()
        {
            HierarchyRow row = (HierarchyRow)NewRow();

            return(row);
        }
예제 #11
0
 public void Remove(HierarchyRow row)
 {
     Rows.Remove(row);
 }
예제 #12
0
 public void Add(HierarchyRow row)
 {
     Rows.Add(row);
 }