⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preview_javadoc_of_buffer.bsh

📁 用java 编写的源码开放的文本编辑器。有很多有用的特性
💻 BSH
📖 第 1 页 / 共 2 页
字号:
/* * Preview_Javadoc_of_Buffer.bsh * a BeanShell macro script for the jEdit text editor * * Copyright (C) 2001 Tom Gutwin * tgutwin@webarts.bc.ca * *   - Macro to create and preview the JavaDocs for the current buffer *   - Includes the ability to use the Bouvard Doclet. *     Visit *     http://community.jedit.org/modules.php? *        op=modload&name=web_links&file=index&req=viewlink&cid=6 *     for the Bouvard link *     If you want... map it to a button on the button bar and away you go * * ****Features *   - javadoc of current buffer's package *     by setting a boolean flag in the macro code *     save a different macroname if you want *     ie Preview_JavaDoc_Of_Current_Buffer_Package.bsh * *   - default Doclet is the standard Java Doclet * *   - doclet choice dialog can be bypassed if using the *     default doclet *     by setting a boolean macro flag in the code * *   - has built in support for Bouvard Doclet (see link below) * *   - Added many of the standard Doclet commandline parms *     like header, footer etc. with default values. *     They are all controlled via boolean flags in the code *     Switch them on/off as you like. * *   - can be easily extended for other doclets * *   - easy selection of output dir *     defaults to system temp dir *     set with a var in the macro code * * 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_Buffer.bsh,v 1.3 2003/02/28 04:28:35 spestov Exp $ */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.   *   * Get_Class_Name.bsh,v 1.1.1.1 2001/09/02 05:39:29 spestov Exp $   */  name = buffer.getName();  index = name.lastIndexOf('.');  return (index != -1 ? name.substring(0, index) : name);}String _determinePackageName(){  packageName = "";  text = buffer.getText(0, buffer.getLength());  //String lineSep = System.getProperty("line.separator");  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 _returnCommandInConsole(View view, String shell, String command){  import console.Shell;  // 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;  }  manager = view.getDockableWindowManager();  // Open the console if it isn't already open  manager.addDockableWindow("console");  // Obtain the console instance  console.Shell _shell = console.Shell.getShell(shell);  _console = manager.getDockable("console");  // Ensure we are using the console shell  _console.setShell(_shell);  // Call its run() method  _console.run(_shell, _console, command);  outputPane = _console.getOutputPane();  text = outputPane.getText();  textLength = text.length();  _shell.waitFor(_console);  _shell.waitFor(_console);  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">&nbsp;<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.1";String SYSTEM_TEMP_DIR = System.getProperty("java.io.tmpdir");String SYSTEM_FILE_SEPERATOR = File.separator;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.yourproductsite.com";    // Output directory .... set this to somewhere permanent if you want    String outputDir = SYSTEM_TEMP_DIR;    // 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    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("My Company Name Javadoc API");    docTitle.append("\" ");    /* Header Text */    boolean addHeader = true;    StringBuffer header = new StringBuffer("-header \"");    header.append("<B><A href=");    header.append(yourProductUrlStr);    header.append(">ProductName</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:ss zzz");     java.util.Date currentTime_1 = new java.util.Date();     String dateString = formatter.format(currentTime_1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -