Beispiel #1
0
        /// <summary>
        /// PreRender
        /// </summary>
        protected override void OnPreRender(EventArgs e)
        {
            try
            {
                //_Menu.DefaultItemLookId = TopItemLookId;
                //_Menu.DefaultGroupCssClass = MenuGroupCssClass;
                _MenuDiv.Attributes.Add("class", MenuDivCssClass);

                if (_View != null)
                {
                    PrintMenuItem.Attributes.Add("onclick", "openPrintGridPopup('sessionviewid=" + _View.SessionViewId + "');");
                }
                else
                {
                    PrintMenuItem.Attributes.Add("onclick", "openPrintGridPopup('');");
                }

                _ChangeViewMenuItem.Visible = false;
                _EditViewMenuItem.Visible   = false;
                //_SearchMenuItem.Visible = false;
                //ExportMenuItem.Visible = false;
                PrintMenuItem.Visible      = false;
                PrintLabelMenuItem.Visible = false;
                _BatchOpsMenuItem.Visible  = false;
                SaveViewAsMenuItem.Visible = false;
                //if( AllowSearch )
                //_SearchMenuItem.Visible = true;
                if (AllowChangeView)
                {
                    _ChangeViewMenuItem.Visible = true;
                }
                if (AllowBatch)
                {
                    _BatchOpsMenuItem.Visible = true;
                }
                if (AllowMobile && _CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SI))
                {
                    _MobileMenuItem.Visible = true;
                }
                //if( AllowEditView && ( (CswNbtObjClassRole) _CswNbtResources.CurrentNbtUser.RoleNode ).ActionPermissions.CheckValue( CswNbtAction.PermissionXValue, CswNbtAction.ActionNameEnumToString( _CswNbtResources.Actions[CswNbtActionName.Edit_View].Name ) ) )
                if (AllowEditView && _CswNbtResources.Permit.can(CswEnumNbtActionName.Edit_View))
                {
                    _EditViewMenuItem.Visible = true;
                }
                //if ( AllowExport && NbtViewRenderingMode.Unknown != NbtViewRenderingMode )
                //    ExportMenuItem.Visible = true;
                //if( AllowExportXml )
                //    ExportAsXmlMenuItem.Visible = true;
                if (AllowPrint)
                {
                    PrintMenuItem.Visible = true;
                }

                if (AllowPrintLabel && SelectedNodeKey != null)
                {
                    CswNbtMetaDataNodeType SelectedNodeType = _CswNbtResources.MetaData.getNodeType(SelectedNodeKey.NodeTypeId);
                    if (SelectedNodeType != null)
                    {
                        CswNbtMetaDataNodeTypeProp BarcodeProperty = (CswNbtMetaDataNodeTypeProp)SelectedNodeType.getBarcodeProperty();
                        if (BarcodeProperty != null)
                        {
                            PrintLabelMenuItem.Visible = true;
                            PrintLabelMenuItem.Attributes.Add("onclick", "openPrintLabelPopup('" + SelectedNodeKey.NodeId.ToString() + "','" + BarcodeProperty.PropId.ToString() + "');");
                        }
                    }
                }

                if (this.View is CswNbtView && !((CswNbtView)View).ViewId.isSet())
                {
                    SaveViewAsMenuItem.Visible = true;
                    SaveViewAsMenuItem.Attributes.Add("onclick", "openSaveViewAsPopup('" + View.SessionViewId + "');");
                }

                // Setup delete menu
                if (DeleteMenuItem != null)
                {
                    DeleteMenuItem.Visible = false;
                    if (SelectedNodeKey != null &&
                        //_Node != null &&
                        SelectedNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.Plain &&
                        this.AllowDelete &&
                        SelectedNodeKeyViewNode != null)
                    {
                        if (SelectedNodeKeyViewNode is CswNbtViewRelationship &&
                            ((CswNbtViewRelationship)SelectedNodeKeyViewNode).AllowDelete &&
                            _CswNbtResources.Permit.isNodeWritable(CswEnumNbtNodeTypePermission.Delete, _CswNbtResources.MetaData.getNodeType(SelectedNodeKey.NodeTypeId), CswNbtResources.Nodes[SelectedNodeKey].NodeId))
                        {
                            DeleteMenuItem.Visible = true;

                            // This lives in MainLayout.aspx, because the dialog cannot be inside an UpdatePanel.
                            DeleteMenuItem.Attributes.Add("onclick", "openDeleteNodePopup('" + SelectedNodeKey.ToString() + "');");
                        }
                    }
                    else if (IsDesignMode &&
                             this.AllowDelete &&
                             (DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.NodeType ||
                              DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.Tab ||
                              DesignSelectedType == CswNodeTypeTree.NodeTypeTreeSelectedType.Property) &&
                             DesignSelectedValue != string.Empty)
                    {
                        // Can't delete the first tab
                        if ((DesignSelectedType != CswNodeTypeTree.NodeTypeTreeSelectedType.Tab) ||
                            (_CswNbtResources.MetaData.getNodeTypeTab(Convert.ToInt32(DesignSelectedValue)).getNodeType().getNodeTypeTabs().Count() > 1))
                        {
                            DeleteMenuItem.Visible = true;

                            // This lives in main.js
                            DeleteMenuItem.Attributes.Add("onclick", "openDesignDeletePopup('" + DesignSelectedType.ToString() + "','" + DesignSelectedValue + "');");
                        }
                    }
                }

                // case 21158
                _SearchMenuItem.Visible     = false;
                _ChangeViewMenuItem.Visible = false;
                _EditViewMenuItem.Visible   = false;
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
            base.OnPreRender(e);
        }
Beispiel #2
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()