コード例 #1
0
 /// <summary>
 /// Opens the URL if the selected page in the default browser.
 /// </summary>
 public void ViewInBrowser()
 {
     if (treeView.SelectedNode != null)
     {
         if (treeView.SelectedNode.Level == TREE_PAGE_LEVEL)
         {
             try
             {
                 String pageFullName = treeView.SelectedNode.Name;
                 String url          = Client.GetURL(pageFullName);
                 //url = Addin.serverURL + url;
                 Process p = new Process();
                 p.StartInfo = new ProcessStartInfo(url);
                 p.Start();
             }
             catch (Win32Exception ex)
             {
                 UserNotifier.Error(ex.Message);
             }
             catch (WebException webex)
             {
                 UserNotifier.Error(webex.Message);
             }
         }
         else
         {
             UserNotifier.Exclamation("No page is selected");
         }
     }
     else
     {
         UserNotifier.Exclamation("Please select a page in the Wiki Explorer first.");
     }
 }
コード例 #2
0
 private void btnSavePage_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         if (Addin.currentPageFullName == "" || Addin.currentPageFullName == null)
         {
             AddPageForm addPageForm = new AddPageForm(ref Addin.wiki, false, true);
             new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
             addPageForm.ShowDialog();
         }
         else
         {
             try
             {
                 Addin.AddinActions.SaveToServer();
             }
             catch (Exception ex)
             {
                 Log.Exception(ex);
                 UserNotifier.Exclamation("There was an error when trying to save the page to the server");
             }
         }
     }
     catch (NullReferenceException ex)
     {
         Log.Exception(ex);
         UserNotifier.Exclamation("You are not currently editing a wiki page");
     }
 }
コード例 #3
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionAddAttachments()
 {
     if (Globals.XWord2003AddIn.Wiki != null &&
         ("" + Globals.XWord2003AddIn.CurrentPageFullName).Length > 1 &&
         Globals.XWord2003AddIn.CurrentPagePublished)
     {
         Globals.XWord2003AddIn.AddinActions.AttachFiles(Globals.XWord2003AddIn.CurrentPageFullName);
     }
     else
     {
         UserNotifier.Exclamation(UIMessages.NOT_A_PUBLISHED_PAGE);
     }
 }
コード例 #4
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionViewInBrowser()
 {
     if (Globals.XWord2003AddIn.Wiki != null &&
         ("" + Globals.XWord2003AddIn.CurrentPageFullName).Length > 1 &&
         Globals.XWord2003AddIn.CurrentPagePublished)
     {
         string pageFullName = Globals.XWord2003AddIn.CurrentPageFullName;
         string pageURL      = Globals.XWord2003AddIn.Client.GetURL(pageFullName);
         Globals.XWord2003AddIn.AddinActions.StartProcess(pageURL);
     }
     else
     {
         UserNotifier.Exclamation(UIMessages.NOT_A_PUBLISHED_PAGE);
     }
 }
コード例 #5
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionViewAttachments()
 {
     if (Globals.XWord2003AddIn.Wiki != null &&
         ("" + Globals.XWord2003AddIn.CurrentPageFullName).Length > 1 &&
         Globals.XWord2003AddIn.CurrentPagePublished)
     {
         ViewPageAttachmentsForm        viewPageAttachmentsForm = new ViewPageAttachmentsForm(Globals.XWord2003AddIn.CurrentPageFullName);
         ViewPageAttachmentsFormManager viewAttachmentsManager  = new ViewPageAttachmentsFormManager(ref viewPageAttachmentsForm);
         viewAttachmentsManager.EnqueueAllHandlers();
         viewPageAttachmentsForm.ShowDialog();
     }
     else
     {
         UserNotifier.Exclamation(UIMessages.NOT_A_PUBLISHED_PAGE);
     }
 }
