Пример #1
0
 public void OnItemDelete(String deleteFunction, ProcessingNode deletedItem)
 {
     if (ItemDelete != null)
     {
         ItemDelete(deleteFunction, deletedItem);
     }
     NoActionProcessingNode node = new NoActionProcessingNode(-1, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty);
     OnAfterSelect(new TreeViewEventArgs(node));
 }
Пример #2
0
        // Given node xml, create the node and process its functions
        // the drag function determines the type of node created
        // the other functions are stored in the node and can be quickly looked up
        // (e.g. on a right click context menu)
        private ProcessingNode CreateNodeAndProcessFunctions(XPathNavigator nodeNavigator, String linkType)
        {
            ProcessingNode returnNode = null;

            int nodeID = Convert.ToInt32(nodeNavigator.GetAttribute(IDAttribute, nodeNavigator.NamespaceURI));
            String nodeType = nodeNavigator.GetAttribute(TypeAttribute, nodeNavigator.NamespaceURI);
            String nodeName = nodeNavigator.GetAttribute(NameAttribute, nodeNavigator.NamespaceURI);
            String nodeDescription = nodeNavigator.GetAttribute(DescriptionAttribute, nodeNavigator.NamespaceURI);
            String nodeEType = nodeNavigator.GetAttribute(ETypeAttribute, nodeNavigator.NamespaceURI);
            String nodeLinkID = nodeNavigator.GetAttribute(LinkIDAttribute, nodeNavigator.NamespaceURI);
            String nodeLinkType = linkType;

            List<Function> nodeFunctions = FunctionHelper.GetFunctions(nodeNavigator);

            Dictionary<String, String> parameterMap = new Dictionary<String, String>();

            XPathNodeIterator parameters = nodeNavigator.Select(imageCategoryParameter);

            String name, category, value;
            while (parameters.MoveNext())
            {
                category = parameters.Current.GetAttribute(categoryAttr, String.Empty);
                if (category.Equals(categoryMatch)) // Image
                {
                    name = parameters.Current.GetAttribute(displayedNameAttr, String.Empty);
                    value = parameters.Current.GetAttribute(ConfigFileConstants.Value, String.Empty);
                    parameterMap.Add(String.Concat(category, SchemaConstants.ParameterDelimiter, name), value);
                }
            }

            String imagePath = FunctionHelper.ProcessNavForImage(this.Controller, this.ImageList, nodeType, nodeNavigator, nodeFunctions, parameterMap);  // update node image.

            foreach (Function nodeFunction in nodeFunctions)
            {
                if (nodeFunction.FunctionName == ConfigFileConstants.Drag || nodeFunction.FunctionName == ConfigFileConstants.ObjectType)
                {
                    // instantiate class based on function name
                    Type type = AMEManager.GetType(nodeFunction.FunctionAction); 

                    if (type != null)
                    {
                        //returnNode = (ProcessingNode)Activator.CreateInstance(type, new object[] { nodeID, nodeType, nodeName, nodeEType, imagePath, linkType });
                        returnNode = createNode(type, new object[] { nodeID, nodeType, nodeName, nodeEType, imagePath, linkType });
                        break;
                    }
                }
            }

            if (returnNode == null) // no-op is default
            {
                returnNode = new NoActionProcessingNode(nodeID, nodeType, nodeName, nodeEType, imagePath, nodeLinkType);
            }

            // set linkID, if available
            if (nodeLinkID != null && nodeLinkID.Length > 0)
            {
                returnNode.LinkID = Int32.Parse(nodeLinkID);
            }

            returnNode.ToolTipText = nodeDescription;
            returnNode.Functions = nodeFunctions;
            if (decorateNodes)
            {
                XPathNodeIterator links = nodeNavigator.Select("LinkParameters/Parameter/Parameter");
                StringBuilder decoraterBuilder = new StringBuilder();
                decoraterBuilder.Append(returnNode.Name);
                decoraterBuilder.Append(" :");
                foreach (XPathNavigator link in links)
                {
                    String paramName = link.GetAttribute(ConfigFileConstants.displayedName, String.Empty);
                    String paramValue = link.GetAttribute(ConfigFileConstants.Value, String.Empty);

                    if (!String.IsNullOrEmpty(paramValue))
                    {
                        decoraterBuilder.Append(" ");
                        decoraterBuilder.Append(paramName);
                        decoraterBuilder.Append(" [");
                        decoraterBuilder.Append(paramValue);
                        decoraterBuilder.Append("]");
                    }
                }
                returnNode.Text = decoraterBuilder.ToString();
            }

            // **** Maintain Selection when we reload ****
            if (lastSelectID >= 0 && lastSelectID == nodeID)
            {
                // don't add if the eType is none - e.g. for XSL
                if (!returnNode.EType.Equals("None"))
                {
                    selectedNodes.Add(returnNode);
                }
            }

            return returnNode;
        }