Skip to content

Commit

Permalink
Merge pull request #63 from skowront/issue26
Browse files Browse the repository at this point in the history
Issue26
  • Loading branch information
krzysztof-lorenc authored Jul 2, 2020
2 parents aecb43c + 5f0cb90 commit dd80a0f
Show file tree
Hide file tree
Showing 24 changed files with 437 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock><LineBreak/></TextBlock>
</StackPanel>
<buildServer:ProgressBarTooltipControl DataContext="{Binding}" />
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@

<converters:TimeToApproximateTimeConverter x:Key="TimeToApproximateTimeConverter" />
<converters:NullOrDefaultToVisibilityConverter x:Key="NullOrDefaultVisibilityConverter" />
<ToolTip x:Key="CruiseControlBuildInfoToolTip">
<StackPanel>
<local:CCProgressBarTooltipControl DataContext="{Binding}" />
<buildServer:CulpritsControl Caption="Changes by:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
<converters:MainStatusToVisibilityConverter x:Key="MainStatusToVisibilityConverter" />
<ToolTip x:Key="CruiseControlBuildInfoToolTip" Visibility="{Binding Path=. , Converter={StaticResource MainStatusToVisibilityConverter}}">
<StackPanel>
<local:CCProgressBarTooltipControl DataContext="{Binding}" />
<buildServer:CulpritsControl Caption="Changes by:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
</ToolTip>

<DataTemplate DataType="{x:Type local:CruiseControlProjectViewModel}">
<DockPanel Width="Auto" ContextMenu="{DynamicResource BuildServerProjectContextMenu}">
<ToolTip x:Key="RowToolTip" Visibility="{Binding CurrentStatus , Converter={StaticResource MainStatusToVisibilityConverter}}">
<StackPanel DataContext="{Binding CurrentStatus}">
<local:CCProgressBarTooltipControl DataContext="{Binding}" />
<buildServer:CulpritsControl Caption="Changes by:" CulpritsProp="{Binding DataContext.Culprits, RelativeSource={RelativeSource AncestorType=StackPanel}}" />
</StackPanel>
</ToolTip>

