Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #8

Merged
merged 70 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
155bb73
Added displayName property.
May 7, 2020
a9599db
Cleanup
May 7, 2020
2d947fd
Cleanup
May 7, 2020
70b79fb
Type fix.
May 7, 2020
889810f
First trials to display description
May 7, 2020
fd7e338
trials with string substitution in xaml
May 8, 2020
70dc5ed
TODO converter from rgba to rgb
May 8, 2020
d4845c5
adding a converter
May 8, 2020
1e1d6d9
TODO: find what material should be applied to tooltip font, code work…
May 12, 2020
91ccbfc
Cleanup
May 12, 2020
aae414f
AddedMaxWidthtoTooTip
May 12, 2020
4371fc9
Merge pull request #43 from skowront/issue28
krzysztof-lorenc May 12, 2020
023ec3a
CCnet hyperlinks fixed, ccnet status & history diplay fixed
May 14, 2020
1e0e36f
server null assignment to cache exception fix
May 14, 2020
375bd5f
Separated address and base address for cruise control. Links in wizar…
May 14, 2020
4fbec09
ok button was updating currently bound item on the list, since Connec…
May 15, 2020
436f2c6
cleaner solution
May 15, 2020
8ba6e3b
wirking with project descriptions
May 15, 2020
61309cd
Merge pull request #44 from skowront/issue15
krzysztof-lorenc May 19, 2020
5e0365e
cc category fix
May 19, 2020
5916c5a
Merge issue 15 (wizard tooltips)
May 19, 2020
5c8e466
Merge pull request #46 from skowront/issue45
krzysztof-lorenc May 19, 2020
2639a04
Working button blocking while pending changes. TODO move on configura…
May 21, 2020
d25e10b
Hyperlinks error from issue15 merge fix
May 21, 2020
c18c7dd
early trials
May 22, 2020
484bbe8
mouse up fires twice and messes with unclicking, counters seem useless
May 22, 2020
c0c2c33
multiselecTree
May 26, 2020
f2bd64e
Revert "multiselecTree"
May 26, 2020
f0e0292
correct direction, it is possible to move multiple items when there a…
May 26, 2020
f6a94ab
dragging between groups is flower
May 26, 2020
9ae672d
Merge branch 'master' into issue40v1
krzysztof-lorenc May 26, 2020
f5f5633
Merge pull request #48 from skowront/issue40v1
krzysztof-lorenc May 26, 2020
32f4432
Moving between groups works fine now. TODO style, the multiple deleti…
May 26, 2020
d5e4603
Color works with night mode.
May 26, 2020
3a2be15
Unused line fix
May 26, 2020
a5b21bc
TODO multiple deletions
May 26, 2020
34050e2
working multiple connector deletions from multiple groups
May 28, 2020
184a1e1
Fixed suspicious behaviour when moving items
May 28, 2020
a3bb08c
refactor in ConnectorTreeViewModel
May 28, 2020
b7c19da
connectors redundancy for selection and drop
May 28, 2020
e5331df
Refactor 1.0 in ConnectorTreeView.xaml.cs
May 28, 2020
a264107
REFACTOR 2.0 + Selection seems absolutely decent
May 28, 2020
611d876
converter option base?
May 29, 2020
d46b591
rearrangement when dropping fix
May 29, 2020
5afe6af
Most buttons disabled when multiple selection
May 29, 2020
5c0d1d5
Working keyboard delete, also multiple deletions.
May 29, 2020
e23ce91
Ctrl+A -> de/selecting all AND removing empty groups
May 29, 2020
ecf0aa5
Shift+select
May 29, 2020
6d95590
Refactor 2.1 + documenting
May 29, 2020
f20b292
Refactor 2.2
May 29, 2020
76da68c
Issue50 done
Jun 2, 2020
8a144eb
4 liner fix... -,-
Jun 5, 2020
8dced65
Merge pull request #49 from skowront/issue36
krzysztof-lorenc Jun 16, 2020
610a667
Merge pull request #51 from skowront/issue39v2
krzysztof-lorenc Jun 16, 2020
26f0700
Merge pull request #53 from skowront/issue29
krzysztof-lorenc Jun 16, 2020
c170148
Added older version handling.
Jun 18, 2020
f24c613
Fix
Jun 18, 2020
43511f8
refactor
Jun 18, 2020
8d438d6
Removed configuration save.
Jun 18, 2020
d3ca2e4
merge problem fix
Jun 18, 2020
cf70abc
optional direct address
Jun 23, 2020
0aae500
Merge pull request #5 from Soloplan/master
skowront Jun 23, 2020
e162a55
Merge pull request #6 from skowront/ConfigurationFiles
skowront Jun 23, 2020
0bca9fa
Merge pull request #7 from skowront/issue50
skowront Jun 23, 2020
97f6e83
Optimization should be now improved.
Jun 23, 2020
f5fefcc
Refactor
Jun 23, 2020
7a7d61c
Merge pull request #57 from skowront/ConfigurationFiles
krzysztof-lorenc Jun 24, 2020
25a80de
Merge pull request #58 from skowront/issue50
krzysztof-lorenc Jun 24, 2020
4d8474c
Merge branch 'master' into Optimization
krzysztof-lorenc Jun 24, 2020
aecb43c
Merge pull request #59 from skowront/Optimization
krzysztof-lorenc Jun 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,33 @@
</ToolTip>

