📄 preview_javadoc_of_buffer.bsh
字号:
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, <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("Some HTML to go at the bottom of the pages"); 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 need be copy the file to the temp dir into its package dir */ String currBufferdir = savedBufferdir; StringBuffer tmpBufferName = new StringBuffer(SYSTEM_TEMP_DIR); if (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"); 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" }; String[] docletClassName = { "", "bp.doclet.Bouvard" }; String[] docletClassPath = { "", "Bouvard.jar" }; 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.", "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. /* String outputDir = _chooseADir("Please Choose an Output Directory.", "/"); */ 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])) { // Bouvard Doclet // This assumes the Bouvard.jar already exists // in the jeditUser/jars dir 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("\" "); } 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(showOnlyStr[showOnlyLevel]); /* if not found add your source dir to the 'extraClassesdir' var */ command.append("-classpath \""); 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) { /* 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(currBufferdir); command.append(SYSTEM_PATH_SEPERATOR); command.append(extraSourceDir); command.append("\" "); command.append(packName); } else { command.append(currBufferPath); } retVal = _returnCommandInConsole(view, "System", 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 implemewntation 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 { urlStr.append(packName.replace('.', '/').trim()); urlStr.append("/"); urlStr.append(className); urlStr.append(".html"); //Macros.message(view, urlStr.toString()); } // now which viewer (standard or Pecuchet) if (((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("bp.app.Main "); bViewerCommand.append(outputDir); //bViewerCommand.append(SYSTEM_FILE_SEPERATOR); bViewerCommand.append("data.bou &"); retVal = _returnCommandInConsole(view, "System", bViewerCommand.toString()); StringBuffer macroMessage = new StringBuffer("When the Pecuchet browser starts.\n"); macroMessage.append("Open file: "); macroMessage.append(outputDir); macroMessage.append("data.bou"); Macros.message(view, macroMessage.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 javadoc for current buffer. </para></abstract> <para> The macro includes configuration variables for using different doclets for generating javadocs and for genreating javadocs of the package of which the current buffer is a part. Details for use are included in the note accompanying the macro's source code. </para> </listitem>*/// end Preview_JavaDoc_of_Buffer.bsh
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -