void appearanceController_CustomApplyAppearance(object sender, ApplyAppearanceEventArgs e) { if (e.AppearanceObject.Visibility == null || e.AppearanceObject.Visibility == ViewItemVisibility.Show) { if (View is ListView) { if (e.Item is ColumnWrapper) { if (!DataManipulationRight.CanRead(View.ObjectTypeInfo.Type, ((ColumnWrapper)e.Item).PropertyName, null, ((ListView)View).CollectionSource, View.ObjectSpace)) { e.AppearanceObject.Visibility = ViewItemVisibility.Hide; } } } if (View is DetailView) { if (e.Item is PropertyEditor) { if (!DataManipulationRight.CanRead(View.ObjectTypeInfo.Type, ((PropertyEditor)e.Item).PropertyName, e.ContextObjects.Length > 0 ? e.ContextObjects[0] : null, null, View.ObjectSpace)) { e.AppearanceObject.Visibility = ViewItemVisibility.Hide; } } } } }
Object FindObjectToOpen(GridColumn column, int rowHandle) { Object result = null; if (column != null && GridListEditor != null && GridListEditor.GridView() != null) { Object currObject = XtraGridUtils.GetRow(GridListEditor.GridView(), rowHandle); ITypeInfo typeInfo = currObject != null ? XafTypesInfo.Instance.FindTypeInfo(currObject.GetType()) : _listView.ObjectTypeInfo; IMemberInfo memberInfo = typeInfo.FindMember(column.FieldName); Object lastObject = null; if (GridListEditor.GridView().ActiveEditor != null) { lastObject = GridListEditor.GridView().ActiveEditor.EditValue; } else if (currObject != null && memberInfo != null) { lastObject = FindLastObject(currObject, memberInfo); } if (memberInfo != null && (IsDetailViewExists(lastObject) && DataManipulationRight.CanRead(typeInfo.Type, memberInfo.Name, currObject, LinkToListViewController.FindCollectionSource( Controller.Frame), ObjectSpace))) { result = lastObject; } } return(result); }
bool CanNotRead(string propertyName, object currentObject) { bool content = !(View.ObjectTypeInfo.FindMember(propertyName) == null || DataManipulationRight.CanRead(View.ObjectTypeInfo.Type, propertyName, null, View.CollectionSource, View.ObjectSpace)); var fit = ((MemberLevelObjectAccessComparer)ObjectAccessComparerBase.CurrentComparer).Fit(currentObject, View.ObjectTypeInfo.FindMember(propertyName), MemberOperation.Read); return(content && fit); }
protected virtual bool HasRights(ChoiceActionItem item, IModelView view) { var data = (ViewShortcut)item.Data; if (view == null) { throw new ArgumentException(string.Format("Cannot find the '{0}' view specified by the shortcut: {1}", data.ViewId, data)); } Type type = (view is IModelObjectView) ? ((IModelObjectView)view).ModelClass.TypeInfo.Type : null; if (type != null) { if (!string.IsNullOrEmpty(data.ObjectKey) && !data.ObjectKey.StartsWith("@")) { try { using (IObjectSpace space = CreateObjectSpace()) { object objectByKey = space.GetObjectByKey(type, space.GetObjectKey(type, data.ObjectKey)); return(DataManipulationRight.CanRead(type, null, objectByKey, null, space) && DataManipulationRight.CanNavigate(type, objectByKey, space)); } } catch { return(true); } } return(DataManipulationRight.CanNavigate(type, null, null)); } return(true); }
protected virtual bool HasRights(ChoiceActionItem item, IModelView view) { var data = (ViewShortcut)item.Data; if (view == null) { if (Application.GetPlatform() == Platform.Win) { throw new ArgumentException($"Cannot find the '{data.ViewId}' view specified by the shortcut: {data}"); } var webApi = Application.WhenWeb().Wait(); webApi.Redirect(webApi.GetRequestUri().GetLeftPart(UriPartial.Authority)); } var objectView = view as IModelObjectView; Type type = objectView?.ModelClass.TypeInfo.Type; if (type != null) { if (!string.IsNullOrEmpty(data.ObjectKey) && !data.ObjectKey.StartsWith("@")) { try { using IObjectSpace space = CreateObjectSpace(); object objectByKey = space.GetObjectByKey(type, space.GetObjectKey(type, data.ObjectKey)); return(DataManipulationRight.CanRead(type, null, objectByKey, null, space) && DataManipulationRight.CanNavigate(type, objectByKey, space)); } catch { return(true); } } return(DataManipulationRight.CanNavigate(type, null, null)); } return(true); }
bool GetCanRead(string name) { bool canRead = DataManipulationRight.CanRead(View.ObjectTypeInfo.Type, name, View.CurrentObject, null, View.ObjectSpace); bool fit = ((MemberLevelObjectAccessComparer)ObjectAccessComparerBase.CurrentComparer).Fit(View.CurrentObject, View.ObjectTypeInfo.FindMember(name), MemberOperation.Read); return(!fit || canRead); }
void CreateButtons(RepositoryItemGridLookUpEditEx properties) { properties.ButtonsStyle = BorderStyles.HotFlat; var editButton = CreatelButton("Action_Edit", "tooltipDetail", "DetailButtonTag"); editButton.Enabled = _lookup.EditValue != null; string info; editButton.Visible = DataManipulationRight.CanEdit(MemberInfo.MemberType, null, null, null, null) && DataManipulationRight.CanEdit(ObjectType, propertyName, CurrentObject, null, _helper.ObjectSpace); properties.Buttons.Add(editButton); var newButton = CreatelButton("MenuBar_New", "tooltipNew", "AddButtonTag"); newButton.Visible = DataManipulationRight.CanCreate(null, MemberInfo.MemberType, null, out info); properties.Buttons.Add(newButton); var clearButton = CreatelButton("Action_Clear", "tooltipClear", "MinusButtonTag"); clearButton.Enabled = editButton.Enabled; if (!editButton.Visible) { properties.ReadOnly = true; clearButton.Visible = false; newButton.Visible = false; } properties.Buttons.Add(clearButton); _lookup.EditValueChanged += (sender, args) => { editButton.Enabled = _lookup.EditValue != null && AllowEdit.ResultValue; clearButton.Enabled = editButton.Enabled; }; }
protected override void OnActivated() { base.OnActivated(); var bussinessObjectType = XafTypesInfo.Instance.FindBussinessObjectType(typeof(ISerializationConfigurationGroup)); _ioAction.Active["Security"] = DataManipulationRight.CanRead(bussinessObjectType, null, null, null, ObjectSpace); }
private SimpleAction CreateSimpleTransitionAction(IStateMachine stateMachine, ChoiceActionItem transitionItem) { var simpleAction = new SimpleAction(this, Guid.NewGuid( ).ToString( ), PredefinedCategory.Edit /*, "StateMachineActions"*/); simpleAction.Enabled["ViewIsInEditMode"] = (( DetailView )View).ViewEditMode == ViewEditMode.Edit; simpleAction.Enabled["EnabledBySecurity"] = DataManipulationRight.CanEdit(stateMachine.TargetObjectType, stateMachine.StatePropertyName, View.CurrentObject, null, View.ObjectSpace); simpleAction.Tag = transitionItem; simpleAction.Caption = transitionItem.Caption; simpleAction.Execute += SimpleAction_Execute; return(simpleAction); }
public override void UpdateOpenObjectActionState(object objectToOpen) { base.UpdateOpenObjectActionState(objectToOpen); if (objectToOpen != null) { OpenObjectAction.Enabled[HasReadPermissionToTargetObjectEnabledKey] = DataManipulationRight.CanRead(objectToOpen.GetType(), null, objectToOpen, LinkToListViewController.FindCollectionSource(Controller.Frame), ObjectSpace); } }
private void UpdateActionState( ) { string diagnosticInfo; addFromFileAction.Enabled.SetItemValue("Security", DataManipulationRight.CanCreate(View, View.ObjectTypeInfo.Type, LinkToListViewController.FindCollectionSource(Frame), out diagnosticInfo)); if (View != null && View.IsRoot) { addFromFileAction.Enabled.SetItemValue("ObjectSpaceNotModified", !ObjectSpace.IsModified); } else { addFromFileAction.Enabled.RemoveItem("ObjectSpaceNotModified"); } }
private void UpdateDropDownLookupControlAddButton(ASPxSearchDropDownEdit control) { control.AddingEnabled = false; if (CurrentObject != null) { string diagnosticInfo = ""; RecreateListView(true); control.AddingEnabled = AllowEdit && DataManipulationRight.CanCreate(listView, helper.LookupObjectType, listView.CollectionSource, out diagnosticInfo); if (control.AddingEnabled) { if (newObjectViewController != null) { control.AddingEnabled = newObjectViewController.NewObjectAction.Active && newObjectViewController.NewObjectAction.Enabled; } } } }
public override void OnControllerActivated() { base.OnControllerActivated(); _listView = (ListView)Controller.View; OpenObjectAction.Active[ DevExpress.ExpressApp.Win.SystemModule.OpenObjectController.ActiveKeyHasReadPermissionToTargetType] = DataManipulationRight.CanRead(_listView.ObjectTypeInfo.Type, null, null, _listView.CollectionSource, ObjectSpace); bool hasObjectRefControl = false; if (_listView.Model != null) { if ( _listView.Model.Columns.Select( columnInfo => _listView.ObjectTypeInfo.FindMember(columnInfo.PropertyName)).Any( findMember => findMember != null && IsDetailViewExists(findMember.MemberType))) { hasObjectRefControl = true; } } OpenObjectAction.Active[ViewContainsObjectEditorActiveKey] = hasObjectRefControl; _listView.ControlsCreated += listView_ControlsCreated; }
protected internal virtual void UpdateActionState( ) { if (!StateMachineCacheController.Active) { StateMachineCacheController.Activated += StateMachineCacheController_Activated; } else { stateMachineAction.Items.Clear( ); var detailView = View as DetailView; ISupportUpdate supportUpdate = null; try { if (detailView != null) { supportUpdate = detailView.LayoutManager.Container as ISupportUpdate; if (supportUpdate != null) { supportUpdate.BeginUpdate( ); } ResetActionsPanel( ); } object targetObject = View.SelectedObjects.Count == 1 ? View.SelectedObjects[0] : null; if (targetObject != null) { foreach (var stateMachine in GetStateMachines( )) { IState currentState = stateMachine.FindCurrentState(targetObject); if (currentState != null && currentState.Transitions.Count > 0) { var choiceActionItem = new ChoiceActionItem(stateMachine.Name, stateMachine); choiceActionItem.Enabled["EnabledBySecurity"] = DataManipulationRight.CanEdit(stateMachine.TargetObjectType, stateMachine.StatePropertyName, targetObject, null, View.ObjectSpace); stateMachineAction.Items.Add(choiceActionItem); foreach (var transition in GetOrderedTransitions(currentState.Transitions)) { choiceActionItem.Items.Add(new ChoiceActionItem(transition.Caption, transition)); } if (View is DetailView && stateMachine is IStateMachineUISettings && (( IStateMachineUISettings )stateMachine).ExpandActionsInDetailView) { IntializeActionsPanel(stateMachine, choiceActionItem.Items); } } } } if (detailView != null) { stateMachineAction.Enabled["ViewIsInEditMode"] = detailView.ViewEditMode == ViewEditMode.Edit; bool flag = true; foreach (string id in panelActions.Keys) { if (!(detailView.FindItem(id) is ActionContainerViewItem)) { flag = false; break; } } if (flag) { RegisterActionsInPanelContainers(detailView); } else { if (!detailView.IsControlCreated) { return; } View.BreakLinksToControls( ); View.LoadModel( ); View.CreateControls( ); } } else { stateMachineAction.Enabled.RemoveItem("ViewIsInEditMode"); } } finally { if (supportUpdate != null) { supportUpdate.EndUpdate( ); } } } }
bool CanNotWrite(string fieldName, object baseObject) { return(!(View.ObjectTypeInfo.FindMember(fieldName) == null || DataManipulationRight.CanEdit(View.ObjectTypeInfo.Type, fieldName, baseObject, null, View.ObjectSpace))); }