<DataTemplate DataType="{x:Type local:CruiseControlProjectViewModel}">
<DockPanel Width="Auto" ContextMenu="{DynamicResource BuildServerProjectContextMenu}">
<buildServer:BuildInformationIconControl DataContext="{Binding CurrentStatus}"
<DockPanel Width="Auto" ContextMenu="{DynamicResource BuildServerProjectContextMenu}">
<buildServer:BuildInformationIconControl DataContext="{Binding CurrentStatus}"
DockPanel.Dock="Left"
ToolTip="{StaticResource CruiseControlBuildInfoToolTip}" />
<buildServer:BuildNumberControl Margin="5,0,0,0"
<buildServer:BuildNumberControl Margin="5,0,0,0"
VerticalAlignment="Center"
BuildNumber="{Binding DataContext.CurrentStatus.BuildNumber, RelativeSource={RelativeSource AncestorType=DockPanel}}" />
<TextBlock MinWidth="150"
<TextBlock MinWidth="150"
MaxWidth="250"
Margin="5,0,0,0"
FontSize="{Binding DataContext.FontSize, Mode=OneWay, RelativeSource={RelativeSource AncestorType=connectorTreeView:ConnectorsTreeView}}"
FontWeight="Normal"
Text="{Binding Name}"
TextTrimming="CharacterEllipsis" />
<buildServer:HistoryBuildList DataContext="{Binding ConnectorSnapshots, Mode=OneWay}" DockPanel.Dock="Right" />
<TextBlock Margin="5,0,10,0"
TextTrimming="CharacterEllipsis">
</TextBlock>
<buildServer:HistoryBuildList DataContext="{Binding ConnectorSnapshots, Mode=OneWay}" DockPanel.Dock="Right" />
<TextBlock Margin="5,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
DockPanel.Dock="Right"
FontSize="{Binding DataContext.FontSizeSmall, Mode=OneWay, RelativeSource={RelativeSource AncestorType=connectorTreeView:ConnectorsTreeView}}"
FontWeight="Normal"
Text="{Binding CurrentStatus.FinishTime, Converter={StaticResource TimeToApproximateTimeConverter}}"
Visibility="{Binding CurrentStatus.FinishTime, Converter={StaticResource NullOrDefaultVisibilityConverter}}" />
</DockPanel>
</DataTemplate>
<DockPanel.ToolTip>
<TextBlock Text="{Binding Description}"></TextBlock>
</DockPanel.ToolTip>
</DockPanel>
</DataTemplate>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CruiseControlProjectViewModel : ConnectorViewModel
public CruiseControlProjectViewModel(CruiseControlConnector connector)
: base(connector)
{
this.Url = CruiseControlServer.UrlHelper.GetReportUrl(connector.Address, connector.Project);
this.Url = CruiseControlServer.UrlHelper.GetReportUrl(connector.directAddress, connector.Project);
}

