-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It must be possible to start whatsON when plugin referenced in config…
…uration is not available. Log error instead of throwing exception. Add special viewmodel to display the subject which can't be properly created.
- Loading branch information
1 parent
4ec61eb
commit 4925d9b
Showing
6 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Soloplan.WhatsON.GUI/SubjectTreeView/SubjectMissingDataTemplate.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:Soloplan.WhatsON.GUI.SubjectTreeView"> | ||
|
||
<ContextMenu x:Key="copyData"> | ||
<MenuItem Header="Copy data" Command="{Binding CopyData}" /> | ||
</ContextMenu> | ||
|
||
<DataTemplate DataType="{x:Type local:SubjectMissingViewModel}"> | ||
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource copyData}"> | ||
<StackPanel.ToolTip> | ||
<StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="Identifier: " /> | ||
<TextBlock Text="{Binding Identifier, Mode=OneWay}" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="Name: " /> | ||
<TextBlock Text="{Binding Name, Mode=OneWay}" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="Description: " /> | ||
<TextBlock Text="{Binding Description, Mode=OneWay}" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="Expected plugin type: " /> | ||
<TextBlock Text="{Binding ExpectedPluginType, Mode=OneWay}" /> | ||
</StackPanel> | ||
</StackPanel> | ||
</StackPanel.ToolTip> | ||
<TextBlock FontWeight="Bold" Text="No plugIn found: " /> | ||
<TextBlock Text="{Binding Name}" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
</ResourceDictionary> |
61 changes: 61 additions & 0 deletions
61
src/Soloplan.WhatsON.GUI/SubjectTreeView/SubjectMissingViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="SubjectMissingViewModel.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.SubjectTreeView | ||
{ | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Input; | ||
using Microsoft.Expression.Interactivity.Core; | ||
|
||
public class SubjectMissingViewModel : SubjectViewModel | ||
{ | ||
public SubjectMissingViewModel() | ||
{ | ||
void Act() | ||
{ | ||
var builder = new StringBuilder(); | ||
builder.AppendLine($"Identifier: {this.Identifier}"); | ||
builder.AppendLine($"Name: {this.Name}"); | ||
builder.AppendLine($"Description: {this.Description}"); | ||
builder.AppendLine($"Expected plugin type: {this.ExpectedPluginType}"); | ||
Clipboard.SetText(builder.ToString()); | ||
} | ||
|
||
this.CopyData = new ActionCommand(Act); | ||
} | ||
|
||
/// <summary> | ||
/// Gets command for copying model data to clipboard. | ||
/// </summary> | ||
public ICommand CopyData { get; } | ||
|
||
/// <summary> | ||
/// Gets plugin type which was expected. | ||
/// </summary> | ||
public string ExpectedPluginType { get; private set; } | ||
|
||
/// <summary> | ||
/// Initializes viewmodel based on <paramref name="configuration"/>. | ||
/// </summary> | ||
/// <param name="configuration">Configuration of this subject.</param> | ||
public override void Init(SubjectConfiguration configuration) | ||
{ | ||
this.ExpectedPluginType = configuration.PluginTypeName; | ||
base.Init(configuration); | ||
} | ||
|
||
/// <summary> | ||
/// Doesn't do anything since <paramref name="changedSubject"/> is null. | ||
/// </summary> | ||
/// <param name="changedSubject">Subject which has changed - always null.</param> | ||
public override void Update(Subject changedSubject) | ||
{ | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters