Browse Source

- Finished support for external AddIns installed from .addin files. They are shown with a different icon in AddIn list.

- Improved error handling and visualization.
- Some more refactoring.
pull/32/head
Andreas Weizel 13 years ago
parent
commit
f6c202745f
  1. 3
      src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj
  2. 5
      src/AddIns/Misc/AddInManager2/Project/Resources/StringResources.resx
  3. BIN
      src/AddIns/Misc/AddInManager2/Project/Resources/external_addin_small.png
  4. 24
      src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInExceptionEventArgs.cs
  5. 12
      src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInManagerEvents.cs
  6. 49
      src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInOperationErrorEventArgs.cs
  7. 74
      src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs
  8. 5
      src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/IAddInManagerEvents.cs
  9. 1
      src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/ISDAddInManagement.cs
  10. 5
      src/AddIns/Misc/AddInManager2/Project/Src/Model/SDAddInManagement.cs
  11. 22
      src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml
  12. 18
      src/AddIns/Misc/AddInManager2/Project/Src/View/AddInsView.xaml
  13. 9
      src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInManagerViewModel.cs
  14. 8
      src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInPackageViewModelBase.cs
  15. 2
      src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/InstalledAddInsViewModel.cs
  16. 12
      src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/NuGetPackageViewModel.cs
  17. 42
      src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/OfflineAddInViewModel.cs

3
src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj

@ -77,6 +77,7 @@ @@ -77,6 +77,7 @@
<Resource Include="Resources\sd_packageicon.png" />
<Resource Include="Resources\accept.png" />
<Resource Include="Resources\exclamation.png" />
<Resource Include="Resources\external_addin_small.png" />
<None Include="Resources\license.txt" />
<Resource Include="Resources\magnifier.png" />
<Resource Include="Resources\packageicon.png" />
@ -110,7 +111,7 @@ @@ -110,7 +111,7 @@
<Compile Include="Src\Model\NuGetPackageManager.cs" />
<Compile Include="Src\Model\AddInSetup.cs" />
<Compile Include="Src\Model\AddInManagerEvents.cs" />
<Compile Include="Src\Model\AddInExceptionEventArgs.cs" />
<Compile Include="Src\Model\AddInOperationErrorEventArgs.cs" />
<Compile Include="Src\Model\NuGetPackageOperationEventArgs.cs" />
<Compile Include="Src\Model\PackageMessageLoggedEventArgs.cs" />
<Compile Include="Src\Model\PackageRepositories.cs" />

5
src/AddIns/Misc/AddInManager2/Project/Resources/StringResources.resx

@ -236,7 +236,7 @@ If you do not agree to the license terms click "I Decline".</value> @@ -236,7 +236,7 @@ If you do not agree to the license terms click "I Decline".</value>
<value>License Agreements</value>
</data>
<data name="AddInManager2.SDAddInFileFilter" xml:space="preserve">
<value>SharpDevelop AddIns|*.sdaddin|All files|*.*</value>
<value>SharpDevelop AddIns|*.sdaddin;*.addin|All files|*.*</value>
</data>
<data name="AddInManager2.InstallDependentMessage" xml:space="preserve">
<value>Package "{0}" needs at least one additional package:
@ -254,4 +254,7 @@ The application will try to download and install them, as well. Do you want to c @@ -254,4 +254,7 @@ The application will try to download and install them, as well. Do you want to c
<data name="AddInManager2.Details.FileName" xml:space="preserve">
<value>File name:</value>
</data>
<data name="AddInManager2.InvalidPackage" xml:space="preserve">
<value>Selected package doesn't contain a valid SharpDevelop AddIn.</value>
</data>
</root>

BIN
src/AddIns/Misc/AddInManager2/Project/Resources/external_addin_small.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

24
src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInExceptionEventArgs.cs

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.AddInManager2.Model
{
/// <summary>
/// Data for events indicating an exception during package-related operations.
/// </summary>
public class AddInExceptionEventArgs : EventArgs
{
public AddInExceptionEventArgs(Exception exception)
{
Exception = exception;
}
public Exception Exception
{
get;
private set;
}
}
}

