Index: xword/UICommons/UIActionsManagement/AbstractAddPageFormActionsManager.cs
===================================================================
--- xword/UICommons/UIActionsManagement/AbstractAddPageFormActionsManager.cs (revision 0)
+++ xword/UICommons/UIActionsManagement/AbstractAddPageFormActionsManager.cs (revision 0)
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace UICommons.UIActionsManagement
+{
+ ///
+ /// Abstract actions manager for AddPageForm
instances.
+ ///
+ public abstract class AbstractAddPageFormActionsManager : IActionsManager
+ {
+ ///
+ /// Action to perform when OnAdd event is raised.
+ ///
+ /// Sender object
+ /// Event arguments
+ protected abstract void ActionAdd(object sender, EventArgs e);
+
+
+ #region IActionsManager Members
+
+ ///
+ /// Enqueues all event handlers for an AddPageForm.
+ ///
+ public abstract void EnqueueAllHandlers();
+
+ #endregion IActionsManager Members
+ }
+}
Index: xword/UICommons/UIActionsManagement/IActionsManager.cs
===================================================================
--- xword/UICommons/UIActionsManagement/IActionsManager.cs (revision 22792)
+++ xword/UICommons/UIActionsManagement/IActionsManager.cs (working copy)
@@ -17,7 +17,6 @@
///
/// Enqueues all (known) event handlers defined for a control.
///
- /// A reference to a generic control.
- void EnqueueAllHandlers(ref T control);
+ void EnqueueAllHandlers();
}
}
\ No newline at end of file
Index: xword/UICommons/UICommons.csproj
===================================================================
--- xword/UICommons/UICommons.csproj (revision 22792)
+++ xword/UICommons/UICommons.csproj (working copy)
@@ -1,4 +1,4 @@
-
+
Debug
@@ -55,6 +55,7 @@
+
@@ -76,4 +77,4 @@
-->
-
+
\ No newline at end of file
Index: xword/XWord/AddPageFormManager.cs
===================================================================
--- xword/XWord/AddPageFormManager.cs (revision 22792)
+++ xword/XWord/AddPageFormManager.cs (working copy)
@@ -4,61 +4,32 @@
using System.Text;
using System.Windows.Forms;
using UICommons;
+using UICommons.UIActionsManagement;
namespace XWord
{
///
- /// Manages the instances and public events handlers for AddPageForm.
+ /// Manages the public events handlers for AddPageForm.
///
- public class AddPageFormManager
+ public class AddPageFormManager : AbstractAddPageFormActionsManager
{
- private AddPageForm addPageForm;
+ AddPageForm addPageForm;
///
- /// Creates a new AddPageForm.
+ /// Default constructor.
///
- /// A reference to XWiki.WikiSructure
.
- /// New AddPageForm.
- public AddPageForm NewAddPageForm(ref XWiki.WikiStructure wiki)
+ /// A reference to an AddPageForm
instance.
+ public AddPageFormManager(ref AddPageForm addPageForm)
{
- addPageForm = new AddPageForm(ref wiki);
- addPageForm.OnAdd += new EventHandler(this.ActionAdd);
- return addPageForm;
+ this.addPageForm = addPageForm;
}
///
- /// Creates a new AddPageForm.
+ /// Event trigerred when OnAdd event of the AddPageForm instance is raised.
///
- /// A reference to XWiki.WikiSructure
.
- /// Space name.
- /// New AddPageForm.
- public AddPageForm NewAddPageForm(ref XWiki.WikiStructure wiki, string spaceName)
- {
- addPageForm = new AddPageForm(ref wiki,spaceName);
- addPageForm.OnAdd += new EventHandler(this.ActionAdd);
- return addPageForm;
- }
-
- ///
- /// Creates a new AddPageForm.
- ///
- /// A reference to XWiki.WikiSructure
.
- /// TRUE if it's a new space.
- /// TRUE if export mode.
- /// New AddPageForm.
- public AddPageForm NewAddPageForm(ref XWiki.WikiStructure wiki, bool newSpace,bool exportMode)
- {
- addPageForm = new AddPageForm(ref wiki, newSpace, exportMode);
- addPageForm.OnAdd += new EventHandler(this.ActionAdd);
- return addPageForm;
- }
-
- ///
- /// Event trigeered when OnAdd event of the AddPageForm instance is raised.
- ///
/// Sender object.
/// Event args.
- private void ActionAdd(object sender, EventArgs e)
+ protected override void ActionAdd(object sender, EventArgs e)
{
if (!addPageForm.ExportMode)
{
@@ -70,5 +41,17 @@
Globals.XWikiAddIn.AddinActions.SaveToServer();
}
}
+
+ #region IActionsManager Members
+
+ ///
+ /// Enqueues all event handlers for an AddPageForm.
+ ///
+ public override void EnqueueAllHandlers()
+ {
+ addPageForm.OnAdd += new EventHandler(this.ActionAdd);
+ }
+
+ #endregion IActionsManager Members
}
}
Index: xword/XWord/XWikiNavigationPane.cs
===================================================================
--- xword/XWord/XWikiNavigationPane.cs (revision 22792)
+++ xword/XWord/XWikiNavigationPane.cs (working copy)
@@ -14,6 +14,7 @@
using XWiki.Clients;
using System.Diagnostics;
using XWiki.Logging;
+using UICommons;
namespace XWord
{
@@ -512,7 +513,9 @@
{
String spaceName = treeView.SelectedNode.Text;
WikiStructure wiki = Wiki;
- new AddPageFormManager().NewAddPageForm(ref wiki, spaceName).ShowDialog();
+ AddPageForm addPageForm = new AddPageForm(ref wiki, spaceName);
+ new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
+ addPageForm.ShowDialog();
}
}
@@ -611,8 +614,9 @@
///
private void btnAddSpace_Click(object sender, EventArgs e)
{
- //new AddPageForm(ref Globals.XWikiAddIn.wiki, true, false).ShowDialog();
- new AddPageFormManager().NewAddPageForm(ref Globals.XWikiAddIn.wiki, true, false).ShowDialog();
+ AddPageForm addPageForm = new AddPageForm(ref Globals.XWikiAddIn.wiki, true, false);
+ new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
+ addPageForm.ShowDialog();
}
///
Index: xword/XWord/XWikiRibbon.cs
===================================================================
--- xword/XWord/XWikiRibbon.cs (revision 22792)
+++ xword/XWord/XWikiRibbon.cs (working copy)
@@ -9,6 +9,7 @@
using XWord.VstoExtensions;
using XWiki.Logging;
using XWiki;
+using UICommons;
namespace XWord
{
@@ -138,7 +139,9 @@
private void btnNewPage_Click(object sender, RibbonControlEventArgs e)
{
- new AddPageFormManager().NewAddPageForm(ref Globals.XWikiAddIn.wiki).ShowDialog();
+ AddPageForm addPageForm = new AddPageForm(ref Globals.XWikiAddIn.wiki);
+ new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
+ addPageForm.ShowDialog();
}
private void btnSavePage_Click(object sender, RibbonControlEventArgs e)
@@ -147,7 +150,9 @@
{
if (Addin.currentPageFullName == "" || Addin.currentPageFullName == null)
{
- new AddPageFormManager().NewAddPageForm(ref Addin.wiki, false, true).ShowDialog();
+ AddPageForm addPageForm = new AddPageForm(ref Addin.wiki, false, true);
+ new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
+ addPageForm.ShowDialog();
}
else
{
@@ -167,13 +172,17 @@
if (treeView.SelectedNode != null)
{
String spaceName = treeView.SelectedNode.Text;
- new AddPageFormManager().NewAddPageForm(ref Globals.XWikiAddIn.wiki, spaceName).ShowDialog();
+ AddPageForm addPageForm = new AddPageForm(ref Globals.XWikiAddIn.wiki, spaceName);
+ new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
+ addPageForm.ShowDialog();
}
else
{
//see XOFFICE-20
//MessageBox.Show("You need to select a space in the wiki explorer.","XWord");
- new AddPageFormManager().NewAddPageForm(ref Globals.XWikiAddIn.wiki, true, false).ShowDialog();
+ AddPageForm addPageForm = new AddPageForm(ref Globals.XWikiAddIn.wiki, true, false);
+ new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
+ addPageForm.ShowDialog();
}
}