コード例 #1
0
        private void customizeContextMenuForSelection()
        {
            int  count         = this.GetBrowser().Form.Grid.SelectedItems.Count;
            bool itemsSelected = count > 0;

            bool create = true;
            bool saveAs = count == 1;
            bool delete = count == 1;

            if (count == 1)
            {
                BrowserData       item     = (BrowserData)this.GetBrowser().Form.Grid.SelectedItem;
                List <Right>      rights   = null;
                PrivilegeObserver observer = new PrivilegeObserver();
                if (!ApplicationManager.User.IsAdmin())
                {
                    RightService service = ApplicationManager.ControllerFactory.ServiceFactory.GetRightService();
                    rights = service.getUserRights(this.SubjectType.label, item.oid);
                }
                saveAs = RightsUtil.HasRight(Domain.RightType.SAVE_AS, rights);
                delete = RightsUtil.HasRight(Domain.RightType.DELETE, rights);
                create = observer.hasPrivilege(this.FunctionalityCode, Domain.RightType.CREATE);
            }
            this.GetBrowser().Form.Grid.NewMenuItem.IsEnabled  = create;
            this.GetBrowser().Form.Grid.OpenMenuItem.IsEnabled = itemsSelected;
            //this.GetBrowser().Form.Grid.RenameMenuItem.IsEnabled = saveAs && count == 1;
            this.GetBrowser().Form.Grid.SaveAsMenuItem.IsEnabled = saveAs && count == 1;
            //this.GetBrowser().Form.Grid.CopyMenuItem.IsEnabled = itemsSelected && create;
            //this.GetBrowser().Form.Grid.PasteMenuItem.IsEnabled = create;
            this.GetBrowser().Form.Grid.DeleteMenuItem.IsEnabled = itemsSelected && delete;
            customizeContextMenu();
        }
コード例 #2
0
        /// <summary>
        /// Customize toolbar for connected user
        /// </summary>
        /// <param name="rights"></param>
        /// <param name="readOnly"></param>
        public virtual void Customize(String fuctionality, PrivilegeObserver observer, List <Domain.Right> rights, bool readOnly = false)
        {
            bool create = observer.hasPrivilege(fuctionality, Domain.RightType.CREATE);
            bool edit   = RightsUtil.HasRight(Domain.RightType.EDIT, rights);

            SaveButton.Visibility = edit && !readOnly ? Visibility.Visible : Visibility.Collapsed;
            NewButton.Visibility  = create && !readOnly ? Visibility.Visible : Visibility.Collapsed;
        }
コード例 #3
0
        /// <summary>
        /// Effectue l'initialisation du controller.
        /// On initialize la vue et on met this.IsModify = false
        /// </summary>
        /// <returns>
        /// OperationState.CONTINUE si l'opération a réussi
        /// OperationState.STOP sinon
        /// </returns>
        public override OperationState Initialize()
        {
            base.Initialize();
            List <Right>      rights   = null;
            PrivilegeObserver observer = new PrivilegeObserver();

            if (this.ToolBar != null)
            {
                this.ToolBar.Customize(this.FunctionalityCode, observer, rights, false);
            }
            bool edit = observer.hasPrivilege(this.FunctionalityCode, Domain.RightType.CREATE);

            GetBrowser().SetReadOnly(!edit);
            return(OperationState.CONTINUE);
        }
コード例 #4
0
        protected virtual void InitializeNewPage(String functionality)
        {
            PrivilegeObserver observer = new PrivilegeObserver();
            bool create = observer.hasPrivilege(functionality, RightType.CREATE);

            if (create)
            {
                NewPage                  = getNewPage();
                NewPage.CanClose         = false;
                NewPage.CanFloat         = false;
                NewPage.Title            = "+";
                newPageEventHandler      = new EventHandler(this.OnNewPageSelected);
                NewPage.IsActiveChanged += newPageEventHandler;
            }
        }
コード例 #5
0
        public virtual void CustomizeContexMenu(PrivilegeObserver observer, List <Right> rights, EditorItem <T> page)
        {
            if (page != null)
            {
                bool edit   = RightsUtil.HasRight(Domain.RightType.EDIT, rights);
                bool saveAs = RightsUtil.HasRight(Domain.RightType.SAVE_AS, rights);
                bool delete = RightsUtil.HasRight(Domain.RightType.DELETE, rights);
                bool create = observer.hasPrivilege(this.FunctionalityCode, Domain.RightType.CREATE);

                RefreshMenuItem.Visibility = !page.IsReadOnly ? Visibility.Visible : Visibility.Collapsed;
                DeleteMenuItem.Visibility  = delete && !page.IsReadOnly ? Visibility.Visible : Visibility.Collapsed;
                SaveAsMenuItem.Visibility  = saveAs && !page.IsReadOnly ? Visibility.Visible : Visibility.Collapsed;
                SaveMenuItem.Visibility    = edit && !page.IsReadOnly ? Visibility.Visible : Visibility.Collapsed;
                RenameMenuItem.Visibility  = saveAs && !page.IsReadOnly ? Visibility.Visible : Visibility.Collapsed;
                NewMenuItem.Visibility     = create ? Visibility.Visible : Visibility.Collapsed;
            }
        }
コード例 #6
0
ファイル: ApplicationMenu.cs プロジェクト: schifflee/bcephal2
        public virtual ApplicationMenu customize(PrivilegeObserver observer)
        {
            if (observer.user == null || !observer.user.active.Value)
            {
                return(null);
            }
            if (observer.user.IsAdmin())
            {
                return(this);
            }
            if (observer.user.profil == null || !observer.user.profil.active)
            {
                return(null);
            }
            String    code      = this.GetFunctionalityCode();
            RightType?rightType = this.RightType;

            if (!string.IsNullOrWhiteSpace(code))
            {
                if (rightType.HasValue)
                {
                    if (observer.hasPrivilege(code, rightType.Value))
                    {
                        return(this);
                    }
                }
                else if (observer.hasPrivilege(code))
                {
                    return(this);
                }
            }

            List <String> list = new List <String>(0);

            list.Add(FunctionalitiesCode.FILE_QUIT);
            list.Add(FunctionalitiesCode.FILE_SAVE);
            list.Add(FunctionalitiesCode.FILE_SAVE_AS);
            list.Add(FunctionalitiesCode.HELP);
            if (!string.IsNullOrWhiteSpace(code) && list.Contains(code))
            {
                return(this);
            }

            int           added    = 0;
            List <Object> controls = new List <Object>(0);

            foreach (Control control in Items)
            {
                if (control is ApplicationMenu)
                {
                    ApplicationMenu menu  = (ApplicationMenu)control;
                    ApplicationMenu other = menu.customize(observer);
                    if (other != null)
                    {
                        added++;
                    }
                    else
                    {
                        controls.Add(menu);
                    }
                }
            }
            foreach (Control control in controls)
            {
                Items.Remove(control);
            }
            if (added <= 0)
            {
                return(null);
            }
            return(this);
        }