private static void InitializeWithCommonValue(XElement element, Tree tree, ActionNode actionNode, string defaultIconName, string defaultLabelName = null, ActionLocation defaultActionLocation = null, List <PermissionType> defaultPermissionTypes = null) { XAttribute labelAttribute = element.Attribute("Label"); XAttribute toolTipAttribute = element.Attribute("ToolTip"); XAttribute iconAttribute = element.Attribute("Icon"); if ((defaultLabelName == null) && (labelAttribute == null)) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Label"); } actionNode.XPath = element.GetXPath(); actionNode.Id = tree.BuildProcessContext.ActionIdCounter++; actionNode.Label = labelAttribute.GetValueOrDefault(defaultLabelName); actionNode.ToolTip = toolTipAttribute.GetValueOrDefault(actionNode.Label); actionNode.Icon = FactoryHelper.GetIcon(iconAttribute.GetValueOrDefault(defaultIconName)); actionNode.Location = GetActionLocation(element, tree, defaultActionLocation); if (defaultPermissionTypes != null) { actionNode.PermissionTypes = defaultPermissionTypes; } else { actionNode.PermissionTypes = GetPermissionTypes(element, tree); } }
private static TreeNode BuildDataFolderElementsTreeNode(XElement element, Tree tree) { XAttribute typeAttribute = element.Attribute("Type"); XAttribute fieldGroupingNameAttribute = element.Attribute("FieldGroupingName"); XAttribute dateFormatAttribute = element.Attribute("DateFormat"); XAttribute iconAttribute = element.Attribute("Icon"); XAttribute rangeAttribute = element.Attribute("Range"); XAttribute firstLetterOnlyAttribute = element.Attribute("FirstLetterOnly"); XAttribute showForeignItemsAttribute = element.Attribute("ShowForeignItems"); XAttribute leafDisplayAttribute = element.Attribute("Display"); XAttribute sortDirectionAttribute = element.Attribute("SortDirection"); if (fieldGroupingNameAttribute == null) { tree.AddValidationError(element, "TreeValidationError.Common.MissingAttribute", "FieldGroupingName"); return(null); } Type interfaceType = null; if (typeAttribute != null) { interfaceType = TypeManager.TryGetType(typeAttribute.Value); if (interfaceType == null) { tree.AddValidationError(element, "TreeValidationError.Common.UnknownInterfaceType", typeAttribute.Value); return(null); } } bool firstLetterOnly = false; if (firstLetterOnlyAttribute != null) { if (!firstLetterOnlyAttribute.TryGetBoolValue(out firstLetterOnly)) { tree.AddValidationError(element, "TreeValidationError.Common.WrongAttributeValue", "FirstLetterOnly"); } } LeafDisplayMode leafDisplay = LeafDisplayModeHelper.ParseDisplayMode(leafDisplayAttribute, tree); SortDirection sortDirection = ParseSortDirection(sortDirectionAttribute, tree); return(new DataFolderElementsTreeNode { Tree = tree, Id = tree.BuildProcessContext.CreateNewNodeId(), InterfaceType = interfaceType, Icon = FactoryHelper.GetIcon(iconAttribute.GetValueOrDefault(DefaultDataGroupingFolderResourceName)), FieldName = fieldGroupingNameAttribute.Value, DateFormat = dateFormatAttribute.GetValueOrDefault(null), Range = rangeAttribute.GetValueOrDefault(null), FirstLetterOnly = firstLetterOnly, ShowForeignItems = showForeignItemsAttribute.GetValueOrDefault("true").ToLowerInvariant() == "true", Display = leafDisplay, SortDirection = sortDirection }); }
private static TreeNode BuildSimpleElementTreeNode(XElement element, Tree tree) { XAttribute idAttribute = element.Attribute("Id"); XAttribute labelAttribute = element.Attribute("Label"); XAttribute toolTipAttribute = element.Attribute("ToolTip"); XAttribute iconAttribute = element.Attribute("Icon"); XAttribute openedIconAttribute = element.Attribute("OpenedIcon"); XAttribute browserUrlAttribute = element.Attribute("BrowserUrl"); XAttribute browserImageAttribute = element.Attribute("BrowserImage"); if (idAttribute == null) { tree.AddValidationError(element, "TreeValidationError.Common.MissingAttribute", "Id"); return(null); } if (idAttribute.Value == "" || idAttribute.Value == "RootTreeNode" || idAttribute.Value.StartsWith("NodeAutoId_")) { tree.AddValidationError(idAttribute, "TreeValidationError.SimpleElement.WrongIdValue"); } else if (tree.BuildProcessContext.AlreadyUsed(idAttribute.Value)) { tree.AddValidationError(idAttribute, "TreeValidationError.SimpleElement.AlreadyUsedId", idAttribute.Value); } else { tree.BuildProcessContext.AddUsedId(idAttribute.Value); } if (labelAttribute == null) { tree.AddValidationError(element, "TreeValidationError.Common.MissingAttribute", "Label"); return(null); } ResourceHandle icon = FactoryHelper.GetIcon(iconAttribute.GetValueOrDefault(DefaultFolderResourceName)); ResourceHandle openedIcon = FactoryHelper.GetIcon(openedIconAttribute.GetValueOrDefault(DefaultOpenedFolderResourceName)); if (iconAttribute != null && openedIconAttribute == null) { openedIcon = icon; } return(new SimpleElementTreeNode { Tree = tree, Id = idAttribute.Value, Label = labelAttribute.Value, ToolTip = toolTipAttribute.GetValueOrDefault(labelAttribute.Value), Icon = icon, OpenIcon = openedIcon, BrowserUrl = browserUrlAttribute.GetValueOrDefault(null), BrowserImage = browserImageAttribute.GetValueOrDefault(null) }); }
private static TreeNode BuildFunctionElementGeneratorTreeNode(XElement element, Tree tree) { XAttribute labelAttribute = element.Attribute("Label"); XAttribute toolTipAttribute = element.Attribute("ToolTip"); XAttribute iconAttribute = element.Attribute("Icon"); XElement functionMarkupContainerElement = element.Element(TreeMarkupConstants.Namespace + "FunctionMarkup"); if (functionMarkupContainerElement == null) { //MRJ: DSLTree: FunctionElementGeneratorTreeNode: Validation error } XElement functionMarkupElement = functionMarkupContainerElement.Element((XNamespace)FunctionTreeConfigurationNames.NamespaceName + FunctionTreeConfigurationNames.FunctionTagName); if (functionMarkupElement == null) { //MRJ: DSLTree: FunctionElementGeneratorTreeNode: Validation error } if (labelAttribute == null) { tree.AddValidationError(element, "TreeValidationError.Common.MissingAttribute", "Label"); return(null); } return(new FunctionElementGeneratorTreeNode { Tree = tree, Id = tree.BuildProcessContext.CreateNewNodeId(), FunctionMarkup = functionMarkupElement, Label = labelAttribute.Value, ToolTip = toolTipAttribute.GetValueOrDefault(labelAttribute.Value), Icon = FactoryHelper.GetIcon(iconAttribute.GetValueOrDefault(DefaultFolderResourceName)) }); }
public static ActionNode CreateActionNode(XElement element, Tree tree) { if (element.Name == TreeMarkupConstants.Namespace + "AddDataAction") { GenericAddDataActionNode actionNode = new GenericAddDataActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultAddDataResourceName, StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "GenericAddDataAction.DefaultLabel"), ActionLocation.AddPrimaryActionLocation, DefaultAddPermissionTypes); XAttribute typeAttribute = element.Attribute("Type"); XAttribute customFormMarkupAttribute = element.Attribute("CustomFormMarkupPath"); if (typeAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Type"); } else { actionNode.InterfaceType = TypeManager.TryGetType(typeAttribute.Value); if (actionNode.InterfaceType == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.UnknownInterfaceType", typeAttribute.Value); } } actionNode.CustomFormMarkupPath = customFormMarkupAttribute.GetValueOrDefault(null); return(actionNode); } else if (element.Name == TreeMarkupConstants.Namespace + "EditDataAction") { GenericEditDataActionNode actionNode = new GenericEditDataActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultEditDataResourceName, StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "GenericEditDataAction.DefaultLabel"), ActionLocation.EditPrimaryActionLocation, DefaultEditPermissionTypes); XAttribute customFormMarkupAttribute = element.Attribute("CustomFormMarkupPath"); actionNode.CustomFormMarkupPath = customFormMarkupAttribute.GetValueOrDefault(null); return(actionNode); } else if (element.Name == TreeMarkupConstants.Namespace + "DeleteDataAction") { GenericDeleteDataActionNode actionNode = new GenericDeleteDataActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultDeleteDataResourceName, StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "GenericDeleteDataAction.DefaultLabel"), ActionLocation.DeletePrimaryActionLocation, DefaultDeletePermissionTypes); return(actionNode); } else if (element.Name == TreeMarkupConstants.Namespace + "ReportFunctionAction") { ReportFunctionActionNode actionNode = new ReportFunctionActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultReportFunctionResourceName); XAttribute documentLabelAttribute = element.Attribute("DocumentLabel"); XAttribute documentIconAttribute = element.Attribute("DocumentIcon"); XElement functionMarkupElement = element.Element((XNamespace)FunctionTreeConfigurationNames.NamespaceName + FunctionTreeConfigurationNames.FunctionTagName); if (functionMarkupElement == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingFunctionMarkup"); } actionNode.FunctionMarkup = functionMarkupElement; actionNode.DocumentLabel = documentLabelAttribute.GetValueOrDefault(actionNode.Label); if (documentIconAttribute != null) { actionNode.DocumentIcon = FactoryHelper.GetIcon(documentIconAttribute.Value); } else { actionNode.DocumentIcon = actionNode.Icon; } return(actionNode); } else if (element.Name == TreeMarkupConstants.Namespace + "MessageBoxAction") { MessageBoxActionNode actionNode = new MessageBoxActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultMessageBoxResourceName); XAttribute messageBoxTitleAttribute = element.Attribute("MessageBoxTitle"); XAttribute messageBoxMessageAttribute = element.Attribute("MessageBoxMessage"); if (messageBoxTitleAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "MessageBoxTitle"); } else { actionNode.Title = messageBoxTitleAttribute.Value; } if (messageBoxMessageAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "MessageBoxMessage"); } else { actionNode.Message = messageBoxMessageAttribute.Value; } XAttribute dialogTypeAttribute = element.Attribute("MessageDialogType"); string dialogTypeValue = dialogTypeAttribute.GetValueOrDefault("message"); switch (dialogTypeValue) { case "message": actionNode.DialogType = DialogType.Message; break; case "question": actionNode.DialogType = DialogType.Question; break; case "warning": actionNode.DialogType = DialogType.Warning; break; case "error": actionNode.DialogType = DialogType.Error; break; default: tree.AddValidationError(element.GetXPath(), "TreeValidationError.MessageBoxAction.UnknownDialogType", dialogTypeValue); break; } return(actionNode); } else if (element.Name == TreeMarkupConstants.Namespace + "CustomUrlAction") { CustomUrlActionNode actionNode = new CustomUrlActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultCustomUrlResourceName); XAttribute urlAttribute = element.Attribute("Url"); XAttribute viewLabelAttribute = element.Attribute("ViewLabel"); XAttribute viewToolTipAttribute = element.Attribute("ViewToolTip"); XAttribute viewIconAttribute = element.Attribute("ViewIcon"); IEnumerable <XElement> postParameterElements = element.Elements(TreeMarkupConstants.Namespace + "PostParameters"); XElement postParametersElement = null; if (postParameterElements.Count() == 1) { postParametersElement = element.Element(TreeMarkupConstants.Namespace + "PostParameters"); } else if (postParameterElements.Count() > 1) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.CustomUrlAction.TooManyPostParameterElements", "PostParameters"); } if (urlAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Url"); } else { actionNode.Url = urlAttribute.Value; } actionNode.ViewLabel = viewLabelAttribute.GetValueOrDefault(actionNode.Label); actionNode.ViewToolTip = viewToolTipAttribute.GetValueOrDefault(actionNode.ToolTip); actionNode.ViewIcon = FactoryHelper.GetIcon(viewIconAttribute.GetValueOrDefault(DefaultCustomUrlResourceName)); bool urlIsAbsolute = actionNode.Url != null && actionNode.Url.Contains("://"); XAttribute viewTypeAttribute = element.Attribute("ViewType"); string viewTypeValue = viewTypeAttribute.GetValueOrDefault(urlIsAbsolute ? "externalview" : "documentview"); switch (viewTypeValue) { case "externalview": actionNode.ViewType = CustomUrlActionNodeViewType.ExternalView; break; case "genericview": actionNode.ViewType = CustomUrlActionNodeViewType.GenericView; break; case "pagebrowser": actionNode.ViewType = CustomUrlActionNodeViewType.PageBrowser; break; case "filedownload": actionNode.ViewType = CustomUrlActionNodeViewType.FileDownload; break; case "documentview": actionNode.ViewType = CustomUrlActionNodeViewType.DocumentView; break; default: tree.AddValidationError(element.GetXPath(), "TreeValidationError.CustomUrlAction.UnknownViewType", viewTypeValue); break; } actionNode.PostParameters = new Dictionary <string, string>(); if (postParametersElement != null) { foreach (XElement parameterElement in postParametersElement.Elements(TreeMarkupConstants.Namespace + "Parameter")) { XAttribute keyAttribute = parameterElement.Attribute("Key"); XAttribute valueAttribute = parameterElement.Attribute("Value"); if (keyAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Key"); continue; } else if (string.IsNullOrWhiteSpace(keyAttribute.Value)) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.WrongAttributeValue", "Key"); continue; } if (valueAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Value"); continue; } actionNode.PostParameters.Add(keyAttribute.Value, valueAttribute.Value); } } return(actionNode); } else if (element.Name == TreeMarkupConstants.Namespace + "ConfirmAction") { ConfirmActionNode actionNode = new ConfirmActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultConfirmResourceName); XAttribute confirmTitleAttribute = element.Attribute("ConfirmTitle"); XAttribute confirmMessageAttribute = element.Attribute("ConfirmMessage"); if (confirmTitleAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "ConfirmTitle"); } else { actionNode.ConfirmTitle = confirmTitleAttribute.Value; } if (confirmMessageAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "ConfirmMessage"); } else { actionNode.ConfirmMessage = confirmMessageAttribute.Value; } XElement functionMarkupElement = element.Element((XNamespace)FunctionTreeConfigurationNames.NamespaceName + FunctionTreeConfigurationNames.FunctionTagName); if (functionMarkupElement == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingFunctionMarkup"); } actionNode.FunctionMarkup = functionMarkupElement; XAttribute refreshTreeAttribute = element.Attribute("RefreshTree"); string refreshTreeAttributeValue = refreshTreeAttribute.GetValueOrDefault("false").ToLowerInvariant(); if (refreshTreeAttributeValue == "true") { actionNode.RefreshTree = true; } else { actionNode.RefreshTree = false; } return(actionNode); } else if (element.Name == TreeMarkupConstants.Namespace + "WorkflowAction") { WorkflowActionNode actionNode = new WorkflowActionNode(); InitializeWithCommonValue(element, tree, actionNode, DefaultWorkflowResourceName); XAttribute workflowTypeAttribute = element.Attribute("WorkflowType"); if (workflowTypeAttribute == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "ConfirmTitle"); } else { actionNode.WorkflowType = TypeManager.TryGetType(workflowTypeAttribute.Value); if (actionNode.WorkflowType == null) { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.UnknownInterfaceType", workflowTypeAttribute.Value); } } return(actionNode); } else { tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.UnknownElement", element.Name); return(null); } }
private static TreeNode BuildDataElementsTreeNode(XElement element, Tree tree) { XAttribute typeAttribute = element.Attribute("Type"); XAttribute labelAttribute = element.Attribute("Label"); XAttribute toolTipAttribute = element.Attribute("ToolTip"); XAttribute iconAttribute = element.Attribute("Icon"); XAttribute openedIconAttribute = element.Attribute("OpenedIcon"); XAttribute showForeignItemsAttribute = element.Attribute("ShowForeignItems"); XAttribute leafDisplayAttribute = element.Attribute("Display"); if (typeAttribute == null) { tree.AddValidationError(element, "TreeValidationError.Common.MissingAttribute", "Type"); return(null); } Type interfaceType = TypeManager.TryGetType(typeAttribute.Value); if (interfaceType == null) { tree.AddValidationError(element, "TreeValidationError.Common.UnknownInterfaceType", typeAttribute.Value); return(null); } LeafDisplayMode leafDisplay = LeafDisplayModeHelper.ParseDisplayMode(leafDisplayAttribute, tree); ResourceHandle icon = null; if (iconAttribute != null) { icon = FactoryHelper.GetIcon(iconAttribute.Value); } ResourceHandle openedIcon = null; if (icon != null && openedIconAttribute == null) { openedIcon = icon; } else if (openedIconAttribute != null) { openedIcon = FactoryHelper.GetIcon(openedIconAttribute.Value); } var dataElementsTreeNode = new DataElementsTreeNode { Tree = tree, Id = tree.BuildProcessContext.CreateNewNodeId(), InterfaceType = interfaceType, Label = labelAttribute.GetValueOrDefault(null), ToolTip = toolTipAttribute.GetValueOrDefault(null), Icon = icon, OpenedIcon = openedIcon, ShowForeignItems = showForeignItemsAttribute.GetValueOrDefault("true").ToLowerInvariant() == "true", Display = leafDisplay }; List <TreeNode> treeNodes; if (tree.BuildProcessContext.DataInteraceToTreeNodes.TryGetValue(interfaceType, out treeNodes) == false) { treeNodes = new List <TreeNode>(); tree.BuildProcessContext.DataInteraceToTreeNodes.Add(interfaceType, treeNodes); } treeNodes.Add(dataElementsTreeNode); return(dataElementsTreeNode); }