12
src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInManagerEvents.cs

@ -13,6 +13,14 @@ namespace ICSharpCode.AddInManager2.Model @@ -13,6 +13,14 @@ namespace ICSharpCode.AddInManager2.Model
{
public event EventHandler OperationStarted;
public void OnOperationStarted()
{
if (OperationStarted != null)
{
OperationStarted(this, new EventArgs());
}
}
public void OnOperationStarted(EventArgs e)
{
if (OperationStarted != null)
@ -41,9 +49,9 @@ namespace ICSharpCode.AddInManager2.Model @@ -41,9 +49,9 @@ namespace ICSharpCode.AddInManager2.Model
}
}
public event EventHandler<AddInExceptionEventArgs> AddInOperationError;
public event EventHandler<AddInOperationErrorEventArgs> AddInOperationError;
public void OnAddInOperationError(AddInExceptionEventArgs e)
public void OnAddInOperationError(AddInOperationErrorEventArgs e)
{
if (AddInOperationError != null)
{

49
src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInOperationErrorEventArgs.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.AddInManager2.Model
{
/// <summary>
/// Data for events indicating an exception or other errors during package-related operations.
/// </summary>
public class AddInOperationErrorEventArgs : EventArgs
{
private string _message = null;
public AddInOperationErrorEventArgs(Exception exception)
{
Exception = exception;
}
public AddInOperationErrorEventArgs(string message)
{
Exception = null;
_message = message;
}
public Exception Exception
{
get;
private set;
}
public string Message
{
get
{
if (_message != null)
{
return _message;
}
if (Exception != null)
{
return Exception.Message;
}
return null;
}
}
}
}

74
src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs

@ -56,7 +56,7 @@ namespace ICSharpCode.AddInManager2.Model @@ -56,7 +56,7 @@ namespace ICSharpCode.AddInManager2.Model
}
catch (Exception ex)
{
_events.OnAddInOperationError(new AddInExceptionEventArgs(ex));
_events.OnAddInOperationError(new AddInOperationErrorEventArgs(ex));
}
}
@ -71,8 +71,9 @@ namespace ICSharpCode.AddInManager2.Model @@ -71,8 +71,9 @@ namespace ICSharpCode.AddInManager2.Model
if (addInEntry != null)
{
_events.OnAddInOperationError(
new AddInExceptionEventArgs(
new AddInLoadException("The package may only contain one .addin file.")));
new AddInOperationErrorEventArgs(
SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
return null;
}
addInEntry = entry;
}
@ -80,8 +81,9 @@ namespace ICSharpCode.AddInManager2.Model @@ -80,8 +81,9 @@ namespace ICSharpCode.AddInManager2.Model
if (addInEntry == null)
{
_events.OnAddInOperationError(
new AddInExceptionEventArgs(
new AddInLoadException("The package must contain one .addin file.")));
new AddInOperationErrorEventArgs(
SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
return null;
}
using (Stream s = file.GetInputStream(addInEntry))
{
@ -100,22 +102,28 @@ namespace ICSharpCode.AddInManager2.Model @@ -100,22 +102,28 @@ namespace ICSharpCode.AddInManager2.Model
{
AddIn addIn = null;
bool installAsExternal = false;
switch (Path.GetExtension(fileName).ToLowerInvariant())
{
case ".addin":
if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, fileName))
{
// TODO Send around the error message
// MessageService.ShowMessage("${res:AddInManager.CannotInstallIntoApplicationDirectory}");
// Don't allow to install AddIns from application root path
_events.OnAddInOperationError(
new AddInOperationErrorEventArgs(
SD.ResourceService.GetString("AddInManager.CannotInstallIntoApplicationDirectory")));
return null;
}
// Load directly from location
addIn = _sdAddInManagement.Load(fileName);
installAsExternal = true;
break;
case ".sdaddin":
case ".zip":
// Try to load the *.sdaddin file as ZIP archive
ZipFile zipFile = null;
try
@ -123,10 +131,12 @@ namespace ICSharpCode.AddInManager2.Model @@ -123,10 +131,12 @@ namespace ICSharpCode.AddInManager2.Model
zipFile = new ZipFile(fileName);
addIn = LoadAddInFromZip(zipFile);
}
catch (Exception ex)
catch (Exception)
{
// Report the exception
_events.OnAddInOperationError(new AddInExceptionEventArgs(ex));
// ZIP file seems not to be valid
_events.OnAddInOperationError(
new AddInOperationErrorEventArgs(
SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
return null;
}
finally
@ -139,8 +149,10 @@ namespace ICSharpCode.AddInManager2.Model @@ -139,8 +149,10 @@ namespace ICSharpCode.AddInManager2.Model
break;
default:
// TODO Send around the error message
// MessageService.ShowMessage("${res:AddInManager.UnknownFileFormat} " + Path.GetExtension(file));
// Unknown format of file
_events.OnAddInOperationError(
new AddInOperationErrorEventArgs(
SD.ResourceService.GetString("AddInManager.UnknownFileFormat") + " " + Path.GetExtension(fileName)));
return null;
}
@ -149,7 +161,7 @@ namespace ICSharpCode.AddInManager2.Model @@ -149,7 +161,7 @@ namespace ICSharpCode.AddInManager2.Model
if ((addIn.Manifest == null) || (addIn.Manifest.PrimaryIdentity == null))
{
_events.OnAddInOperationError(
new AddInExceptionEventArgs(
new AddInOperationErrorEventArgs(
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity"))));
return null;
}
@ -172,18 +184,26 @@ namespace ICSharpCode.AddInManager2.Model @@ -172,18 +184,26 @@ namespace ICSharpCode.AddInManager2.Model
_sdAddInManagement.AbortRemoveUserAddInOnNextStart(installedIdentity);
}
// Create target directory for AddIn in user profile & copy package contents there
CopyAddInFromZip(addIn, fileName);
// Install the AddIn using manifest
if (foundAddIn != null)
if (!installAsExternal)
{
addIn.Action = AddInAction.Update;
// Create target directory for AddIn in user profile & copy package contents there
CopyAddInFromZip(addIn, fileName);
// Install the AddIn using manifest
if (foundAddIn != null)
{
addIn.Action = AddInAction.Update;
}
else
{
addIn.Action = AddInAction.Install;
_sdAddInManagement.AddToTree(addIn);
}
}
else
{
addIn.Action = AddInAction.Install;
_sdAddInManagement.AddToTree(addIn);
// Only add a reference to an external manifest
_sdAddInManagement.AddExternalAddIns(new AddIn[] { addIn });
}
// Mark this AddIn
@ -202,13 +222,9 @@ namespace ICSharpCode.AddInManager2.Model @@ -202,13 +222,9 @@ namespace ICSharpCode.AddInManager2.Model
return addIn;
}
else
{
// This is not a valid SharpDevelop AddIn package!
// TODO Show a message to user!
}
}
// In successful cases we should have exited somewhere else, in error cases the error event was already fired.
return null;
}
@ -222,7 +238,7 @@ namespace ICSharpCode.AddInManager2.Model @@ -222,7 +238,7 @@ namespace ICSharpCode.AddInManager2.Model
if (addIn.Manifest.PrimaryIdentity == null)
{
_events.OnAddInOperationError(
new AddInExceptionEventArgs(
new AddInOperationErrorEventArgs(
new AddInLoadException(SD.ResourceService.GetString("AddInManager.AddInMustHaveIdentity"))));
return null;
}
@ -278,7 +294,9 @@ namespace ICSharpCode.AddInManager2.Model @@ -278,7 +294,9 @@ namespace ICSharpCode.AddInManager2.Model
else
{
// This is not a valid SharpDevelop AddIn package!
// TODO Throw something.
_events.OnAddInOperationError(
new AddInOperationErrorEventArgs(
SD.ResourceService.GetString("AddInManager2.InvalidPackage")));
}
return null;

5
src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/IAddInManagerEvents.cs

@ -13,6 +13,7 @@ namespace ICSharpCode.AddInManager2.Model @@ -13,6 +13,7 @@ namespace ICSharpCode.AddInManager2.Model
{
event EventHandler OperationStarted;
void OnOperationStarted(EventArgs e);
void OnOperationStarted();
event EventHandler<AddInInstallationEventArgs> AddInInstalled;
void OnAddInInstalled(AddInInstallationEventArgs e);
@ -20,8 +21,8 @@ namespace ICSharpCode.AddInManager2.Model @@ -20,8 +21,8 @@ namespace ICSharpCode.AddInManager2.Model
event EventHandler<AddInInstallationEventArgs> AddInUninstalled;
void OnAddInUninstalled(AddInInstallationEventArgs e);
event EventHandler<AddInExceptionEventArgs> AddInOperationError;
void OnAddInOperationError(AddInExceptionEventArgs e);
event EventHandler<AddInOperationErrorEventArgs> AddInOperationError;
void OnAddInOperationError(AddInOperationErrorEventArgs e);
event EventHandler<PackageOperationEventArgs> AddInPackageDownloaded;
void OnAddInPackageDownloaded(PackageOperationEventArgs e);

1
src/AddIns/Misc/AddInManager2/Project/Src/Model/Interfaces/ISDAddInManagement.cs

@ -35,5 +35,6 @@ namespace ICSharpCode.AddInManager2.Model @@ -35,5 +35,6 @@ namespace ICSharpCode.AddInManager2.Model
void RemoveUserAddInOnNextStart(string identity);
AddIn Load(TextReader textReader);
AddIn Load(string fileName);
void AddExternalAddIns(IList<AddIn> addIns);
}
}

5
src/AddIns/Misc/AddInManager2/Project/Src/Model/SDAddInManagement.cs

@ -84,5 +84,10 @@ namespace ICSharpCode.AddInManager2.Model @@ -84,5 +84,10 @@ namespace ICSharpCode.AddInManager2.Model
{
return AddIn.Load(SD.AddInTree, fileName);
}
public void AddExternalAddIns(IList<AddIn> addIns)
{
ICSharpCode.Core.AddInManager.AddExternalAddIns(addIns);
}
}
}

