File: Preview_JavaDoc_Of_Current_Buffer.bsh

package info (click to toggle)
jedit 5.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,252 kB
  • ctags: 11,190
  • sloc: java: 98,480; xml: 94,070; makefile: 52; sh: 42; cpp: 6; python: 6
file content (824 lines) | stat: -rw-r--r-- 31,612 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
/*
 * Preview_JavaDoc_Of_Current_Buffer.bsh
 * version 1.8
 * A BeanShell macro script for the jEdit text editor
 * :tabSize=2:indentSize=2:noTabs=true:
 * :folding=explicit:collapseFolds=1:
 *
 *  $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.
 */

//{{{ _getClassName() method
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 10711 2007-09-22 09:12:15Z kpouer $
   */
  name = buffer.getName();
  index = name.lastIndexOf('.');
  return (index != -1 ? name.substring(0, index) : name);
} //}}}

//{{{ _determinePackageName() method
/** 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;
} //}}}

//{{{ _chooseADir() method
/** 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;
} //}}}

//{{{ _infoView() method
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);
  }
} //}}}

//{{{ _returnSystemCommand() method
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");
  if (_console == null)
  {
      manager.showDockableWindow("console");
      _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;
} //}}}

//{{{ _ensureFolderExists() method
/**
 * 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.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 &copy; 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
        StringBuilder command = new StringBuilder(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("\"");
          //}}}

        }
System.out.println("****************************************************************");
System.out.println(command.toString());
System.out.println("****************************************************************");
        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