コード例 #6
0
 protected override void ActionViewAttachments(object sender, EventArgs e)
 {
     editPageOnClose = false;
     if (editPageForm.ListBoxPagesSelectedValue != null && editPageForm.ListBoxSpacesSelectedValue != null)
     {
         pageFullName = editPageForm.ListBoxSpacesSelectedValue.ToString() + "." + editPageForm.ListBoxPagesSelectedValue.ToString();
         ViewPageAttachmentsForm        viewPageAttachmentsForm = new ViewPageAttachmentsForm(pageFullName);
         ViewPageAttachmentsFormManager viewAttachmentsManager  = new ViewPageAttachmentsFormManager(ref viewPageAttachmentsForm);
         viewAttachmentsManager.EnqueueAllHandlers();
         viewPageAttachmentsForm.ShowDialog();
     }
     else
     {
         UserNotifier.Exclamation(UIMessages.SELECT_SPACE_AND_PAGE);
     }
 }
コード例 #7
0
 protected override void ActionOpenAttachment(object sender, EventArgs e)
 {
     if (viewPageAttachmentsForm.ListBoxAttachmentsIndex < 0 || attachments == null || attachments.Count < 1)
     {
         UserNotifier.Exclamation("No attachment selected!");
     }
     else
     {
         string path = addinActions.SaveFileDialog(attachmentName);
         if (path != null)
         {
             FileInfo attachmentInfo = addinActions.DownloadAttachment(pageFullName, attachmentName, path);
             addinActions.StartProcess(attachmentInfo.FullName);
         }
     }
 }
コード例 #8
0
 /// <summary>
 /// Action to be performed on edit page (ex: when the user clicks 'Edit' button).
 /// Closed the form, and the page wil be edited when the form is disposed.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 protected override void ActionEditPage(object sender, EventArgs e)
 {
     if (editPageForm.ListBoxPagesSelectedValue != null && editPageForm.ListBoxSpacesSelectedValue != null)
     {
         pageFullName              = editPageForm.ListBoxSpacesSelectedValue.ToString() + "." + editPageForm.ListBoxPagesSelectedValue.ToString();
         editPageOnClose           = true;
         editPageForm.DialogResult = DialogResult.OK;
         editPageForm.Visible      = false;
         editPageForm.Close();
         editPageForm.Dispose();
     }
     else
     {
         editPageOnClose = false;
         UserNotifier.Exclamation(UIMessages.SELECT_SPACE_AND_PAGE);
     }
 }
コード例 #9
0
 private void btnDownloadAndOpen_Click(object sender, RibbonControlEventArgs e)
 {
     if (Addin.XWikiTaskPane.treeView.SelectedNode != null)
     {
         String page           = Globals.XWikiAddIn.AddinStatus.TaskPaneSelectedPage.Get("page");
         String attachmentName = Addin.XWikiTaskPane.treeView.SelectedNode.Name;
         String path           = Globals.XWikiAddIn.AddinActions.SaveFileDialog(attachmentName);
         if (path != null)
         {
             FileInfo attachmentInfo = Addin.AddinActions.DownloadAttachment(page, attachmentName, path);
             Addin.AddinActions.StartProcess(attachmentInfo.FullName);
         }
     }
     else
     {
         UserNotifier.Exclamation("You need to select an attachment in the wiki explorer.");
     }
 }
コード例 #10
0
        private void UploadAttToPage_Click(object sender, RibbonControlEventArgs e)
        {
            String page = Globals.XWikiAddIn.AddinStatus.TaskPaneSelectedPage.Get("page");

            if (page == null)
            {
                UserNotifier.Exclamation("You need to select a page in the wiki explorer first.");
                return;
            }
            bool finished = Globals.XWikiAddIn.AddinActions.AttachCurrentFile(page);

            if (finished)
            {
                UserNotifier.Message("Upload finished.");
            }
            else
            {
                UserNotifier.Error("Upload failed. Make sure you have selected a page before uploading");
            }
        }