22
src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml

@ -20,6 +20,25 @@ @@ -20,6 +20,25 @@
<BitmapImage x:Key="ErrorIcon"
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/exclamation.png"/>
<Style x:Key="errorImageStyle" TargetType="{x:Type Image}">
<Setter Property="Visibility" Value="{Binding Path=HasError, Converter={StaticResource BoolToVisibility}}" />
<Setter Property="Source" Value="{StaticResource ErrorIcon}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=HasError}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Name="BlinkingIconStoryboard">
<Storyboard>
<DoubleAnimation
RepeatBehavior="Forever" AutoReverse="True"
From="1" To="0" Duration="0:0:0.75"
Storyboard.TargetProperty="Opacity" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="tabHeaderTextStyle" TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.HasHighlightCount}" Value="True">
@ -60,8 +79,7 @@ @@ -60,8 +79,7 @@
<StackPanel>
<Image
Margin="4, 4"
Visibility="{Binding Path=HasError, Converter={StaticResource BoolToVisibility}}"
Source="{StaticResource ErrorIcon}"/>
Style="{StaticResource errorImageStyle}" />
</StackPanel>
<TextBlock
Grid.Column="1"

18
src/AddIns/Misc/AddInManager2/Project/Src/View/AddInsView.xaml

@ -19,6 +19,8 @@ @@ -19,6 +19,8 @@
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/packageicon_small.png"/>
<BitmapImage x:Key="SDPackageIcon"
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/sd_packageicon.png"/>
<BitmapImage x:Key="SmallExternalAddInIcon"
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/external_addin_small.png"/>
<BitmapImage x:Key="PackageAddedIcon"
UriSource="pack://application:,,,/ICSharpCode.AddInManager2;component/Resources/accept.png"/>
<BitmapImage x:Key="SearchIcon"
@ -53,6 +55,16 @@ @@ -53,6 +55,16 @@
</Style.Triggers>
</Style>
<Style x:Key="AddInExternalStateImageStyle" TargetType="{x:Type Image}">
<Setter Property="Source" Value="{StaticResource SmallExternalAddInIcon}" />
<Setter Property="Visibility" Value="{Binding Path=IsExternallyReferenced, Converter={StaticResource BoolToVisibility}}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsEnabled}" Value="False">
<Setter Property="Opacity" Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="addInListButtonStyle" TargetType="{x:Type Button}" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
@ -97,6 +109,12 @@ @@ -97,6 +109,12 @@
Margin="36,0,0,0"
VerticalAlignment="Top"
Style="{StaticResource AddInOnlineStateImageStyle}" />
<Image
Grid.Column="0"
Height="16"
Margin="36,0,0,0"
VerticalAlignment="Top"
Style="{StaticResource AddInExternalStateImageStyle}" />
<StackPanel
Grid.Column="1"
Margin="4, 0">

