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 @@ -19,6 +19,16 @@ namespace Grunwald.BooBinding.Designer
{
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)
{
if (viewContent is ITextEditorControlProvider) {
@ -38,6 +48,10 @@ namespace Grunwald.BooBinding.Designer @@ -38,6 +48,10 @@ namespace Grunwald.BooBinding.Designer
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);
IDesignerGenerator generator = new BooDesignerGenerator();
return new ISecondaryViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) };

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

@ -20,6 +20,16 @@ namespace ICSharpCode.FormsDesigner @@ -20,6 +20,16 @@ namespace ICSharpCode.FormsDesigner
{
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)
{
c = c.DefaultReturnType.GetUnderlyingClass();
@ -99,6 +109,10 @@ namespace ICSharpCode.FormsDesigner @@ -99,6 +109,10 @@ namespace ICSharpCode.FormsDesigner
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 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 @@ -40,6 +40,16 @@ namespace ICSharpCode.Svn
{
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)
{
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 @@ -98,6 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui
protected override void Dispose(bool disposing)
{
if (disposing) {
ParserService.LoadSolutionProjectsThreadEnded -= LoadSolutionProjectsThreadEndedEvent;
if (content != null)
DetachContent();
if (this.TabPageContextMenu != null) {
@ -126,16 +127,22 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -126,16 +127,22 @@ namespace ICSharpCode.SharpDevelop.Gui
SetTitleEvent(this, EventArgs.Empty);
this.TabPageContextMenu = MenuService.CreateContextMenu(this, contextMenuPath);
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()
{
if (content.SecondaryViewContents.Count > 0) {
viewTabControl = new TabControl();
viewTabControl.Alignment = TabAlignment.Bottom;
viewTabControl.Dock = DockStyle.Fill;
viewTabControl.SelectedIndexChanged += new EventHandler(viewTabControlIndexChanged);
CreateViewTabControl();
AttachSecondaryViewContent(content);
foreach (ISecondaryViewContent subContent in content.SecondaryViewContents) {
AttachSecondaryViewContent(subContent);
@ -157,6 +164,41 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -157,6 +164,41 @@ namespace ICSharpCode.SharpDevelop.Gui
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)
{
OnWindowDeselected(EventArgs.Empty);

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

@ -22,6 +22,17 @@ namespace ICSharpCode.Core @@ -22,6 +22,17 @@ namespace ICSharpCode.Core
{
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);
}
}

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

@ -132,6 +132,7 @@ namespace ICSharpCode.Core @@ -132,6 +132,7 @@ namespace ICSharpCode.Core
} finally {
LoggingService.Info("LoadSolutionProjects thread ended");
loadSolutionProjectsThread = null;
OnLoadSolutionProjectsThreadEnded(EventArgs.Empty);
}
}
@ -609,6 +610,14 @@ namespace ICSharpCode.Core @@ -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 EventHandler LoadSolutionProjectsThreadEnded;
}
}

Loading…
Cancel
Save