Browse Source

Fixed SD2-579: Design tab not always available for partial class forms (patch by Christian Hornung)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1019 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
356cea55e4
  1. 14
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/FormsDesignerBinding.cs
  2. 14
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs
  3. 10
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs
  4. 52
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
  5. 11
      src/Main/Base/Project/Src/Services/DisplayBinding/ISubDisplayBinding.cs
  6. 9
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

14
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/FormsDesignerBinding.cs

@ -19,6 +19,16 @@ namespace Grunwald.BooBinding.Designer
{ {
public class FormsDesignerDisplayBinding : ISecondaryDisplayBinding public class FormsDesignerDisplayBinding : ISecondaryDisplayBinding
{ {
/// <summary>
/// When you return true for this property, the CreateSecondaryViewContent method
/// is called again after the LoadSolutionProjects thread has finished.
/// </summary>
public bool ReattachWhenParserServiceIsReady {
get {
return true;
}
}
public bool CanAttachTo(IViewContent viewContent) public bool CanAttachTo(IViewContent viewContent)
{ {
if (viewContent is ITextEditorControlProvider) { if (viewContent is ITextEditorControlProvider) {
@ -38,6 +48,10 @@ namespace Grunwald.BooBinding.Designer
public ISecondaryViewContent[] CreateSecondaryViewContent(IViewContent viewContent) public ISecondaryViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
{ {
if (viewContent.SecondaryViewContents.Exists(delegate(ISecondaryViewContent c) { return c.GetType() == typeof(FormsDesignerViewContent); })) {
return new ISecondaryViewContent[0];
}
IDesignerLoaderProvider loader = new BooDesignerLoaderProvider(((ITextEditorControlProvider)viewContent).TextEditorControl); IDesignerLoaderProvider loader = new BooDesignerLoaderProvider(((ITextEditorControlProvider)viewContent).TextEditorControl);
IDesignerGenerator generator = new BooDesignerGenerator(); IDesignerGenerator generator = new BooDesignerGenerator();
return new ISecondaryViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) }; return new ISecondaryViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) };

14
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs

@ -20,6 +20,16 @@ namespace ICSharpCode.FormsDesigner
{ {
public class FormsDesignerSecondaryDisplayBinding : ISecondaryDisplayBinding public class FormsDesignerSecondaryDisplayBinding : ISecondaryDisplayBinding
{ {
/// <summary>
/// When you return true for this property, the CreateSecondaryViewContent method
/// is called again after the LoadSolutionProjects thread has finished.
/// </summary>
public bool ReattachWhenParserServiceIsReady {
get {
return true;
}
}
public static IMethod GetInitializeComponents(IClass c) public static IMethod GetInitializeComponents(IClass c)
{ {
c = c.DefaultReturnType.GetUnderlyingClass(); c = c.DefaultReturnType.GetUnderlyingClass();
@ -99,6 +109,10 @@ namespace ICSharpCode.FormsDesigner
public ISecondaryViewContent[] CreateSecondaryViewContent(IViewContent viewContent) public ISecondaryViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
{ {
if (viewContent.SecondaryViewContents.Exists(delegate(ISecondaryViewContent c) { return c.GetType() == typeof(FormsDesignerViewContent); })) {
return new ISecondaryViewContent[0];
}
string fileExtension = String.Empty; string fileExtension = String.Empty;
string fileName = viewContent.IsUntitled ? viewContent.UntitledName : viewContent.FileName; string fileName = viewContent.IsUntitled ? viewContent.UntitledName : viewContent.FileName;

10
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs

@ -40,6 +40,16 @@ namespace ICSharpCode.Svn
{ {
public class HistoryViewDisplayBinding : ISecondaryDisplayBinding public class HistoryViewDisplayBinding : ISecondaryDisplayBinding
{ {
/// <summary>
/// When you return true for this property, the CreateSecondaryViewContent method
/// is called again after the LoadSolutionProjects thread has finished.
/// </summary>
public bool ReattachWhenParserServiceIsReady {
get {
return false;
}
}
public ICSharpCode.SharpDevelop.Gui.ISecondaryViewContent[] CreateSecondaryViewContent(ICSharpCode.SharpDevelop.Gui.IViewContent viewContent) public ICSharpCode.SharpDevelop.Gui.ISecondaryViewContent[] CreateSecondaryViewContent(ICSharpCode.SharpDevelop.Gui.IViewContent viewContent)
{ {
return new ICSharpCode.SharpDevelop.Gui.ISecondaryViewContent[] { new HistoryView(viewContent) }; return new ICSharpCode.SharpDevelop.Gui.ISecondaryViewContent[] { new HistoryView(viewContent) };

52
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

@ -98,6 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing) { if (disposing) {
ParserService.LoadSolutionProjectsThreadEnded -= LoadSolutionProjectsThreadEndedEvent;
if (content != null) if (content != null)
DetachContent(); DetachContent();
if (this.TabPageContextMenu != null) { if (this.TabPageContextMenu != null) {
@ -126,16 +127,22 @@ namespace ICSharpCode.SharpDevelop.Gui
SetTitleEvent(this, EventArgs.Empty); SetTitleEvent(this, EventArgs.Empty);
this.TabPageContextMenu = MenuService.CreateContextMenu(this, contextMenuPath); this.TabPageContextMenu = MenuService.CreateContextMenu(this, contextMenuPath);
InitControls(); InitControls();
ParserService.LoadSolutionProjectsThreadEnded += LoadSolutionProjectsThreadEndedEvent;
}
private void CreateViewTabControl()
{
viewTabControl = new TabControl();
viewTabControl.Alignment = TabAlignment.Bottom;
viewTabControl.Dock = DockStyle.Fill;
viewTabControl.SelectedIndexChanged += new EventHandler(viewTabControlIndexChanged);
} }
internal void InitControls() internal void InitControls()
{ {
if (content.SecondaryViewContents.Count > 0) { if (content.SecondaryViewContents.Count > 0) {
viewTabControl = new TabControl(); CreateViewTabControl();
viewTabControl.Alignment = TabAlignment.Bottom;
viewTabControl.Dock = DockStyle.Fill;
viewTabControl.SelectedIndexChanged += new EventHandler(viewTabControlIndexChanged);
AttachSecondaryViewContent(content); AttachSecondaryViewContent(content);
foreach (ISecondaryViewContent subContent in content.SecondaryViewContents) { foreach (ISecondaryViewContent subContent in content.SecondaryViewContents) {
AttachSecondaryViewContent(subContent); AttachSecondaryViewContent(subContent);
@ -157,6 +164,41 @@ namespace ICSharpCode.SharpDevelop.Gui
viewTabControl.TabPages.Add(newPage); viewTabControl.TabPages.Add(newPage);
} }
/// <summary>
/// Ensures that all possible secondary view contents are attached.
/// This is primarily used to add the FormsDesigner view content for files
/// containing partial classes after the designer file has been parsed if
/// the view content has been created too early on startup.
/// </summary>
void RefreshSecondaryViewContents()
{
if (content == null) {
return;
}
int oldSvcCount = content.SecondaryViewContents.Count;
DisplayBindingService.AttachSubWindows(content, true);
if (content.SecondaryViewContents.Count > oldSvcCount) {
LoggingService.Debug("Attaching new secondary view contents to '"+this.Title+"'");
if (viewTabControl == null) {
// The tab control needs to be created first.
Controls.Remove(content.Control);
CreateViewTabControl();
AttachSecondaryViewContent(content);
Controls.Add(viewTabControl);
}
foreach (ISecondaryViewContent svc in content.SecondaryViewContents) {
if (svc.WorkbenchWindow == null) {
AttachSecondaryViewContent(svc);
}
}
}
}
void LoadSolutionProjectsThreadEndedEvent(object sender, EventArgs e)
{
this.BeginInvoke(new MethodInvoker(this.RefreshSecondaryViewContents));
}
void LeaveTabPage(object sender, EventArgs e) void LeaveTabPage(object sender, EventArgs e)
{ {
OnWindowDeselected(EventArgs.Empty); OnWindowDeselected(EventArgs.Empty);

11
src/Main/Base/Project/Src/Services/DisplayBinding/ISubDisplayBinding.cs

@ -22,6 +22,17 @@ namespace ICSharpCode.Core
{ {
bool CanAttachTo(IViewContent content); bool CanAttachTo(IViewContent content);
/// <summary>
/// When you return true for this property, the CreateSecondaryViewContent method
/// is called again after the LoadSolutionProjects thread has finished.
/// </summary>
bool ReattachWhenParserServiceIsReady { get; }
/// <summary>
/// Creates the secondary view contents for the given view content.
/// If ReattachWhenParserServiceIsReady is used, the implementation is responsible
/// for checking that no duplicate secondary view contents are added.
/// </summary>
ISecondaryViewContent [] CreateSecondaryViewContent(IViewContent viewContent); ISecondaryViewContent [] CreateSecondaryViewContent(IViewContent viewContent);
} }
} }

9
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -132,6 +132,7 @@ namespace ICSharpCode.Core
} finally { } finally {
LoggingService.Info("LoadSolutionProjects thread ended"); LoggingService.Info("LoadSolutionProjects thread ended");
loadSolutionProjectsThread = null; loadSolutionProjectsThread = null;
OnLoadSolutionProjectsThreadEnded(EventArgs.Empty);
} }
} }
@ -609,6 +610,14 @@ namespace ICSharpCode.Core
} }
} }
static void OnLoadSolutionProjectsThreadEnded(EventArgs e)
{
if (LoadSolutionProjectsThreadEnded != null) {
LoadSolutionProjectsThreadEnded(null, e);
}
}
public static event ParseInformationEventHandler ParseInformationUpdated; public static event ParseInformationEventHandler ParseInformationUpdated;
public static event EventHandler LoadSolutionProjectsThreadEnded;
} }
} }

Loading…
Cancel
Save