9
src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInManagerViewModel.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -39,7 +39,7 @@ namespace ICSharpCode.AddInManager2.ViewModel
// Add event handlers
AddInManager.Events.OperationStarted += AddInManager_Events_OperationStarted;
AddInManager.Events.AddInOperationError += AddInManager_Events_NuGetPackageOperationError;
AddInManager.Events.AddInOperationError += AddInManager_Events_AddInOperationError;
AddInManager.Events.AcceptLicenses += AddInManager_Events_AcceptLicenses;
AvailableAddInsViewModel = new AvailableAddInsViewModel();
@ -79,7 +79,8 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -79,7 +79,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
public void Dispose()
{
AddInManager.Events.AddInOperationError -= AddInManager_Events_NuGetPackageOperationError;
AddInManager.Events.OperationStarted -= AddInManager_Events_OperationStarted;
AddInManager.Events.AddInOperationError -= AddInManager_Events_AddInOperationError;
AddInManager.Events.AcceptLicenses -= AddInManager_Events_AcceptLicenses;
}
@ -126,9 +127,9 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -126,9 +127,9 @@ namespace ICSharpCode.AddInManager2.ViewModel
this.HasError = false;
}
private void AddInManager_Events_NuGetPackageOperationError(object sender, AddInExceptionEventArgs e)
private void AddInManager_Events_AddInOperationError(object sender, AddInOperationErrorEventArgs e)
{
ShowErrorMessage(e.Exception.Message);
ShowErrorMessage(e.Message);
}
private void AddInManager_Events_AcceptLicenses(object sender, AcceptLicensesEventArgs e)

