Esempio n. 1
0
        private IDocumentNode VisitListProcess(DashParser.ListItemContext firstItem, IEnumerable <ParserRuleContext> others, bool ordered = false)
        {
            var node = new ListNode {
                Ordered = ordered
            };
            var lastItem = new ListItemNode
            {
                Line      = (LineNode)firstItem.line().Accept(this),
                Important = firstItem.important
            };

            node.Children.Add(lastItem);

            foreach (ParserRuleContext rule in others)
            {
                if (rule is DashParser.ListItemContext listItemContext)
                {
                    lastItem = new ListItemNode
                    {
                        Line      = (LineNode)listItemContext.line().Accept(this),
                        Important = listItemContext.important
                    };
                    node.Children.Add(lastItem);
                }
                else
                {
                    lastItem.Sublist = (ListNode)rule.Accept(this);
                }
            }

            return(node);
        }
Esempio n. 2
0
        /*
         * Process Method
         */

        public override ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui)
        {
            if (node.Decorations[ItemDecision.DECISION_KEY] == null &&
                node is LabeledListNode &&
                cio is PhoneListViewCIO)
            {
                // the item node represents an appliance object and it will be
                // contained within a list
                LabeledListNode  newList = (LabeledListNode)node;
                PhoneListViewCIO list    = (PhoneListViewCIO)cio;

                PhoneListViewCIO subList = new PhoneListViewCIO();

                IPhoneListViewItem listItem =
                    new SubListViewItemCIO(list, subList, newList.Labels);

                list.AddItem(listItem);
                newList.Decorations[ItemDecision.DECISION_KEY] =
                    new ListItemDecision(listItem);

                return(subList);
            }

            return(cio);
        }
Esempio n. 3
0
        private void DisplayName(bool isHide)
        {
            InitListView();
            if (linList == null)
            {
                return;
            }
            for (int i = 0; i < linList.Count; i++)
            {
                ListItemNode lin       = linList[i];
                string       fileName  = lin.FileName;
                string       keyPos    = lin.KeyPos;
                string       findTimes = lin.FindTimes;
                if (isHide)
                {
                    fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
                }
                ListViewItem item = new ListViewItem();
                System.Windows.Forms.ListViewItem.ListViewSubItem lvsi1 = new ListViewItem.ListViewSubItem(item, fileName);
                System.Windows.Forms.ListViewItem.ListViewSubItem lvsi2 = new ListViewItem.ListViewSubItem(item, keyPos);
                System.Windows.Forms.ListViewItem.ListViewSubItem lvsi3 = new ListViewItem.ListViewSubItem(item, findTimes);
                item.SubItems.Clear();
                item.SubItems.Insert(0, lvsi1);
                item.SubItems.Insert(1, lvsi2);
                item.SubItems.Insert(2, lvsi3);

                //item.SubItems.AddRange(new ListViewItem.ListViewSubItem[] { lvsi1, lvsi2, lvsi3 });
                lvFilePath.Items.Insert(i, item);
            }
        }
Esempio n. 4
0
        protected ConcreteInteractionObject invokeRules(ListItemNode node,
                                                        ConcreteInteractionObject cio,
                                                        UIGenerator ui)
        {
            IEnumerator e = _rules.GetEnumerator();

            while (e.MoveNext())
            {
                cio = ((BuildConcreteListRule)e.Current).Process(node, cio, ui);
            }

            return(cio);
        }
        public override INode Consume(Parser parser, ParseData data, Lines lines, string scope)
        {
            // Put all the subtrees into a dummy item node
            var item = new ListItemNode(PlainTextNode.Empty);
            var _    = CreateListItems(item, "", parser, data, lines, scope).ToList();

            // Pull the subtrees out again for the result
            if (item.Subtrees.Count == 1)
            {
                return(item.Subtrees[0]);
            }
            return(new NodeCollection(item.Subtrees));
        }
Esempio n. 6
0
        public override void VisitListItem(ListItemNode node)
        {
            if (node.Important)
            {
                Write(">");
            }

            Write(" ");
            Write(node.Line);
            if (node.Sublist != null)
            {
                Write(node.Sublist);
            }
        }
