예제 #1
0
        public virtual void CustomizeForUser(EditorItem <T> page)
        {
            List <Right>      rights   = null;
            PrivilegeObserver observer = new PrivilegeObserver();

            if (!ApplicationManager.User.IsAdmin() && page.EditedObject.oid.HasValue)
            {
                RightService service = ApplicationManager.ControllerFactory.ServiceFactory.GetRightService();
                rights = service.getUserRights(this.SubjectType.label, page.EditedObject.oid.Value);
            }
            if (this.ToolBar != null)
            {
                this.ToolBar.Customize(this.FunctionalityCode, observer, rights, page.IsReadOnly);
            }
            if (this.SideBar != null)
            {
                this.SideBar.Customize(rights, page.IsReadOnly);
            }
            CustomizeContexMenu(observer, rights, page);

            bool edit = RightsUtil.HasRight(Domain.RightType.EDIT, rights);

            page.CanRename = edit && !page.IsReadOnly;
            page.CanSave   = edit;
        }
예제 #2
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();
        }
예제 #3
0
        /// <summary>
        /// Crée et rajoute la page d'édition d'un objet donné.
        /// </summary>
        /// <param name="anObject">L'objet dont la page doit être rejoutée</param>
        /// <returns>La page créée</returns>
        protected virtual EditorItem <T> addPage(T anObject, bool readOnly = false, List <Domain.Right> rights = null)
        {
            if (!ApplicationManager.Instance.User.IsAdmin() && anObject != null && anObject.oid.HasValue)
            {
                RightService service = ApplicationManager.Instance.ControllerFactory.ServiceFactory.GetRightService();
                rights = service.getUserRights(this.SubjectType.label, anObject.oid.Value);
            }

            EditorItem <T> page = getNewPage();

            if (readOnly)
            {
                page.SetReadOnly(readOnly);
            }
            page.ChangeEventHandler = this.ChangeEventHandler;
            page.EditedObject       = anObject;
            page.Title = anObject != null?anObject.ToString() : "";

            page.Customize(rights, readOnly);
            page.displayObject();
            page.IsActiveChanged += ActivePageChangedEventHandler;
            bool canAddNewPage = NewPage != null;

            if (canAddNewPage)
            {
                NewPage.IsActiveChanged -= newPageEventHandler;
            }

            try
            {
                if (canAddNewPage)
                {
                    this.Children.Remove(NewPage);
                }
                this.Children.Add(page);
                if (canAddNewPage)
                {
                    this.Children.Add(NewPage);
                }
            }
            catch (Exception)
            {
            }
            page.IsActive = true;
            if (canAddNewPage)
            {
                NewPage.IsActiveChanged += newPageEventHandler;
            }
            return(page);
        }