Beispiel #1
0
        /// <summary>
        /// Sets up the Add menu and the Edit View menu item
        /// </summary>
        void CswMainMenu_DataBinding(object sender, EventArgs e)
        {
            try
            {
                EnsureChildControls();

                if (BatchEnabled)
                {
                    _BatchOpsMenuItem.Text = "Single-Edit";
                }
                else
                {
                    _BatchOpsMenuItem.Text = "Multi-Edit";
                }


                // Setup Export Menu
                ExportMenuItem.Visible = false;
                if (AllowExport)
                {
                    if (_View != null)
                    {
                        ExportMenuItem.Visible = true;
                        ExportMenuItem.Items.Clear();
                        if (CswEnumNbtViewRenderingMode.Grid == NbtViewRenderingMode)
                        {
                            foreach (ExportOutputFormat FormatType in Enum.GetValues(typeof(ExportOutputFormat)))
                            {
                                if (ExportOutputFormat.MobileXML != FormatType || _CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SI))
                                {
                                    _addExportMenuItem(_View, FormatType, NbtViewRenderingMode);
                                }
                            }
                        }
                        else // tree or list
                        {
                            _addExportMenuItem(_View, ExportOutputFormat.ReportXML, NbtViewRenderingMode);
                            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SI))
                            {
                                _addExportMenuItem(_View, ExportOutputFormat.MobileXML, NbtViewRenderingMode);
                            }
                        }
                    }
                    else if (IsDesignMode && _CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SI))
                    {
                        ExportMenuItem.Visible = false;
                        CswNbtMetaDataNodeType NodeType = null;
                        switch (DesignSelectedType)
                        {
                        case CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType:
                            NodeType = _CswNbtResources.MetaData.getNodeType(Convert.ToInt32(DesignSelectedValue));
                            break;

                        case CswNodeTypeTree.NodeTypeTreeSelectedType.Property:
                            CswNbtMetaDataNodeTypeProp NodeTypeProp = _CswNbtResources.MetaData.getNodeTypeProp(Convert.ToInt32(DesignSelectedValue));
                            NodeType = NodeTypeProp.getNodeType();
                            break;

                        case CswNodeTypeTree.NodeTypeTreeSelectedType.Tab:
                            CswNbtMetaDataNodeTypeTab NodeTypeTab = _CswNbtResources.MetaData.getNodeTypeTab(Convert.ToInt32(DesignSelectedValue));
                            NodeType = NodeTypeTab.getNodeType();
                            break;
                        }

                        ExportMenuItem.Visible = true;
                        ExportMenuItem.Items.Clear();
                        if (NodeType != null)
                        {
                            RadMenuItem DesignExportItem = new RadMenuItem();
                            DesignExportItem.Text     = "Export NodeType XML";
                            DesignExportItem.Value    = "export_" + ExportOutputFormat.MobileXML.ToString().ToLower();
                            DesignExportItem.CssClass = SubMenuGroupCssClass;
                            DesignExportItem.Attributes.Add("onclick", "openExportPopup('nodetypeid=" + NodeType.NodeTypeId.ToString() + "&format=" + ExportOutputFormat.MobileXML.ToString().ToLower() + "&renderingmode=" + NbtViewRenderingMode.ToString() + "');");
                            ExportMenuItem.Items.Add(DesignExportItem);
                        }
                    }
                } // if( AllowExport )

                if (AllowMobile && _View != null && _CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SI))
                {
                    _MobileMenuItem.Visible = true;
                    _MobileMenuItem.Items.Clear();

                    RadMenuItem MobileExportItem = new RadMenuItem();
                    MobileExportItem.Text     = "Export Mobile XML";
                    MobileExportItem.Value    = "export_" + ExportOutputFormat.MobileXML.ToString().ToLower();
                    MobileExportItem.CssClass = SubMenuGroupCssClass;
                    MobileExportItem.Attributes.Add("onclick", "openExportPopup('sessionviewid=" + _View.SessionViewId + "&format=" + ExportOutputFormat.MobileXML.ToString().ToLower() + "&renderingmode=" + NbtViewRenderingMode.ToString() + "');");
                    _MobileMenuItem.Items.Add(MobileExportItem);
                }
                else
                {
                    _MobileMenuItem.Visible = false;
                }

                // Setup Add Menu
                _AddMenuItem.Visible = false;
                if (ParentNodeKey != null)
                {
                    if (ParentNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.Plain)
                    {
                        _Node = _CswNbtResources.Nodes[ParentNodeKey];
                    }

                    if (AllowAdd)
                    {
                        if (ParentNodeKeyViewNode != null)
                        {
                            bool LimitToFirstGeneration = (View.ViewMode == CswEnumNbtViewRenderingMode.Grid);
                            Collection <CswNbtViewNode.CswNbtViewAddNodeTypeEntry> AllowedChildNodeTypes = ParentNodeKeyViewNode.AllowedChildNodeTypes(LimitToFirstGeneration);
                            if (AllowedChildNodeTypes.Count > 0)
                            {
                                _AddMenuItem.Visible = true;
                                _AddMenuItem.Items.Clear();

                                string AddMenuDoesntChangeViewString = "0";
                                if (AddMenuDoesntChangeView)
                                {
                                    AddMenuDoesntChangeViewString = "1";
                                }
                                string AddMenuDoesntChangeSelectedNodeString = "0";
                                if (AddMenuDoesntChangeSelectedNode)
                                {
                                    AddMenuDoesntChangeSelectedNodeString = "1";
                                }

                                foreach (CswNbtViewNode.CswNbtViewAddNodeTypeEntry Entry in AllowedChildNodeTypes)
                                {
                                    RadMenuItem TypeMenuItem = new RadMenuItem();
                                    TypeMenuItem.Text     = Entry.NodeType.NodeTypeName;
                                    TypeMenuItem.Value    = "addnode_" + Entry.NodeType.NodeTypeId.ToString();
                                    TypeMenuItem.CssClass = SubMenuGroupCssClass;
                                    //TypeMenuItem.Attributes.Add( "onclick", "openNewNodePopup('" + Entry.NodeType.NodeTypeId.ToString() + "', '" + ParentNodeKey.ToJavaScriptParam() + "', '" + ParentNodeKeyViewNode.View.SessionViewId.ToString() + "', '" + Entry.ViewRelationship.UniqueId + "', '" + AddMenuDoesntChangeViewString + "', '" + AddMenuDoesntChangeSelectedNodeString + "');" );
                                    // Case 20544 - Add viewid to querystring
                                    TypeMenuItem.Attributes.Add("onclick", "openNewNodePopup('" + Entry.NodeType.NodeTypeId.ToString() + "', '" + ParentNodeKey.ToString() + "', '" + ParentNodeKeyViewNode.View.SessionViewId.ToString() + "', '" + AddMenuDoesntChangeViewString + "', '" + AddMenuDoesntChangeSelectedNodeString + "', '" + _View.ViewId.ToString() + "');");
                                    _AddMenuItem.Items.Add(TypeMenuItem);
                                }
                            }
                        }
                    }
                }
                else if (IsDesignMode)
                {
                    _AddMenuItem.Items.Clear();

                    if (DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.Property ||
                        DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.NodeTypeBaseVersion ||
                        DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.PropertyFilter)
                    {
                        // No Add Menu
                    }
                    else if (DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.Tab)
                    {
                        CswNbtMetaDataNodeTypeTab SelectedTab = CswNbtResources.MetaData.getNodeTypeTab(Convert.ToInt32(DesignSelectedValue));
                        if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, SelectedTab.getNodeType()))
                        {
                            if (SelectedTab.getNodeType().IsLatestVersion())
                            {
                                _AddMenuItem.Visible = true;
                                RadMenuItem AddPropMenuItem = new RadMenuItem();
                                if (DesignMode == NbtDesignMode.Inspection)
                                {
                                    AddPropMenuItem.Text = "Question";
                                }
                                else
                                {
                                    AddPropMenuItem.Text = "Property";
                                }
                                AddPropMenuItem.Value    = "addprop_" + DesignSelectedValue;
                                AddPropMenuItem.CssClass = SubMenuGroupCssClass;
                                string js = string.Empty;
                                if (DesignMode == NbtDesignMode.Inspection)
                                {
                                    js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.Property + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.Tab + "','" + DesignSelectedValue + "', 'i');";
                                }
                                else
                                {
                                    js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.Property + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.Tab + "','" + DesignSelectedValue + "', '');";
                                }
                                AddPropMenuItem.Attributes.Add("onclick", js);
                                AddPropMenuItem.PostBack = false;
                                _AddMenuItem.Items.Add(AddPropMenuItem);
                            }
                        }
                    }
                    else if (DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType)
                    {
                        CswNbtMetaDataNodeType SelectedNodeType = CswNbtResources.MetaData.getNodeType(Convert.ToInt32(DesignSelectedValue));
                        if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, SelectedNodeType))
                        {
                            if (SelectedNodeType != null && SelectedNodeType.IsLatestVersion())
                            {
                                _AddMenuItem.Visible = true;
                                RadMenuItem AddTabMenuItem = new RadMenuItem();
                                if (DesignMode == NbtDesignMode.Inspection)
                                {
                                    AddTabMenuItem.Text = "Section";
                                }
                                else
                                {
                                    AddTabMenuItem.Text = "Tab";
                                }
                                AddTabMenuItem.Value    = "addtab_" + DesignSelectedValue;
                                AddTabMenuItem.CssClass = SubMenuGroupCssClass;
                                string js = string.Empty;
                                if (DesignMode == NbtDesignMode.Inspection)
                                {
                                    js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.Tab + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType + "','" + DesignSelectedValue + "', 'i');";
                                }
                                else
                                {
                                    js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.Tab + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType + "','" + DesignSelectedValue + "', '');";
                                }
                                AddTabMenuItem.Attributes.Add("onclick", js);
                                AddTabMenuItem.PostBack = false;
                                _AddMenuItem.Items.Add(AddTabMenuItem);
                            }
                        }
                    }
                    else
                    {
                        _AddMenuItem.Visible = true;
                        RadMenuItem AddTypeMenuItem = new RadMenuItem();
                        if (DesignMode == NbtDesignMode.Inspection)
                        {
                            AddTypeMenuItem.Text = "Inspection Design";
                        }
                        else
                        {
                            AddTypeMenuItem.Text = "NodeType";
                        }
                        AddTypeMenuItem.Value    = "addtype";
                        AddTypeMenuItem.CssClass = SubMenuGroupCssClass;
                        string js = string.Empty;
                        if (DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.Category)
                        {
                            if (DesignMode == NbtDesignMode.Inspection)
                            {
                                js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType.ToString() + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.Category.ToString() + "','" + DesignSelectedValue + "', 'i');";
                            }
                            else
                            {
                                js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType.ToString() + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.Category.ToString() + "','" + DesignSelectedValue + "', '');";
                            }
                        }
                        else
                        {
                            if (DesignMode == NbtDesignMode.Inspection)
                            {
                                js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType.ToString() + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.Root.ToString() + "','', 'i');";
                            }
                            else
                            {
                                js = "openDesignAddPopup('" + CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType.ToString() + "','" + CswNodeTypeTree.NodeTypeTreeSelectedType.Root.ToString() + "','', '');";
                            }
                        }
                        AddTypeMenuItem.Attributes.Add("onclick", js);
                        AddTypeMenuItem.PostBack = false;
                        _AddMenuItem.Items.Add(AddTypeMenuItem);
                    }
                }

                // Edit View
                if (AllowEditView && _EditViewMenuItem != null && View != null)
                {
                    _EditViewMenuItem.NavigateUrl = "EditView.aspx?viewid=" + View.ViewId.ToString();
                    if (View.Visibility == CswEnumNbtViewVisibility.Property ||
                        View.Visibility == CswEnumNbtViewVisibility.Hidden)
                    {
                        _EditViewMenuItem.NavigateUrl += "&step=2";
                    }
                }
                else
                {
                    _EditViewMenuItem.NavigateUrl = "EditView.aspx";
                }

                // Search
                //if( View is CswNbtView && View != null && View.IsSearchable() )
                //{
                _SearchMenuItem.Visible = true;
                // Handle searching from grid properties:
                if (View != null && ParentNodeKey != null)
                {
                    // Case 20715 - need to check NodeSpecies first
                    if (ParentNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.Plain && null != ParentNodeKey.NodeId)
                    {
                        _SearchMenuItem.NavigateUrl = "Search.aspx?nodeid=" + ParentNodeKey.NodeId.ToString() + "&viewid=" + View.ViewId.ToString();
                    }
                    else
                    {
                        _SearchMenuItem.NavigateUrl = "Search.aspx?nodeid=" + "&viewid=" + View.ViewId.ToString();
                    }
                }
                else
                {
                    _SearchMenuItem.NavigateUrl = "Search.aspx";
                }
                //}
                //else
                //{
                //    _SearchMenuItem.Visible = false;
                //}


                // Copy
                if (AllowCopy && SelectedNodeKey != null &&
                    SelectedNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.Plain &&
                    _CswNbtResources.Permit.canNodeType(Nbt.Security.CswEnumNbtNodeTypePermission.Create, _CswNbtResources.MetaData.getNodeType(SelectedNodeKey.NodeTypeId)))
                {
                    if (SelectedNodeKeyViewNode != null && SelectedNodeKeyViewNode is CswNbtViewRelationship &&
                        ((CswNbtViewRelationship)SelectedNodeKeyViewNode).NodeIdsToFilterIn.Count == 0)     // BZ 8022
                    {
                        CswNbtMetaDataNodeType CopyNodeType = _CswNbtResources.MetaData.getNodeType(SelectedNodeKey.NodeTypeId);
                        string badproperty = string.Empty;
                        if (!CopyNodeType.IsUniqueAndRequired(ref badproperty))
                        {
                            _CopyMenuItem.Visible = true;
                            _CopyMenuItem.Attributes.Add("onclick", "openCopyPopup('" + SelectedNodeKey.ToString() + "');");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        } // CswMainMenu_DataBinding()