Browse Source

Improved AddInManager (updating AddIns now works correctly).

Form Designer now no longer rewrites fields without modifier, patch by Christian Hornung.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@812 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
9158302376
  1. 2
      src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin
  2. 14
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/AbstractDesignerGenerator.cs
  3. 21
      src/AddIns/Misc/AddInManager/Project/Src/AddInControl.cs
  4. 20
      src/AddIns/Misc/AddInManager/Project/Src/InstallableAddIn.cs
  5. 175
      src/AddIns/Misc/AddInManager/Project/Src/ManagerForm.cs
  6. 8
      src/Libraries/NRefactory/Project/Src/Output/CodeDOM/CodeDOMOutputVisitor.cs
  7. 16
      src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs
  8. BIN
      src/Main/StartUp/Project/Resources/BitmapResources.resources

2
src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
</Manifest>
<Runtime>
<Import assembly = "../../DisplayBindings/FormDesigner/FormDesigner.dll"/>
<Import assembly = "$ICSharpCode.FormDesigner/FormDesigner.dll"/>
<Import assembly = "BooBinding.dll"/>
<Import assembly = ":ICSharpCode.SharpDevelop"/>
</Runtime>

14
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/AbstractDesignerGenerator.cs

@ -202,11 +202,19 @@ namespace ICSharpCode.FormDesigner @@ -202,11 +202,19 @@ namespace ICSharpCode.FormDesigner
}
// compare modifiers
ModifierEnum[] sdModifiers = new ModifierEnum[] {ModifierEnum.Private, ModifierEnum.Protected, ModifierEnum.ProtectedAndInternal, ModifierEnum.Internal, ModifierEnum.Public};
MemberAttributes[] cdModifiers = new MemberAttributes[] {MemberAttributes.Private, MemberAttributes.Family, MemberAttributes.FamilyOrAssembly, MemberAttributes.Assembly, MemberAttributes.Public};
ModifierEnum oldModifiers = oldField.Modifiers & ModifierEnum.VisibilityMask;
MemberAttributes newModifiers = newField.Attributes & MemberAttributes.AccessMask;
// SharpDevelop.Dom always adds Private modifier, even if not specified
// CodeDom omits Private modifier if not present (although it is the default)
if (oldModifiers == ModifierEnum.Private) {
if (newModifiers != 0 && newModifiers != MemberAttributes.Private) {
return true;
}
}
ModifierEnum[] sdModifiers = new ModifierEnum[] {ModifierEnum.Protected, ModifierEnum.ProtectedAndInternal, ModifierEnum.Internal, ModifierEnum.Public};
MemberAttributes[] cdModifiers = new MemberAttributes[] {MemberAttributes.Family, MemberAttributes.FamilyOrAssembly, MemberAttributes.Assembly, MemberAttributes.Public};
for (int i = 0; i < sdModifiers.Length; i++) {
if ((oldModifiers == sdModifiers[i]) ^ (newModifiers == cdModifiers[i])) {
return true;

21
src/AddIns/Misc/AddInManager/Project/Src/AddInControl.cs

@ -61,15 +61,30 @@ namespace ICSharpCode.AddInManager @@ -61,15 +61,30 @@ namespace ICSharpCode.AddInManager
Focus();
}
Color Mix(Color c1, Color c2, double perc)
{
double p1 = 1 - perc;
double p2 = perc;
return Color.FromArgb((int)(c1.R * p1 + c2.R * p2),
(int)(c1.G * p1 + c2.G * p2),
(int)(c1.B * p1 + c2.B * p2));
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle bounds = this.ClientRectangle;
bounds.Offset(1, 1);
bounds.Inflate(-2, -2);
Color startColor = SystemColors.ControlLightLight;
Color endColor = SystemColors.Control;
if (selected) {
startColor = Mix(SystemColors.ControlLightLight, SystemColors.Highlight, 0.1);
endColor = Mix(SystemColors.ControlLightLight, SystemColors.Highlight, 0.65);
}
Brush gradient = new LinearGradientBrush(bounds,
selected ? SystemColors.Control : SystemColors.ControlLightLight,
selected ? SystemColors.Highlight : SystemColors.ControlDark,
startColor,
endColor,
LinearGradientMode.ForwardDiagonal);
GraphicsPath path = new GraphicsPath();
@ -100,8 +115,6 @@ namespace ICSharpCode.AddInManager @@ -100,8 +115,6 @@ namespace ICSharpCode.AddInManager
gradient.Dispose();
Brush textBrush;
string description = GetText(out textBrush);
if (selected && textBrush == SystemBrushes.GrayText)
textBrush = SystemBrushes.HighlightText;
int titleWidth;
using (Font boldFont = new Font("Arial", 8, FontStyle.Bold)) {
g.DrawString(addIn.Name, boldFont, textBrush, innerMargin, innerMargin);

20
src/AddIns/Misc/AddInManager/Project/Src/InstallableAddIn.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.AddInManager @@ -62,7 +62,7 @@ namespace ICSharpCode.AddInManager
}
}
public void Install()
public void Install(bool isUpdate)
{
foreach (string identity in addIn.Manifest.Identities.Keys) {
ICSharpCode.Core.AddInManager.AbortRemoveUserAddInOnNextStart(identity);
@ -78,13 +78,15 @@ namespace ICSharpCode.AddInManager @@ -78,13 +78,15 @@ namespace ICSharpCode.AddInManager
fastZip.ExtractZip(fileName, targetDir, null);
addIn.Action = AddInAction.Install;
AddInTree.InsertAddIn(addIn);
if (!isUpdate) {
AddInTree.InsertAddIn(addIn);
}
} else {
ICSharpCode.Core.AddInManager.AddExternalAddIns(new AddIn[] { addIn });
}
}
public static void Uninstall(IList<AddIn> addIns)
public static void CancelUpdate(IList<AddIn> addIns)
{
foreach (AddIn addIn in addIns) {
foreach (string identity in addIn.Manifest.Identities.Keys) {
@ -93,9 +95,17 @@ namespace ICSharpCode.AddInManager @@ -93,9 +95,17 @@ namespace ICSharpCode.AddInManager
identity);
if (Directory.Exists(targetDir))
Directory.Delete(targetDir, true);
}
}
}
public static void Uninstall(IList<AddIn> addIns)
{
CancelUpdate(addIns);
foreach (AddIn addIn in addIns) {
foreach (string identity in addIn.Manifest.Identities.Keys) {
// remove the user AddIn
targetDir = Path.Combine(ICSharpCode.Core.AddInManager.UserAddInPath, identity);
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.UserAddInPath, identity);
if (Directory.Exists(targetDir)) {
if (!addIn.Enabled) {
try {

175
src/AddIns/Misc/AddInManager/Project/Src/ManagerForm.cs

@ -30,7 +30,9 @@ namespace ICSharpCode.AddInManager @@ -30,7 +30,9 @@ namespace ICSharpCode.AddInManager
{
if (instance == null) {
instance = new ManagerForm();
#if !STANDALONE
instance.Owner = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm;
#endif
instance.Show();
} else {
instance.Activate();
@ -44,7 +46,9 @@ namespace ICSharpCode.AddInManager @@ -44,7 +46,9 @@ namespace ICSharpCode.AddInManager
//
InitializeComponent();
#if !STANDALONE
ICSharpCode.SharpDevelop.Gui.FormLocationHelper.Apply(this, "AddInManager.WindowBounds", true);
#endif
CreateAddInList();
}
@ -198,6 +202,7 @@ namespace ICSharpCode.AddInManager @@ -198,6 +202,7 @@ namespace ICSharpCode.AddInManager
bool allDisabled = true;
bool allInstalling = true;
bool allUninstalling = true;
bool allUpdating = true;
bool allUninstallable = true;
bool hasErrors = false;
foreach (AddIn addIn in selected) {
@ -206,6 +211,7 @@ namespace ICSharpCode.AddInManager @@ -206,6 +211,7 @@ namespace ICSharpCode.AddInManager
hasErrors = true;
else
allDisabled &= addIn.Action == AddInAction.Disable;
allUpdating &= addIn.Action == AddInAction.Update;
allInstalling &= addIn.Action == AddInAction.Install;
allUninstalling &= addIn.Action == AddInAction.Uninstall;
if (allUninstallable) {
@ -218,27 +224,33 @@ namespace ICSharpCode.AddInManager @@ -218,27 +224,33 @@ namespace ICSharpCode.AddInManager
selectedAction = AddInAction.Disable;
actionGroupBox.Text = runActionButton.Text = "Disable";
actionDescription.Text = "Disables the selected AddIns.";
runActionButton.Enabled = ShowDependencies(selected, false);
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
uninstallButton.Enabled = allUninstallable && runActionButton.Enabled;
} else if (allDisabled) {
selectedAction = AddInAction.Enable;
actionGroupBox.Text = runActionButton.Text = "Enable";
actionDescription.Text = "Enables the selected AddIns.";
runActionButton.Enabled = ShowDependencies(selected, true);
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
if (hasErrors)
runActionButton.Enabled = false;
uninstallButton.Enabled = allUninstallable;
} else if (allInstalling) {
selectedAction = AddInAction.Uninstall;
actionGroupBox.Text = runActionButton.Text = "Cancel installation";
actionDescription.Text = "Cancels the installation of the selected AddIns.";
runActionButton.Enabled = ShowDependencies(selected, false);
actionDescription.Text = "Aborts the installation of the selected AddIns.";
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
uninstallButton.Visible = false;
} else if (allUninstalling) {
selectedAction = AddInAction.Enable;
actionGroupBox.Text = runActionButton.Text = "Cancel deinstallation";
actionDescription.Text = "Cancels the deinstallation of the selected AddIns.";
runActionButton.Enabled = ShowDependencies(selected, true);
actionDescription.Text = "Aborts the deinstallation of the selected AddIns.";
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
uninstallButton.Visible = false;
} else if (allUpdating) {
selectedAction = AddInAction.InstalledTwice;
actionGroupBox.Text = runActionButton.Text = "Cancel update";
actionDescription.Text = "Aborts the update of the selected AddIns.";
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.CancelUpdate);
uninstallButton.Visible = false;
} else {
actionGroupBox.Text = "";
@ -250,7 +262,13 @@ namespace ICSharpCode.AddInManager @@ -250,7 +262,13 @@ namespace ICSharpCode.AddInManager
ignoreFocusChange = false;
}
bool ShowDependencies(IList<AddIn> addIns, bool enable)
enum ShowDependencyMode {
Disable,
Enable,
CancelUpdate
}
bool ShowDependencies(IList<AddIn> addIns, ShowDependencyMode mode)
{
List<AddInReference> dependencies = new List<AddInReference>(); // only used with enable=true
List<KeyValuePair<AddIn, AddInReference>> dependenciesToSel = new List<KeyValuePair<AddIn, AddInReference>>();
@ -276,8 +294,11 @@ namespace ICSharpCode.AddInManager @@ -276,8 +294,11 @@ namespace ICSharpCode.AddInManager
}
// add new addins
if (enable) {
if (mode != ShowDependencyMode.Disable) {
foreach (AddIn addIn in addIns) {
if (mode == ShowDependencyMode.CancelUpdate && !addIn.Enabled) {
continue;
}
foreach (KeyValuePair<string, Version> pair in addIn.Manifest.Identities) {
addInDict[pair.Key] = pair.Value;
}
@ -398,8 +419,14 @@ namespace ICSharpCode.AddInManager @@ -398,8 +419,14 @@ namespace ICSharpCode.AddInManager
List<InstallableAddIn> list = new List<InstallableAddIn>();
foreach (string file in fileNames) {
try {
// Same file-extension check is in Panel1DragEnter
switch (Path.GetExtension(file).ToLowerInvariant()) {
case ".addin":
if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, file)) {
MessageService.ShowMessage("You cannot install AddIns inside the SharpDevelop directory, " +
"they will be picked up as pre-installed AddIns automatically.");
return false;
}
list.Add(new InstallableAddIn(file, false));
break;
case ".sdaddin":
@ -431,17 +458,75 @@ namespace ICSharpCode.AddInManager @@ -431,17 +458,75 @@ namespace ICSharpCode.AddInManager
uninstallButton.Visible = false;
selectedAction = AddInAction.Install;
actionGroupBox.Text = runActionButton.Text = "Install";
List<string> installAddIns = new List<string>();
List<string> updateAddIns = new List<string>();
foreach (InstallableAddIn addInPackage in addInPackages) {
string identity = addInPackage.AddIn.Manifest.PrimaryIdentity;
AddIn foundAddIn = null;
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Action != AddInAction.Install
&& addIn.Manifest.Identities.ContainsKey(identity))
{
foundAddIn = addIn;
break;
}
}
if (foundAddIn != null) {
updateAddIns.Add(addInPackage.AddIn.Name);
} else {
installAddIns.Add(addInPackage.AddIn.Name);
}
}
if (updateAddIns.Count == 0)
actionGroupBox.Text = runActionButton.Text = "Install";
else if (installAddIns.Count == 0)
actionGroupBox.Text = runActionButton.Text = "Update";
else
actionGroupBox.Text = runActionButton.Text = "Install + Update";
List<AddIn> addInList = new List<AddIn>();
StringBuilder b = new StringBuilder("Install the AddIns ");
for (int i = 0; i < addInPackages.Count; i++) {
if (i > 0) b.Append(", ");
addInList.Add(addInPackages[i].AddIn);
b.Append(addInPackages[i].AddIn.Name);
StringBuilder b = new StringBuilder();
if (installAddIns.Count == 1) {
b.Append("Installs the AddIn " + installAddIns[0]);
} else if (installAddIns.Count > 1) {
b.Append("Installs the AddIns " + string.Join(",", installAddIns.ToArray()));
}
if (updateAddIns.Count > 0 && installAddIns.Count > 0)
b.Append("; ");
if (updateAddIns.Count == 1) {
b.Append("Updates the AddIn " + updateAddIns[0]);
} else if (updateAddIns.Count > 1) {
b.Append("Updates the AddIns " + string.Join(",", updateAddIns.ToArray()));
}
b.Append(".");
actionDescription.Text = b.ToString();
runActionButton.Enabled = ShowDependencies(addInList, true);
runActionButton.Enabled = ShowDependencies(addInList, ShowDependencyMode.Enable);
}
void RunInstallation()
{
// install new AddIns
foreach (InstallableAddIn addInPackage in shownAddInPackages) {
string identity = addInPackage.AddIn.Manifest.PrimaryIdentity;
AddIn foundAddIn = null;
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Manifest.Identities.ContainsKey(identity)) {
foundAddIn = addIn;
break;
}
}
if (foundAddIn != null) {
addInPackage.Install(true);
if (foundAddIn.Action != AddInAction.Enable) {
ICSharpCode.Core.AddInManager.Enable(new AddIn[] { foundAddIn });
}
if (foundAddIn.Action != AddInAction.Install) {
foundAddIn.Action = AddInAction.Update;
}
} else {
addInPackage.Install(false);
}
}
RefreshAddInList();
}
#endregion
@ -454,6 +539,47 @@ namespace ICSharpCode.AddInManager @@ -454,6 +539,47 @@ namespace ICSharpCode.AddInManager
}
#endregion
#region Drag'N'Drop
void Panel1DragEnter(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effect = DragDropEffects.None;
return;
}
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
int addInCount = 0;
int packageCount = 0;
foreach (string file in files) {
switch (Path.GetExtension(file).ToLowerInvariant()) {
case ".addin":
addInCount += 1;
break;
case ".sdaddin":
case ".zip":
packageCount += 1;
break;
default:
e.Effect = DragDropEffects.None;
return;
}
}
if (addInCount == 0 && packageCount == 0) {
e.Effect = DragDropEffects.None;
} else if (addInCount == 0) {
e.Effect = DragDropEffects.Copy;
} else {
e.Effect = DragDropEffects.Link;
}
}
void Panel1DragDrop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
return;
ShowInstallableAddIns((string[])e.Data.GetData(DataFormats.FileDrop));
}
#endregion
void CloseButtonClick(object sender, EventArgs e)
{
Close();
@ -475,15 +601,17 @@ namespace ICSharpCode.AddInManager @@ -475,15 +601,17 @@ namespace ICSharpCode.AddInManager
ICSharpCode.Core.AddInManager.Enable(selected);
break;
case AddInAction.Install:
// install new AddIns
foreach (InstallableAddIn addInPackage in shownAddInPackages) {
addInPackage.Install();
}
RefreshAddInList();
RunInstallation();
return;
case AddInAction.Uninstall:
UninstallButtonClick(sender, e);
return;
case AddInAction.InstalledTwice: // used to cancel installation of update
InstallableAddIn.CancelUpdate(selected);
foreach (AddIn addIn in selected) {
addIn.Action = addIn.Enabled ? AddInAction.Enable : AddInAction.Disable;
}
break;
default:
throw new NotImplementedException();
}
@ -587,8 +715,11 @@ namespace ICSharpCode.AddInManager @@ -587,8 +715,11 @@ namespace ICSharpCode.AddInManager
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.AllowDrop = true;
this.splitContainer.Panel1.AutoScroll = true;
this.splitContainer.Panel1.BackColor = System.Drawing.SystemColors.Window;
this.splitContainer.Panel1.DragDrop += new System.Windows.Forms.DragEventHandler(this.Panel1DragDrop);
this.splitContainer.Panel1.DragEnter += new System.Windows.Forms.DragEventHandler(this.Panel1DragEnter);
this.splitContainer.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.OnSplitContainerPanel1Paint);
this.splitContainer.Panel1MinSize = 100;
//
@ -739,5 +870,7 @@ namespace ICSharpCode.AddInManager @@ -739,5 +870,7 @@ namespace ICSharpCode.AddInManager
private System.Windows.Forms.Panel bottomPanel;
private System.Windows.Forms.Panel topPanel;
#endregion
}
}

