15 Replies Latest reply: Mar 11, 2014 9:21 PM by AMAGARWA@ADOBE.COM RSS

    RoboHelp 8 Eclipse Help Index/Search Problem

    Rick Poole Community Member

      When using RoboHelp 8 to generate Eclipse via the EclipseHelp.jsx script I encounter the following problem: WebHelp generates its own search and index which does not work once placed inside the EclipsePlugin.

       

      Is anyone else using RoboHelp to generate Eclipse Help? How do you overcome this problem?

        • 1. Re: RoboHelp 8 Eclipse Help Index/Search Problem
          Siddharth Sodhani

          Hello Rick,

           

          True that the WebHelp generated search and index won't work inside the Eclipse. But when you create a new help system, Eclipse takes care of its indexing and makes content searchable.

           

          Refer to: http://www.ibm.com/developerworks/opensource/library/os-echelp/

          Excerpt: "Documentation is provided with a collapsible index on the left side and HTML documentation on the right, and can be searched (thanks to the Apache Lucene search engine)."

           

          I created an help system and search is working fine in it. When you search anything for the first time, Eclipse performs re-indexing the help system.

           

          Is search not working on your help?

           

          Thanks,

          Siddharth Sodhani

          RoboHelp Engineering Team

           

           

          • 2. Re: RoboHelp 8 Eclipse Help Index/Search Problem
            Rick Poole Community Member

            Search appears to work fine but the Index that shows up isn't for my help but another one that is included with Eclipse the Web Application Dev. User Guide.

             

            Also the "Show" link appears on the help pages. When clicked the non-functional webhelp index and search appears within the help text pane. Attempting to disable this by unselecting In-Topic Nav Bar Element in the SSL properties doesn't work.

            • 3. Re: RoboHelp 8 Eclipse Help Index/Search Problem
              Rick Poole Community Member

              Could you share your WebHelp SSL properties with me?

               

              Thanks,

               

              RP

              • 4. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                Rick Poole Community Member

                I have the show link problem fixed however the Eclipse Index doesn't see my help.

                • 5. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                  Siddharth Sodhani Community Member

                  Hello Rick,

                   

                  Like Eclipse has a format for TOC, it has the same for Index as well. As of now the script (EclipseHelp.jsx) does not handle it. I am still working on that and should keep you posted.

                   

                  Thanks,

                  Siddharth

                  • 6. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                    Siddharth Sodhani Community Member

                    Hi Rick,

                     

                    Please find attached EclipseHelpWithIndex.jsx file which should also generate index.xml and show index in Eclipse index. Please restart eclispe using "eclipse.exe -clean" from command prompt.

                     

                    Let me know how it goes.

                     

                    Thanks,

                    Siddharth

                    • 7. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                      Rick Poole Community Member

                      Siddharth,

                       

                      Excellent! That does the trick. Thank you very much.

                       

                      Best Regards,

                       

                      RP

                      • 8. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                        mknoll1

                        I had some issues with this specific script.  When I had entries with multiple topics the text was not displaying correctly on the index in Eclipse.  I verified that this was an issue within the eclipse help but it is easily solvable by making each topic a child of a new entry.  I did this by editting the AddTopic function to be like the one below.  I know this is an old thread but it comes up high on the Google search so I thought it should be updated.

                         

                        function AddTopic(tNode)

                        {

                             var keyName = tNode.attribute(NAME);

                             var url = tNode.attribute(URL);

                             

                             var keyXML = XML(String("<entry keyword=\"" + keyName + "\"/>"));

                             var topicXML = XML(String("<topic href=\"" + url + "\"/>"));

                             keyXML.appendChild(topicXML);

                             

                             return keyXML;

                        }

                        • 9. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                          laurenkusa Community Member

                          Hi All,

                           

                          In the past, I was able to use the EclipseHelpWithIndex.jsx script with the modification:

                           

                          function AddTopic(tNode)

                          {

                               var keyName = tNode.attribute(NAME);

                               var url = tNode.attribute(URL);

                           

                               var keyXML = XML(String("<entry keyword=\"" + keyName + "\"/>"));

                               var topicXML = XML(String("<topic href=\"" + url + "\"/>"));

                               keyXML.appendChild(topicXML);

                           

                               return keyXML;

                          }

                           

                          But I have since changed from a Windows XP to a Windows 7 system.  I am running Robohelp 9 as Administrator.  When I run this script now, I see an error: undefined is not an object Line 181, Column 1.

                           

                          Line 181 is:

                          ecIndex.write(indexXML.toXMLString());

                           

                          Any thoughts as to why this is happening?

                          • 10. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                            Thorntondan

                            We have the same problem with the EclipseHelpWithIndex.jsx script ("undefined is not an object Line 181, Column 1.") The index.xml file is generated, but only has the single tag "<index/>" in it. The problem surfaced in RoboHelp 8 and still occurs when running the same script under RoboHelp 10.

                             

                            We assumed the new RoboHelp 10 with its EclipseHelp output option would take care of this problem, but the index portion of the new script code doesn't actually create an index.xml file; it simply returns the value "true" so the script won't fail.

                             

                            Our company has a critical need to provide EclipseHelp indices and would like to see a solution provided by Adobe.

                             

                                 - Dan Thornton

                            • 11. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                              Peter Grainge ACP/MVPs

                              Dan

                               

                              These forums are user to user and not monitored by Adobe. To get a solution from Adobe you will need to contact Support or submit a bug report. Please follow this link.

                               

                              http://www.Adobe.com/cfusion/mmform/index.cfm?name=wishform&product=38

                               

                              I understand that you feel Adobe should provide the script but if your developers can fix the script as above, that might be a quicker solution.

                               


                              See www.grainge.org for RoboHelp and Authoring tips

                               

                               

                              @petergrainge

                              • 12. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                                laurenkusa Community Member

                                Hi,

                                 

                                We managed to find a fix to the ModifiedEclipseHelpwithIndex script.  It turns out that in RoboHelp 10 some of the XML files are now Javascript files.

                                 

                                Here is the code we added before the function RunEclipseHelp() section to make a fix:

                                 

                                var baseFolder = projFolder.fsName.concat("\\whxdata");

                                if(Folder(baseFolder).exists)

                                      {           ConvertJavaScriptFilesToXML(baseFolder); //Convert JS files in Robohelp 10 to XML files

                                           var wtoc = File(baseFolder.concat("\\whtoc.xml"));

                                           var indexFile = File(baseFolder.concat("\\whidx.xml"));

                                           RunEclipseHelp();

                                      }    

                                else Window.alert("Generate WebHelp before running this script");

                                }

                                 

                                function DoConvertJavaScriptFileToXML(path_to_dir, re, js_file)

                                {

                                      if (!js_file.open('r')) return;

                                         var content = "";

                                     while (js_file.tell() != js_file.length)

                                     {

                                         content += js_file.readln();

                                     }

                                      js_file.close();

                                       var matches = re.exec(content);

                                      if (!matches) return;

                                       var xml_content = re.exec(content)[1].replace(/\\/g, "");

                                      var xml_file = new File(path_to_dir.concat("\\" + js_file.name.replace("_xml.js", ".xml")));

                                      if (xml_file.open('w'))

                                      {

                                           xml_file.write(xml_content);

                                           xml_file.close();

                                      }

                                }

                                 

                                function ConvertJavaScriptFilesToXML(path_to_dir)

                                {

                                      var base_folder = new Folder(path_to_dir);

                                      if (!base_folder.exists) return;

                                            var re = new RegExp(/^\s*gXMLBuffer\s*=\s*"(.*)";$/m);

                                      var js_files = base_folder.getFiles("*.js");

                                      for (var i = 0; i < js_files.length; i++)

                                      {

                                           DoConvertJavaScriptFileToXML(path_to_dir, re, js_files[i]);

                                      }

                                }

                                • 13. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                                  AMAGARWA@ADOBE.COM Adobe Employee

                                  For RH10, here is a attached script that handles the index.xml generation too in eclipsehelp. Would work for RH10 and higher.

                                  Do let us know if there are any issues.

                                   

                                   

                                  https://workspaces.acrobat.com/?d=GPhvDwgkj5YWeUK4MBRrFA

                                   

                                   

                                  Regards,

                                  Amit

                                  RoboHelp Engineering

                                  • 14. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                                    laurenkusa Community Member

                                    I will give this script a try as well and let you know if there are problems.

                                     

                                    THanks,

                                     

                                    Lauren

                                    • 15. Re: RoboHelp 8 Eclipse Help Index/Search Problem
                                      AMAGARWA@ADOBE.COM Adobe Employee

                                      Since workspaces.acrobat.com is retiring soon, placing the (above) refered complete script here itself:

                                       

                                       

                                      ---------------------------------------------------------

                                       

                                      /***************************************************************************************** ******************

                                      * $$FileName                    EclipseHelp Generator.jsx

                                      *

                                      * $$Description             This script file generates Eclipse help from RoboHelp Project

                                      *                                        (works for version 9 & above.)

                                      *

                                      * $$Author                      Praful Jain

                                      *

                                      * $$Modified By         Amit Agarwal (Added index.xml generation)

                                      *

                                      * Copyright (c) 2014 Adobe Systems Incorporated. All Rights Reserved.

                                      ****************************************************************************************** ******************/

                                       

                                       

                                       

                                       

                                      var mainDlg;

                                       

                                       

                                      //load all the information

                                      var OPF_TITLE;

                                      var OPF_PROVIDER;

                                      var OPF_VERSION;

                                      var OPF_ID;

                                      var userOutputFolder;

                                      var outputFolder;

                                      var currentProject;

                                      var strTOCOutputXML;

                                      var szCurrentXMLSSLName;

                                       

                                       

                                      var PAGE = "page";

                                      var BOOK = "book";

                                      var TITLE = "title";

                                      var URL = "url";

                                      var ITEM = "item";

                                      var CHUNK = "chunk";

                                      var NAME = "name";

                                      var REF = "ref";

                                      var INDEXDATA = "indexdata";

                                      var CHUNKINFO = "chunkinfo";

                                      var KEY = "key";

                                      var TOPIC = "topic";

                                       

                                       

                                      var ECLIPSEHELPCONFXMLFILE = "RH_EclipseHelp.xml";

                                      var PLUGINFILENAME = "plugin.xml";

                                      var OUTPUTTOCFILENAME = "toc.xml";

                                      var OUTPUTINDEXFILENAME = "index.xml";

                                      var listOfTOCFiles = new Array();

                                       

                                       

                                      //this is the main UI dialog string

                                      var mainDlgResource = "dialog {          \

                                                properties: { closeButton: false },          \

                                                text:'Generate Eclipse Help output',          \

                                                g_Output: Group {          \

                                                          st: StaticText {          \

                                                                    text:'Help Output Location:'          \

                                                          },          \

                                                          et: EditText { \

                                                                    characters: 40          \

                                                          },          \

                                                          btn: Button{          \

                                                                    text: 'Browse'          \

                                                          }          \

                                                },          \

                                                g_SSL: Group { orientation: 'row',  alignment: ['fill', 'bottom'], \

                                                          st: StaticText {          \

                                                                    text:'Select WebHelp output SSL:'          \

                                                          },          \

                                                          ddl: DropDownList { alignment: ['fill', 'center']} \

                                                },          \

                                                tabnav: Panel {          \

                                                          type:'tabbedpanel',          \

                                                          helpTip:'Panel: type tabbedpanel',          \

                                                          minimumSize:[500, 250],          \

                                                          metaTab: Panel {          \

                                                                              type:'tab', text:'Eclipse Help Information',          \

                                                                              orientation: 'column',          \

                                                                              alignChildren:'right',          \

                                                                              g_Title: Group {          \

                                                                                        st: StaticText {          \

                                                                                                  text:'Title:'          \

                                                                                        },          \

                                                                                        et: EditText {          \

                                                                                                  characters: 60          \

                                                                                        }          \

                                                                              },          \

                                                                              g_Provider: Group {          \

                                                                                        st: StaticText {          \

                                                                                                  text:'Provider Name:'          \

                                                                                        },          \

                                                                                        et: EditText {          \

                                                                                                  characters: 60          \

                                                                                        }          \

                                                                              },          \

                                                                              g_Version: Group {          \

                                                                                        st: StaticText {          \

                                                                                                  text:'Version:'          \

                                                                                        },          \

                                                                                        et: EditText {          \

                                                                                                  characters: 60          \

                                                                                        }          \

                                                                              },          \

                                                                              g_ID: Group {          \

                                                                                        st: StaticText {          \

                                                                                                  text:'ID:'          \

                                                                                        },          \

                                                                                        et: EditText {          \

                                                                                                  helpTip:'Enter Plugin ID here',          \

                                                                                                  characters: 60          \

                                                                                        }          \

                                                                              }          \

                                                                    }          \

                                                },          \

                                                btnGroup: Group {                                                                                          \

                                                          alignment:['right', 'bottom'],          \

                                                          okBtn: Button {          \

                                                                    text:'Generate'                    \

                                                          },                                                                                                                        \

                                                          cancelBtn: Button {                                                                       \

                                                                    text:'Close'          \

                                                          }                                                                                                                        \

                                                }                              \

                                      }          ";

                                       

                                       

                                      //start

                                      main();

                                       

                                       

                                      function main() {

                                          if (isValidType(RoboHelp)) {

                                              //check for the project open

                                              currentProject = RoboHelp.getCurrentProject();

                                              if (isValidType(currentProject)) {

                                                  //we need to show the main dialog now

                                                  showMainDialog();

                                              }

                                              else {

                                                  alert("Please open project");

                                              }

                                          }

                                          else {

                                              alert("Please launch RoboHelp HTML");

                                          }

                                      }

                                       

                                       

                                      function readFile(szFilePath) {

                                         

                                          return RoboHelp.readWholeFile(szFilePath); //this takes care of BOM, encoding and all   

                                         

                                      }

                                       

                                       

                                      function writeToFile(szFilePath, szOutput, bWriteUsingNewFunction) {

                                          var bSuccess = false;

                                          if (bWriteUsingNewFunction) {

                                              bSuccess = RoboHelp.writeWholeFile(szFilePath, szOutput); //this takes care of BOM and encoding as well.

                                          }

                                       

                                       

                                          if (!bSuccess) {

                                              var fileObj = new File(szFilePath);

                                              fileObj.open("w");

                                              fileObj.write(szOutput);

                                              fileObj.close();

                                              bSuccess = true;

                                          }

                                          return bSuccess;

                                      }

                                       

                                       

                                      function AddEventHandlers() {

                                          mainDlg.btnGroup.okBtn.onClick = OnGenerateBtnClick;

                                          mainDlg.g_Output.btn.onClick = onBrowseOutputClick;

                                      }

                                       

                                       

                                      function showMainDialog() {

                                       

                                       

                                          mainDlg = new Window(mainDlgResource);

                                       

                                       

                                          //set close button as cancel button now

                                          mainDlg.cancelElement = mainDlg.btnGroup.cancelBtn;

                                       

                                       

                                          //set the generate button command handler

                                          AddEventHandlers();

                                       

                                       

                                          //we need to load the  output SSL dialog now

                                          LoadDDList();

                                       

                                          //we need to load all the saved values as well

                                          LoadAllSavedInformation();

                                          mainDlg.show();

                                      }

                                       

                                       

                                      function isEmptyString(szString) {

                                          var bRetVal = true;

                                          if (isValidType(szString)) {

                                              szString = trim(szString);

                                              bRetVal = szString.length == 0;

                                          }

                                          return bRetVal;

                                      }

                                       

                                       

                                      function FilePathExists(szFile) {

                                          var bRetVal = false;

                                          if (!isEmptyString(szFile)) {

                                              //check if the file exists or not

                                              var file = new File(szFile);

                                              if (isValidType(file)) {

                                                  bRetVal = file.exists;

                                              }

                                          }

                                          return bRetVal;

                                      }

                                       

                                       

                                      function trim(szString) {

                                          return szString.replace(/^\s+|\s+$/g, "");

                                      }

                                       

                                       

                                      function ValidateAllInputs() {

                                          var bRetVal = true;

                                          var szOutputFile = mainDlg.g_Output.et.text;

                                          var szHelpTitle = mainDlg.tabnav.metaTab.g_Title.et.text;

                                          var szHelpProvider = mainDlg.tabnav.metaTab.g_Provider.et.text;

                                          var szHelpVersion = mainDlg.tabnav.metaTab.g_Version.et.text;

                                          var szHelpID = mainDlg.tabnav.metaTab.g_ID.et.text;

                                          //check for output file location

                                          if (isEmptyString(szOutputFile) || !FilePathExists(szOutputFile)) {

                                              bRetVal = false;

                                              Window.alert("Please specify valid Output File Path");

                                              mainDlg.g_Output.et.active = true;

                                          }

                                          else if (isEmptyString(szHelpTitle)) {

                                              bRetVal = false;

                                              Window.alert("Please specify Help Title");

                                              mainDlg.tabnav.metaTab.g_Title.et.active = true;

                                          }

                                          else if (isEmptyString(szHelpProvider)) {

                                              bRetVal = false;

                                              Window.alert("Please specify Provider Name");

                                              mainDlg.tabnav.metaTab.g_Provider.et.active = true;

                                          } else if (isEmptyString(szHelpVersion)) {

                                              bRetVal = false;

                                              Window.alert("Please specify Help Version");

                                              mainDlg.tabnav.metaTab.g_Version.et.active = true;

                                          } else if (isEmptyString(szHelpID)) {

                                              bRetVal = false;

                                              Window.alert("Please specify Help ID");

                                              mainDlg.tabnav.metaTab.g_ID.et.active = true;

                                          }

                                          return bRetVal;

                                      }

                                       

                                       

                                      function onBrowseOutputClick() {

                                          var folder = new Folder(mainDlg.g_Output.et.text);

                                          var selectedFolder = folder.selectDlg("Select Eclipse Help Output Location");

                                          if (isValidType(selectedFolder)) {

                                              mainDlg.g_Output.et.text = selectedFolder.fsName;

                                          }

                                          return isValidType(selectedFile);

                                      }

                                       

                                       

                                      function ReadXMLChild(xml, tagName, TextField, defaultValue) {

                                          var child = null;

                                          if (isValidType(xml)) {

                                              child = xml.child(tagName);

                                          }

                                          if (isValidType(child)) {

                                              TextField.text = child.toString();

                                          }

                                          if (isEmptyString(TextField.text)) {

                                              TextField.text = defaultValue;

                                          }

                                      }

                                       

                                       

                                      function LoadDDList() {

                                          var sslManager = currentProject.SSLManager;

                                          var nCount = sslManager.count;

                                          for (var i = 1; i <= nCount; i++) {

                                              var ssl = sslManager.item(i);

                                              if (ssl.layoutType == RoboHelp.SSLLayoutType.WEBHELP) {

                                                  //this is output, add this to DD

                                                  mainDlg.g_SSL.ddl.add("item", ssl.name);

                                              }

                                          }

                                      }

                                       

                                       

                                      function SaveAllInformation() {

                                          //we need to save the 7zip information in common location,

                                          var xmloutput = new XML("<eclipsehelpinfo/>");

                                          //we need to save the project specific information in the project folder area only

                                          //we need the currentProject Path

                                          var projectXMLFile = currentProject.path + "\\" + ECLIPSEHELPCONFXMLFILE;

                                       

                                       

                                          //we need to read all the information now

                                          xmloutput = new XML("<eclipsehelpinfo/>");

                                       

                                          var szSSLName = "";

                                          if (isValidType(mainDlg.g_SSL.ddl.selection)) {

                                              szSSLName = mainDlg.g_SSL.ddl.selection.toString();

                                          }

                                       

                                                xmloutput.appendChild(GetNewXMLChild("sslname", szSSLName));

                                          xmloutput.appendChild(GetNewXMLChild("title", mainDlg.tabnav.metaTab.g_Title.et.text));

                                          xmloutput.appendChild(GetNewXMLChild("provider", mainDlg.tabnav.metaTab.g_Provider.et.text));

                                          xmloutput.appendChild(GetNewXMLChild("version", mainDlg.tabnav.metaTab.g_Version.et.text));

                                          xmloutput.appendChild(GetNewXMLChild("id", mainDlg.tabnav.metaTab.g_ID.et.text));

                                          xmloutput.appendChild(GetNewXMLChild("outputfile", mainDlg.g_Output.et.text));

                                          writeToFile(projectXMLFile, xmloutput.toXMLString(), true);

                                      }

                                       

                                       

                                      function LoadAllSavedInformation() {

                                          //we need to load the project specific information as well

                                          //we need the currentProject Path

                                          var projectXMLFile = currentProject.path + "\\" + ECLIPSEHELPCONFXMLFILE;

                                          szXML = readFile(projectXMLFile);

                                          inputXML = null;

                                          if (!isEmptyString(szXML)) {

                                              //we need to load the XML and read all the information now

                                              try {

                                                  inputXML = new XML(szXML);

                                              } catch (e) { inputXML = null; }

                                          }

                                       

                                       

                                          ReadXMLChild(inputXML, "sslname", mainDlg.tabnav.metaTab.g_Title.et, "");

                                          var szSSLName = mainDlg.tabnav.metaTab.g_Title.et.text;

                                          mainDlg.tabnav.metaTab.g_Title.et.text = "";

                                       

                                          ReadXMLChild(inputXML, "title", mainDlg.tabnav.metaTab.g_Title.et, currentProject.name);

                                          ReadXMLChild(inputXML, "provider", mainDlg.tabnav.metaTab.g_Provider.et, "RoboHelp");

                                          ReadXMLChild(inputXML, "version", mainDlg.tabnav.metaTab.g_Version.et, "1.00");

                                          ReadXMLChild(inputXML, "id", mainDlg.tabnav.metaTab.g_ID.et, currentProject.name);

                                          ReadXMLChild(inputXML, "outputfile", mainDlg.g_Output.et, "");

                                          //we need to select the ssl name from drop down list now

                                          UpdateSSLSelection(mainDlg.g_SSL.ddl, szSSLName);

                                      }

                                       

                                       

                                      function UpdateSSLSelection(dropdownControl,szSSLName) {

                                          var currentSelectionIndex = 0;

                                          for (var index = 0; index < dropdownControl.children.length; index++) {

                                              if (dropdownControl.children[index].toString() == szSSLName) {

                                                  currentSelectionIndex = index;

                                                  break;

                                              }

                                          }

                                          dropdownControl.selection = dropdownControl.children[currentSelectionIndex];

                                      }

                                       

                                       

                                      function GetNewXMLChild(tagName, tagValue) {

                                          return new XML("<" + tagName + "><![CDATA[" + tagValue + "]]></" + tagName + ">");

                                      }

                                       

                                       

                                      function OnGenerateBtnClick() {

                                          //before going further we need to check if all the things are in place or not

                                          if (ValidateAllInputs()) {

                                              //in this case we need to save this information in a file and start the generate process now

                                              SaveAllInformation();

                                       

                                       

                                              //load all the information

                                              OPF_TITLE = mainDlg.tabnav.metaTab.g_Title.et.text;

                                              OPF_PROVIDER = mainDlg.tabnav.metaTab.g_Provider.et.text;

                                              OPF_VERSION = mainDlg.tabnav.metaTab.g_Version.et.text;

                                              OPF_ID = mainDlg.tabnav.metaTab.g_ID.et.text;

                                                          if (isValidType(mainDlg.g_SSL.ddl.selection)) {

                                                  szCurrentXMLSSLName = mainDlg.g_SSL.ddl.selection.toString();

                                              }

                                              userOutputFolder = mainDlg.g_Output.et.text;

                                              mainDlg.close(); //hide the main dialog now

                                              GenerateEclipseHelpFormat();

                                          }

                                      }

                                       

                                       

                                      function GenerateEclipseHelpFormat() {

                                       

                                       

                                          var bSuccess = true;

                                          ShowMessage("\nStarting the Generation of Eclipse Help Output Now....\n");

                                          outputFolder = new Folder(userOutputFolder);

                                          strTOCOutputXML = "";

                                          //listOfTOCFiles = new Array();

                                       

                                       

                                          strProjectName = currentProject.name;

                                          if (GenerateOutput()) {

                                       

                                       

                                              //create TOC File

                                              bSuccess = bSuccess && CreateTOCFile();

                                       

                                       

                                              //create plugin file now

                                              bSuccess = bSuccess && CreatePluginFile();

                                             

                                              //create Index File

                                              bSuccess = bSuccess && CreateIndexFile();

                                              if (bSuccess) {

                                                  ShowMessage("\n EclipseHelp Generated Successfully!");

                                                  alert("EclipseHelp Generated Successfully!");

                                              }

                                              else {

                                                  alert("Script Failed");

                                              }

                                          }

                                      }

                                      function CreateTOCFile() {

                                          ShowMessage("\nCreating TOC File Now");

                                          var bSuccess = false;

                                          var baseTOCFile = new File(outputFolder.fsName + "\\whxdata\\whtoc_xml.js");

                                          if (baseTOCFile.exists) {

                                              //read this base TOC now

                                              PatchEclipseHelpTOC("whtoc.xml");

                                              bSuccess = true;

                                          }

                                          else {

                                              alert('TOC file not found');

                                          }

                                          return bSuccess;

                                      }

                                       

                                       

                                      function AddChunk(tNode) {

                                          var fileName = getAttributeFromXML(tNode,REF);

                                          var labelName = getAttributeFromXML(tNode,NAME);

                                       

                                       

                                          var newFile = new File(outputFolder.fsName.concat("\\eclipse_", fileName));

                                          listOfTOCFiles.push(newFile);

                                       

                                       

                                          var y = new XML("<toc label=\"" + EscapeAllXMLValues(labelName) + "\">");

                                       

                                       

                                          y.appendChild(PatchEclipseHelpTOC(fileName));

                                          var szXMLOutput = GenerateXMLOutput(y.toXMLString());

                                          writeToFile(newFile.fsName, szXMLOutput);

                                       

                                       

                                          var x = new XML("<topic label=\"" + EscapeAllXMLValues(labelName) + "\">");

                                          return x.appendChild(XML("<link toc=\"" + EscapeAllXMLValues(newFile.displayName) + "\" />")); ;

                                      }

                                       

                                       

                                      function GetXMLContentFromJSFile(szBuffer){

                                                var szRetVal = szBuffer;

                                                var szTemp;

                                                var index = szBuffer.indexOf('"');

                                                if(index!=-1){

                                                          szTemp = szBuffer.substr(index+1);

                                                          //find the last index of "

                                                          index = szTemp.lastIndexOf('"');

                                                          if(index!=-1)

                                                          {

                                                                    szTemp = szTemp.substr(0,index);

                                                                    //we have the XML convert \" to "

                                                                    szRetVal =ReplaceString(szTemp,"\\\\\"",'\"');

                                                          }

                                                }

                                                return szRetVal;

                                      }

                                       

                                       

                                      function PatchEclipseHelpTOC(szFileName) {

                                          var inputTOCFile = new File(outputFolder.fsName + "\\whxdata\\" + szFileName);

                                                if(!inputTOCFile.exists)

                                                {

                                                          szFileName=ReplaceString(szFileName,'.xml','_xml.js');

                                                          inputTOCFile = new File(outputFolder.fsName + "\\whxdata\\" + szFileName);

                                                }

                                          var szBuffer = readFile(inputTOCFile.fsName);

                                                var szXMLBuffer = GetXMLContentFromJSFile(szBuffer);

                                          var xmlInput = new XML(szXMLBuffer);

                                          var books = xmlInput.children();

                                          var ec = XML(String("<toc/>"));

                                       

                                       

                                          if (books.length() <= 0) {

                                              //this case is for whtoc.xml which is always <toc root="whdata0.xml"></toc>

                                              if (xmlInput.name() == "toc") {

                                                  AddRoot(xmlInput)

                                              }

                                          }

                                       

                                       

                                          if (books.length() == 1) {

                                              var tNode = books;

                                              if (tNode.name() == ITEM) {

                                                  ec = ec.appendChild(AddItem(tNode));

                                              }

                                              else if (tNode.name() == BOOK) {

                                                  ec = ec.appendChild(AddBook(tNode));

                                              }

                                          }

                                          else {

                                              var i = 0;

                                              for (i = 0; i < books.length(); i++) {

                                                  var tNode = books.child(i);

                                                  if (tNode.name() == ITEM) {

                                                      ec = ec.appendChild(AddItem(tNode));

                                                  }

                                                  else if (tNode.name() == BOOK) {

                                                      ec = ec.appendChild(AddBook(tNode));

                                                  }

                                              }

                                          }

                                          return ec.children();

                                      }

                                       

                                       

                                      function PatchEclipseHelpIndex(szFileName) {

                                          var inputIndexFile = new File(outputFolder.fsName + "\\whxdata\\" + szFileName);

                                         

                                                if(!inputIndexFile.exists)

                                                {       

                                                          szFileName=ReplaceString(szFileName,'.xml','_xml.js');

                                                          inputIndexFile = new File(outputFolder.fsName + "\\whxdata\\" + szFileName);

                                                }

                                          var szBuffer = readFile(inputIndexFile.fsName);

                                                var szXMLBuffer = GetXMLContentFromJSFile(szBuffer);

                                          var xmlInput = new XML(szXMLBuffer);

                                         

                                          var books = xmlInput.children();

                                                var indexXML;

                                       

                                                if(books.length() == 1)

                                                {

                                                          var tNode = books;

                                                          if(tNode.name() == CHUNKINFO) 

                                                                    indexXML = AddIndex(tNode);

                                                          else

                                                    Window.alert("Script failed as index data file is incorrect, please check whidx_xml.js");

                                                }

                                          else

                                          {

                                              ShowMessage ("Script failed as no index data file was found, please check whidx_xml.js");

                                              return true;

                                          }

                                       

                                       

                                          if (writeToFile(outputFolder.fsName + "\\"+OUTPUTINDEXFILENAME+"", GenerateXMLOutput(indexXML), true))

                                              return true;

                                          else

                                          {

                                              ShowMessage ("Script failed in writing index output xml");

                                              return;

                                          }

                                             

                                      }

                                       

                                       

                                      function AddIndex(tNode)

                                      {

                                                var fileName = tNode.attribute(URL);

                                                return ParseIndexFile(fileName.toString());

                                      }

                                       

                                       

                                      function ParseIndexFile(szFileName)

                                      {

                                          var inputIndexFile = new File(outputFolder.fsName + "\\whxdata\\" + szFileName);

                                         

                                                if(!inputIndexFile.exists)

                                                {       

                                                          szFileName = ReplaceString(szFileName,'.xml','_xml.js');

                                                          inputIndexFile = new File(outputFolder.fsName + "\\whxdata\\" + szFileName);

                                                }

                                          var szBuffer = readFile(inputIndexFile.fsName);

                                                var szXMLBuffer = GetXMLContentFromJSFile(szBuffer);

                                          var xmlInput = new XML(szXMLBuffer);

                                         

                                          var keys = xmlInput.children();

                                                var indexXML = XML(String("<index/>"));

                                                var i = 0;

                                       

                                                if(keys.length() == 1)

                                                {

                                                          indexXML = indexXML.appendChild(AddEntry(keys));

                                                }

                                                else

                                                {

                                                          for(i=0;i<keys.length();i++)

                                                          {

                                                                    var tNode = keys.child(i);

                                                                    if(tNode.name() == KEY) indexXML = indexXML.appendChild(AddEntry(tNode));

                                                                    else ShowMessage ("Index key did not match in the XML");

                                                          }

                                                }

                                       

                                       

                                                return indexXML;

                                      }

                                       

                                       

                                      function AddEntry(tNode)

                                      {

                                                var keyName = tNode.attribute(NAME);

                                                var keyXML = XML(String("<entry keyword=\"" + keyName + "\"/>"));

                                       

                                                var keyChildren = tNode.children();

                                       

                                                var i = 0;

                                                if(keyChildren.length() == 1)

                                                {

                                                          var tChild = keyChildren;

                                                          if(tChild.name() == KEY) keyXML = keyXML.appendChild(AddEntry(tChild));

                                                          else if(tChild.name() == TOPIC) keyXML = keyXML.appendChild(AddTopic(tChild));

                                                }

                                                else

                                                {

                                                          for(i = 0; i < keyChildren.length();i++)

                                                          {

                                                                    var tChild = keyChildren.child(i);

                                                                    if(tChild.name() == KEY) keyXML = keyXML.appendChild(AddEntry(tChild));

                                                                    else if(tChild.name() == TOPIC) keyXML = keyXML.appendChild(AddTopic(tChild));

                                                          }

                                                }

                                       

                                       

                                                return keyXML;

                                      }

                                       

                                       

                                      function AddTopic(tNode)

                                      {

                                                var url = tNode.attribute(URL);

                                                var topicXML = XML(String("<topic href=\"" + url + "\"/>"));

                                       

                                                return topicXML;

                                      }

                                       

                                       

                                      function AddItem(tItem) {

                                          var szName = getAttributeFromXML(tItem, NAME);

                                          var szURL = getAttributeFromXML(tItem, URL);

                                          var txt = "<topic label=\"" + EscapeAllXMLValues(szName) + "\" ";

                                          if(!isEmptyString(szURL))

                                          {

                                              txt += "href=\"" + EscapeAllXMLValues(szURL) + "\" ";

                                          }

                                          txt += "/>";

                                          return new XML(txt);

                                      }

                                       

                                       

                                      function AddBook(tBook) {

                                          var x = AddItem(tBook);

                                         

                                          var tChildren = tBook.children();

                                       

                                       

                                          var i = 0;

                                          if (tChildren.length() == 1) {

                                              var tNode = tChildren;

                                              if (tNode.name() == ITEM) x = x.appendChild(AddItem(tNode));

                                              else if (tNode.name() == BOOK) x = x.appendChild(AddBook(tNode));

                                              else if (tNode.name() == CHUNK) x = AddChunk(tNode);

                                          }

                                          else {

                                              for (i = 0; i < tChildren.length(); i++) {

                                                  var tNode = tChildren.child(i);

                                                  if (tNode.name() == ITEM) x = x.appendChild(AddItem(tNode));

                                                  else if (tNode.name() == BOOK) x = x.appendChild(AddBook(tNode));

                                                  else if (tNode.name() == CHUNK) x = AddChunk(tNode);

                                              }

                                          }

                                          return x;

                                      }

                                       

                                       

                                      function AddRoot(xl) {

                                          var tXML = XML(String("<toc label=\"" + EscapeAllXMLValues(OPF_TITLE) + "\"/>"));

                                          var res = PatchEclipseHelpTOC(getAttributeFromXML(xl, "root"));

                                          var tX = tXML.appendChild(res);

                                          var ecTOC = File(outputFolder.fsName.concat("\\"+OUTPUTTOCFILENAME));

                                          var szXMLOutput = GenerateXMLOutput(tX.toXMLString());

                                          writeToFile(ecTOC.fsName, szXMLOutput, true)

                                      }

                                       

                                       

                                      function CreatePluginFile() {

                                          ShowMessage("\nCreating Plugin File Now");

                                          var pluginfile = new File(outputFolder.fsName + "\\" + PLUGINFILENAME);

                                          var szXMLOutput = "<plugin ";

                                          szXMLOutput += "name=\"" + EscapeAllXMLValues(OPF_TITLE) + "\" ";

                                          szXMLOutput += "id=\"" + EscapeAllXMLValues(OPF_ID) + "\" ";

                                          szXMLOutput += "version=\"" + EscapeAllXMLValues(OPF_VERSION) + "\" ";

                                          szXMLOutput += "provider-name=\"" + EscapeAllXMLValues(OPF_PROVIDER) + "\" ";

                                          szXMLOutput += ">\n";

                                          szXMLOutput += "<extension point=\"org.eclipse.help.toc\">\n<toc file=\""+OUTPUTTOCFILENAME+"\" primary=\"true\" />\n";

                                         

                                          if (isValidType(listOfTOCFiles) && listOfTOCFiles.length > 0) {

                                              for (; listOfTOCFiles.length > 0; ) {

                                                  var tFile = listOfTOCFiles.pop();

                                                  szXMLOutput += "\n<toc file=\"" + EscapeAllXMLValues(tFile.displayName) + "\"  />";

                                              }

                                          }

                                         

                                          szXMLOutput += "</extension>";

                                       

                                          szXMLOutput += "<extension point=\"org.eclipse.help.index\">";

                                          szXMLOutput += "<index file=\""+OUTPUTINDEXFILENAME+"\"/>";

                                         

                                          szXMLOutput += "\n</extension>\n</plugin>";

                                          return writeToFile(pluginfile.fsName, GenerateXMLOutput(szXMLOutput), true);

                                      }

                                       

                                       

                                      function CreateIndexFile() {

                                              ShowMessage("\nCreating Index File Now");

                                       

                                       

                                              var bSuccess = false;

                                              var baseIndexFile = new File(outputFolder.fsName + "\\whxdata\\whidx_xml.js");

                                              if (baseIndexFile.exists) {

                                                  // read this base Index now

                                                  bSuccess = PatchEclipseHelpIndex("whidx.xml");           // the bSuccess is false if the index is not patched

                                              }

                                              else {

                                                  alert('Index file not found');      

                                              }

                                              return bSuccess;

                                      }

                                       

                                       

                                      function GenerateXMLOutput(szOutput) {

                                          var szRetVal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";    //start of XML file

                                          var xml = new XML(szOutput);

                                          return szRetVal + xml.toXMLString();

                                      }

                                       

                                       

                                      function GenerateOutput() {

                                          ShowMessage("\nGenerating Webhelp output...");

                                          strProjectName = currentProject.name;

                                          var sslManager = currentProject.SSLManager;

                                          var nCount = sslManager.count;

                                          var bWebHelpOutputExists = false;

                                          for (var i = 1; i <= nCount; i++) {

                                              var ssl = sslManager.item(i);

                                              if (ssl.layoutType == RoboHelp.SSLLayoutType.WEBHELP && ssl.name == szCurrentXMLSSLName) {

                                                  bWebHelpOutputExists = true;

                                                  break;

                                              }

                                          }

                                       

                                       

                                          if (!bWebHelpOutputExists) {

                                              alert("WebHelp Output SSL does not exist. Please create one");

                                          }

                                          else {

                                              //we need to check if there is a multiple context defined or not

                                              if (!isMultipleContentCategoryDefined(ssl)) {

                                                  var szOldSSLOutputFileName = ssl.outputFileName;

                                       

                                       

                                                  //we need to clean up the folder as well now

                                                  CleanUp(outputFolder, true);

                                                  if (!outputFolder.exists) {

                                                      CreateFolderRecursive(outputFolder);

                                                  }

                                                 

                                                  var szOldBreadCrumbOption;

                                                  var szOldTOCShowOption;

                                                  //we need to set some values like

                                                  //reset breadcrumb and reset toc navigation

                                                 

                                                      var sslFilePath = currentProject.path + "\\" + ssl.name + ".ssl";

                                                      if (!FilePathExists(sslFilePath) || isEmptyString(szOldSSLOutputFileName)) {

                                                          ssl.generate();

                                                      }

                                                      szOldSSLOutputFileName = ssl.outputFileName;

                                                      //get the old values first

                                                      szOldBreadCrumbOption = ssl.getSpecificProperty("m_bAddBreadcrumbs");

                                                      szOldTOCShowOption = ssl.getSpecificProperty("m_strTopicBarSelOrder");

                                       

                                       

                                                      //now set the new values

                                                      var szNewTOCShowOption = szOldTOCShowOption;

                                                      szNewTOCShowOption = ReplaceString(szNewTOCShowOption, "TpcShow|", "");

                                                      ssl.setSpecificProperty("m_bAddBreadcrumbs", "0");

                                                      ssl.setSpecificProperty("m_strTopicBarSelOrder", szNewTOCShowOption);

                                                 

                                                  //before generate first save the old HTML output option

                                                  var bHTMLOutputOption = false;

                                                 

                                                      bHTMLOutputOption = RoboHelp.convertToHTMLOutput;

                                                      RoboHelp.convertToHTMLOutput = true;

                                                 

                                       

                                       

                                                  ssl.outputFileName = outputFolder.fsName + "\\index.htm";

                                                  ssl.generate();

                                                  ShowMessage("\nWebHelp Output Generated successfully");

                                                  var tempFile = new File(szOldSSLOutputFileName);

                                                  tempFile = tempFile.parent;

                                                  if (!tempFile.exists) {

                                                      CreateFolderRecursive(tempFile);

                                                  }

                                                  ssl.outputFileName = szOldSSLOutputFileName;

                                                 

                                                      RoboHelp.convertToHTMLOutput = bHTMLOutputOption;

                                                      ssl.setSpecificProperty("m_bAddBreadcrumbs", szOldBreadCrumbOption);

                                                      ssl.setSpecificProperty("m_strTopicBarSelOrder", szOldTOCShowOption);

                                                 

                                              }

                                              else {

                                                  bWebHelpOutputExists = false;

                                                  alert("Multiple content categories are not supported for Eclipse Help generation.");

                                              }

                                          }

                                          return bWebHelpOutputExists;

                                      }

                                       

                                       

                                      function isMultipleContentCategoryDefined(ssl) {

                                          var iCount = 0;

                                          if (isValidType(ssl)) {

                                              var contentManager = ssl.ContentManager;

                                              if (isValidType(contentManager)) {

                                                  iCount = contentManager.count;

                                              }

                                          }

                                          return iCount > 1;

                                      }

                                       

                                       

                                      function ReplaceString(szStringToBeReplaced, szStringToSearch, szStringToReplace) {

                                          try {

                                              if (isValidType(szStringToBeReplaced) && isValidType(szStringToSearch) && isValidType(szStringToReplace)) {

                                       

                                       

                                                  var myPattern = new RegExp(szStringToSearch, "gi");

                                                  return szStringToBeReplaced.replace(myPattern, szStringToReplace);

                                              }

                                          } catch (e) {

                                              ShowMessage("\nError While calling Replace String function check the string");

                                          }

                                          return szStringToBeReplaced;

                                      }

                                       

                                       

                                      function EscapeAllXMLValues(szTemp) {

                                          if (!isEmptyString(szTemp)) {

                                              // special handling for XML restricted characters - Begins //

                                              szTemp = ReplaceString(szTemp, "&", "&amp;");

                                              szTemp = ReplaceString(szTemp, "<", "&lt;");

                                              szTemp = ReplaceString(szTemp, ">", "&gt;");

                                              szTemp = ReplaceString(szTemp, "'", "&apos;");

                                              szTemp = ReplaceString(szTemp, "‘", "&apos;");

                                              szTemp = ReplaceString(szTemp, "’", "&apos;");

                                              szTemp = ReplaceString(szTemp, "\"", "&quot;");

                                              szTemp = ReplaceString(szTemp, "“", "&quot;");

                                              szTemp = ReplaceString(szTemp, "”", "&quot;");

                                          }

                                          // special handling for XML restricted characters - ends //

                                          return szTemp;

                                      }

                                       

                                       

                                      function CopyFilesFolder(srcFolder, tarFolder) {

                                          var listOfFiles = new Array();

                                          listOfFiles = srcFolder.getFiles("*.*");

                                          for (; listOfFiles.length > 0; ) {

                                              tFile = listOfFiles.pop();

                                              if (tFile instanceof Folder) {

                                                  var tempFolder = Folder(tarFolder.fsName.concat("\\", tFile.displayName));

                                                  if (tempFolder.exists == false) {

                                                      CreateFolderRecursive(tempFolder);

                                                  }

                                                  CopyFilesFolder(tFile, tempFolder);

                                              }

                                              else {

                                                  tFile.copy(tarFolder.fsName.concat("\\", tFile.displayName));

                                              }

                                          }

                                      }

                                       

                                       

                                      function CreateFolderRecursive(folderObject) {

                                          if (isValidType(folderObject) && !folderObject.exists) {

                                              //try to create the parent first of all

                                              CreateFolderRecursive(folderObject.parent);

                                              folderObject.create();

                                          }

                                      }

                                       

                                       

                                      function CleanUp(folder, deleteRootFolder) {

                                          if (folder.exists == false) {

                                              return false;

                                          }

                                          var listOfFiles = folder.getFiles("*.*");

                                          var tFile;

                                       

                                       

                                          for (; listOfFiles.length > 0; ) {

                                              tFile = listOfFiles.pop();

                                              if (tFile instanceof Folder) {

                                                  CleanUp(tFile, true);

                                              }

                                              else {

                                                  tFile.remove();

                                              }

                                          }

                                          if (deleteRootFolder == true) {

                                              folder.remove();

                                          }

                                          if (isValidType(listOfFiles)) {

                                              delete listOfFiles;

                                          }

                                      }

                                       

                                       

                                      function getAttributeFromXML(xml, attributeName) {

                                          var szRetVal = null;

                                          if (isValidType(xml)) {

                                              var attributeValue = xml.attribute(attributeName);

                                              if (isValidType(attributeValue)) {

                                                  szRetVal = attributeValue.toString();

                                              }

                                          }

                                          return szRetVal;

                                      }

                                       

                                       

                                      function isValidType(value) {

                                          if (typeof (value) !== 'undefined' && value != null) {

                                              return true;

                                          }

                                          return false;

                                      }

                                       

                                       

                                      function ShowMessage(msg) {

                                          RoboHelp.project.outputMessage(msg);

                                      }

                                       

                                      ---------------------------------------------------------