public ViewStatus (BuildOutputNode node)
			{
				if (node == null)
					throw new ArgumentNullException (nameof (node));
				Node = node;
				layout.Font = GetFont (node);
			}
        void FillCellBackground(Context ctx, BuildOutputNode buildOutputNode, ViewStatus status)
        {
            if (!buildOutputNode.HasChildren)
            {
                if (buildOutputNode.NodeType == BuildOutputNodeType.Error)
                {
                    FillCellBackground(ctx, Styles.CellErrorBackgroundColor);

                    if (status.DrawsTopLine)
                    {
                        DrawTopLine(ctx, Styles.CellErrorLineBackgroundColor);
                    }

                    if (status.DrawsBottomLine)
                    {
                        DrawBottomLine(ctx, Styles.CellErrorLineBackgroundColor);
                    }
                }
                else if (buildOutputNode.NodeType == BuildOutputNodeType.Warning)
                {
                    FillCellBackground(ctx, Styles.CellWarningBackgroundColor);

                    if (status.DrawsTopLine)
                    {
                        DrawTopLine(ctx, Styles.CellWarningLineBackgroundColor);
                    }

                    if (status.DrawsBottomLine)
                    {
                        DrawBottomLine(ctx, Styles.CellWarningLineBackgroundColor);
                    }
                }
            }
        }
 public static Xwt.Drawing.Color GetTextColor(BuildOutputNode buildOutputNode, bool isSelected)
 {
     if (isSelected)
     {
         if (buildOutputNode.NodeType == BuildOutputNodeType.TargetSkipped)
         {
             return(Styles.CellTextSkippedSelectionColor);
         }
         else
         {
             return(Styles.CellTextSelectionColor);
         }
     }
     else
     {
         if (buildOutputNode.NodeType == BuildOutputNodeType.TargetSkipped)
         {
             return(Styles.CellTextSkippedColor);
         }
         else
         {
             return(Styles.CellTextColor);
         }
     }
 }
Пример #4
0
 public void RaiseNodeChanged(BuildOutputNode node)
 {
     if (node != null)
     {
         NodeChanged?.Invoke(this, new TreeNodeEventArgs(node));
     }
 }
Пример #5
0
        public BuildOutputNode AddChild(BuildOutputNode child)
        {
            if (children == null)
            {
                children = new List <BuildOutputNode> ();
            }

            if (child.NodeType == BuildOutputNodeType.Message && NodeType == BuildOutputNodeType.Task && KnownTools.Contains(Message))
            {
                child.IsCommandLine = true;
            }

            var parent = children.LastOrDefault();

            if (parent != null)
            {
                parent.Next    = child;
                child.Previous = parent;
            }

            children.Add(child);

            child.Parent = this;
            return(child);
        }
Пример #6
0
        public void AddParameter(string message, string fullMessage)
        {
            var parametersNode = FindChild(ParametersNodeName);

            if (parametersNode == null)
            {
                parametersNode = new BuildOutputNode {
                    NodeType    = BuildOutputNodeType.Parameters,
                    Message     = ParametersNodeName,
                    FullMessage = ParametersNodeName,
                    Parent      = this
                };

                if (children == null)
                {
                    children = new List <BuildOutputNode> ();
                }

                children.Insert(0, parametersNode);
            }

            parametersNode.AddChild(new BuildOutputNode {
                NodeType    = BuildOutputNodeType.Diagnostics,
                Message     = message,
                FullMessage = fullMessage
            });
        }
 ViewStatus GetViewStatus(BuildOutputNode node)
 {
     if (!viewStatus.TryGetValue(node, out var status))
     {
         status = viewStatus [node] = new ViewStatus(node);
     }
     return(status);
 }