8
src/Libraries/NRefactory/Project/Src/Output/CodeDOM/CodeDOMOutputVisitor.cs

@ -191,6 +191,7 @@ namespace ICSharpCode.NRefactory.Parser @@ -191,6 +191,7 @@ namespace ICSharpCode.NRefactory.Parser
public override object Visit(TypeDeclaration typeDeclaration, object data)
{
TypeDeclaration oldTypeDeclaration = currentTypeDeclaration;
this.currentTypeDeclaration = typeDeclaration;
CodeTypeDeclaration codeTypeDeclaration = new CodeTypeDeclaration(typeDeclaration.Name);
codeTypeDeclaration.IsClass = typeDeclaration.Type == ClassType.Class;
@ -210,7 +211,12 @@ namespace ICSharpCode.NRefactory.Parser @@ -210,7 +211,12 @@ namespace ICSharpCode.NRefactory.Parser
typeDeclarations.Pop();
((CodeNamespace)namespaceDeclarations.Peek()).Types.Add(codeTypeDeclaration);
if (typeDeclarations.Count > 0) {
((CodeTypeDeclaration)typeDeclarations.Peek()).Members.Add(codeTypeDeclaration);
} else {
((CodeNamespace)namespaceDeclarations.Peek()).Types.Add(codeTypeDeclaration);
}
currentTypeDeclaration = oldTypeDeclaration;
return null;
}

16
src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs

@ -45,6 +45,22 @@ namespace ICSharpCode.Core @@ -45,6 +45,22 @@ namespace ICSharpCode.Core
try {
if (assembly[0] == ':') {
loadedAssembly = System.Reflection.Assembly.Load(assembly.Substring(1));
} else if (assembly[0] == '$') {
int pos = assembly.IndexOf('/');
if (pos < 0)
throw new ApplicationException("Expected '/' in path beginning with '$'!");
string referencedAddIn = assembly.Substring(1, pos - 1);
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Enabled && addIn.Manifest.Identities.ContainsKey(referencedAddIn)) {
string assemblyFile = Path.Combine(Path.GetDirectoryName(addIn.FileName),
assembly.Substring(pos + 1));
loadedAssembly = System.Reflection.Assembly.LoadFrom(assemblyFile);
break;
}
}
if (loadedAssembly == null) {
throw new FileNotFoundException("Could not find referenced AddIn " + referencedAddIn);
}
} else {
loadedAssembly = System.Reflection.Assembly.LoadFrom(Path.Combine(hintPath, assembly));
}

BIN
src/Main/StartUp/Project/Resources/BitmapResources.resources

Binary file not shown.
Loading…
Cancel
Save