コード例 #11
0
        /// <summary>
        /// Saves the currently edited page or document to the server.
        /// Displays the operation in progress dialog.
        /// </summary>
        public void SaveToServer()
        {
            if (addin.currentPageFullName == "" || addin.currentPageFullName == null)
            {
                UserNotifier.Exclamation("You are not currently editing a wiki page");
                return;
            }

            if (addin.CurrentPagePublished)
            {
                //Checks if a newer version exists. If yes, then the publishing is canceled redardless if
                //the user  merged the documents or not.
                if (MergeWithLatestVersion(addin.currentPageFullName))
                {
                    return;
                }
            }
            LoadingDialog loadingDialog = new LoadingDialog("Saving to wiki...");

            ThreadPool.QueueUserWorkItem(new WaitCallback(loadingDialog.ShowSyncDialog));
            SaveToXwiki();

            //TODO: Create an SaveCompleted event. Listen for the event and do an async version update
            //Update local history to the latest version
            pagesHistory[addin.currentPageFullName] = Client.GetPageHistory(addin.currentPageFullName);

            loadingDialog.CloseSyncDialog();
            //After a new page has been published to XWiki, refresh the tree view
            //so the user can see his/her page plus other pages that might have been
            //created while the user was working on the current one.
            if (!addin.CurrentPagePublished)
            {
                Globals.XWikiAddIn.XWikiTaskPane.RefreshWikiExplorer();
                addin.CurrentPagePublished = true;
            }
        }
コード例 #12
0
        /// <summary>
        /// Saves the currently edited page or document to the server.
        /// </summary>
        public void SaveToServer()
        {
            string msgSaving    = "Saving to server ...";
            string msgPublished = "Page published!";

            addin.StatusMessage         = msgSaving;
            addin.Application.StatusBar = msgSaving;

            if (addin.CurrentPageFullName == "" || addin.CurrentPageFullName == null)
            {
                UserNotifier.Exclamation(UIMessages.NOT_A_WIKI_PAGE);
                return;
            }
            SaveToXWiki();

            if (!addin.CurrentPagePublished)
            {
                //mark page as published
                addin.CurrentPagePublished = true;
                if (addin.PublishedStatus.ContainsKey(addin.CurrentPageFullName))
                {
                    addin.PublishedStatus[addin.CurrentPageFullName] = true;
                }
                else
                {
                    addin.PublishedStatus.Add(addin.CurrentPageFullName, true);
                }

                char[]   separator    = { '.' };
                string[] pageFullName = addin.CurrentPageFullName.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                string   spaceName    = pageFullName[0].Trim();
                string   pageName     = pageFullName[1].Trim();

                XWiki.Space currentSpace = null;

                //if it's a new space add it to the local wiki structure
                bool spaceExists = false;
                foreach (XWiki.Space space in addin.Wiki.spaces)
                {
                    if (space.name == spaceName)
                    {
                        spaceExists  = true;
                        currentSpace = space;
                        break;
                    }
                }
                if (!spaceExists)
                {
                    currentSpace           = new Space();
                    currentSpace.name      = spaceName;
                    currentSpace.documents = new List <XWikiDocument>();
                    currentSpace.hidden    = false;
                    currentSpace.published = true;
                }

                //add the new page to the space in the local wiki structure
                bool pageExists = false;
                foreach (XWiki.XWikiDocument page in currentSpace.documents)
                {
                    if (page.name == pageName)
                    {
                        pageExists = true;
                        break;
                    }
                }
                if (!pageExists)
                {
                    XWiki.XWikiDocument currentPage = new XWikiDocument();
                    currentPage.name      = pageName;
                    currentPage.published = true;
                    currentPage.space     = spaceName;
                    currentSpace.documents.Add(currentPage);
                }
            }

            addin.StatusMessage         = msgPublished;
            addin.Application.StatusBar = msgPublished;
        }