Пример #8
0
        IEnumerable <BuildOutputNode> GetProjectRootNodes()
        {
            int errorCount = 0, warningCount = 0;
            Dictionary <string, AggregatedBuildOutputNode> result = new Dictionary <string, AggregatedBuildOutputNode> ();
            DateTime maximum = default(DateTime);
            DateTime minimum = default(DateTime);

            foreach (var proj in projects)
            {
                foreach (var node in proj.RootNodes)
                {
                    AggregatedBuildOutputNode aggregated = null;
                    if (result.TryGetValue(node.Message, out aggregated))
                    {
                        aggregated.AddNode(node);
                    }
                    else
                    {
                        result [node.Message] = new AggregatedBuildOutputNode(node);
                    }

                    if (maximum == default(DateTime) || node.EndTime.Ticks > maximum.Ticks)
                    {
                        maximum = node.EndTime;
                    }

                    if (minimum == default(DateTime) || node.StartTime.Ticks < minimum.Ticks)
                    {
                        minimum = node.StartTime;
                    }

                    errorCount   += node.Children.Sum(x => x.ErrorCount);
                    warningCount += node.Children.Sum(x => x.WarningCount);
                }
            }

            if (result.Values.Count > 0)
            {
                // Add summary node
                var message     = errorCount > 0 ? GettextCatalog.GetString("Build failed") : GettextCatalog.GetString("Build succeeded");
                var summaryNode = new BuildOutputNode {
                    NodeType     = BuildOutputNodeType.BuildSummary,
                    StartTime    = minimum,
                    EndTime      = maximum,
                    Message      = message,
                    FullMessage  = message,
                    HasErrors    = errorCount > 0,
                    HasWarnings  = warningCount > 0,
                    HasData      = false,
                    ErrorCount   = errorCount,
                    WarningCount = warningCount
                };

                return(result.Values.Concat(summaryNode));
            }

            return(result.Values);
        }
Пример #9
0
 public void EndCurrentNode(string message, DateTime endTime)
 {
     currentNode.EndTime = endTime;
     if (currentNode.Parent != null)
     {
         currentNode.Parent.EndTime = endTime;
     }
     currentNode = currentNode?.Parent;
 }
			Font GetFont (BuildOutputNode node)
			{
				if (IsRootNode) {
					return defaultBoldFont;
				} else if (node.IsCommandLine) {
					return monospaceFont;
				}
				return defaultFont;
			}
Пример #11
0
 public ViewStatus(BuildOutputNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException(nameof(node));
     }
     Node        = node;
     Icon        = Node.GetImage();
     layout.Font = GetFont(node);
 }
Пример #12
0
 Font GetFont(BuildOutputNode node)
 {
     if (IsRootNode)
     {
         return(defaultBoldFont);
     }
     if (node.IsCommandLine)
     {
         return(monospaceFont);
     }
     return(defaultFont);
 }
Пример #13
0
        public static Color GetTextColor(BuildOutputNode buildOutputNode, bool isSelected)
        {
            if (isSelected)
            {
                return(CellTextSelectionColor);
            }

            if (buildOutputNode.NodeType == BuildOutputNodeType.TargetSkipped)
            {
                return(CellTextSkippedColor);
            }
            return(CellTextColor);
        }
Пример #14
0
        public void AddNode(BuildOutputNodeType nodeType, string message, string fullMessage, bool isStart, DateTime startTime, string file = null, string project = null, int lineNumber = default(int))
        {
            var node = new BuildOutputNode {
                NodeType    = nodeType,
                Message     = message,
                FullMessage = fullMessage,
                File        = file,
                Project     = project,
                LineNumber  = lineNumber,
                StartTime   = startTime
            };

            if (currentNode == null)
            {
                rootNodes.Add(node);
            }
            else
            {
                currentNode.AddChild(node);
            }

            if (isStart)
            {
                currentNode = node;
            }

            if (nodeType == BuildOutputNodeType.Error || nodeType == BuildOutputNodeType.Message || nodeType == BuildOutputNodeType.Warning)
            {
                var p = node;
                while (p != null)
                {
                    if (nodeType == BuildOutputNodeType.Error)
                    {
                        p.HasErrors = true;
                        p.ErrorCount++;
                    }
                    else if (nodeType == BuildOutputNodeType.Warning)
                    {
                        p.HasWarnings = true;
                        p.WarningCount++;
                    }
                    else if (nodeType == BuildOutputNodeType.Message)
                    {
                        p.HasData = true;
                    }

                    p = p.Parent;
                }
            }
        }
Пример #15
0
        public void AddNode(BuildOutputNode node)
        {
            if (nodes.Count > 0 && (node.NodeType != NodeType || node.Message != Message))
            {
                return;
            }

            nodes.Add(node);
            if (node.HasChildren)
            {
                foreach (var child in node.Children)
                {
                    AddChild(child);
                }
            }
        }
Пример #16
0
 public AggregatedBuildOutputNode(BuildOutputNode node)
 {
     AddNode(node);
 }