Esempio n. 7
0
        /*
         * Process Method
         */

        public override ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui)
        {
            if (node.Decorations[ItemDecision.DECISION_KEY] == null &&
                node is PanelListNode &&
                cio is PhoneListViewCIO)
            {
                // the item node represents an appliance object and it will be
                // contained within a list
                PanelListNode             newPanel = (PanelListNode)node;
                PhoneListViewCIO          list     = (PhoneListViewCIO)cio;
                ListViewItemCIO           listItem = null;
                ConcreteInteractionObject panel    = null;

                if (((ListNode)node).Items.Count == 1)
                {
                    ConcreteInteractionObject statecio = ((CIOListItemNode)newPanel.Items[0]).CIO;
                    if (statecio is StateLinkedCIO)
                    {
                        StateLinkedCIO childCIO =
                            (StateLinkedCIO)statecio;
                        listItem = new SingleItemPanelListViewItemCIO(
                            list,
                            (ApplianceState)childCIO.GetApplObj());
                        panel = ((SingleItemPanelListViewItemCIO)listItem).Panel;
                    }
                    else
                    {
                        listItem = new PanelListViewItemCIO(list, newPanel.Labels);
                        panel    = ((PanelListViewItemCIO)listItem).Panel;
                    }
                }
                else
                {
                    listItem = new PanelListViewItemCIO(list, newPanel.Labels);
                    panel    = ((PanelListViewItemCIO)listItem).Panel;
                }

                list.AddItem(listItem);
                newPanel.Decorations[ItemDecision.DECISION_KEY] =
                    new ListItemDecision(listItem);

                return(panel);
            }

            return(cio);
        }
Esempio n. 8
0
        protected void processHelper(ListNode node, UIGenerator ui)
        {
            Hashtable _handledNodes = new Hashtable();
            bool      keepGoing     = true;
            bool      changed       = false;

            while (keepGoing)
            {
                changed = false;

                for (int i = 0; i < node.Items.Count; i++)
                {
                    ListItemNode item = (ListItemNode)node.Items[i];

                    // skip items that have already been handled
                    if (_handledNodes[item] != null)
                    {
                        continue;
                    }

                    _handledNodes[item] = true;

                    if (item is ListNode)
                    {
                        processHelper((ListNode)item, ui);
                    }

                    changed = invokeRules(item, ui);

                    if (changed)
                    {
                        break;
                    }
                }

                // if we were iterating on the root, reload it
                if (node.Parent == null)
                {
                    node = ui.ListRoot;
                }

                if (!changed)
                {
                    keepGoing = false;
                }
            }
        }
Esempio n. 9
0
        /*
         * Process Method
         */

        public override ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui)
        {
            if (node.Decorations[ItemDecision.DECISION_KEY] == null &&
                node is StateValueListNode &&
                cio is PhoneListViewCIO)
            {
                // the item node represents an appliance object and it will be
                // contained within a list
                StateValueListNode newList = (StateValueListNode)node;
                PhoneListViewCIO   list    = (PhoneListViewCIO)cio;

                PhoneListViewCIO subList = new PhoneListViewCIO();

                LabelDictionary labels = null;

                if (newList.State.Type.ValueLabels != null)
                {
                    labels =
                        (LabelDictionary)newList.State.Type.ValueLabels[newList.Value];
                }

                if (labels == null)
                {
                    labels = new LabelDictionary();
                    labels.AddLabel(new StringValue(newList.Value.ToString()));
                }

                IPhoneListViewItem listItem =
                    new SubListViewItemCIO(list, subList, labels);

                ItemActivationListener l = new ItemActivationListener(newList.State,
                                                                      newList.Value);

                listItem.ItemActivated += new EventHandler(l.itemActivated);

                list.AddItem(listItem);
                newList.Decorations[ItemDecision.DECISION_KEY] =
                    new ListItemDecision(listItem);

                return(subList);
            }

            return(cio);
        }
Esempio n. 10
0
        protected void processHelper(ListNode node, ConcreteInteractionObject cio, UIGenerator ui)
        {
            IEnumerator e = node.Items.GetEnumerator();

            while (e.MoveNext())
            {
                ConcreteInteractionObject newCIO = cio;
                ListItemNode item = (ListItemNode)e.Current;

                newCIO = invokeRules(item, newCIO, ui);

                if (item is ListNode)
                {
                    processHelper((ListNode)item, newCIO, ui);
                }
            }
        }