<DataTemplate DataType="{x:Type local:CruiseControlProjectViewModel}">
<DockPanel Width="Auto" ContextMenu="{DynamicResource BuildServerProjectContextMenu}" DataContext="{Binding}" ToolTip="{StaticResource RowToolTip}">
<buildServer:BuildInformationIconControl DataContext="{Binding CurrentStatus}"
DockPanel.Dock="Left"
ToolTip="{StaticResource CruiseControlBuildInfoToolTip}" />
Expand All @@ -39,9 +47,9 @@
FontWeight="Normal"
Text="{Binding CurrentStatus.FinishTime, Converter={StaticResource TimeToApproximateTimeConverter}}"
Visibility="{Binding CurrentStatus.FinishTime, Converter={StaticResource NullOrDefaultVisibilityConverter}}" />
<DockPanel.ToolTip>
<TextBlock Text="{Binding Description}"></TextBlock>
</DockPanel.ToolTip>
<DockPanel>
<TextBlock/>
</DockPanel>
</DockPanel>
</DataTemplate>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
namespace Soloplan.WhatsON.CruiseControl.GUI
{
using System;
using System.Windows.Navigation;
using Soloplan.WhatsON.GUI.Common.BuildServer;
using Soloplan.WhatsON.GUI.Common.ConnectorTreeView;
using Soloplan.WhatsON.Model;

public class CruiseControlProjectViewModel : ConnectorViewModel
{
Expand All @@ -23,5 +25,19 @@ protected override BuildStatusViewModel GetStatusViewModel()
{
return new CruiseControlStatusViewModel(this);
}

/// <summary>
/// Implements function that decides if a tooltip should be visible.
/// </summary>
/// <returns>True when should be visible, false when should not be visible.</returns>
public override bool ShouldDisplayTooltip()
{
if (this.CurrentStatus is CruiseControlStatusViewModel status)
{
return (status.Culprits.Count == 0 && status.State != ObservationState.Running) ? false : true;
}

return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
<converters:StatusToColorConverter x:Key="StatusToColorConverter" />
<converters:TimeToApproximateTimeConverter x:Key="TimeToApproximateTimeConverter" />
<converters:NullOrDefaultToVisibilityConverter x:Key="NullOrDefaultVisibilityConverter" />
<converters:DebugConverter x:Key="DebugConverter" />

<ContextMenu x:Key="BuildServerProjectContextMenu">
<!-- CommandParameter must be declared before Command or else value from previous opening of context menu will be passed. WTF?! -->
<MenuItem CommandParameter="{Binding CurrentStatus}" Command="{Binding CurrentStatus.CopyBuildLabel}">
<MenuItem CommandParameter="{Binding CurrentStatus}" Command="{Binding CurrentStatus.CopyBuildLabel}" IsEnabled="{Binding IsOnlyOneSelected}">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="TagOutline" />
<TextBlock Padding="10,0,0,0" Text="Copy latest build label" IsEnabled="{Binding RenameCommand.canExecuteState}"/>
</StackPanel>
<TextBlock Padding="10,0,0,0" Text="Copy latest build label"/>
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem Command="{Binding RenameCommand}" IsEnabled="{Binding RenameCommand.canExecuteState}">
<MenuItem Command="{Binding RenameCommand}" IsEnabled="{Binding RenameCommand.canExecuteState}">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Rename" />
Expand Down Expand Up @@ -53,7 +54,7 @@
</MenuItem.Header>
</MenuItem>
<Separator />
<MenuItem CommandParameter="{Binding CurrentStatus.Parent.Url}" Command="{Binding OpenWebPage}">
<MenuItem CommandParameter="{Binding CurrentStatus.Parent.Url}" Command="{Binding OpenWebPage}" IsEnabled="{Binding IsOnlyOneSelected}">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Link" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
</UserControl.Resources>

<StackPanel Visibility="{Binding CulpritsProp, Mode=OneWay, Converter={StaticResource CountToVisibility}}">
<TextBlock Text="" />
<TextBlock Text="{Binding Caption}" />
<ItemsControl ItemsSource="{Binding CulpritsProp}">
<ItemsControl.ItemTemplate>
Expand All @@ -26,5 +25,6 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="" />
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<UserControl x:Class="Soloplan.WhatsON.GUI.Common.BuildServer.ProgressBarControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Soloplan.WhatsON.GUI.Common.BuildServer"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance local:BuildStatusViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
</UserControl.Resources>
<StackPanel Orientation="{Binding ControlOrientation, RelativeSource={RelativeSource AncestorType=local:ProgressBarTooltipControl}}">
<StackPanel Orientation="{Binding ControlOrientation, RelativeSource={RelativeSource AncestorType=local:ProgressBarTooltipControl}}" Visibility="{Binding BuildingNoLongerThenExpected, Converter={StaticResource BoolToVisibility}}">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="CompletionText" Text="Completion: " />
<TextBlock Text="{Binding Progress}" />
<TextBlock x:Name="PercentSignText" Text="% " />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:00}:{1:00}:{2:00}">
<Binding Path="EstimatedRemaining.Hours" />
<Binding Path="EstimatedRemaining.Minutes" />
<Binding Path="EstimatedRemaining.Seconds" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Name="EstimatedRemainingText" Text=" estimated remaining" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Visibility="{Binding BuildingLongerThenExpected, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="Taking " />
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:00}:{1:00}:{2:00}">
<Binding Path="BuildTimeExcedingEstimation.Hours" />
<Binding Path="BuildTimeExcedingEstimation.Minutes" />
<Binding Path="BuildTimeExcedingEstimation.Seconds" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Text=" longer than estimated." />
</StackPanel>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ProgressBarTooltipControl.xaml.cs" company="Soloplan GmbH">
// Copyright (c) Soloplan GmbH. All rights reserved.
// Licensed under the MIT License. See License-file in the project root for license information.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Soloplan.WhatsON.GUI.Common.BuildServer
{
using System.Windows;
using System.Windows.Controls;

/// <summary>
/// Control for project build progress.
/// </summary>
public partial class ProgressBarControl : UserControl
{
/// <summary>
/// Dependency property for <see cref="CulpritsProp"/>.
/// </summary>
public static readonly DependencyProperty ControlOrientationProperty = DependencyProperty.Register(nameof(ControlOrientation), typeof(Orientation), typeof(ProgressBarControl), new PropertyMetadata(Orientation.Vertical));

public static readonly DependencyProperty CompactDisplayProperty = DependencyProperty.Register(nameof(CompactDisplay), typeof(bool), typeof(ProgressBarControl), new PropertyMetadata(false, new PropertyChangedCallback(OnCurrentReadingChanged)));

public ProgressBarControl()
{
this.InitializeComponent();
}

private static void OnCurrentReadingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ProgressBarTooltipControl control)
{
control.UpdateTexts();
}
}

public Orientation ControlOrientation
{
get => (Orientation)this.GetValue(ControlOrientationProperty);
set => this.SetValue(ControlOrientationProperty, value);
}

public bool CompactDisplay
{
get => (bool)this.GetValue(CompactDisplayProperty);
set => this.SetValue(CompactDisplayProperty, value);
}

public void UpdateTexts()
{
if (this.CompactDisplay)
{
this.CompletionText.Text = string.Empty;
this.EstimatedRemainingText.Text = " ETA";
this.PercentSignText.Text = "%/";
}
else
{
this.CompletionText.Text = "Completion: ";
this.EstimatedRemainingText.Text = " estimated remaining";
this.PercentSignText.Text = "% ";
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</TextBlock.Text>
</TextBlock>
<TextBlock Name="EstimatedRemainingText" Text=" estimated remaining" />
<TextBlock><LineBreak/></TextBlock>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Visibility="{Binding BuildingLongerThenExpected, Converter={StaticResource BoolToVisibility}}">
Expand All @@ -42,7 +43,8 @@
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Text=" longer than estimated." />
<TextBlock Text=" longer than estimated." />
<TextBlock><LineBreak/></TextBlock>
</StackPanel>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ namespace Soloplan.WhatsON.GUI.Common.BuildServer
using System.Windows.Controls;

/// <summary>
/// Interaction logic for ProgressInformationControl.xaml.
/// Control for project tooltips.
/// </summary>
public partial class ProgressBarTooltipControl : UserControl
{
/// <summary>
/// Dependency property for <see cref="CulpritsProp"/>.
/// </summary>
public static readonly DependencyProperty ControlOrientationProperty = DependencyProperty.Register(nameof(ControlOrientation), typeof(Orientation), typeof(ProgressBarTooltipControl), new PropertyMetadata(Orientation.Vertical));
public static readonly DependencyProperty ControlOrientationTooltipProperty = DependencyProperty.Register(nameof(ControlOrientation), typeof(Orientation), typeof(ProgressBarTooltipControl), new PropertyMetadata(Orientation.Vertical));

public static readonly DependencyProperty CompactDisplayProperty = DependencyProperty.Register(nameof(CompactDisplay), typeof(bool), typeof(ProgressBarTooltipControl), new PropertyMetadata(false, new PropertyChangedCallback(OnCurrentReadingChanged)));
public static readonly DependencyProperty CompactDisplayTooltipProperty = DependencyProperty.Register(nameof(CompactDisplay), typeof(bool), typeof(ProgressBarTooltipControl), new PropertyMetadata(false, new PropertyChangedCallback(OnCurrentReadingChanged)));

public ProgressBarTooltipControl()
{
Expand All @@ -37,14 +37,14 @@ private static void OnCurrentReadingChanged(DependencyObject d, DependencyProper

public Orientation ControlOrientation
{
get => (Orientation)this.GetValue(ControlOrientationProperty);
set => this.SetValue(ControlOrientationProperty, value);
get => (Orientation)this.GetValue(ControlOrientationTooltipProperty);
set => this.SetValue(ControlOrientationTooltipProperty, value);
}

public bool CompactDisplay
{
get => (bool)this.GetValue(CompactDisplayProperty);
set => this.SetValue(CompactDisplayProperty, value);
get => (bool)this.GetValue(CompactDisplayTooltipProperty);
set => this.SetValue(CompactDisplayTooltipProperty, value);
}

public void UpdateTexts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,33 @@ private void DeleteSelectedConnectors()
}
}

/// <summary>
/// Performs a deletion of a connector.
/// </summary>
private void DeleteConnector(ConnectorViewModel connectorViewModel)
{
bool madeChanges = false;
foreach (var connectorGroup in this.connectorGroups.ToList())
{
foreach (var connector in connectorGroup.ConnectorViewModels.ToList())
{
if (connectorViewModel.Identifier == connector.Identifier)
{
connectorGroup.ConnectorViewModels.Remove(connectorViewModel);
madeChanges = true;
}
}
}

this.ClearEmptyGroups();

if (madeChanges)
{
this.OnConfigurationChanged(this, EventArgs.Empty);
this.FireOneGroupChanged();
}
}

public async void DeleteGroup(object sender, DeleteTreeItemEventArgs e)
{
if (e.DeleteItem is ConnectorViewModel clickedConnector)
Expand All @@ -670,6 +697,12 @@ public async void DeleteGroup(object sender, DeleteTreeItemEventArgs e)
var canceled = await e.CheckCanceled();
if (!canceled)
{
if (selectedConnectors.Count == 0)
{
this.DeleteConnector(clickedConnector);
return;
}

this.DeleteSelectedConnectors();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ public virtual void Update(Connector changedConnector)
}));
}

/// <summary>
/// Implements function that decides if a tooltip should be visible.
/// </summary>
/// <returns>Base returns always true.</returns>
public virtual bool ShouldDisplayTooltip()
{
return true;
}

protected virtual BuildStatusViewModel GetStatusViewModel()
{
return new BuildStatusViewModel(this);
Expand All @@ -191,7 +200,7 @@ protected virtual BuildStatusViewModel GetStatusViewModel()
protected override CustomCommand CreateEditCommand()
{
var command = base.CreateEditCommand();
command.CanExecuteExternal += (s, e) => { e.Cancel = this.ConfigurationModifiedInTree || !this.isOnlyOneSelected; };
command.CanExecuteExternal += (s, e) => { e.Cancel = this.ConfigurationModifiedInTree || !this.IsOnlyOneSelected; };
return command;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,8 @@
HorizontalContentAlignment="Stretch"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
VirtualizingPanel.IsVirtualizing="True"
ScrollViewer.ScrollChanged="OnScroll">
<TreeView.InputBindings>
dd:DragDrop.IsDropTarget="True">
<TreeView.InputBindings>
<KeyBinding Key="Delete" Command="{Binding DeleteSelectedObject, Mode=OneWay, RelativeSource={RelativeSource AncestorType=local:ConnectorsTreeView}}" />
</TreeView.InputBindings>
<TreeView.ItemContainerStyle>
Expand Down
Loading

0 comments on commit dd80a0f

Please sign in to comment.