Пример #17
0
 protected void Clear()
 {
     currentNode = null;
     rootNodes.Clear();
     NeedsProcessing = true;
 }
        void DrawNodeInformation(Context ctx, Xwt.Rectangle cellArea, BuildOutputNode buildOutputNode, double padding, bool isSelected, int imageSize, int imagePadding, ViewStatus status)
        {
            if (!buildOutputNode.HasChildren)
            {
                if (buildOutputNode.NodeType == BuildOutputNodeType.Error || buildOutputNode.NodeType == BuildOutputNodeType.Warning)
                {
                    if (isSelected)
                    {
                        ctx.SetColor(Styles.CellTextSelectionColor);
                    }
                    else
                    {
                        ctx.SetColor(Styles.LinkForegroundColor);
                    }
                    var text = string.Format("{0}, line {1}", buildOutputNode.File, buildOutputNode.LineNumber);

                    status.TaskLinkRenderRectangle.X = lastErrorPanelStartX + 5;
                    status.TaskLinkRenderRectangle.Y = cellArea.Y + padding;

                    //TODO: we can do a cache of the text layout and only resize
                    //Our link text layoud needs to be created with real size
                    var layout = CreateTextLayout(cellArea, text, defaultFont, trimming: TextTrimming.WordElipsis, underline: true);
                    status.TaskLinkRenderRectangle.Size = layout.GetSize();

                    //Now we calculate if fits the content and readjust
                    var maxSize = cellArea.Width + cellArea.X + padding - status.TaskLinkRenderRectangle.X;
                    status.TaskLinkRenderRectangle.Width = layout.Width = maxSize;

                    DrawText(ctx, layout, cellArea, status.TaskLinkRenderRectangle.X, padding);
                    return;
                }
                return;
            }

            UpdateInformationTextColor(ctx, isSelected);

            var textStartX = cellArea.X + (cellArea.Width - DefaultInformationContainerWidth);

            Size size = Size.Zero;

            //Duration text
            var duration = status.Duration;

            if (duration != "")
            {
                size        = DrawText(ctx, cellArea, textStartX, duration, padding, defaultFont, DefaultInformationContainerWidth).GetSize();
                textStartX += size.Width + 10;
            }

            if (textStartX > lastErrorPanelStartX)
            {
                lastErrorPanelStartX = textStartX;
            }
            else
            {
                textStartX = lastErrorPanelStartX;
            }

            status.TaskLinkRenderRectangle.X = status.TaskLinkRenderRectangle.Y = status.TaskLinkRenderRectangle.Width = status.TaskLinkRenderRectangle.Height = 0;

            //Error and Warnings count
            if (!IsRowExpanded(buildOutputNode) &&
                (buildOutputNode.NodeType == BuildOutputNodeType.Task || buildOutputNode.NodeType == BuildOutputNodeType.Target) &&
                (buildOutputNode.ErrorCount > 0 || buildOutputNode.WarningCount > 0))
            {
                if (buildOutputNode.ErrorCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.ErrorIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    var errors = buildOutputNode.ErrorCount.ToString();

                    var layout = DrawText(ctx, cellArea, textStartX, errors, padding, defaultFont, trimming: TextTrimming.Word);
                    textStartX += layout.GetSize().Width;
                }

                if (buildOutputNode.WarningCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.WarningIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    DrawText(ctx, cellArea, textStartX, buildOutputNode.WarningCount.ToString(), padding, defaultFont, 10, trimming: TextTrimming.Word);
                }
            }
        }
 public BuildOutputCellSelection(BuildOutputNode node, int selectionStart, int selectionEnd)
 {
     SelectionStart = selectionStart;
     SelectionEnd   = selectionEnd;
     Node           = node;
 }
        void DrawNodeInformation(Context ctx, Xwt.Rectangle cellArea, BuildOutputNode buildOutputNode, double padding, bool isSelected, int imageSize, int imagePadding, ViewStatus status)
        {
            if (!buildOutputNode.HasChildren)
            {
                if (buildOutputNode.NodeType == BuildOutputNodeType.Error || buildOutputNode.NodeType == BuildOutputNodeType.Warning)
                {
                    if (isSelected)
                    {
                        ctx.SetColor(Styles.CellTextSelectionColor);
                    }
                    else
                    {
                        ctx.SetColor(Styles.LinkForegroundColor);
                    }
                    var text = string.Format("{0}, line {1}", buildOutputNode.File, buildOutputNode.LineNumber);

                    status.TaskLinkRenderRectangle.X = lastErrorPanelStartX + 5;
                    status.TaskLinkRenderRectangle.Y = cellArea.Y + padding;

                    var layout = DrawText(ctx, cellArea, status.TaskLinkRenderRectangle.X, text, padding, font: defaultFont, trimming: TextTrimming.Word, underline: true);
                    status.TaskLinkRenderRectangle.Size = layout.GetSize();
                    return;
                }
                return;
            }

            UpdateInformationTextColor(ctx, isSelected);

            var textStartX = cellArea.X + (cellArea.Width - DefaultInformationContainerWidth);

            Size size = Size.Zero;

            //Duration text
            var duration = buildOutputNode.GetDurationAsString(contextProvider.IsShowingDiagnostics);

            if (duration != "")
            {
                size        = DrawText(ctx, cellArea, textStartX, duration, padding, defaultFont, DefaultInformationContainerWidth).GetSize();
                textStartX += size.Width + 10;
            }

            if (textStartX > lastErrorPanelStartX)
            {
                lastErrorPanelStartX = textStartX;
            }
            else
            {
                textStartX = lastErrorPanelStartX;
            }

            status.TaskLinkRenderRectangle.X = status.TaskLinkRenderRectangle.Y = status.TaskLinkRenderRectangle.Width = status.TaskLinkRenderRectangle.Height = 0;

            //Error and Warnings count
            if (!IsRowExpanded(buildOutputNode) &&
                (buildOutputNode.NodeType == BuildOutputNodeType.Task || buildOutputNode.NodeType == BuildOutputNodeType.Target) &&
                (buildOutputNode.ErrorCount > 0 || buildOutputNode.WarningCount > 0))
            {
                if (buildOutputNode.ErrorCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.ErrorIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    var errors = buildOutputNode.ErrorCount.ToString();

                    var layout = DrawText(ctx, cellArea, textStartX, errors, padding, defaultFont, trimming: TextTrimming.Word);
                    textStartX += layout.GetSize().Width;
                }

                if (buildOutputNode.WarningCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.WarningIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    DrawText(ctx, cellArea, textStartX, buildOutputNode.WarningCount.ToString(), padding, defaultFont, 10, trimming: TextTrimming.Word);
                }
            }
        }
        internal bool IsViewClickable(BuildOutputNode node, Point position)
        {
            var view = GetViewStatus(node);

            return(!view.LastRenderExpanderBounds.Contains(position) && view.LastRenderBounds.Contains(position));
        }
 string GetInformationMessage(BuildOutputNode buildOutputNode) => GettextCatalog.GetString("{0} | {1}     Started at {2}", buildOutputNode.Configuration, buildOutputNode.Platform, buildOutputNode.StartTime.ToString("h:m tt on MMM d, yyyy"));
 bool IsRowExpanded(BuildOutputNode buildOutputNode) => ((Xwt.TreeView)ParentWidget)?.IsRowExpanded(buildOutputNode) ?? false;
        protected override void OnButtonPressed(ButtonEventArgs args)
        {
            var node   = GetValue(BuildOutputNodeField);
            var status = GetViewStatus(node);

            if (args.Button == PointerButton.Left && args.MultiplePress == 0)
            {
                if (status.TaskLinkRenderRectangle.Contains(args.Position))
                {
                    GoToTask?.Invoke(this, node);
                    return;
                }

                if (status.ErrorsRectangle.Contains(args.Position))
                {
                    ExpandErrors?.Invoke(this, node);
                    return;
                }

                if (status.WarningsRectangle.Contains(args.Position))
                {
                    ExpandWarnings?.Invoke(this, node);
                    return;
                }
            }

            status.CalculateLayout(status.LastRenderBounds, out var layout, out var layoutBounds, out var expanderRect);

            if (expanderRect != Rectangle.Zero && expanderRect.Contains(args.Position))
            {
                if (DateTime.Now.Subtract(lastExpanderClick).TotalMilliseconds < DefaultExpandClickDelay)
                {
                    return;
                }
                status.Expanded   = !status.Expanded;
                lastExpanderClick = DateTime.Now;
                QueueResize();
                return;
            }

            if (args.Button == PointerButton.Left && layoutBounds.Contains(args.Position))
            {
                var pos = layout.GetIndexFromCoordinates(args.Position.X - layoutBounds.X, args.Position.Y - layoutBounds.Y);
                if (pos != -1)
                {
                    selectionStart = selectionEnd = pos;
                    selectionRow   = node;
                    clicking       = true;
                }
                else
                {
                    selectionRow = null;
                }

                QueueDraw();
            }

            //HACK: to avoid automatic scroll behaviour in Gtk (we handle the behaviour)
            //we only want break the normal click behaviour of treeview, in cases when label size is bigger than tree height
            var treeView = ((TreeView)ParentWidget);

            if (status.Expanded && status.LastRenderBounds.Height > treeView.Size.Height)
            {
                args.Handled = true;
                treeView.SelectRow(node);
            }
            base.OnButtonPressed(args);
        }