Esempio n. 11
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        /// <summary>
        /// This method checks if for a pattern that looks like
        /// ListNode->ListNode(one child)->ListNode and removes the
        /// intermediate ListNode.
        /// </summary>
        public override bool Process(ListItemNode node, UIGenerator ui)
        {
            // special case for root node
            if (node.Parent == null)
            {
                // this happens only if the following pattern is seen:
                // ListNode(root-one child)->List Node
                // in this case, the child node is promoted to the root
                if (node is ListNode)
                {
                    ListNode listNode = (ListNode)node;

                    if (listNode.Items.Count == 1 &&
                        listNode.Items[0] is ListNode)
                    {
                        ui.ListRoot        = (ListNode)listNode.Items[0];
                        ui.ListRoot.Parent = null;

                        return(true);
                    }
                }

                return(false);
            }

            if (node is ListNode)
            {
                ListNode listNode = (ListNode)node;

                if (listNode.Items.Count == 1 &&
                    listNode.Items[0] is ListNode)
                {
                    ListNode newItem = (ListNode)listNode.Items[0];
                    ListNode parent  = listNode.Parent;

                    int idx = parent.Items.IndexOf(listNode);
                    parent.Items[idx] = newItem;
                    newItem.Parent    = parent;

                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Converts lines into list items for a given prefix until the prefix no longer matches a line
        /// </summary>
        private IEnumerable <ListItemNode> CreateListItems(ListItemNode lastItemNode, string prefix, Parser parser, ParseData data, Lines lines, string scope)
        {
            do
            {
                var value = lines.Value().TrimEnd();

                if (!value.StartsWith(prefix))
                {
                    // No longer valid for this list
                    lines.Back();
                    yield break;
                }

                value = value.Substring(prefix.Length); // strip the prefix off the line

                // Possibilities:
                // empty string : not valid - stop parsing
                // first character is whitespace : trim and create list item
                // first character is list token, second character is whitespace: create sublist
                // anything else : not valid - stop parsing

                if (value.Length > 1 && value[0] == ' ' && prefix.Length > 0) // don't allow this if we're parsing at level 0
                {
                    // List item
                    value = value.Trim();
                    var pt = parser.ParseTags(data, value.Trim(), scope, "inline");
                    lastItemNode = new ListItemNode(pt);
                    yield return(lastItemNode);
                }
                else if (value.Length > 2 && IsListToken(value[0]) && value[1] == ' ' && lastItemNode != null)
                {
                    // Sublist
                    var tag     = IsSortedToken(value[0]) ? "ol" : "ul";
                    var sublist = new ListNode(tag, CreateListItems(lastItemNode, prefix + value[0], parser, data, lines, scope));
                    lastItemNode.Subtrees.Add(sublist);
                }
                else
                {
                    // Cannot parse this line, list is complete
                    lines.Back();
                    yield break;
                }
            } while (lines.Next());
        }
Esempio n. 13
0
        protected bool invokeRules(ListItemNode node, UIGenerator ui)
        {
            bool changed     = false;
            bool tempChanged = false;

            IEnumerator e = _rules.GetEnumerator();

            while (e.MoveNext())
            {
                tempChanged = ((ListManipulateRule)e.Current).Process(node, ui);

                if (tempChanged)
                {
                    changed = true;
                }
            }

            return(changed);
        }
Esempio n. 14
0
        public override void VisitListItem(ListItemNode node)
        {
            Write("<li>");

            if (node.Important)
            {
                Write("<b>");
                Write(node.Line);
                Write("</b>");
            }
            else
            {
                Write(node.Line);
            }

            if (node.Sublist != null)
            {
                Write(node.Sublist);
            }

            WriteLine("</li>");
        }
Esempio n. 15
0
        /*
         * Process Method
         */

        public override ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui)
        {
            if (node.Decorations[ItemDecision.DECISION_KEY] == null &&
                node is CIOListItemNode &&
                !((PanelDecision)node.Decorations[PanelDecision.DECISION_KEY]).IsPanel &&
                cio is PhoneListViewCIO)
            {
                // the item node represents an appliance object and it will be
                // contained within a list
                CIOListItemNode  item = (CIOListItemNode)node;
                PhoneListViewCIO list = (PhoneListViewCIO)cio;

                IPhoneListViewItem listItem = (IPhoneListViewItem)item.CIO;

                list.AddItem(listItem);
                item.Decorations[ItemDecision.DECISION_KEY] =
                    new ListItemDecision(listItem);
            }

            return(cio);
        }
Esempio n. 16
0
        /**
         * Parses markdown text out of an XML node
         *
         * @param child			xml node we want to parse into Markdown
         * @param Indent		indenting prefix for each newline of text in the converted markdown
         * @param Output		storage for the output string
         * @param ResolveLink	delegate to call to resolve doxygen id's into link paths. may be null.
         */
        static void ConvertNode(XmlNode Node, MarkdownWriter Writer, ResolveLinkDelegate ResolveLink)
        {
            switch (Node.Name)
            {
            case "ulink":
                string LinkText = Node.InnerText;
                string LinkUrl  = Node.Attributes.GetNamedItem("url").InnerText;

                const string WebPrefix    = "docs.unrealengine.com/latest/INT/";
                int          WebPrefixIdx = LinkUrl.IndexOf(WebPrefix);
                if (WebPrefixIdx != -1 && LinkText.Contains("docs.unrealengine.com"))
                {
                    LinkText = "";
                    LinkUrl  = LinkUrl.Substring(WebPrefixIdx + WebPrefix.Length);

                    int AnchorIdx = LinkUrl.LastIndexOf('#');
                    if (AnchorIdx == -1)
                    {
                        LinkUrl = RemoveDefaultPageName(LinkUrl);
                    }
                    else
                    {
                        LinkUrl = RemoveDefaultPageName(LinkUrl.Substring(0, AnchorIdx)) + LinkUrl.Substring(AnchorIdx);
                    }
                }
                Writer.WriteLink(LinkText, LinkUrl);
                break;

            case "ref":
                XmlAttribute RefAttribute = Node.Attributes["refid"];
                if (RefAttribute != null && ResolveLink != null)
                {
                    string LinkPath = ResolveLink(RefAttribute.Value);
                    if (LinkPath != null)
                    {
                        Writer.WriteLink(Node.InnerText, LinkPath);
                        break;
                    }
                }
                Writer.Write(Node.InnerText);
                break;

            case "bold":
                Writer.Write("**");
                ConvertNodeContents(Node, Writer, ResolveLink);
                Writer.Write("**");
                break;

            case "emphasis":
                Writer.Write("_");
                ConvertNodeContents(Node, Writer, ResolveLink);
                Writer.Write("_");
                break;

            case "computeroutput":
                Writer.Write("`");
                ConvertNodeContents(Node, Writer, ResolveLink);
                Writer.Write("_");
                break;

            case "parameterlist":
                break;

            case "parameteritem":
                break;

            case "parameternamelist":
                break;

            case "parameterdescription":
                ConvertNodeContents(Node, Writer, ResolveLink);
                break;

            case "xrefsect":
                break;

            case "simplesect":
                XmlAttribute KindAttribute = Node.Attributes["kind"];
                if (KindAttribute == null || KindAttribute.Value != "see")
                {
                    ConvertNodeContents(Node, Writer, ResolveLink);
                }
                break;

            case "para":
                Writer.WriteParagraph();
                ConvertNodeContents(Node, Writer, ResolveLink);
                break;

            case "itemizedlist":
                Writer.WriteLine();
                foreach (XmlNode ListItemNode in Node.SelectNodes("listitem"))
                {
                    XmlNodeList ParaNodes = ListItemNode.SelectNodes("para");
                    if (ParaNodes.Count > 0)
                    {
                        // Write the first node
                        Writer.Write("* ");
                        Writer.AddIndent(" ");
                        ConvertNodeContents(ParaNodes[0], Writer, ResolveLink);

                        // Write anything else as an actual paragraph
                        for (int Idx = 1; Idx < ParaNodes.Count; Idx++)
                        {
                            Writer.WriteLine();
                            ConvertNodeContents(ParaNodes[Idx], Writer, ResolveLink);
                        }

                        // Finish the line
                        Writer.RemoveIndent();
                        Writer.WriteLine();
                    }
                }
                break;

            default:
                ConvertNodeContents(Node, Writer, ResolveLink);
                break;
            }
        }
Esempio n. 17
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        public abstract ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui);
Esempio n. 18
0
        /*
         * Process Method
         */

        public override ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui)
        {
            if (node.Decorations[ItemDecision.DECISION_KEY] == null &&
                node is CIOListItemNode &&
                cio is ScrollingPanelCIO)
            {
                // the item node represents an appliance object and it will be
                // placed on the ScrollingPanelCIO
                CIOListItemNode   item  = (CIOListItemNode)node;
                ScrollingPanelCIO panel = (ScrollingPanelCIO)cio;
                LabelDictionary   labels;
                if (item.CIO is StateLinkedCIO)
                {
                    labels = ((ApplianceState)((StateLinkedCIO)item.CIO).GetApplObj()).Labels;
                }
                else if (item.CIO is SmartCIO)
                {
                    labels = ((SmartCIO)item.CIO).Labels;
                }

                // get information about the bottom of the current
                // panel's layout
                PanelLayoutDecision panelDecision =
                    (PanelLayoutDecision)node.Parent.Decorations[PanelLayoutDecision.DECISION_KEY];

                if (panelDecision == null)
                {
                    // make one
                    panelDecision = new PanelLayoutDecision();
                    node.Parent.Decorations.Add(PanelLayoutDecision.DECISION_KEY, panelDecision);
                }

                LabelCIO label = null;
                if (item.CIO.HasLabel())
                {
                    label = (LabelCIO)item.CIO.GetLabelCIO();
                    panel.AddCIO(label);
                }

                ControlBasedCIO control = (ControlBasedCIO)item.CIO;
                panel.AddCIO(control);

                // do some sizing here
                int width = ui.Size.Width - 2 * ui.LayoutVars.RowPadding - 5;

                if (item.CIO.HasLabel())
                {
                    // layout label CIO
                    label.GetControl().Location =
                        new System.Drawing.Point(ui.LayoutVars.RowPadding, panelDecision.Bottom);
                    label.GetControl().Size =
                        new System.Drawing.Size(width, label.GetMinimumSize().Height);
                    panelDecision.Bottom += label.GetControl().Size.Height + ui.LayoutVars.RowPadding;

                    label.FinalSizeNotify();
                }

                control.GetControl().Location =
                    new System.Drawing.Point(ui.LayoutVars.RowPadding, panelDecision.Bottom);
                control.GetControl().Size =
                    new System.Drawing.Size(width, ((ControlBasedCIO)item.CIO).GetMinimumSize().Height);
                panelDecision.Bottom += ((ControlBasedCIO)item.CIO).GetMinimumSize().Height + 2 * ui.LayoutVars.RowPadding;

                item.Decorations[ItemDecision.DECISION_KEY] =
                    new PanelItemDecision(item.CIO);
            }

            return(cio);
        }
