/jEdit/tags/jedit-4-3-pre5/macros/Java/Preview_JavaDoc_Of_Current_Buffer.bsh
Unknown | 797 lines | 729 code | 68 blank | 0 comment | 0 complexity | 8e3fa56bfa9f5453524347f8320a67c3 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /*
- * Preview_JavaDoc_Of_Current_Buffer.bsh
- * version 1.8
- * A BeanShell macro script for the jEdit text editor
- *
- * $Header$
- * Copyright (C) 2001-2003 Tom Gutwin
- * tgutwin@webarts.bc.ca
- *
- * - Macro to create and preview the JavaDocs for the current buffer
- * - It tries to figure everything out for you.
- * - Map this macro to it to a button on the button bar and away you go!
- *
- * ************************************************************************
- * ** Requires the Console plugin and the InfoViewer plugin
- * ** ALSO
- * ** Requires Downloading of the different doclets if you are going to use
- * them and pdfReaderCommand if using the pdfDoclet.
- * ***********************************************************************
- * ** Features
- * ***********************************************************************
- *
- * - most of the settings to customize how this macro performs are set with
- * boolean flags (see code below). The following features are some of the
- * features already selectable/customizable
- *
- * - javadoc of current buffer OR current buffer's package
- * set the 'doFullPackage' boolean flag in the macro code
- * You can then save a copy of this macro as a different name
- * for example... Preview_JavaDoc_Of_Current_Buffers_Package.bsh
- *
- * - default Doclet is the standard Java Doclet
- * (the user can change the default doclet to use by changing the XXXX
- * variable in this macro)
- *
- * - When this macro starts, a doclet choice dialog is presented.
- * this dialog can be bypassed by setting 'showDocletDialog' to false
- * see the code below
- *
- * - Many of the standard Doclet commandline parms are preset with some
- * defaults... header, footer etc.
- * They are all controlled via boolean flags in the code
- * Switch them on/off as you like.
- *
- * - Includes the ability to use 'user selectable' doclets
- * The following are already built in. (you just have to go get the doclet)
- * > the DocBook doclet - dbdoclet http://www.michael-a-fuchs.de
- * > the Bouvard Doclet - http://web.tiscali.it/no-redirect-tiscali/farello/bp/intro.html
- * > the XMLDoclet - http://
- * > the pdfdoclet (Java API to PDF) - http://sourceforge.net/projects/pdfdoclet
- * > others
- *
- * - easy selection of output dir (defaults to system temp dir)
- * set with the 'outputDir' var in the macro code
- *
- * - other standard doclets parameters have been supervised by variables.
- * see below for adding extra classpath, source path, title, header, footer
- * MORE below
- *
- * ************************************************************************
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with the jEdit program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA.
- */
- String _getClassName()
- {
- /*
- * Get_Class_Name.bsh - a BeanShell macro script for the
- * jEdit text editor - gets class name from buffer name
- * Copyright (C) 2001 John Gellene
- * jgellene@nyc.rr.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with the jEdit program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id: Preview_JavaDoc_Of_Current_Buffer.bsh 4937 2003-12-22 04:14:55Z spestov $
- */
- name = buffer.getName();
- index = name.lastIndexOf('.');
- return (index != -1 ? name.substring(0, index) : name);
- }
- /** Trys to obtain the package name from the file **/
- String _determinePackageName()
- {
- packageName = "";
- text = buffer.getText(0, buffer.getLength());
- //String lineSep = System.getProperty("line.separator");
- /* look for the word package.
- It must be at the start of a line.
- It should not be within comments. (how can we easily determine this???)
- */
- packageWord = text.indexOf("package");
- // If it is not on the first line of the file
- // then look for the 1st occurence of "package" on its own line
- if (packageWord > 0)
- packageWord = text.indexOf("\npackage");
- if (packageWord != -1)
- {
- packageEOLine = text.indexOf(";", packageWord);
- if (packageEOLine!= -1)
- packageName = text.substring(packageWord+8,packageEOLine);
- }
- return packageName;
- }
- /** Chooses a directory and returns the path. **/
- /* Use this method if you want to customize the macro to choose
- output and input directorys for things */
- String _chooseADir(String dialogTitle, String startDir)
- {
- String retVal = "";
- JFileChooser chooser = new JFileChooser(startDir);
- chooser.setDialogTitle(dialogTitle);
- chooser.setMultiSelectionEnabled(false);
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- if(chooser.showDialog(view, "Okay") == JFileChooser.APPROVE_OPTION)
- {
- retVal = chooser.getSelectedFile().getAbsolutePath();
- }
- return retVal;
- }
- void _infoView(View view, String urlStr)
- {
- // first, check if the plugin is installed.
- boolean version1 = false;
- //With version 1.0 of the plugin ... the name changed to
- //infoviewer.InfoViewerPlugin
- if(jEdit.getPlugin("InfoViewerPlugin") == null)
- {
- if(jEdit.getPlugin("infoviewer.InfoViewerPlugin") == null)
- {
- Macros.error(view,"You must install the InfoViewerPlugin"
- + " to use this macro.");
- return;
- }
- version1 = true;
- }
- try
- {
- // API change with version 1.0 of the InfoViewer
- if (version1)
- jEdit.getPlugin("infoviewer.InfoViewerPlugin").
- openURL(view, urlStr);// version 1.0
- else
- jEdit.getPlugin("InfoViewerPlugin").
- sendURL(new URL(urlStr), view); // pre 1.0
- }
- catch (MalformedURLException mu)
- {
- Macros.error(view,"Cannot find the url " + urlStr);
- }
- }
- String _returnSystemCommand(View view, String command)
- {
- // first, check if the plugin is installed.
- if(jEdit.getPlugin("console.ConsolePlugin") == null)
- {
- Macros.error(view,"You must install the Console plugin"
- + " to use this macro.");
- return;
- }
- //Macros.message(view, "Getting window manager.");
- manager = view.getDockableWindowManager();
- _console = (console.Console) manager.getDockable("console");
- outputPane = _console.getOutputPane();
- text = outputPane.getText();
- textLength = text.length();
- runInSystemShell(view, command);
- waitForConsole(view);
- text = outputPane.getText();
- textLength = text.length();
- text = outputPane.getText().substring(textLength);
- return text;
- }
- /**
- * Ensures that a folder exists.
- * <TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2">
- * <TR><TD COLSPAN="2">
- * <H2>Ensures that a folder exists</H2>
- * </TD></TR>
- *
- * <TR><TD COLSPAN="2"> <BR>
- * <B>Description:</B><BR>
- * use it like this:
- * <br> _ensureFolderExists(new File(fileName).getParentFile());
- * </TD></TR>
- * </TABLE>
- *
- * @param folder The File object to check.
- **/
- void _ensureFolderExists(File folder)
- {
- if ( folder != null && ! folder.exists() )
- {
- _ensureFolderExists(folder.getParentFile());
- folder.mkdir();
- }
- }
- String versionStr = "1.8";
- String SYSTEM_FILE_SEPERATOR = File.separator;
- String SYSTEM_TEMP_DIR = System.getProperty("java.io.tmpdir");
- //SYSTEM_TEMP_DIR = "/tmp";
- String SYSTEM_PATH_SEPERATOR = System.getProperty("path.separator");
- // first, check if the plugin is installed.
- if(jEdit.getPlugin("console.ConsolePlugin") == null ||
- (jEdit.getPlugin("InfoViewerPlugin") == null) &&
- (jEdit.getPlugin("infoviewer.InfoViewerPlugin") == null))
- {
- if(jEdit.getPlugin("console.ConsolePlugin") == null)
- Macros.error(view,"You must install the Console plugin"
- + " to use this macro.");
- else
- Macros.error(view,"You must install the InfoViewerPlugin plugin"
- + " to use this macro.");
- }
- else
- {
- String currBufferPath = buffer.getPath();
- //Macros.message(view,"Current Buffer Path:\n"+currBufferPath);
- if (currBufferPath.endsWith(".java"))
- {
- /* Store Some class/package/path info for use later */
- // Get the Package name
- String packName = _determinePackageName();
- // Get the Class Name
- String className = _getClassName();
- /* ********************************************************************** */
- /* Change the Following Vars to personalize things */
- /* You should also Change the Header and Botton javadoc text down below */
- /* ********************************************************************** */
- // header message
- String yourProductUrlStr = "http://www.yourProductURL.goes.here";
- String yourProductNameStr = "My Java Product Name";
- // header message
- String yourBottomStr = "Released under a GNU Public License.";
- // PDFDoclet outputfilename
- String pdfDocletOutputFilename = "PDFDoclet.Output.pdf";
- // PDFDoclet outputfilename
- String pdfReaderCommand = "acro";
- // Output directory .... set this to somewhere permanent if you want
- String outputDir = SYSTEM_TEMP_DIR;
- // Allow choice of the output dir at runtime
- boolean chooseOutputDir = false;
- // This macro attempts to get the source search path right
- // if its not getting it... this var gets added to the Javadoc search path
- String extraSourceDir = "";
- // This macro doesn't do much with the javadoc classpath
- // if its not getting it... this var gets added to the Javadoc classpath
- String extraClassesDir = "";
- // flag to do the Javadoc on the package instead of just the file
- // Set this to true then save this macro with a new name
- // ie... Preview_Javadoc_Of_Current_Package.bsh
- boolean doFullPackage = false;
- // set to false to default to the standard java doclet
- boolean showDocletDialog = true;
- /* Set some default options for the javadoc command */
- /* change these to suit how you like your output to show up */
- /* better yet... make a little dialog for input at runtime */
- int showOnlyLevel = 3; // protected is the default
- String[] showOnlyStr = {"-public ","-protected ","-package ","-private"};
- /* some (not All) standard doclet options */
- /* ************************************** */
- // if you want one of the following options...
- // set the corresponding flag to true
- boolean[] optionFlags = {false,false,false,false,false,
- false,false,false,false};
- String[] optionStrs = {"-use ","-version ","-author ","-nosince","-notree ",
- "-noindex ","-nohelp ","-nodeprecated ","-verbose"};
- // beware OS/2 users...
- // ALL the following options break the IBM 1.3.0 JDK Javadoc tool
- // don't ask me?
- boolean addWindowTitle = true;
- StringBuffer windowTitle = new StringBuffer("-windowtitle \"Javadoc for");
- windowTitle.append((doFullPackage?"package ":"class "));
- windowTitle.append(className);
- windowTitle.append("\" ");
- /* DocTitle Text */
- boolean addDocTitle = true;
- StringBuffer docTitle = new StringBuffer("-doctitle \"");
- docTitle.append("Your Document Title here Javadoc API");
- docTitle.append("\" ");
- /* Header Text */
- boolean addHeader = true;
- StringBuffer header = new StringBuffer("-header \"");
- header.append("<B><A href=\"");
- header.append(yourProductUrlStr);
- header.append("\">");
- header.append(yourProductNameStr);
- header.append("</A></B>");
- header.append("<BR>Version xx.xx.xx");
- // Format the current time.
- java.text.SimpleDateFormat formatter
- = new java.text.SimpleDateFormat ("yyyy.MMMMM.dd 'at' hh:mm:sszzz");
- java.util.Date currentTime_1 = new java.util.Date();
- String dateString = formatter.format(currentTime_1);
- header.append("<BR><font size=-1>");
- header.append(dateString);
- header.append("</font>\" ");
- /* Footer Text */
- boolean addFooter = true;
- StringBuffer footer = new StringBuffer("-footer \"");
- footer.append("Produced Using the <A href=\"http://www.jedit.org\">");
- footer.append("jEdit</A><BR>Preview Javadoc Beanshell Macro.<BR>");
- footer.append("Copyright © 2001-2003, ");
- footer.append("<A href=\"http://www.webarts.bc.ca>\"");
- footer.append("Tom B. Gutwin</A>");
- footer.append("\" ");
- /* Bottom Text */
- boolean addBottom = true;
- StringBuffer bottom = new StringBuffer("-bottom \"");
- bottom.append(yourBottomStr);
- bottom.append("\" ");
- /*********************************************************************** */
- /* All users setting now complete */
- /*********************************************************************** */
- // Store the directory where the buffer file lives
- String savedBufferdir = currBufferPath.substring(0,
- currBufferPath.length()-6-className.length());
- // build the full package.classname
- StringBuffer fullClassName = new StringBuffer();
- if (packName != null && !packName.equals(""))
- {
- fullClassName.append(packName);
- fullClassName.append(".");
- }
- fullClassName.append(className);
- /* Javadoc needs the file to live in a directory structure */
- /* named like its Package name */
- // If needed... copy the file to the temp dir into its package dir */
- String currBufferdir = savedBufferdir;
- StringBuffer tmpBufferName = new StringBuffer(SYSTEM_TEMP_DIR);
- if (packName != null && !packName.equals("") &&
- savedBufferdir.indexOf(
- packName.replace('.',File.separatorChar).trim()) == -1 )
- {
- // The buffer file is not in an appropriate named dir
- // copy and work on it in temp
- if (!SYSTEM_TEMP_DIR.endsWith(SYSTEM_FILE_SEPERATOR))
- tmpBufferName.append(SYSTEM_FILE_SEPERATOR);
- _ensureFolderExists(new File(tmpBufferName.toString() +
- packName.replace('.', File.separatorChar).trim()));
- tmpBufferName.append(fullClassName.toString().
- replace('.', File.separatorChar).trim());
- tmpBufferName.append(".java");
- //Macros.message(view, "Saving "+tmpBufferName.toString());
- buffer.save(view, tmpBufferName.toString(), false);
- // the rest of the macro uses the currBufferdir variable
- currBufferPath = tmpBufferName.toString();
- currBufferdir = currBufferPath.substring(0,
- currBufferPath.length()-6-className.length());
- }
- // some debug statements
- //Macros.message(view,"Package Name ="+packName);
- //Macros.message(view,"fullClassName ="+fullClassName);
- //Macros.message(view,"Buffer Path ="+currBufferPath);
- //Macros.message(view,"Buffer Dir ="+currBufferdir);
- /* ************************************************* */
- /* *********** On with the Processing ************* */
- Object[] options = { "Standard Java Doclet", "Bouvard Doclet",
- "DocBook Doclet", "XML Doclet", "PDF Doclet" };
- String[] docletClassName = { "", "bp.doclet.Bouvard",
- "com.mf.doclet.docbook.DocBookDoclet",
- "codeinsight.xmldoclet.XMLDoclet",
- "com.tarsec.javadoc.pdfdoclet.PDFDoclet"};
- String[] docletClassPath = { "", "Bouvard.jar", "dbdoclet.jar",
- "xmldoclet.jar",
- "pdfdoclet.jar:itext.jar:/usr/lib/pkgs" };
- String PDFDocletConfigPropertiesFile = "pdfdoclet.config.properties";
- // Set the DEFAULT Doclet to the JavaDoclet
- String proceed = options[0];
- /* Shows a Doclet Selection Dialog */
- if (showDocletDialog)
- proceed = JOptionPane.showInputDialog(view,
- "Choose the Doclet to use for previewing the"+
- "\n" + className + " JavaDocs."+
- "\n(Bypass this dialog... set "+
- "'showDocletDialog=false;' in the macro)",
- "JavaDoc Buffer Macro - version "+versionStr,
- JOptionPane.QUESTION_MESSAGE, null, options,
- options[0]);
- if (proceed != null)
- {
- // this is where you could use the _chooseADir(String startDir) method
- // to choose an output dir at runtime.
- if (chooseOutputDir)
- outputDir = _chooseADir("Please Choose an Output Directory.",outputDir);
- docletChoice = 0;
- for (int choiceNum = 0; choiceNum < options.length;choiceNum++)
- {
- if (((String)proceed).equals((String)options[choiceNum]))
- {
- docletChoice = choiceNum;
- choiceNum = options.length;
- }
- }
- // The currBufferSrcDir expects the current buffer to be in a subDirectory
- // path the same as the package name
- // THIS is definitely NOT always the case
- String currBufferSrcDir = currBufferPath.substring(0,
- currBufferPath.length()-fullClassName.toString().length()-5);
- if(outputDir != null && !outputDir.equals(""))
- {
- // you might need some of the follwing if you want to add some
- // commandline parms
- String jedit_userdir=System.getProperty("user.home") +
- SYSTEM_FILE_SEPERATOR +".jedit";
- String jedit_homedir=jEdit.getJEditHome();
- String currClassPath=System.getProperty("java.class.path");
- String java_home=System.getProperty("java.home");
- // Construct the command which will be executed
- StringBuffer command = new StringBuffer(java_home);
- if (java_home.toLowerCase().endsWith("jre"))
- command.append(File.separator).append("..");
- command.append(File.separator).append("bin");
- command.append(File.separator).append("javadoc ");
- if (!((String)proceed).equals((String)options[0]))
- {
- // general parms for 'other' doclets
- command.append("-doclet \"");
- command.append(docletClassName[docletChoice]);
- command.append("\" ");
- command.append("-docletpath \"");
- command.append(jedit_userdir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("jars");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append(docletClassPath[docletChoice]);
- command.append("\" ");
- // Bouvard Doclet
- // This assumes the Bouvard.jar already exists
- // in the jeditUser/jars dir
- if (((String)proceed).equals((String)options[1]))
- {
- /* Specify the output dir */
- command.append("-d \"");
- command.append(outputDir);
- command.append("\" ");
- }
- // the DocBookDoclet has an extra parm
- if (((String)proceed).equals((String)options[2]))
- {
- command.append("-properties \"");
- command.append(jedit_userdir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("macros");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("Java");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("dbdoclet-xml.properties\" ");
- }
- // the XMLDoclet has an extra parm
- if (((String)proceed).equals((String)options[3]))
- {
- /* Specify the output dir */
- //command.append("-d \"");
- //command.append(outputDir);
- //command.append("\" ");
- }
- // the PDFDoclet has an extra parm
- if (((String)proceed).equals((String)options[4]))
- {
- command.append("-pdf \"");
- command.append(outputDir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append(pdfDocletOutputFilename);
- command.append("\" ");
- if (PDFDocletConfigPropertiesFile != null
- &&!PDFDocletConfigPropertiesFile.equals(""))
- {
- command.append(" -workdir \"");
- command.append(outputDir);
- command.append("\" ");
- command.append("-config \"");
- command.append(jedit_userdir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("macros");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("Java");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append(PDFDocletConfigPropertiesFile);
- command.append("\"");
- }
- }
- }
- else
- { // standard doclet parms
- if (addWindowTitle)
- command.append(windowTitle.toString());
- if (addDocTitle)
- command.append(docTitle.toString());
- if (addHeader)
- command.append(header.toString());
- if (addFooter)
- command.append(footer.toString());
- if (addBottom)
- command.append(bottom.toString());
- /* add the on/off options */
- for (int opt = 0; opt <optionFlags.length; opt++)
- {
- if (optionFlags[opt])
- command.append(optionStrs[opt]);
- }
- /* Specify the output dir */
- command.append("-d \"");
- command.append(outputDir);
- command.append("\" ");
- }
- /* Set the Level of detail to show */
- command.append(" ");
- command.append(showOnlyStr[showOnlyLevel]);
- /* if not found add your source dir to the 'extraClassesdir' var */
- command.append(" -classpath \"");
- command.append(SYSTEM_TEMP_DIR);
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(System.getProperty("java.class.path"));
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(extraClassesDir);
- command.append("\" ");
- /* **** Done with the options ***** */
- /* Specify the package or file name */
- if (doFullPackage && packName != null && !packName.equals(""))
- {
- /* Guess where the package source is located */
- /* if not found... add your source dir to the 'extraSourcedir' var */
- command.append("-sourcepath \"");
- command.append(savedBufferdir);
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferSrcDir);
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferSrcDir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferSrcDir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferSrcDir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferSrcDir);
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_FILE_SEPERATOR);
- command.append("..");
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferdir);
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(extraSourceDir);
- command.append("\" ");
- command.append(packName);
- }
- else
- {
- // add the base sourcepath
- command.append("-sourcepath \"");
- command.append(savedBufferdir);
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferSrcDir);
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(currBufferdir);
- command.append(SYSTEM_PATH_SEPERATOR);
- command.append(extraSourceDir);
- command.append("\" ");
- // now add the file to javadoc
- command.append("\"");
- command.append(currBufferPath);
- command.append("\"");
- }
- retVal = _returnSystemCommand(view, command.toString());
- if (retVal.indexOf("error") == -1)
- {
- // Build the url for the Viewer
- // If you don't want to use the InfoViewer plugin...
- // easy, change the implementation in this macros _infoView method
- StringBuffer urlStr = new StringBuffer();
- urlStr.append("file:///");
- urlStr.append(outputDir.replace('\\', '/').trim());
- if (!outputDir.endsWith(SYSTEM_FILE_SEPERATOR))
- urlStr.append("/");
- if (doFullPackage)
- {
- urlStr.append("index.html");
- }
- else
- {
- if (packName != null && !packName.equals(""))
- {
- urlStr.append(packName.replace('.', '/').trim());
- urlStr.append("/");
- }
- //Macros.message(view, packName);
- urlStr.append(className);
- urlStr.append(".html");
- //Macros.message(view, urlStr.toString());
- }
- // now which viewer (standard or Pecuchet)
- if (!showDocletDialog || ((String)proceed).equals((String)options[0]))
- _infoView(view, urlStr.toString());
- else if (((String)proceed).equals((String)options[1]))
- {
- // Bouvard Browser
- // This assumes the Pecuchet.jar already exists
- // and xerces is in the classpath already
- StringBuffer classPath = new StringBuffer("\"");
- classPath.append(jedit_userdir);
- classPath.append(SYSTEM_FILE_SEPERATOR);
- classPath.append("jars");
- classPath.append(SYSTEM_FILE_SEPERATOR);
- classPath.append("Pecuchet.jar");
- classPath.append(SYSTEM_PATH_SEPERATOR);
- classPath.append(jedit_homedir);
- classPath.append(SYSTEM_FILE_SEPERATOR);
- classPath.append("jars");
- classPath.append(SYSTEM_FILE_SEPERATOR);
- classPath.append("Pecuchet.jar");
- classPath.append(SYSTEM_PATH_SEPERATOR);
- classPath.append(currClassPath);
- classPath.append("\"");
- StringBuffer bViewerCommand = new StringBuffer("java -classpath ");
- bViewerCommand.append(classPath);
- bViewerCommand.append(" ");
- bViewerCommand.append("-Dorg.xml.sax.driver=");
- bViewerCommand.append("org.apache.xerces.parsers.SAXParser");
- bViewerCommand.append(" ");
- bViewerCommand.append("bp.app.Main ");
- bViewerCommand.append(outputDir);
- if (!outputDir.endsWith(SYSTEM_FILE_SEPERATOR))
- bViewerCommand.append(SYSTEM_FILE_SEPERATOR);
- bViewerCommand.append("data.bou &");
- retVal = _returnSystemCommand(view, bViewerCommand.toString());
- StringBuffer macroMessage =
- new StringBuffer("When the Pecuchet browser starts.\n");
- macroMessage.append("Open file: ");
- macroMessage.append(outputDir);
- if (!outputDir.endsWith(SYSTEM_FILE_SEPERATOR))
- macroMessage.append(SYSTEM_FILE_SEPERATOR);
- macroMessage.append("data.bou");
- //Macros.message(view, macroMessage.toString());
- }
- else if (((String)proceed).equals((String)options[2]))
- {
- // XML Doclet
- // Use a new jEdit Buffer
- StringBuffer newFile = new StringBuffer(outputDir);
- if (!outputDir.endsWith(SYSTEM_FILE_SEPERATOR))
- newFile.append(SYSTEM_FILE_SEPERATOR);
- newFile.append("Reference.xml");
- Buffer newTmpBuffer = jEdit.openFile(view,newFile.toString());
- }
- else if (((String)proceed).equals((String)options[3]))
- {
- // XML Doclet
- // Use a new jEdit Buffer
- StringBuffer newFile = new StringBuffer(outputDir);
- if (!outputDir.endsWith(SYSTEM_FILE_SEPERATOR))
- newFile.append(SYSTEM_FILE_SEPERATOR);
- newFile.append("output.xml");
- Buffer newTmpBuffer = jEdit.openFile(view,newFile.toString());
- }
- else if (((String)proceed).equals((String)options[4]))
- {
- // pdf Doclet
- StringBuffer pdfViewerCommand = new StringBuffer(pdfReaderCommand);
- pdfViewerCommand.append(" ");
- pdfViewerCommand.append(outputDir);
- pdfViewerCommand.append(SYSTEM_FILE_SEPERATOR);
- pdfViewerCommand.append(pdfDocletOutputFilename);
- retVal = _returnSystemCommand(view, pdfViewerCommand.toString());
- }
- else
- {
- // put the viewers for other doclets here
- }
- }
- else
- Macros.error(view, "Javadoc did NOT complete successfully. " +
- "See the console output");
- }
- }
- }
- else
- Macros.error(view, "Current Buffer does NOT appear to be a Java File");
- }
- /*
- Macro index data (in DocBook format)
- <listitem>
- <para><filename>Preview_Javadoc_of_Buffer.bsh</filename></para>
- <abstract><para>
- Create and display API documentation for the current buffer.
- </para></abstract>
- <para>
- The macro includes various configuration variables you can change; see the comment at the beginning of the macro source for details.
- </para>
- </listitem>
- */
- // end Preview_JavaDoc_of_Buffer.bsh