protected override BuildStatusViewModel GetStatusViewModel()
Expand Down
8 changes: 5 additions & 3 deletions src/Soloplan.WhatsON.CruiseControl/CruiseControlConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ namespace Soloplan.WhatsON.CruiseControl
using Soloplan.WhatsON.CruiseControl.Model;
using Soloplan.WhatsON.Model;

[ConnectorType(ConnectorName, Description = "Retrieve the current status of a Cruise Control project.")]
[ConnectorType(ConnectorName, ConnectorDisplayName, Description = "Retrieve the current status of a Cruise Control project.")]
[NotificationConfigurationItem(NotificationsVisbility, typeof(ConnectorNotificationConfiguration), SupportsUnstableNotify = false, Priority = 1600000000)]
public class CruiseControlConnector : Connector
{
public const string ConnectorName = "CruiseControl";

public const string ConnectorDisplayName = "Cruise Control.Net";

private static readonly Logger log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType?.ToString());

private TimeSpan estimatedDuration = default;
Expand All @@ -35,7 +37,7 @@ public CruiseControlConnector(ConnectorConfiguration configuration)

protected override async Task<Status> GetCurrentStatus(CancellationToken cancellationToken)
{
var server = CruiseControlManager.GetServer(this.Address);
var server = CruiseControlManager.GetServer(this.directAddress);
var projectData = await server.GetProjectStatus(cancellationToken, this.Project, 5);
if (projectData == null)
{
Expand All @@ -48,7 +50,7 @@ protected override async Task<Status> GetCurrentStatus(CancellationToken cancell

protected override async Task<List<Status>> GetHistory(CancellationToken cancellationToken)
{
var server = CruiseControlManager.GetServer(this.Address);
var server = CruiseControlManager.GetServer(this.directAddress);
var history = new List<Status>();

var builds = await server.GetBuilds(this.Project);
Expand Down
5 changes: 4 additions & 1 deletion src/Soloplan.WhatsON.CruiseControl/CruiseControlManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public static CruiseControlServer GetServer(string address, bool addToCache = tr
server = new CruiseControlServer(uri.AbsoluteUri);
if (addToCache)
{
servers[uri] = server;
if(server!=null)
{
servers[uri] = server;
}
}

return server;
Expand Down
9 changes: 5 additions & 4 deletions src/Soloplan.WhatsON.CruiseControl/CruiseControlPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override async Task<IList<Project>> GetProjects(string address)
var serverProjects = new List<Project>();
foreach (var project in allProjects.CruiseControlProject)
{
var serverProjectTreeItem = new Project(address, project.Name);
var serverProjectTreeItem = new Project(address, project.Name, address + "server/" + project.ServerName + "/project/" + project.Name + "/ViewProjectReport.aspx"); ;
if (string.IsNullOrWhiteSpace(project.ServerName))
{
result.Add(serverProjectTreeItem);
Expand All @@ -51,7 +51,7 @@ public override async Task<IList<Project>> GetProjects(string address)
var serverProject = serverProjects.FirstOrDefault(s => s.Name == project.ServerName);
if (serverProject == null)
{
serverProject = new Project(null, project.ServerName);
serverProject = new Project(null, project.ServerName, address+"server/"+project.ServerName+"/viewServerReport.aspx", project.Name, address + "server/" + project.ServerName + "/project/" + project.Name);
serverProjects.Add(serverProject);
result.Add(serverProject);
}
Expand All @@ -70,10 +70,11 @@ public override async Task<IList<Project>> GetProjects(string address)
/// <param name="project">The server project.</param>
/// <param name="configurationItemsSupport">The configuration items provider.</param>
/// <param name="serverAddress">The server address.</param>
public override void Configure(Project project, IConfigurationItemProvider configurationItemsSupport, string serverAddress)
public override void Configure(Project project, IConfigurationItemProvider configurationItemsSupport, string serverAddress=null)
{
configurationItemsSupport.GetConfigurationByKey(Connector.ProjectName).Value = project.Name;
configurationItemsSupport.GetConfigurationByKey(Connector.ServerAddress).Value = serverAddress;
configurationItemsSupport.GetConfigurationByKey(Connector.ServerAddress).Value = project.Address;
configurationItemsSupport.GetConfigurationByKey(Connector.DirectAddress).Value = project.DirectAddress;
}
}
}
4 changes: 2 additions & 2 deletions src/Soloplan.WhatsON.CruiseControl/CruiseControlServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ private async Task<TModel> GetStatusAsync<TModel>(CancellationToken cancellation

public static class UrlHelper
{
public static string GetReportUrl(string baseUrl, string project)
public static string GetReportUrl(string baseUrl, string project=null)
{
return $"{SanitizeBaseUri(baseUrl)}/project/{Uri.EscapeDataString(project)}/ViewProjectReport.aspx";
return $"{SanitizeBaseUri(baseUrl)}"+(project!=null?$"/project/{Uri.EscapeDataString(project)}/ViewProjectReport.aspx":string.Empty);
}

public static string GetXmlReportUrl(string baseUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="TagOutline" />
<TextBlock Padding="10,0,0,0" Text="Copy latest build label" />
<TextBlock Padding="10,0,0,0" Text="Copy latest build label" IsEnabled="{Binding RenameCommand.canExecuteState}"/>
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem Command="{Binding RenameCommand}">
<MenuItem Command="{Binding RenameCommand}" IsEnabled="{Binding RenameCommand.canExecuteState}">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Rename" />
<TextBlock Padding="10,0,0,0" Text="Rename" />
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem Command="{Binding EditCommand}">
<MenuItem Command="{Binding EditCommand}" IsEnabled="{Binding EditCommand.canExecuteState}">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Edit" />
Expand All @@ -44,7 +44,7 @@
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem Command="{Binding ExportCommand}">
<MenuItem Command="{Binding ExportCommand}" IsEnabled="{Binding ExportCommand.canExecuteState}">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Export" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,6 @@ private async void DeleteConnector(object sender, DeleteTreeItemEventArgs e)
if (e.DeleteItem is ConnectorViewModel model)
{
this.OnDeleteItem(this, e);
var canceled = await e.CheckCanceled();
if (!canceled && this.ConnectorViewModels.Remove(model))
{
this.OnConfigurationChanged(this, EventArgs.Empty);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace Soloplan.WhatsON.GUI.Common.ConnectorTreeView
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using GongSolutions.Wpf.DragDrop;
using NLog;
Expand All @@ -33,6 +35,11 @@ public class ConnectorTreeViewModel : NotifyPropertyChanged, IHandleDoubleClick,
/// </summary>
private ObservableCollection<ConnectorGroupViewModel> connectorGroups;

/// <summary>
/// Copy of currently selected connectors in case of multiple actions on viewmodel/>.
/// </summary>
private Collection<ConnectorViewModel> selectedConnectors;

/// <summary>
/// Flag indicating that <see cref="ConfigurationChanged"/> event is triggered - used to ignore updates of model.
/// </summary>
Expand All @@ -48,6 +55,11 @@ public class ConnectorTreeViewModel : NotifyPropertyChanged, IHandleDoubleClick,
/// </summary>
private bool prevOneGroupValue;

/// <summary>
/// Previous value of relative instert position.
/// </summary>
private Collection<ConnectorViewModel> connectorsToDrop = new Collection<ConnectorViewModel>();

private int fontSize;

private int fontSizeSmall;
Expand Down Expand Up @@ -185,6 +197,7 @@ public void DragOver(IDropInfo dropInfo)
/// <param name="dropInfo">Information about the drop.</param>
public void Drop(IDropInfo dropInfo)
{

if (dropInfo.Effects != DragDropEffects.Move)
{
log.Warn("Unexpected drop operation. {data}", new { Effect = dropInfo.Effects, dropInfo.Data, Target = dropInfo.TargetItem });
Expand All @@ -198,7 +211,36 @@ public void Drop(IDropInfo dropInfo)
}
else if (dropInfo.Data is ConnectorViewModel draggedConnector)
{
changesExist = this.DropConnector(dropInfo, draggedConnector);
if (this.connectorsToDrop.Count != 0)
{
if (dropInfo.InsertPosition == GongSolutions.Wpf.DragDrop.RelativeInsertPosition.BeforeTargetItem)
{
var targetGroup = this.GetConnectorGroup((ConnectorViewModel)dropInfo.TargetItem);
foreach (var element in this.connectorsToDrop.Reverse())
{
var sourceGroup = this.GetConnectorGroup(element);
MoveObject(sourceGroup, targetGroup, dropInfo.InsertPosition);
targetGroup = this.GetConnectorGroup(element);
}
}
else
{
var targetGroup = this.GetConnectorGroup((ConnectorViewModel)dropInfo.TargetItem);
foreach (var element in this.connectorsToDrop)
{
var sourceGroup = this.GetConnectorGroup(element);
MoveObject(sourceGroup, targetGroup, dropInfo.InsertPosition);
targetGroup = this.GetConnectorGroup(element);
}
}

this.connectorsToDrop = new Collection<ConnectorViewModel>();
this.OnConfigurationChanged(this, EventArgs.Empty);
}
else
{
changesExist = this.DropConnector(dropInfo, draggedConnector);
}
}

if (changesExist)
Expand Down Expand Up @@ -401,6 +443,13 @@ protected void OnConfigurationChanged(object sender, EventArgs args)
}
}

public bool UpdateConnectorsToDrop(Collection<ConnectorViewModel> list)
{
this.connectorsToDrop = list;
return true;
}


/// <summary>
/// Moves object given by <paramref name="source"/> to <paramref name="target"/>.
/// </summary>
Expand Down Expand Up @@ -556,8 +605,77 @@ private void ExportHandler(object sender, ValueEventArgs<TreeItemViewModel> e)
this.ExportItem?.Invoke(sender, e);
}

private async void DeleteGroup(object sender, DeleteTreeItemEventArgs e)
/// <summary>
/// Removes any empty rpesent groups.
/// </summary>
private void ClearEmptyGroups()
{
foreach (var group in this.connectorGroups.ToList())
{
if (group.ConnectorViewModels.Count == 0)
{
this.connectorGroups.Remove(group);
}
}
}

/// <summary>
/// Performs a deletion of all selected connectors.
/// </summary>
private void DeleteSelectedConnectors()
{
bool madeChanges = false;
foreach (var connectorGroup in this.connectorGroups.ToList())
{
foreach (var connector in connectorGroup.ConnectorViewModels.ToList())
{
for (int i = 0; i < this.selectedConnectors.Count;)
{
if (this.selectedConnectors[i].Identifier == connector.Identifier)
{
connectorGroup.ConnectorViewModels.Remove(this.selectedConnectors[i]);
this.selectedConnectors.RemoveAt(i);
madeChanges = true;
i--;
}

i++;
}
}
}

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)
{
if (this.selectedConnectors.Count > 1)
{
e.NoOtherSelections = false;
}
else
{
e.NoOtherSelections = true;
}

this.DeleteItem?.Invoke(sender, e);
var canceled = await e.CheckCanceled();
if (!canceled)
{
this.DeleteSelectedConnectors();
}

return;
}

this.DeleteItem?.Invoke(sender, e);
if (e.DeleteItem is ConnectorGroupViewModel group)
{
Expand Down Expand Up @@ -591,10 +709,18 @@ private void SetConnectionModifiedInTree(bool value)
}
}

/// <summary>
/// Updates the currently selected items form view
/// </summary>
public void UpdateSelectedConnectors(Collection<ConnectorViewModel> selectedConnectors)
{
this.selectedConnectors = selectedConnectors;
}

/// <summary>
/// Helper class with information about where the moved object is or should be in <see cref="List"/>.
/// </summary>
private class MovedObjectLocation
public class MovedObjectLocation
{
public MovedObjectLocation(IList list, int index)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ protected virtual BuildStatusViewModel GetStatusViewModel()
protected override CustomCommand CreateEditCommand()
{
var command = base.CreateEditCommand();
command.CanExecuteExternal += (s, e) => e.Cancel = this.ConfigurationModifiedInTree;
command.CanExecuteExternal += (s, e) => { e.Cancel = this.ConfigurationModifiedInTree || !this.isOnlyOneSelected; };
return command;
}
}
Expand Down
Loading