protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericDeleteDataWorkflow"), this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
public string CustomFormMarkupPath { get; internal set; } // Optional /// <exclude /> protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { var payload = new StringBuilder(); this.Serialize(payload); StringConversionServices.SerializeKeyValuePair(payload, "_IconResourceName_", Icon.ResourceName); if (!String.IsNullOrEmpty(CustomFormMarkupPath)) { StringConversionServices.SerializeKeyValuePair(payload, "_CustomFormMarkupPath_", CustomFormMarkupPath); actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericEditDataWorkflow"), this.PermissionTypes) { Payload = payload.ToString() })) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); } else { actionAdder(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Edit, this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); } }
protected override IEnumerable <Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext) { var entityToken = new TreeSimpleElementEntityToken( this.Id, this.Tree.TreeId, EntityTokenSerializer.Serialize(parentEntityToken)); Element element = new Element(new ElementHandle( dynamicContext.ElementProviderName, entityToken, dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken) )); if (parentEntityToken is TreePerspectiveEntityToken) { element.ElementHandle.Piggyback[StringConstants.PiggybagTreeId] = Tree.TreeId; } var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag); element.VisualData = new ElementVisualizedData { Label = this.LabelDynamicValuesHelper.ReplaceValues(replaceContext), ToolTip = this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext), HasChildren = ChildNodes.Any(), Icon = this.Icon, OpenedIcon = this.OpenIcon }; yield return(element); }
protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { string url = this.UrlDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext); this.External = url.Contains("://"); if(!External) { url = UrlUtils.ResolvePublicUrl(url); } CustomUrlActionNodeActionToken actionToken = new CustomUrlActionNodeActionToken( url, this.External, (this.External ? "externalview" : "documentview"), this.ViewLabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.ViewToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.Serialize(), this.PermissionTypes); ElementAction elementAction = new ElementAction(new ActionHandle(actionToken)) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }; actionAdder(elementAction); }
/// <exclude /> public string ReplaceValues(DynamicValuesHelperReplaceContext context) { string currentValue = this.Template; if (this.DataFieldValueHelper != null) { currentValue = this.DataFieldValueHelper.ReplaceValues(currentValue, context.PiggybagDataFinder, context.CurrentDataItem, this.UseUrlEncode); } if (currentValue.Contains(CurrentEntityTokenMask)) { string serializedEntityToken = context.CurrentEntityToken != null ? EntityTokenSerializer.Serialize(context.CurrentEntityToken) : "(null)"; if (this.UseUrlEncode) { serializedEntityToken = HttpUtility.UrlEncode(serializedEntityToken); } currentValue = currentValue.Replace(CurrentEntityTokenMask, serializedEntityToken); } return(StringResourceSystemFacade.ParseString(currentValue)); }
/// <exclude /> protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { Icon = new ResourceHandle(BuildInIconProviderName.ProviderName, "copy"); actionAdder(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Duplicate,this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
/// <exclude /> protected ActionVisualizedData CreateActionVisualizedData(DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { return new ActionVisualizedData { Label = this.LabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), ToolTip = this.ToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), Icon = this.Icon, Disabled = false, ActionLocation = this.Location }; }
/// <exclude /> protected ActionVisualizedData CreateActionVisualizedData(DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { return(new ActionVisualizedData { Label = this.LabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), ToolTip = this.ToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), Icon = this.Icon, Disabled = false, ActionLocation = this.Location }); }
/// <exclude /> public void AddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext) { var piggybag = dynamicContext.Piggybag; if (!entityToken.Equals(dynamicContext.CurrentEntityToken)) { piggybag = piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken); } var replaceContext = new DynamicValuesHelperReplaceContext(entityToken, piggybag); OnAddAction(actionAdder, entityToken, dynamicContext, replaceContext); }
/// <exclude /> public XElement ReplaceValues(DynamicValuesHelperReplaceContext context) { XElement result = new XElement(this.Element); foreach (XAttribute attribute in GetAttributes(result)) { DynamicValuesHelper dynamicValuesHelper = _dynamicValuesHelpers[GetKeyValue(attribute)]; string newValue = dynamicValuesHelper.ReplaceValues(context); attribute.SetValue(newValue); } return(result); }
public Type WorkflowType { get; internal set; } // Requried protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { WorkflowActionToken actionToken = new WorkflowActionToken( WorkflowFacade.GetWorkflowType(TypeManager.SerializeType(this.WorkflowType)), this.PermissionTypes) { Payload = this.Serialize(), ExtraPayload = PiggybagSerializer.Serialize(dynamicContext.Piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken)), DoIgnoreEntityTokenLocking = true }; actionAdder(new ElementAction(new ActionHandle(actionToken)) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
/// <exclude /> protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { var payload = new StringBuilder(); this.Serialize(payload); if (this.ParentIdEntries.Count > 0) { List<EntityToken> entityTokens = dynamicContext.Piggybag.GetParentEntityTokens().ToList(); entityTokens.Reverse(); entityTokens.Add(dynamicContext.CurrentEntityToken); entityTokens.Add(entityToken); entityTokens.Reverse(); foreach (ParentIdEntry parentIdEntry in this.ParentIdEntries) { DataEntityToken dataEntityToken = entityTokens.FindDataEntityToken(parentIdEntry.TargetInterface); if (dataEntityToken == null) continue; IData data = dataEntityToken.Data; object keyValue = parentIdEntry.TargetPropertyInfo.GetValue(data, null); StringConversionServices.SerializeKeyValuePair(payload, parentIdEntry.SourcePropertyName, keyValue); } } StringConversionServices.SerializeKeyValuePair(payload, "_InterfaceType_", InterfaceType); StringConversionServices.SerializeKeyValuePair(payload, "_IconResourceName_", Icon.ResourceName); if (!String.IsNullOrEmpty(CustomFormMarkupPath)) { StringConversionServices.SerializeKeyValuePair(payload, "_CustomFormMarkupPath_", CustomFormMarkupPath); } actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericAddDataWorkflow"), this.PermissionTypes) { Payload = payload.ToString(), DoIgnoreEntityTokenLocking = true, ExtraPayload = PiggybagSerializer.Serialize(dynamicContext.Piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken)) })) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { ActionToken actionToken = new MessageBoxActionNodeActionToken( this.TitleDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.MessageDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.Serialize(), this.PermissionTypes ); ElementAction elementAction = new ElementAction(new ActionHandle(actionToken)) { VisualData = this.CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }; elementAction.VisualData.ActionLocation = this.Location; actionAdder(elementAction); }
public override Expression CreateUpwardsFilterExpression(ParameterExpression parameterExpression, TreeNodeDynamicContext dynamicContext) { DataEntityToken currentEntityToken = dynamicContext.CurrentEntityToken as DataEntityToken; IData filteredDataItem = null; Func<IData, bool> upwardsFilter = dataItem => { var ancestorEntityToken = dataItem.GetDataEntityToken(); var replaceContext = new DynamicValuesHelperReplaceContext { CurrentDataItem = dataItem, CurrentEntityToken = ancestorEntityToken, PiggybagDataFinder = new PiggybagDataFinder(dynamicContext.Piggybag, ancestorEntityToken) }; XElement markup = this.FunctionMarkupDynamicValuesHelper.ReplaceValues(replaceContext); BaseRuntimeTreeNode baseRuntimeTreeNode = FunctionTreeBuilder.Build(markup); LambdaExpression expression = GetLambdaExpression(baseRuntimeTreeNode); if (expression.Parameters.Count != 1) { throw new InvalidOperationException("Only 1 parameter lamdas supported when calling function: " + markup); } Delegate compiledExpression = expression.Compile(); if (filteredDataItem == null) { filteredDataItem = currentEntityToken.Data; } return (bool)compiledExpression.DynamicInvoke(filteredDataItem); }; return upwardsFilter.Target != null ? Expression.Call(Expression.Constant(upwardsFilter.Target), upwardsFilter.Method, parameterExpression) : Expression.Call(upwardsFilter.Method, parameterExpression); }
public override Expression CreateUpwardsFilterExpression(ParameterExpression parameterExpression, TreeNodeDynamicContext dynamicContext) { DataEntityToken currentEntityToken = dynamicContext.CurrentEntityToken as DataEntityToken; IData filteredDataItem = null; Func <IData, bool> upwardsFilter = dataItem => { var ancestorEntityToken = dataItem.GetDataEntityToken(); var replaceContext = new DynamicValuesHelperReplaceContext { CurrentDataItem = dataItem, CurrentEntityToken = ancestorEntityToken, PiggybagDataFinder = new PiggybagDataFinder(dynamicContext.Piggybag, ancestorEntityToken) }; XElement markup = this.FunctionMarkupDynamicValuesHelper.ReplaceValues(replaceContext); BaseRuntimeTreeNode baseRuntimeTreeNode = FunctionTreeBuilder.Build(markup); LambdaExpression expression = GetLambdaExpression(baseRuntimeTreeNode); if (expression.Parameters.Count != 1) { throw new InvalidOperationException("Only 1 parameter lamdas supported when calling function: " + markup); } Delegate compiledExpression = expression.Compile(); if (filteredDataItem == null) { filteredDataItem = currentEntityToken.Data; } return((bool)compiledExpression.DynamicInvoke(filteredDataItem)); }; return(upwardsFilter.Target != null ? Expression.Call(Expression.Constant(upwardsFilter.Target), upwardsFilter.Method, parameterExpression) : Expression.Call(upwardsFilter.Method, parameterExpression)); }
/// <exclude /> protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { StringBuilder payload = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(payload, "TreeId", this.OwnerNode.Tree.TreeId); StringConversionServices.SerializeKeyValuePair(payload, "ActionId", this.Id); WorkflowActionToken actionToken = new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.ReportFunctionActionWorkflow"), this.PermissionTypes) { Payload = this.Serialize(), ExtraPayload = PiggybagSerializer.Serialize(dynamicContext.Piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken)), DoIgnoreEntityTokenLocking = true }; actionAdder(new ElementAction(new ActionHandle(actionToken)) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
public override Expression CreateDownwardsFilterExpression(ParameterExpression parameterExpression, TreeNodeDynamicContext dynamicContext) { var replaceContext = new DynamicValuesHelperReplaceContext(dynamicContext.CurrentEntityToken, dynamicContext.Piggybag); XElement markup = this.FunctionMarkupDynamicValuesHelper.ReplaceValues(replaceContext); BaseRuntimeTreeNode baseRuntimeTreeNode = FunctionTreeBuilder.Build(markup); LambdaExpression expression = GetLambdaExpression(baseRuntimeTreeNode); if (expression.Parameters.Count != 1) { throw new InvalidOperationException("Only 1 parameter lamdas supported when calling function: " + markup); } ParameterChangerExpressionVisitor expressionVisitor = new ParameterChangerExpressionVisitor(expression.Parameters.Single(), parameterExpression); Expression resultExpression = expressionVisitor.Visit(expression.Body); return resultExpression; }
public override Expression CreateDownwardsFilterExpression(ParameterExpression parameterExpression, TreeNodeDynamicContext dynamicContext) { var replaceContext = new DynamicValuesHelperReplaceContext(dynamicContext.CurrentEntityToken, dynamicContext.Piggybag); XElement markup = this.FunctionMarkupDynamicValuesHelper.ReplaceValues(replaceContext); BaseRuntimeTreeNode baseRuntimeTreeNode = FunctionTreeBuilder.Build(markup); LambdaExpression expression = GetLambdaExpression(baseRuntimeTreeNode); if (expression.Parameters.Count != 1) { throw new InvalidOperationException("Only 1 parameter lamdas supported when calling function: " + markup); } ParameterChangerExpressionVisitor expressionVisitor = new ParameterChangerExpressionVisitor(expression.Parameters.Single(), parameterExpression); Expression resultExpression = expressionVisitor.Visit(expression.Body); return(resultExpression); }
/// <exclude /> protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { StringBuilder payload = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(payload, "TreeId", this.OwnerNode.Tree.TreeId); StringConversionServices.SerializeKeyValuePair(payload, "ActionId", this.Id); WorkflowActionToken actionToken = new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.ReportFunctionActionWorkflow"), this.PermissionTypes) { Payload = this.Serialize(), ExtraPayload = PiggybagSerializer.Serialize(dynamicContext.Piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken)), DoIgnoreEntityTokenLocking = true }; actionAdder(new ElementAction(new ActionHandle(actionToken)) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
} // Requried protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { WorkflowActionToken actionToken = new WorkflowActionToken( WorkflowFacade.GetWorkflowType(TypeManager.SerializeType(this.WorkflowType)), this.PermissionTypes) { Payload = this.Serialize(), ExtraPayload = PiggybagSerializer.Serialize(dynamicContext.Piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken)), DoIgnoreEntityTokenLocking = true }; actionAdder(new ElementAction(new ActionHandle(actionToken)) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
protected override IEnumerable <Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext) { var entityToken = new TreeSimpleElementEntityToken( this.Id, this.Tree.TreeId, EntityTokenSerializer.Serialize(parentEntityToken)); var element = new Element(new ElementHandle( dynamicContext.ElementProviderName, entityToken, dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken) )); if (this.BrowserUrl != null) { var url = this.BrowserUrl; if (!url.Contains("//")) { url = Core.WebClient.UrlUtils.ResolvePublicUrl(url); } element.PropertyBag.Add("BrowserUrl", url); element.PropertyBag.Add("BrowserToolingOn", "false"); } if (this.BrowserImage != null) { var url = this.BrowserImage; if (!url.Contains("//")) { url = Core.WebClient.UrlUtils.ResolvePublicUrl(url); } element.PropertyBag.Add("ListViewImage", url); if (this.BrowserUrl == null) { element.PropertyBag.Add("DetailViewImage", url); } } if (parentEntityToken is TreePerspectiveEntityToken) { element.ElementHandle.Piggyback[StringConstants.PiggybagTreeId] = Tree.TreeId; } var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag); element.VisualData = new ElementVisualizedData { Label = this.LabelDynamicValuesHelper.ReplaceValues(replaceContext), ToolTip = this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext), HasChildren = ChildNodes.Any(), Icon = this.Icon, OpenedIcon = this.OpenIcon }; yield return(element); }
protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericDeleteDataWorkflow"), this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
/// <exclude /> protected abstract void OnAddAction(Action <ElementAction> actionAdder, EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext);
private Element BuildElement(IData data, DynamicValuesHelperReplaceContext replaceContext, TreeNodeDynamicContext dynamicContext, bool localizationEnabled, List<object> itemKeys, ref IEnumerable<object> keysJoinedByParentFilters, EntityToken parentEntityToken ) { replaceContext.CurrentDataItem = data; object keyValue = this.KeyPropertyInfo.GetValue(data, null); bool itemLocalizationEnabledAndForeign = localizationEnabled && !data.DataSourceId.LocaleScope.Equals(UserSettings.ActiveLocaleCultureInfo); if (itemLocalizationEnabledAndForeign && itemKeys.Contains(keyValue)) return null; var currentEntityToken = data.GetDataEntityToken(); var element = new Element(new ElementHandle ( dynamicContext.ElementProviderName, currentEntityToken, dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken) )); bool hasChildren; bool isDisabled = false; ResourceHandle icon, openedIcon; if (itemLocalizationEnabledAndForeign) { hasChildren = false; isDisabled = !data.IsTranslatable(); if (this.Icon != null) { icon = this.Icon; openedIcon = this.OpenedIcon; } else { icon = data.GetForeignIcon(); openedIcon = icon; } } else { if (this.Display != LeafDisplayMode.Auto) { hasChildren = ChildNodes.Any(); } else { hasChildren = ChildNodes.OfType<SimpleElementTreeNode>().Any(); if (!hasChildren) { if (keysJoinedByParentFilters != null) { keysJoinedByParentFilters = keysJoinedByParentFilters.Evaluate(); hasChildren = keysJoinedByParentFilters.Contains(keyValue); } } // Checking children filtered by FunctionFilters if (!hasChildren) { foreach (var childNode in this.ChildNodes.OfType<DataElementsTreeNode>() .Where(n => n.FilterNodes.OfType<FunctionFilterNode>().Any())) { var newDynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down) { ElementProviderName = dynamicContext.ElementProviderName, Piggybag = dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken), CurrentEntityToken = currentEntityToken }; if (childNode.GetDataset(newDynamicContext, false).DataItems.Any()) { hasChildren = true; break; } } } } if (this.Icon != null) { icon = this.Icon; openedIcon = this.OpenedIcon; } else { openedIcon = icon = data.GetIcon(); } } string label = this.Label.IsNullOrEmpty() ? data.GetLabel() : this.LabelDynamicValuesHelper.ReplaceValues(replaceContext); string toolTip = this.ToolTip.IsNullOrEmpty() ? label : this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext); if (itemLocalizationEnabledAndForeign) { label = string.Format("{0} ({1})", label, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo)); if (!data.IsTranslatable()) { toolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.DisabledData"); } else { toolTip = string.Format("{0} ({1})", toolTip, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo)); } } element.VisualData = new ElementVisualizedData { Label = label, ToolTip = toolTip, HasChildren = hasChildren, Icon = icon, OpenedIcon = openedIcon, IsDisabled = isDisabled }; if (InternalUrls.DataTypeSupported(data.DataSourceId.InterfaceType)) { var dataReference = data.ToDataReference(); if (DataUrls.CanBuildUrlForData(dataReference)) { string internalUrl = InternalUrls.TryBuildInternalUrl(dataReference); if (internalUrl != null) { element.PropertyBag.Add("Uri", internalUrl); } } } if (itemLocalizationEnabledAndForeign) { var actionToken = new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.LocalizeDataWorkflow"), LocalizeDataPermissionTypes); element.AddAction(new ElementAction(new ActionHandle(actionToken)) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataToolTip"), Icon = LocalizeDataTypeIcon, Disabled = false, ActionLocation = ActionLocation.OtherPrimaryActionLocation } }); } return element; }
} // Optional /// <exclude /> protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { var payload = new StringBuilder(); this.Serialize(payload); StringConversionServices.SerializeKeyValuePair(payload, "_IconResourceName_", Icon.ResourceName); if (!String.IsNullOrEmpty(CustomFormMarkupPath)) { StringConversionServices.SerializeKeyValuePair(payload, "_CustomFormMarkupPath_", CustomFormMarkupPath); actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericEditDataWorkflow"), this.PermissionTypes) { Payload = payload.ToString() })) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); } else { actionAdder(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Edit, this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); } }
/// <exclude /> public string ReplaceValues(DynamicValuesHelperReplaceContext context) { string currentValue = this.Template; if (this.DataFieldValueHelper != null) { currentValue = this.DataFieldValueHelper.ReplaceValues(currentValue, context.PiggybagDataFinder, context.CurrentDataItem, this.UseUrlEncode); } if (currentValue.Contains(CurrentEntityTokenMask)) { string serializedEntityToken = context.CurrentEntityToken != null ? EntityTokenSerializer.Serialize(context.CurrentEntityToken) : "(null)"; if (this.UseUrlEncode) { serializedEntityToken = HttpUtility.UrlEncode(serializedEntityToken); } currentValue = currentValue.Replace(CurrentEntityTokenMask, serializedEntityToken); } return StringResourceSystemFacade.ParseString(currentValue); }
protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { ActionToken actionToken = new MessageBoxActionNodeActionToken( this.TitleDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.MessageDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.Serialize(), this.PermissionTypes ); ElementAction elementAction = new ElementAction(new ActionHandle(actionToken)) { VisualData = this.CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }; elementAction.VisualData.ActionLocation = this.Location; actionAdder(elementAction); }
/// <exclude /> protected abstract void OnAddAction(Action<ElementAction> actionAdder, EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext);
private static void DoInitialize(string elementAttachingProviderName) { var sharedRootFolders = new Dictionary <string, CustomTreePerspectiveInfo>(); var treeNodeDynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down); treeNodeDynamicContext.Piggybag = new Dictionary <string, string>(); foreach (var tree in TreeFacade.AllTrees) { if (!tree.ShareRootElementById) { continue; } IEnumerable <NamedAttachmentPoint> namedAttachmentPoints = tree.AttachmentPoints. OfType <NamedAttachmentPoint>(); if (namedAttachmentPoints.Count() != 1) { continue; } if (tree.RootTreeNode.ChildNodes.Count() != 1) { continue; } SimpleElementTreeNode childTreeNode = tree.RootTreeNode.ChildNodes.Single() as SimpleElementTreeNode; if (childTreeNode == null) { continue; } NamedAttachmentPoint namedAttachmentPoint = namedAttachmentPoints.Single(); EntityToken perspectiveEntityToken; if (!sharedRootFolders.ContainsKey(childTreeNode.Id)) { perspectiveEntityToken = new TreePerspectiveEntityToken(childTreeNode.Id); var dynamicValuesHelperReplaceContext = new DynamicValuesHelperReplaceContext( namedAttachmentPoint.AttachingPoint.EntityToken, null); // MRJ: Collection actions Element element = new Element(new ElementHandle(elementAttachingProviderName, perspectiveEntityToken)) { VisualData = new ElementVisualizedData { Label = childTreeNode.LabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), ToolTip = childTreeNode.ToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), HasChildren = true, Icon = childTreeNode.Icon, OpenedIcon = childTreeNode.OpenIcon } }; sharedRootFolders.Add(childTreeNode.Id, new CustomTreePerspectiveInfo { AttachmentPoint = new NamedAttachmentPoint { AttachingPoint = new AttachingPoint(namedAttachmentPoint.AttachingPoint), Position = namedAttachmentPoint.Position }, Element = element, Trees = new List <Tree> { tree } }); } else { perspectiveEntityToken = sharedRootFolders[childTreeNode.Id].Element.ElementHandle.EntityToken; sharedRootFolders[childTreeNode.Id].Trees.Add(tree); } namedAttachmentPoint.AttachingPoint = new AttachingPoint(perspectiveEntityToken); tree.RootTreeNode = childTreeNode; } _sharedRootFolders = sharedRootFolders; }
/// <exclude /> protected override IEnumerable <Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext) { bool localizationEnabled = this.ShowForeignItems && !UserSettings.ActiveLocaleCultureInfo.Equals(UserSettings.ForeignLocaleCultureInfo); NodeDataSet dataset = GetDataset(dynamicContext); var itemKeys = new List <object>(); IEnumerable <IData> dataItems; IEnumerable <object> keysJoinedByParentFilters = dataset.JoinedKeys; if (localizationEnabled && UserSettings.ForeignLocaleCultureInfo != null) { NodeDataSet foreignDataset; using (new DataScope(UserSettings.ForeignLocaleCultureInfo)) { foreignDataset = GetDataset(dynamicContext); } ParameterExpression parameterExpression = Expression.Parameter(this.InterfaceType, "data"); IEnumerable combinedData = dataset.DataItems.Concat(foreignDataset.DataItems).ToCastedDataEnumerable(this.InterfaceType); Expression orderByExpression = this.CreateOrderByExpression(combinedData.AsQueryable().Expression, parameterExpression); dataItems = combinedData.AsQueryable().Provider.CreateQuery <IData>(orderByExpression); foreach (IData data in dataset.DataItems) { Verify.IsNotNull(data, "Fetching data for data interface '{0}' with expression '{1}' yielded an null element".FormatWith(this.InterfaceType, orderByExpression)); object keyValue = this.KeyPropertyInfo.GetValue(data, null); itemKeys.Add(keyValue); } keysJoinedByParentFilters = keysJoinedByParentFilters.ConcatOrDefault(foreignDataset.JoinedKeys); } else { dataItems = dataset.DataItems; itemKeys = new List <object>(); } var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag); var elements = new List <Element>(); foreach (IData data in dataItems) { Verify.IsNotNull(data, "Fetching data for data interface '{0}' yielded an null element".FormatWith(this.InterfaceType)); var element = BuildElement(data, replaceContext, dynamicContext, localizationEnabled, itemKeys, ref keysJoinedByParentFilters, parentEntityToken); if (element == null) { continue; } elements.Add(element); } if (!this.OrderByNodes.Any()) { return(elements.OrderBy(f => f.VisualData.Label)); } return(elements); }
/// <exclude /> protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { var payload = new StringBuilder(); this.Serialize(payload); if (this.ParentIdEntries.Count > 0) { List <EntityToken> entityTokens = dynamicContext.Piggybag.GetParentEntityTokens().ToList(); entityTokens.Reverse(); entityTokens.Add(dynamicContext.CurrentEntityToken); entityTokens.Add(entityToken); entityTokens.Reverse(); foreach (ParentIdEntry parentIdEntry in this.ParentIdEntries) { DataEntityToken dataEntityToken = entityTokens.FindDataEntityToken(parentIdEntry.TargetInterface); if (dataEntityToken == null) { continue; } IData data = dataEntityToken.Data; object keyValue = parentIdEntry.TargetPropertyInfo.GetValue(data, null); StringConversionServices.SerializeKeyValuePair(payload, parentIdEntry.SourcePropertyName, keyValue); } } StringConversionServices.SerializeKeyValuePair(payload, "_InterfaceType_", InterfaceType); StringConversionServices.SerializeKeyValuePair(payload, "_IconResourceName_", Icon.ResourceName); if (!String.IsNullOrEmpty(CustomFormMarkupPath)) { StringConversionServices.SerializeKeyValuePair(payload, "_CustomFormMarkupPath_", CustomFormMarkupPath); } actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericAddDataWorkflow"), this.PermissionTypes) { Payload = payload.ToString(), DoIgnoreEntityTokenLocking = true, ExtraPayload = PiggybagSerializer.Serialize(dynamicContext.Piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken)) })) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
private Element BuildElement(IData data, DynamicValuesHelperReplaceContext replaceContext, TreeNodeDynamicContext dynamicContext, bool localizationEnabled, List <object> itemKeys, ref IEnumerable <object> keysJoinedByParentFilters, EntityToken parentEntityToken ) { replaceContext.CurrentDataItem = data; object keyValue = this.KeyPropertyInfo.GetValue(data, null); bool itemLocalizationEnabledAndForeign = localizationEnabled && !data.DataSourceId.LocaleScope.Equals(UserSettings.ActiveLocaleCultureInfo); if (itemLocalizationEnabledAndForeign && itemKeys.Contains(keyValue)) { return(null); } var currentEntityToken = data.GetDataEntityToken(); var element = new Element(new ElementHandle ( dynamicContext.ElementProviderName, currentEntityToken, dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken) )); bool hasChildren; bool isDisabled = false; ResourceHandle icon, openedIcon; if (itemLocalizationEnabledAndForeign) { hasChildren = false; isDisabled = !data.IsTranslatable(); if (this.Icon != null) { icon = this.Icon; openedIcon = this.OpenedIcon; } else { icon = data.GetForeignIcon(); openedIcon = icon; } } else { if (this.Display != LeafDisplayMode.Auto) { hasChildren = ChildNodes.Any(); } else { hasChildren = ChildNodes.OfType <SimpleElementTreeNode>().Any(); if (!hasChildren) { if (keysJoinedByParentFilters != null) { keysJoinedByParentFilters = keysJoinedByParentFilters.Evaluate(); hasChildren = keysJoinedByParentFilters.Contains(keyValue); } } // Checking children filtered by FunctionFilters if (!hasChildren) { foreach (var childNode in this.ChildNodes.OfType <DataElementsTreeNode>() .Where(n => n.FilterNodes.OfType <FunctionFilterNode>().Any())) { var newDynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down) { ElementProviderName = dynamicContext.ElementProviderName, Piggybag = dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken), CurrentEntityToken = currentEntityToken }; if (childNode.GetDataset(newDynamicContext, false).DataItems.Any()) { hasChildren = true; break; } } } } if (this.Icon != null) { icon = this.Icon; openedIcon = this.OpenedIcon; } else { openedIcon = icon = data.GetIcon(); } } string label = this.Label.IsNullOrEmpty() ? data.GetLabel() : this.LabelDynamicValuesHelper.ReplaceValues(replaceContext); string toolTip = this.ToolTip.IsNullOrEmpty() ? label : this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext); if (itemLocalizationEnabledAndForeign) { label = string.Format("{0} ({1})", label, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo)); if (!data.IsTranslatable()) { toolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.DisabledData"); } else { toolTip = string.Format("{0} ({1})", toolTip, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo)); } } element.VisualData = new ElementVisualizedData { Label = label, ToolTip = toolTip, HasChildren = hasChildren, Icon = icon, OpenedIcon = openedIcon, IsDisabled = isDisabled }; if (InternalUrls.DataTypeSupported(data.DataSourceId.InterfaceType)) { var dataReference = data.ToDataReference(); if (DataUrls.CanBuildUrlForData(dataReference)) { string internalUrl = InternalUrls.TryBuildInternalUrl(dataReference); if (internalUrl != null) { element.PropertyBag.Add("Uri", internalUrl); } } } if (itemLocalizationEnabledAndForeign) { var actionToken = new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.LocalizeDataWorkflow"), LocalizeDataPermissionTypes); element.AddAction(new ElementAction(new ActionHandle(actionToken)) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataToolTip"), Icon = LocalizeDataTypeIcon, Disabled = false, ActionLocation = ActionLocation.OtherPrimaryActionLocation } }); } return(element); }
/// <exclude /> public void AddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext) { var piggybag = dynamicContext.Piggybag; if (!entityToken.Equals(dynamicContext.CurrentEntityToken)) { piggybag = piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken); } var replaceContext = new DynamicValuesHelperReplaceContext(entityToken, piggybag); OnAddAction(actionAdder, entityToken, dynamicContext, replaceContext); }
private static void DoInitialize(string elementAttachingProviderName) { var sharedRootFolders = new Dictionary<string, CustomTreePerspectiveInfo>(); var treeNodeDynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down); treeNodeDynamicContext.Piggybag = new Dictionary<string, string>(); foreach (var tree in TreeFacade.AllTrees) { if (!tree.ShareRootElementById) continue; IEnumerable<NamedAttachmentPoint> namedAttachmentPoints = tree.AttachmentPoints. OfType<NamedAttachmentPoint>(); if (namedAttachmentPoints.Count() != 1) continue; if (tree.RootTreeNode.ChildNodes.Count() != 1) continue; SimpleElementTreeNode childTreeNode = tree.RootTreeNode.ChildNodes.Single() as SimpleElementTreeNode; if (childTreeNode == null) continue; NamedAttachmentPoint namedAttachmentPoint = namedAttachmentPoints.Single(); EntityToken perspectiveEntityToken; if (!sharedRootFolders.ContainsKey(childTreeNode.Id)) { perspectiveEntityToken = new TreePerspectiveEntityToken(childTreeNode.Id); var dynamicValuesHelperReplaceContext = new DynamicValuesHelperReplaceContext( namedAttachmentPoint.AttachingPoint.EntityToken, null); // MRJ: Collection actions Element element = new Element(new ElementHandle(elementAttachingProviderName, perspectiveEntityToken)) { VisualData = new ElementVisualizedData { Label = childTreeNode.LabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), ToolTip = childTreeNode.ToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), HasChildren = true, Icon = childTreeNode.Icon, OpenedIcon = childTreeNode.OpenIcon } }; sharedRootFolders.Add(childTreeNode.Id, new CustomTreePerspectiveInfo { AttachmentPoint = new NamedAttachmentPoint { AttachingPoint = new AttachingPoint(namedAttachmentPoint.AttachingPoint), Position = namedAttachmentPoint.Position }, Element = element, Trees = new List<Tree> { tree } }); } else { perspectiveEntityToken = sharedRootFolders[childTreeNode.Id].Element.ElementHandle.EntityToken; sharedRootFolders[childTreeNode.Id].Trees.Add(tree); } namedAttachmentPoint.AttachingPoint = new AttachingPoint(perspectiveEntityToken); tree.RootTreeNode = childTreeNode; } _sharedRootFolders = sharedRootFolders; }
protected override IEnumerable<Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext) { var entityToken = new TreeSimpleElementEntityToken( this.Id, this.Tree.TreeId, EntityTokenSerializer.Serialize(parentEntityToken)); Element element = new Element(new ElementHandle( dynamicContext.ElementProviderName, entityToken, dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken) )); if (parentEntityToken is TreePerspectiveEntityToken) { element.ElementHandle.Piggyback[StringConstants.PiggybagTreeId] = Tree.TreeId; } var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag); element.VisualData = new ElementVisualizedData { Label = this.LabelDynamicValuesHelper.ReplaceValues(replaceContext), ToolTip = this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext), HasChildren = ChildNodes.Any(), Icon = this.Icon, OpenedIcon = this.OpenIcon }; yield return element; }
protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { actionAdder(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Delete, this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { string url = this.UrlDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext); this.External = url.Contains("//"); if (!External) { url = UrlUtils.ResolvePublicUrl(url); } CustomUrlActionNodeActionToken actionToken = new CustomUrlActionNodeActionToken( url, this.External, (this.External ? "externalview" : "documentview"), this.ViewLabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.ViewToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext), this.Serialize(), this.PermissionTypes); ElementAction elementAction = new ElementAction(new ActionHandle(actionToken)) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }; actionAdder(elementAction); }
/// <exclude /> protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { Icon = new ResourceHandle(BuildInIconProviderName.ProviderName, "copy"); actionAdder(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Duplicate, this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); }
/// <exclude /> protected override IEnumerable<Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext) { bool localizationEnabled = this.ShowForeignItems && !UserSettings.ActiveLocaleCultureInfo.Equals(UserSettings.ForeignLocaleCultureInfo); NodeDataSet dataset = GetDataset(dynamicContext); var itemKeys = new List<object>(); IEnumerable<IData> dataItems; IEnumerable<object> keysJoinedByParentFilters = dataset.JoinedKeys; if (localizationEnabled && UserSettings.ForeignLocaleCultureInfo != null) { NodeDataSet foreignDataset; using (new DataScope(UserSettings.ForeignLocaleCultureInfo)) { foreignDataset = GetDataset(dynamicContext); } ParameterExpression parameterExpression = Expression.Parameter(this.InterfaceType, "data"); IEnumerable combinedData = dataset.DataItems.Concat(foreignDataset.DataItems).ToCastedDataEnumerable(this.InterfaceType); Expression orderByExpression = this.CreateOrderByExpression(combinedData.AsQueryable().Expression, parameterExpression); dataItems = combinedData.AsQueryable().Provider.CreateQuery<IData>(orderByExpression); foreach (IData data in dataset.DataItems) { Verify.IsNotNull(data, "Fetching data for data interface '{0}' with expression '{1}' yielded an null element".FormatWith(this.InterfaceType, orderByExpression)); object keyValue = this.KeyPropertyInfo.GetValue(data, null); itemKeys.Add(keyValue); } keysJoinedByParentFilters = keysJoinedByParentFilters.ConcatOrDefault(foreignDataset.JoinedKeys); } else { dataItems = dataset.DataItems; itemKeys = new List<object>(); } var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag); var elements = new List<Element>(); foreach (IData data in dataItems) { Verify.IsNotNull(data, "Fetching data for data interface '{0}' yielded an null element".FormatWith(this.InterfaceType)); var element = BuildElement(data, replaceContext, dynamicContext, localizationEnabled, itemKeys, ref keysJoinedByParentFilters, parentEntityToken); if(element == null) continue; elements.Add(element); } if (!this.OrderByNodes.Any()) { return elements.OrderBy(f => f.VisualData.Label); } return elements; }