Esempio n. 19
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        /// <summary>
        /// This process methods returns a boolean that indicates whether the
        /// phase will need to restart its iteration on the current ListNode.
        /// </summary>
        public abstract bool Process(ListItemNode node, UIGenerator ui);
Esempio n. 20
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        /// <summary>
        /// This method checks if for a pattern that looks like
        /// ListNode->ListNode(one child)->ListNode and removes the
        /// intermediate ListNode.
        /// </summary>
        public override bool Process(ListItemNode node, UIGenerator ui)
        {
            // promotion rules can't work on the root node
            bool ableToPromote = node.Parent != null;

            if (node is ListNode)
            {
                ListNode  listNode   = (ListNode)node;
                Hashtable panelNodes = new Hashtable(listNode.Items.Count);

                IEnumerator e = listNode.Items.GetEnumerator();
                while (e.MoveNext())
                {
                    if (e.Current is PanelListNode)
                    {
                        //
                        // ASSUMPTION: All items in a panel node share
                        // the same parent group
                        //
                        GroupDecision d =
                            (GroupDecision)((ListItemNode)((PanelListNode)e.Current).Items[0]).Decorations[GroupDecision.DECISION_KEY];
                        if (d != null)
                        {
                            ArrayList list = (ArrayList)panelNodes[d.Group.Parent];

                            if (list == null)
                            {
                                list = new ArrayList(listNode.Items.Count);
                            }

                            list.Add(e.Current);

                            panelNodes[d.Group.Parent] = list;
                        }
                    }
                }

                e = panelNodes.Keys.GetEnumerator();
                while (e.MoveNext())
                {
                    GroupNode parent = (GroupNode)e.Current;

                    if (parent.Labels == null)
                    {
                        // has no labels, so abort for this group
                        continue;
                    }

                    // create a new PanelNode and move all items into this node
                    PanelListNode newPanel = new PanelListNode(parent.Labels);
                    ArrayList     list     = (ArrayList)panelNodes[parent];

                    if (list.Count <= 1)
                    {
                        continue;
                    }

                    IEnumerator panels = list.GetEnumerator();
                    while (panels.MoveNext())
                    {
                        PanelListNode existPanel = (PanelListNode)panels.Current;
                        IEnumerator   items      = existPanel.Items.GetEnumerator();
                        while (items.MoveNext())
                        {
                            newPanel.Add((ListItemNode)items.Current);
                        }

                        listNode.Remove(existPanel);
                    }

                    listNode.Add(newPanel);
                }
            }

            return(false);
        }
Esempio n. 21
0
 public abstract void VisitListItem(ListItemNode node);