8
src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInPackageViewModelBase.cs

@ -220,6 +220,14 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -220,6 +220,14 @@ namespace ICSharpCode.AddInManager2.ViewModel
get;
}
public virtual bool IsExternallyReferenced
{
get
{
return false;
}
}
public abstract bool IsPreinstalled
{
get;

2
src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/InstalledAddInsViewModel.cs

@ -125,7 +125,7 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -125,7 +125,7 @@ namespace ICSharpCode.AddInManager2.ViewModel
}
}
addInPackage = new OfflineAddInsViewModelBase(addIn);
addInPackage = new OfflineAddInsViewModel(addIn);
yield return addInPackage;
}
}

12
src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/NuGetPackageViewModel.cs

@ -307,7 +307,8 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -307,7 +307,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
private void ClearReportedMessages()
{
// packageManagementEvents.OnPackageOperationsStarting();
// Notify about new operation
AddInManager.Events.OnOperationStarted();
}
private void GetPackageOperations()
@ -417,11 +418,12 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -417,11 +418,12 @@ namespace ICSharpCode.AddInManager2.ViewModel
private void ReportError(Exception ex)
{
AddInManager.Events.OnAddInOperationError(new AddInExceptionEventArgs(ex));
AddInManager.Events.OnAddInOperationError(new AddInOperationErrorEventArgs(ex));
}
public override void RemovePackage()
{
ClearReportedMessages();
TryUninstallingPackage();
}
@ -451,6 +453,8 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -451,6 +453,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
public override void CancelInstallation()
{
ClearReportedMessages();
AddIn addIn = AddInManager.Setup.GetAddInForNuGetPackage(_package, true);
if (addIn != null)
{
@ -460,6 +464,8 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -460,6 +464,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
public override void CancelUpdate()
{
ClearReportedMessages();
AddIn addIn = AddInManager.Setup.GetAddInForNuGetPackage(_package, true);
if (addIn != null)
{
@ -469,6 +475,8 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -469,6 +475,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
public override void CancelUninstallation()
{
ClearReportedMessages();
AddIn addIn = AddInManager.Setup.GetAddInForNuGetPackage(_package);
if (addIn != null)
{

42
src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/OfflineAddInViewModel.cs

@ -12,7 +12,7 @@ using NuGet; @@ -12,7 +12,7 @@ using NuGet;
namespace ICSharpCode.AddInManager2.ViewModel
{
public class OfflineAddInsViewModelBase : AddInPackageViewModelBase
public class OfflineAddInsViewModel : AddInPackageViewModelBase
{
private AddIn _addIn;
private ManagedAddIn _markedAddIn;
@ -33,13 +33,13 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -33,13 +33,13 @@ namespace ICSharpCode.AddInManager2.ViewModel
private string _description;
private DateTime? _lastUpdated;
public OfflineAddInsViewModelBase(ManagedAddIn addIn)
public OfflineAddInsViewModel(ManagedAddIn addIn)
: base()
{
Initialize(addIn);
}
public OfflineAddInsViewModelBase(IAddInManagerServices services, ManagedAddIn addIn)
public OfflineAddInsViewModel(IAddInManagerServices services, ManagedAddIn addIn)
: base(services)
{
Initialize(addIn);
@ -151,6 +151,24 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -151,6 +151,24 @@ namespace ICSharpCode.AddInManager2.ViewModel
}
}
public override bool IsExternallyReferenced
{
get
{
if (_addIn != null)
{
// The AddIn is externally referenced, if it's .addin file doesn't reside in
// somewhere in application path (preinstalled AddIns) or in config path (usually installed AddIns).
return !FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, _addIn.FileName)
&& !FileUtility.IsBaseDirectory(SD.PropertyService.ConfigDirectory, _addIn.FileName);
}
else
{
return false;
}
}
}
public override bool IsPreinstalled
{
get
@ -452,6 +470,8 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -452,6 +470,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
public override void RemovePackage()
{
ClearReportedMessages();
if (_addIn.Manifest.PrimaryIdentity == "ICSharpCode.AddInManager2")
{
MessageService.ShowMessage("${res:AddInManager2.CannotRemoveAddInManager}", "${res:AddInManager.Title}");
@ -481,21 +501,29 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -481,21 +501,29 @@ namespace ICSharpCode.AddInManager2.ViewModel
public override void CancelInstallation()
{
ClearReportedMessages();
AddInManager.Setup.CancelInstallation(_addIn);
}
public override void CancelUpdate()
{
ClearReportedMessages();
AddInManager.Setup.CancelUpdate(_addIn);
}
public override void CancelUninstallation()
{
ClearReportedMessages();
AddInManager.Setup.CancelUninstallation(_addIn);
}
public override void DisablePackage()
{
ClearReportedMessages();
if (_addIn == null)
{
return;
@ -547,6 +575,8 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -547,6 +575,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
public override void ShowOptions()
{
ClearReportedMessages();
AddInTreeNode dummyNode = new AddInTreeNode();
foreach (KeyValuePair<string, ExtensionPath> pair in _addIn.Paths)
{
@ -559,5 +589,11 @@ namespace ICSharpCode.AddInManager2.ViewModel @@ -559,5 +589,11 @@ namespace ICSharpCode.AddInManager2.ViewModel
_addIn.Name + " " + SD.ResourceService.GetString("AddInManager.Options"),
dummyNode);
}
private void ClearReportedMessages()
{
// Notify about new operation
AddInManager.Events.OnOperationStarted();
}
}
}

Loading…
Cancel
Save