Initial Commit
[packages] / xemacs-packages / jde / lisp / jde.el
1 ;;; jde.el -- Integrated Development Environment for Java.
2 ;; $Revision: 1.357.2.4 $ $Date: 2006/03/09 04:19:37 $ 
3
4 ;; Author: Paul Kinnucan <pkinnucan@attbi.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
7
8 ;; Copyright (C) 1997-2006 Paul Kinnucan.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;; This is one of a set of packages that make up the 
28 ;; Java Development Environment (JDE) for Emacs. See the
29 ;; JDE User's Guide for more information.
30
31 ;; The latest version of the JDE is available at
32 ;; <URL:http://jdee.sunsite.dk>.
33
34 ;; Please send any comments, bugs, or upgrade requests to
35 ;; Paul Kinnucan at paulk@mathworks.com.
36
37 ;;; Code:
38
39 ;;;###autoload
40 (defconst jde-version "2.3.5.1"
41   "JDE version number.")
42
43 (defconst jde-cedet-min-version "1.0beta2"
44   "Cedet minimum version")
45 (defconst jde-cedet-max-version "1.0"
46   "Cedet maximum version")
47
48 (defconst jde-xemacsp (string-match "XEmacs" (emacs-version))
49   "Non-nil if we are running in the XEmacs environment.")
50
51 (defconst jde-xemacs20p (and jde-xemacsp (>= emacs-major-version 20)))
52  
53 (defconst jde-emacs21p (and (string-match "\\bEmacs\\b" (emacs-version))
54                             (>= emacs-major-version 21)))
55
56 (unless (fboundp 'custom-set-default)
57    (defalias 'custom-set-default 'set-default)) 
58
59 (require 'jde-util)
60
61 ;; The version of the JDEE distributed with XEmacs has its own
62 ;; autoloads file (auto-autoloads.el). Therefore, require
63 ;; jde-autoloads only if this JDEE version is not part of the XEmacs
64 ;; package.
65 (unless 
66     (and jde-xemacsp
67          (file-exists-p 
68           (expand-file-name 
69            "jde/auto-autoloads.el"
70            (jde-root))))
71          (require 'jde-autoload))
72
73 (require 'jde-custom)
74 (require 'jde-help)
75 (require 'semantic-load)
76 (require 'easymenu)
77 (require 'cl)
78 (require 'font-lock)
79 (require 'cc-mode)
80 (require 'cus-edit)
81 (require 'comint)
82 (require 'jde-compile)
83 (require 'jde-db)
84 (require 'jde-bug)
85 (require 'jde-jdb)
86 (require 'jde-run)
87 (require 'jde-gen)
88 (require 'compile)
89 (require 'imenu)
90 (require 'browse-url)
91 (require 'beanshell)
92 (require 'jde-plugins)
93 (require 'jde-wiz)
94 (require 'jde-java-grammar)
95 (require 'jde-complete)
96 (require 'jde-which-method)
97 (require 'jde-java-font-lock)
98 (require 'jde-import)
99 (require 'jde-class)
100 (require 'executable)  ;; in XEmacs' sh-script package
101 (require 'efc)
102 (require 'jde-open-source)
103 (require 'jde-annotations)
104 (require 'etags)
105 (require 'regress)
106
107 (if (not (fboundp 'custom-set-default))
108     (defalias 'custom-set-default 'set-default))
109
110
111 (defgroup jde nil
112   "Java Development Environment"
113   :group 'tools
114   :prefix "jde-")
115
116
117 (defcustom jde-check-version-flag t
118   "*Non-nil means to check versions of semantic, eieio, and speedbar.
119 That is if they meet the requirements for this version of the JDE.
120 If nil only check if semantic, eieio, and speedbar are available.
121 See also the function `jde-check-versions'."
122   :group 'jde
123   :type 'boolean)
124
125 ;; (makunbound 'jde-key-bindings)
126 (defcustom jde-key-bindings
127   (list 
128    (cons "[?\C-c ?\C-v ?\C-a]" 'jde-run-menu-run-applet)
129    (cons "[?\C-c ?\C-v ?\C-b]" 'jde-build)
130    (cons "[?\C-c ?\C-v ?\C-c]" 'jde-compile)
131    (cons "[?\C-c ?\C-v ?\C-d]" 'jde-debug)
132    (cons "[?\C-c ?\C-v ?\C-f]" 'jde-find)
133    (cons "[?\C-c ?\C-v ?\C-g]" 'jde-open-class-at-point)
134    (cons "[?\C-c ?\C-v ?\C-k]" 'jde-bsh-run)
135    (cons "[?\C-c ?\C-v ?\C-l]" 'jde-gen-println)
136    (cons "[?\C-c ?\C-v ?\C-n]" 'jde-help-browse-jdk-doc)
137    (cons "[?\C-c ?\C-v ?\C-p]" 'jde-save-project)
138    (cons "[?\C-c ?\C-v ?\C-q]" 'jde-wiz-update-class-list)
139    (cons "[?\C-c ?\C-v ?\C-r]" 'jde-run)
140    (cons "[?\C-c ?\C-v ?\C-s]" 'speedbar-frame-mode)
141    (cons "[?\C-c ?\C-v ?\C-t]" 'jde-jdb-menu-debug-applet)
142    (cons "[?\C-c ?\C-v ?\C-w]" 'jde-help-symbol)
143    (cons "[?\C-c ?\C-v ?\C-x]" 'jde-show-superclass-source)
144    (cons "[?\C-c ?\C-v ?\C-y]" 'jde-open-class-at-point)
145    (cons "[?\C-c ?\C-v ?\C-z]" 'jde-import-find-and-import)
146    (cons "[?\C-c ?\C-v ?e]"    'jde-wiz-extend-abstract-class)
147    (cons "[?\C-c ?\C-v ?f]"    'jde-gen-try-finally-wrapper)
148    (cons "[?\C-c ?\C-v ?i]"    'jde-wiz-implement-interface)
149    (cons "[?\C-c ?\C-v ?j]"    'jde-javadoc-autodoc-at-line)
150    (cons "[?\C-c ?\C-v ?o]"    'jde-wiz-override-method)
151    (cons "[?\C-c ?\C-v ?t]"    'jde-gen-try-catch-wrapper)
152    (cons "[?\C-c ?\C-v ?z]"    'jde-import-all)
153    (cons "[?\C-c ?\C-v ?\C-[]" 'jde-run-etrace-prev)
154    (cons "[?\C-c ?\C-v ?\C-]]" 'jde-run-etrace-next)
155    (cons "[(control c) (control v) (control ?.)]" 'jde-complete)
156    (cons "[(control c) (control v) ?.]" 'jde-complete-in-line)
157    )
158   "*Specifies key bindings for the JDE.
159 The value of this variable is an association list. The car of
160 each element specifies a key sequence. The cdr specifies 
161 an interactive command that the key sequence executes. To enter
162 a key with a modifier, type C-q followed by the desired modified
163 keystroke. For example, to enter C-s (Control s) as the key to be
164 bound, type C-q C-s in the key field in the customization buffer.
165 You can use the notation [f1], [f2], etc., to specify function keys."
166   :group 'jde-project
167   :type '(repeat
168           (cons :tag "Key binding"
169                 (string :tag "Key")
170                 (function :tag "Command")))
171   :set '(lambda (sym val)
172           (mapc
173            (lambda (buf)
174              (save-excursion
175                (set-buffer buf)
176                (when (boundp 'jde-mode-map)
177                  ;; Unmap existing key bindings
178                  (if (and (boundp 'jde-key-bindings)
179                           jde-key-bindings)
180                      (mapc 
181                       (lambda (binding)
182                         (let ((key (car binding)))
183                           (if (string-match "\\[.+]" key)
184                               (setq key (car (read-from-string key))))
185                           (local-unset-key key)))
186                       jde-key-bindings))
187                  ;; Map new key bindings.
188                  (mapc 
189                   (lambda (binding)
190                     (let ((key (car binding))
191                           (fcn (cdr binding)))
192                       (if (string-match "\\[.+]" key)
193                           (setq key (car (read-from-string key))))
194                       (define-key (current-local-map) key fcn)))
195                   val))))
196            (jde-get-java-source-buffers))
197           (set-default sym val)))
198
199 (defcustom jde-launch-beanshell-on-demand-p t
200   "If non-nil, the JDE launches the Beanshell the first time it is needed.
201 Otherwise, the JDE launches the Beanshell, if it is not already running,
202 whenever you open a Java source file."
203   :group 'jde-project
204   :type 'boolean)
205
206
207
208 (defcustom jde-java-environment-variables '("JAVA_VERSION" "JAVA_HOME")
209   "This variable specifies the names of environment variables used to
210 specify the version and location of the JDK to be used by the JDE.
211 If set, the `jde-jdk' customization variable overrides the 
212 java enviroment variables."
213   :group 'jde-project
214   :type '(list
215           (string :tag "Java Version")
216           (string :tag "Java Home")))
217
218 (defun jde-set-jdk-dir-type (sym val)
219   (if val
220       (let ((type
221              (list
222               (quote radio-button-choice)
223                   )))
224             (loop for jdk in val do
225                   (setq 
226                    type 
227                    (append
228                     type
229                     (list (list (quote item) (car jdk))))))
230             (put 'jde-jdk 
231                  'custom-type 
232                  (list (quote list) type))
233             (put 'jde-jdk 'customized-value nil)
234             (put 'jde-jdk
235                  'standard-value
236                  (list (list (quote list) (car (car val)))))
237             (customize-set-value 'jde-jdk (list (car (car val)))))
238     (progn
239       (put 'jde-jdk 'custom-type 'symbol)
240       (put 'jde-jdk 'standard-value nil)
241       (put 'jde-jdk 'customized-value nil)
242       (customize-set-value 'jde-jdk nil)))
243   (set-default sym val))
244
245 ;; (makunbound 'jde-jdk-registry)
246 (defcustom jde-jdk-registry nil
247   "Specifies the versions and locations of the JDKs installed on your
248 system.  For each JDK to be registered, enter the version number
249 (e.g., 1.4.0) of the JDK in the Version field. Enter the path of the
250 JDK's root directory (e.g., c:/jdk1.3.1 or $JAVA_HOME) in the Path
251 field. Setting this variable determines the choices offered by the
252 `jde-jdk' variable. You should therefore customize this variable
253 first."
254   :group 'jde-project
255   :type '(repeat
256           (cons 
257            :tag "JDK"
258            (string :tag "Version")
259            (string :tag "Path")))
260   :set 'jde-set-jdk-dir-type)
261
262 ;; (makunbound 'jde-jdk)
263 (defcustom jde-jdk nil
264   "Specifies the version of the JDK to be used to develop the current
265 project. The version must be one of the versions listed in the
266 `jde-jdk-registry'. If you specify nil (the default), the JDE uses the
267 JDK specified by the Java version environment variable (see
268 `jde-java-enviroment-variables', if set; otherwise, the first JDK
269 located on the system command path specified by te PATH environment
270 variable.
271
272 You must customize `jde-jdk-registry' first, then `jde-jdk'. After you
273 have customized jde-jdk-registry, the customization buffer for`
274 jde-jdk' presents you with a set of radio buttons, one for each
275 registered JDK.  Select the button of the JDK that you want to use for
276 the current project."
277   :group 'jde-project
278   :type 'symbol
279
280   (if (or (featurep 'xemacs) (< emacs-major-version 21))
281       :set
282     :set-after)
283
284   (if (or (featurep 'xemacs) (< emacs-major-version 21))
285       'custom-set-default
286     '(jde-jdk-registry)))
287  
288 (defun jde-find-jdk-in-exec-path ()
289   "Search for a JDK in `exec-path' and return the path of
290 the root directory of the first JDK that is found.  Return nil if a
291 JDK is not found anywhere in exec-path."
292   (let ((list exec-path)
293         (command "java")
294         file)
295     (while list
296       (setq list
297             (if (and (setq file (expand-file-name command (car list)))
298                      (let ((suffixes executable-binary-suffixes)
299                            candidate)
300                        (while suffixes
301                          (setq candidate (concat file (car suffixes)))
302                          (if (and (file-executable-p candidate)
303                                   (not (file-directory-p candidate)))
304                              (setq suffixes nil)
305                            (setq suffixes (cdr suffixes))
306                            (setq candidate nil)))
307                        (setq file candidate)))
308                 nil
309               (setq file nil)
310               (cdr list))))
311     file))
312
313
314 (defun jde-get-jdk-dir () 
315   "Get the root directory of the JDK currently being used by the
316 JDE. The directory is the directory of the version of the JDK
317 specified by `jde-jdk'. If none is specified, this function returns
318 the value of the Java home environment variable (see
319 `jde-java-environment-variables') or the first JDK directory on the
320 system path, i.e., the directory that contains java on Unix systems or
321 java.exe on Windows systems.  If neither `jde-jdk' nor the system path
322 nor the Java home environment variable specify a JDK directory, this
323 function displays an error message."
324   (interactive)
325
326   (if jde-jdk
327       (let* ((jdk (assoc (car jde-jdk) jde-jdk-registry))
328              (jdk-dir (cdr jdk)))
329         (when (null jdk)
330           (error (format
331                   "No mapping in the jde-jdk-registry found for JDK version %s"
332                   (car jde-jdk))))
333         (if (not (string= jdk-dir ""))
334             (progn
335               (setq jdk-dir (substitute-in-file-name jdk-dir))
336               (if (not (file-exists-p jdk-dir))
337                   (error 
338                    (format "The path specified for JDK %s does not exist: %s"
339                            jde-jdk
340                            jdk-dir)))))
341         jdk-dir)
342     (let ((jdk-dir (getenv (nth 1 jde-java-environment-variables))))
343       (if jdk-dir
344           (progn
345             (setq jdk-dir (substitute-in-file-name jdk-dir))
346             (if (not (file-exists-p jdk-dir))
347                 (error 
348                  (format "The path specified by %s does not exist: %s"
349                          (nth 1 jde-java-environment-variables)
350                          jdk-dir))))
351         (progn 
352           (setq jdk-dir 
353                 (executable-find "javac"))
354           (if jdk-dir
355               (setq jdk-dir 
356                     (expand-file-name 
357                      ".." 
358                      (file-name-directory jdk-dir)))
359             (error "Cannot find the JDK directory. See `jde-jdk'."))))
360       jdk-dir)))
361
362
363 (defun jde-get-jdk-prog (progname)
364    "Returns the full path of the program passed in.  By default, assume
365    it's in the bin directory under `jde-get-jdk-dir', but if not,
366    look in the environment's command path."
367    (let* ((progname-str 
368            (if (symbolp progname)
369                (symbol-name progname) progname))
370           (full-progname 
371            (if (eq system-type 'windows-nt)
372                (concat progname-str ".exe")
373              progname-str))
374           (progpath 
375            (expand-file-name 
376             (concat
377              (if (eq system-type 'darwin) "Home/bin/" "bin/")
378              full-progname)
379             (jde-get-jdk-dir))))
380      (if (file-exists-p progpath)
381        progpath
382        (executable-find full-progname))))
383
384
385 (defun jde-get-tools-jar ()
386   "Gets the correct tools.jar or equivalent. Signals an
387 error if it cannot find the jar."
388   (let ((tools 
389          (expand-file-name 
390           (if (eq system-type 'darwin)
391               "Classes/classes.jar"
392             "lib/tools.jar")
393           (jde-get-jdk-dir))))
394     (if (file-exists-p tools)
395         tools
396       (error (concat "Cannot find JDK's tools jar file (or equivalent)." 
397                      "Type M-x describe-function [RET] jde-get-jdk-dir for more info.")))))
398
399 (defvar jde-java-version-cache nil
400 "Cache to hold the version of Java being used.")
401
402 (defun jde-java-version-via-java ()
403   "Get the version of the java vm on the
404 system command path."
405   (if (not jde-java-version-cache)
406       (let ((buf (get-buffer-create "java version"))
407             proc)
408         (save-excursion
409           (set-buffer buf)
410           (setq proc
411                 (start-process
412                  "java version" buf "java" "-version"))
413           (accept-process-output proc 10)
414           (goto-char (point-min))
415           (re-search-forward "[1-9][.][1-9]" (point-max) t)
416           (setq jde-java-version-cache (match-string 0)))
417         (kill-buffer buf)))
418   jde-java-version-cache)
419
420 (defun jde-java-version ()
421   "Get the version of Java used by the JDE."
422   (interactive)
423   (let ((java-version (if jde-jdk (car jde-jdk)
424                         (getenv 
425                          (nth 0 jde-java-environment-variables)))))
426     (if (not java-version)
427         (if jde-java-version-cache
428             (setq java-version jde-java-version-cache)
429           (if (jde-bsh-running-p)
430               (progn
431                 (setq jde-java-version-cache
432                       (jde-jeval-r "jde.util.JdeUtilities.getJavaVersion();"))
433                 (setq java-version jde-java-version-cache))
434             (setq java-version (jde-java-version-via-java)))))      
435     (if (interactive-p)
436       (message java-version)
437       java-version)))
438
439 (defun jde-java-major-version ()
440   "Returns an integer representing
441 the major version of the JDK being used
442 by the current project."
443   (let ((version (jde-java-version)))
444     (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)"
445                 version)
446     (string-to-int
447      (substring 
448      version 
449      (match-beginning 1)
450      (match-end 1)))))
451
452 (defun jde-java-minor-version ()
453   "Returns an integer representing
454 the minor version of the JDK being used
455 by the current project."
456   (let ((version (jde-java-version)))
457     (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)"
458                 version)
459     (string-to-int
460      (substring 
461      version 
462      (match-beginning 2)
463      (match-end 2)))))
464
465
466 ;;(makunbound 'jde-jdk-doc-url)
467 (defcustom jde-jdk-doc-url ""
468   "*URL of JDK documentation. 
469 This can point to a remote or local copy of the documentation. If the value
470 of this variable is the null string, the JDE looks for the JDK documentation
471 in the docs subdirectory of the directory returned by `jde-get-jdk-dir'."
472   :group 'jde-project
473   :type 'file)
474
475 ;;(makunbound 'jde-global-classpath)
476 (defcustom jde-global-classpath nil
477   "Specify a common classpath for compile, run, and debug commands.
478 Use this variable if you want to the JDE to use the same classpath for
479 compiling, running,and debugging an application. Note that the value
480 of this variable is a list of strings, each of which specifies a
481 path. The JDE converts this list to a colon- or semicolon-separated
482 list before inserting in the compiler or vm command line. 
483
484 The path may start with a tilde (~) or period (.) and may include
485 environment variables. The JDEE replaces a ~ with your home directory.
486 If `jde-resolve-relative-paths-p' is nonnil, the JDEE replaces the
487 . with the path of the current project file. The JDEE replaces each
488 instance of an environment variable with its value before inserting it
489 into the command line.
490
491 You can specify different classpaths for compiling, running and
492 debugging applicaitons. Use `jde-compile-option-classpath' to specify
493 the compilation classpath, `jde-run-option-classpath' to specify the
494 run classpath, and/or `jde-db-option-classpath' to specify the debug
495 classpath. You can use these variables together. For example, suppose
496 that you need to use one classpath for compilation and other for
497 running and debugging. You could do this by setting
498 `jde-compile-option-classpath' to the compile classpath and
499 `jde-global-classpath' to the run and debug classpath. If you set
500 `jde-global-classpath', the JDE uses it to construct the classpath for
501 any operation for which you do not set the operation-specific
502 classpath variable (e.g., `jde-compile-option-classpath'). 
503
504 If you do not set `jde-global-classpath', the JDE uses the operation-specific
505 classpath if it is set. If neither the global nor the
506 operation-specific classpath is set, the JDE does not generate a
507 -classpath argument for the operation, e.g., compile or run a Java
508 class. In this case, the operation uses the value of the CLASSPATH variable
509 if specified."
510   :group 'jde-project
511   :type '(repeat (file :tag "Path")))
512
513 (defcustom jde-quote-classpath t
514   "*Quote the classpath argument.
515 Set this option on when using the bash shell with Windows 95 or NT.
516 The semicolons in the classpath confuse the shell."
517   :group 'jde-project
518   :type 'boolean)
519
520 (defcustom jde-expand-classpath-p t
521   "Replace each occurence of a directory named `jde-lib-directory-names'
522  in the classpath with paths to the jar and zip files in that directory."
523   :group 'jde-project
524   :type 'boolean)
525
526 ;; (makunbound 'jde-lib-directory-names)
527 (defcustom jde-lib-directory-names (list "^lib" "^jar")
528   "Regular expressions that matches names of jar/zip directories for 
529 the current project. See `jde-expand-classpath-p' and
530 `jde-expand-classpath' for more information"
531   :group 'jde-project
532   :type '(repeat (string :tag "Name")))
533
534 (defcustom jde-lib-excluded-file-names nil
535    "Regular expressions that matches names of jar or zip files that should
536  be excluded when expanding a library specified by `jde-lib-directory-names'."
537    :group 'jde-project
538    :type '(repeat (string :tag "Name")))
539
540
541 ;; (makunbound 'jde-sourcepath)
542 (defcustom jde-sourcepath nil
543   "*List of source directory paths.  The JDE uses this list to locate
544 source files corresponding to class files.  When entering paths in the
545 custom buffer, enter each path as a separate item in a separate edit
546 field. Do NOT put more than one path in the same edit field. You'll
547 only confuse JDE.  Paths may contain environment variables."
548   :group 'jde-project
549   :type '(repeat (file :tag "Path")))
550
551
552 ;; (makunbound 'jde-build-function)
553 (defcustom jde-build-function '(jde-make)
554   "*Function that will be invoked by the `jde-build' command.
555 The `jde-make' function uses a make 
556 program to rebuild the project. The `jde-ant-build' function
557 uses the Apache Ant program to build the project. You may also
558 specify a custom function to use. The custom function must
559 be an interactive function that can be called by 
560 `call-interactively'."
561   :group 'jde-project
562   :type '(list
563           (radio-button-choice
564            :format "%t \n%v"
565            :tag "Function: "
566            :entry-format " %b %v"
567            (const jde-make)
568            (const jde-ant-build)
569            (function my-custom-build-function))))
570
571 ;;(makunbound 'jde-debugger)
572 (defcustom jde-debugger (list "jdb")
573   "Specify the debugger you want to use to debug Java programs.
574 Select JDEbug, if you want to use the JDE's builtin debugger.  Select
575 jdb, if you want to use the default version of jdb for the JDK used by
576 the current project (see `jde-jdk'). Select old jdb, if you are using
577 JDK 1.2.2 or later and want to use the the old (e.g., pre-JPDA)
578 version of jdb instead of the new (JPDA-based) version of jdb."
579   :group 'jde-project
580   :type '(list 
581           (radio-button-choice
582           (item "JDEbug")
583           (item "jdb")
584           (item "old jdb")))
585   :set '(lambda (sym val)
586           (mapc 
587            (lambda (buff)
588              (save-excursion           
589                (set-buffer buff)
590                (if (string= (car val) "JDEbug")
591                    (progn
592                      (jde-jdb-minor-mode -1)
593                      (jde-bug-minor-mode 1))
594                  (progn
595                    (jde-jdb-minor-mode 1)
596                    (jde-bug-minor-mode -1)))))
597            (jde-get-java-source-buffers))
598           (set-default sym val)))
599
600 (defcustom jde-devel-debug nil
601   "If true, use the JDEE Java classes in the jde/java/classes
602 directory instead of the jde.jar. This variable is intended for
603 use in testing the JDEE's java classes."
604   :group 'jde-project
605   :type 'boolean)
606
607
608 ;; (makunbound 'jde-enable-senator)
609 (defcustom jde-enable-senator t
610   "Enable senator minor mode.
611 This mode provides Java-aware buffer navigation and searching
612 commands."
613   :group 'jde-project
614   :type 'boolean
615   :set '(lambda (sym val)
616           (set-default sym val)
617           (unless (or (not (featurep 'jde)) ;; skip initial set.
618                       jde-loading-project ;; skip when set by project loading system
619                       (and (boundp 'global-senator-minor-mode)
620                            global-senator-minor-mode))
621             (mapc 
622              (lambda (buff)
623                (save-excursion         
624                  (set-buffer buff)
625                  (senator-minor-mode (if val 1 -1))))
626              (jde-get-java-source-buffers)))))
627
628          
629 (defcustom jde-enable-abbrev-mode nil
630 "*Enable expansion of abbreviations in jde-mode.
631 See `jde-mode-abbreviations' for more information."
632   :group 'jde-project
633   :type 'boolean
634   :set '(lambda (sym val)
635           (set-default sym val)
636           (if (featurep 'jde) ;; skip initial set.
637               (mapc
638                (lambda (buf)
639                 (with-current-buffer buf
640                   (setq abbrev-mode val)
641                   (when abbrev-mode
642                     (setq local-abbrev-table (make-abbrev-table))
643                     (jde-init-abbrev-table))))
644                (jde-get-project-source-buffers)))))
645
646 (defcustom jde-mode-abbreviations
647   (list 
648    (cons "ab" "abstract")
649    (cons "bo" "boolean")
650    (cons "br" "break")
651    (cons "by" "byte")
652    (cons "byv" "byvalue")
653    (cons "cas" "cast")
654    (cons "ca" "catch")
655    (cons "ch" "char")
656    (cons "cl" "class")
657    (cons "co" "const")
658    (cons "con" "continue")
659    (cons "de" "default")
660    (cons "dou" "double")
661    (cons "el" "else")
662    (cons "ex" "extends")
663    (cons "fa" "false")
664    (cons "fi" "final")
665    (cons "fin" "finally")
666    (cons "fl" "float")
667    (cons "fo" "for")
668    (cons "fu" "future")
669    (cons "ge" "generic")
670    (cons "go" "goto")
671    (cons "impl" "implements")
672    (cons "impo" "import")
673    (cons "ins" "instanceof")
674    (cons "in" "int")
675    (cons "inte" "interface")
676    (cons "lo" "long")
677    (cons "na" "native")
678    (cons "ne" "new")
679    (cons "nu" "null")
680    (cons "pa" "package")
681    (cons "pri" "private")
682    (cons "pro" "protected")
683    (cons "pu" "public")
684    (cons "re" "return")
685    (cons "sh" "short")
686    (cons "st" "static")
687    (cons "su" "super")
688    (cons "sw" "switch")
689    (cons "sy" "synchronized")
690    (cons "th" "this")
691    (cons "thr" "throw")
692    (cons "thro" "throws")
693    (cons "tra" "transient")
694    (cons "tr" "true")
695    (cons "vo" "void")
696    (cons "vol" "volatile")
697    (cons "wh" "while")
698    )
699 "*Abbreviations used for Java keywords.
700 To use these abbreviations, you must enable abbrev-mode (see
701 `jde-enable-abbrev-mode'). To use an abbreviation, enter the
702 abbreviation followed by a white-space character. To suppress
703 expansion, enter C-q white-space."
704   :group 'jde-project
705   :type '(repeat 
706           (cons :tag "jde-mode abbreviation"
707               (string :tag "Abbreviation")
708               (string :tag "Expansion")))
709   :set '(lambda (sym val)
710           (set-default sym val)
711           (if (and
712                (featurep 'jde)
713                jde-enable-abbrev-mode)
714               (progn
715                 (mapc
716                  (lambda (buf)
717                    (with-current-buffer buf
718                      (setq local-abbrev-table (make-abbrev-table))
719                      (jde-init-abbrev-table)))
720                  (jde-get-project-source-buffers))))))
721
722 (defun jde-init-abbrev-table ()
723   "Load the abbrev table.
724 Load it with a set of abbrevs that invoke an anonymous function that
725 does the expansion only if point is not in a quoted string or a
726 comment."
727
728   ;; Note the use of lexical-let - must have the common lisp packages
729   ;; around, since the anonymous function needs the closure provided by
730   ;; lexical-let.
731   (interactive)
732   (mapc 
733    (lambda (x)
734      (lexical-let
735          ((abbrev (car x))     ; this is the abbrev, lexically scoped
736           (expansion (cdr x))) ; this is the expansion
737        (define-abbrev
738          local-abbrev-table
739          abbrev
740          (if (featurep 'xemacs) abbrev t)
741          (lambda ()
742            (unless (jde-parse-comment-or-quoted-p)
743              (delete-backward-char (length abbrev)) ; remove abbreviation and
744              (insert expansion)))                   ; insert expansion
745          0)))
746    jde-mode-abbreviations)
747
748   (if jde-gen-cflow-enable
749       (jde-gen-load-abbrev-templates))
750
751   (setq abbrevs-changed nil))
752
753 ;; The next two functions contributed by s.nicolas@videotron.ca
754 (defun jde-abbrev-mode ()
755 "*Toggle abbreviation mode in JDE without altering project settings.
756 See `jde-mode-abbreviations' for more information."
757  (interactive)
758   (setq jde-enable-abbrev-mode (not jde-enable-abbrev-mode))
759   (setq abbrev-mode jde-enable-abbrev-mode)
760   (when jde-enable-abbrev-mode
761      ;; Define abbreviations.a
762     (jde-init-abbrev-table))
763   (if jde-enable-abbrev-mode
764       (message "abbreviation mode on")
765     (message "abbreviation mode off")))
766
767 (defun jde-show-abbrevs ()
768 "*Shows a popup menu containing all available expansions.
769 See `jde-mode-abbreviations' for more information."
770   (interactive)
771    (let* ((expansions
772           (mapcar
773             (lambda(x) (cons (cdr x) (car x)))
774               jde-mode-abbreviations))
775          (expansion (car (imenu--mouse-menu expansions (if jde-xemacsp nil
776 t) "Abbreviations"))))
777   (insert expansion)))
778
779
780 (defvar jde-classpath-separator (if (member system-type '(cygwin32 cygwin))
781                                     ";" path-separator)
782   "The separator to use in a classpath.
783 This is usually the same as `path-separator'")
784
785
786 ;;;###autoload
787 (defun jde-set-global-classpath (classpath)
788   "Set the value of `jde-global-classpath'.
789 It specifies the -classpath argument for the Java compiler and
790 interpreter."
791   (interactive 
792    "sEnter classpath: ")
793   (custom-set-variables 
794    '(jde-global-classpath (split-string classpath jde-classpath-separator) t))) 
795                 
796 (defun jde-show-run-options ()
797   "Show the JDE Run Options panel."
798   (interactive)
799   (customize-apropos "jde-run-options" 'groups))
800
801 (defun jde-show-debug-options ()
802   "Show the JDE Debug Options panel."
803   (interactive)
804   (customize-apropos "jde-db-options" 'groups))
805
806 (defun jde-show-project-options ()
807   "Show the JDE Debug Options panel."
808   (interactive)
809   (customize-apropos "jde-project" 'groups))
810
811 (defun jde-show-autocode-options ()
812   "Show the JDE Autocode panel."
813   (interactive)
814   (customize-apropos "jde-gen" 'groups))
815
816 (defun jde-show-wiz-options ()
817   "Show the JDE Wizards Options panel."
818   (interactive)
819   (customize-apropos "jde-wiz" 'groups))
820
821 (defun jde-show-complete-options ()
822   "Show the JDE Complete Options panel."
823   (interactive)
824   (customize-apropos "jde-complete" 'groups))
825
826 ;;;###autoload
827 (defun jde-build ()
828   "Rebuild the entire project.
829 This command invokes the function defined by `jde-build-function'."
830   (interactive)
831   (call-interactively (car jde-build-function)))
832
833 ; (define-derived-mode 
834 ;   jde-mode java-mode "JDE"
835 ;   "Major mode for developing Java applications and applets.
836 ;   \\{jde-mode-map}"
837 ;   (jde-mode-internal)
838 ; )
839
840 ;; The following is the expansion of the above macro.
841 ;; We include the expansion to permit automatic
842 ;; loading of the JDE.
843 (derived-mode-init-mode-variables 'jde-mode)
844 (put 'jde-mode 'derived-mode-parent 'java-mode)
845
846 ;;;###autoload
847 (defun jde-mode ()
848   "Major mode for developing Java applications and applets.
849 \\{jde-mode-map}"
850   (interactive)
851   (condition-case err
852       (progn 
853         (jde-check-versions)
854         (java-mode)
855         (if (get 'java-mode 'special)
856             (put 'jde-mode 'special t))
857         (setq major-mode 'jde-mode)
858         (setq mode-name "JDE")
859         (derived-mode-set-keymap 'jde-mode)
860         (derived-mode-set-syntax-table 'jde-mode)
861         (derived-mode-set-abbrev-table 'jde-mode)
862
863         ;; Define buffer-local variables.
864         (make-local-variable 'jde-project-name)
865         (make-local-variable 'jde-run-applet-document)
866
867         (setq jde-current-project 
868               (or (jde-find-project-file default-directory)
869                   "")) ;; Avoid setting startup values twice!
870
871         (setq jde-buffer-project-file jde-current-project)
872
873         ;; Load the project file for this buffer. The project file
874         ;; defines JDE options for a project.
875         (if (and (not (jde-debugger-running-p)) jde-project-context-switching-enabled-p)
876             (jde-load-project-file))
877
878         ;; Enable support for automatic project switching.
879         ;; This feature loads the appropriate project settings whenever
880         ;; a user switches from a Java buffer belonging to one project
881         ;; to a buffer belonging to another.
882         (make-local-hook 'post-command-hook) ;; necessary for XEmacs (see below)
883         (add-hook 'post-command-hook
884                   'jde-detect-java-buffer-activation 
885                   nil 
886                   t ;; XEmacs ignores this argument if symbol is not local.
887                   )
888
889         (unless jde-monitor-post-command-hook-timer
890           (setq 
891            jde-monitor-post-command-hook-timer
892            (run-with-idle-timer 1 t 'jde-monitor-post-command-hook)))
893
894         (unless (member 'jde-clean-up-after-jde kill-buffer-hook)
895           (add-hook 'kill-buffer-hook 'jde-clean-up-after-jde))
896                         
897         (when jde-xemacsp
898           (require 'jde-xemacs)
899           (jde-insert-menu-in-xemacs-menubar))
900
901         ;; Define underscore as a word constituent. This is needed
902         ;; to support coding styles the begin fields with an underscore.
903         (modify-syntax-entry ?_ "w")
904
905         (when jde-enable-abbrev-mode
906           ;; Define abbreviations.
907           (jde-init-abbrev-table)
908           (abbrev-mode 1))
909
910         ;; Reset the key bindings in case jde-mode-keymap
911         ;; was not bound at startup.
912         (custom-initialize-reset 'jde-key-bindings nil)
913
914         (if (and
915              jde-setnu-mode-enable
916              (< (point-max) jde-setnu-mode-threshold))
917             (setnu-mode 1))
918
919         (make-local-variable 'mode-line-format)
920         (setq mode-line-format jde-mode-line-format)
921   
922         ;; When looking for a tag that has multiple matches
923         ;; in the TAGS file, prefer (find first) the
924         ;; occurrence in the _current_ buffer.
925         ;; Contributed by Charles Rich, Mitsubishi Electric Research Laboratories,
926         ;; Cambridge, MA>
927         (when (boundp 'tags-table-format-functions)
928           (make-local-variable 'tags-table-format-functions)
929           (add-hook 'tags-table-format-functions 'jde-etags-recognize-tags-table nil t))
930
931         (if (and
932              (not jde-launch-beanshell-on-demand-p)
933              (not (jde-bsh-running-p)))
934             (bsh-launch (oref 'jde-bsh the-bsh)))
935
936         (jde-wiz-set-bsh-project)
937
938         ;; Setup Semantic stuff needed by the JDEE when Semantic is ready to
939         ;; parse!
940         (add-hook 'semantic-init-hooks  'jde-parse-semantic-default-setup)
941
942         ;; Install debug menu.
943         (if (string= (car jde-debugger) "JDEbug")
944             (jde-bug-minor-mode 1)
945           (jde-jdb-minor-mode 1))
946
947         ;; Install plugin menu.
948         (jde-plugin-minor-mode 1)
949
950         (when (boundp 'jde-mode-map)
951           (let ((key (car (read-from-string "[return]"))))
952            (if jde-electric-return-mode
953              (define-key (current-local-map) key 'jde-electric-return))))
954
955         ;; Set up indentation of Java annotations.
956         (jde-annotations-setup)
957
958
959         ;; The next form must be the last executed
960         ;; by jde-mode.
961         (derived-mode-run-hooks 'jde-mode))    
962     (error
963      (message "%s" (error-message-string err)))))
964
965                        
966 (defconst jde-check-versions-message
967    "JDEE requires a version of CEDET between %s and %s (found %s)")
968  
969 (defun jde-check-versions () 
970   "Check for correct versions of CEDET provided packages.
971 Signal an error if CEDET is not installed.
972 When `jde-check-version-flag' is non-nil, signal an error if the
973 version of CEDET currently installed doesn't meet the requirements for
974 this version of the JDEE."
975   ;; Check that CEDET is installed.
976   (or (boundp 'cedet-version)
977       (error jde-check-versions-message
978              jde-cedet-min-version
979              jde-cedet-max-version
980              "none"))
981   ;; Check version requirement when requested.
982   (or (not jde-check-version-flag)
983       (jde-check-version cedet-version
984                          jde-cedet-min-version
985                          jde-cedet-max-version)
986       (error jde-check-versions-message
987              jde-cedet-min-version
988              jde-cedet-max-version
989              cedet-version)))
990
991
992 (defun jde-check-version (current-version min-version max-version)
993   "Return non-nil if CURRENT-VERSION >= MIN-VERSION or <= MAX-VERSION."
994   (and (or (jde-earlier-versionp current-version 
995                                  max-version)
996            (string= current-version
997                     max-version))
998        (or (jde-earlier-versionp min-version
999                                  current-version)
1000            (string= current-version
1001                     min-version))))
1002
1003 (defun jde-earlier-versionp (ver1 ver2) 
1004   "Return non-nil if VER1 is earlier than VER2"
1005   (let ((ver1n (replace-in-string ver1 "beta" "zb"))
1006         (ver2n (replace-in-string ver2 "beta" "zb")))
1007     (setq ver1n (replace-in-string ver1n "pre" "zp"))
1008     (setq ver2n (replace-in-string ver2n "pre" "zp"))
1009     (if (string-match "z" ver1n)
1010         (unless (string-match "z" ver2n)
1011           (setq ver2n (concat ver2n "zz")))
1012       (if (string-match "z" ver2n)
1013           (setq ver1n (concat ver1n "zz"))))
1014     (string< ver1n ver2n)))
1015
1016       
1017 (defcustom jde-log-max 500
1018   "*Maximum number of lines to keep in the JDE log buffer.
1019 If nil, disable logging.  If t, don't truncate the buffer."
1020   :group 'jde-project
1021   :type '(choice (integer :tag "Number of lines to keep")
1022                  (boolean :tag "Disable/Unlimited")))
1023
1024 (defun jde-log-msg (msg &rest args)
1025   "Log message MSG to the *jde-log* buffer.
1026 Optional ARGS are used to `format' MSG.
1027 Does nothing if `jde-log-max' is nil."
1028   (if jde-log-max
1029       (save-match-data
1030         (save-excursion
1031           (set-buffer (get-buffer-create "*jde-log*"))
1032           (goto-char (point-max))
1033           (insert (apply 'format msg args))
1034           (insert "\n")
1035           (if (integerp jde-log-max)
1036               (let ((line-cnt 0))
1037                 (while (search-backward "\n" nil t)
1038                   (setq line-cnt (1+ line-cnt)))
1039                 (goto-char (point-min))
1040                 (while (> line-cnt jde-log-max)
1041                   (delete-region (point) (search-forward "\n" nil t))
1042                   (setq line-cnt (1- line-cnt)))))))))
1043
1044 (defun jde-log-msg-t (msg &rest args)
1045   "Log message MSG to the *jde-log* buffer, and return t.
1046 Optional ARGS are used to `format' MSG.
1047 Does nothing but return t if `jde-log-max' is nil."
1048   (jde-log-msg msg args)
1049   t)
1050
1051 (defun jde-log-msg-nil (msg &rest args)
1052   "Log message MSG to the *jde-log* buffer, and return nil.
1053 Optional ARGS are used to `format' MSG.
1054 Does nothing but return nil if `jde-log-max' is nil."
1055   (jde-log-msg msg args)
1056   nil)
1057
1058 ;; Make jde-mode the default mode for Java source code buffers.
1059 ;; Prepend the jde-mode entry so that it shadows the java-mode
1060 ;; entry already in the list.
1061 ;;;###autoload
1062 (add-to-list 'auto-mode-alist '("\\.java\\'" . jde-mode))
1063
1064 (defcustom jde-menu-definition 
1065   (list "JDE"
1066         ["Compile"           jde-compile t]
1067         ;; ["Run App"           jde-run (not (jde-run-application-running-p))]
1068         ["Run App"           jde-run t]
1069         ["Debug App"         jde-debug t]
1070         "-"
1071         ;;["-"                 ignore nil]
1072         ["Run Applet"        jde-run-menu-run-applet t]
1073         ["Debug Applet"      jde-debug-applet t]
1074         "-"  
1075         ["Build"             jde-build t]
1076         (list "Find"
1077               ["Expression"    jde-find 
1078                                   (and 
1079                                    (executable-find
1080                                     (if (eq system-type 'windows-nt) "find.exe" "find"))
1081                                    (executable-find
1082                                     (if (eq system-type 'windows-nt) "grep.exe" "grep")))]
1083               ["Expression..."  jde-find-dlg
1084                                   (and 
1085                                    (executable-find
1086                                     (if (eq system-type 'windows-nt) "find.exe" "find"))
1087                                    (executable-find
1088                                     (if (eq system-type 'windows-nt) "grep.exe" "grep")))]
1089                ["Symbol Definition" jde-open-class-at-point t]
1090                ["Class"  jde-show-class-source t]
1091                ["Super Class"  jde-show-superclass-source t]
1092                ["Interface"  jde-show-interface-source t]
1093               )
1094         (list "Interpreter"
1095               ["Start"         jde-bsh-run t]
1096               ["Exit"          jde-bsh-exit t]
1097               "-"
1098               ["Help"          jde-help-beanshell t]
1099          )
1100         (list "Documentation"
1101               ["Add"             jde-javadoc-autodoc-at-line (jde-javadoc-enable-menu-p)]
1102               ["Remove"          jde-javadoc-remdoc-at-line (jde-javadoc-enable-menu-p)]
1103               ["Check This"      jde-javadoc-checkdoc-at-line (jde-javadoc-enable-menu-p)]
1104               ["Check All"           jde-javadoc-checkdoc t]
1105               ["Generate All"        jde-javadoc-make t]
1106               ["Generate Buffer"     jde-javadoc-make-buffer t]
1107               "-"
1108               ["Javadoc Reference"     jde-javadoc-browse-tool-doc t]
1109         )
1110         "-" 
1111         (list "Code Generation"
1112               (list "Templates"
1113                     ["Get/Set Pair..."  jde-gen-get-set t]
1114                     ["Println..."       jde-gen-println t]
1115                     (list "Listener"
1116                           ["Action"          jde-gen-action-listener t]
1117                           ["Change"          jde-gen-change-listener t]
1118                           ["Window"          jde-gen-window-listener t]
1119                           ["Mouse"           jde-gen-mouse-listener t]
1120                           )
1121                     ["Other..."        jde-gen-code t]
1122                     )
1123               (list "Import"
1124                     ["Class..."                jde-import-\find-and-import t]
1125                     ["All"                     jde-import-all t]
1126                     ["All Unique"              jde-import-all-unique t]
1127                     "-"
1128                     ["Expand Package Imports"  jde-import-expand-imports t]
1129                     ["Collapse Class Imports"  jde-import-collapse-imports t]
1130                     ["Delete Unneeded"         jde-import-kill-extra-imports t]
1131                     ["Organize Imports"        jde-import-organize t]
1132                     ["Show Unimported Classes" jde-import-all-show t]
1133                     )
1134               (list "Wizards"
1135                     ["Override Method"             jde-wiz-override-method t]
1136                     ["Implement Interface..."      jde-wiz-implement-interface t]
1137                     ["Generate Get/Set Methods"    jde-wiz-get-set-methods t]
1138                     ["Generate toString Method"    jde-wiz-tostring t]
1139                     ["Update Package Statement"    jde-package-update t]
1140                     ["Implement Event Source..."   jde-wiz-implement-event-source t]
1141                     ["Extend Abstract Class..."    jde-wiz-extend-abstract-class t]
1142                     ["Delegate Methods..."         jde-wiz-delegate t]
1143                     "-"
1144                     ["Update Class List"   jde-wiz-update-class-list t]
1145                     )
1146               (list "Modes"
1147                     (vector "Abbrev"
1148                             'jde-abbrev-mode
1149                             (if (featurep 'xemacs) :active :enable) t
1150                             :style 'toggle
1151                             :selected 'jde-enable-abbrev-mode)
1152                     (vector "Electric Return"
1153                             'jde-electric-return-mode
1154                             (if (featurep 'xemacs) :active :enable) t
1155                             :style 'toggle
1156                             :selected 'jde-electric-return-mode)
1157               ))
1158         (list "Browse"
1159               ["Source Files"          jde-show-speedbar t]
1160               ["Class at Point"        jde-browse-class-at-point t]
1161              )
1162         ["Check Style"  jde-checkstyle]
1163         (list "Project"
1164               (vector "Auto Switch" 
1165                       'jde-toggle-project-switching
1166                       (if jde-xemacsp :active :enable) t 
1167                       :style 'toggle 
1168                       :selected 'jde-project-context-switching-enabled-p)
1169               (list "Options"
1170                     ["General"         jde-show-project-options t]
1171                     ["Compile"         jde-compile-show-options-buffer t]
1172                     ["Run"             jde-show-run-options t]
1173                     ["Debug"           jde-show-debug-options t]
1174                     ["Autocode"        jde-show-autocode-options t]
1175                     ["Javadoc"         jde-javadoc-customize t]
1176                     ["Make"            jde-make-show-options t]
1177                     ["Ant"             jde-ant-show-options t]
1178                     ["Complete"        jde-show-complete-options t]
1179                     ["Wiz"             jde-show-wiz-options t]
1180                     )
1181               (list "Project File"
1182                     ["Create New" jde-create-new-project t]
1183                     ["Save"     jde-save-project t]
1184                     ["Load"     jde-load-project-file t]
1185                     ["Load All" jde-load-all-project-files t]
1186                     )
1187               )
1188         (list "Help"
1189               ["JDEE Users Guide"      jde-show-help t]
1190               ["JDK"                   jde-help-browse-jdk-doc t]
1191               ["JDEE Key Bindings"     jde-keys t]
1192               "-"
1193               ["Class..."              jde-help-class t]
1194               ["Class Member..."       jde-help-class-member t]
1195               ["Symbol at Point"       jde-help-symbol t]
1196               "-"
1197               ["Submit problem report" jde-submit-problem-report t]
1198               "-"
1199               (concat "JDE " jde-version)
1200               )
1201         )
1202   "*The JDE main menu"
1203   :group 'jde-project
1204   :type 'sexp
1205   :set '(lambda (sym val)
1206           (set-default sym val)
1207           ; Define JDE menu for FSF Emacs.
1208           (if (or (not jde-xemacsp) (featurep 'infodock))
1209               (easy-menu-define jde-menu 
1210                                 jde-mode-map
1211                                 "Menu for JDE."
1212                                 val))
1213           (if (and jde-xemacsp 
1214                    (eq major-mode 'jde-mode))
1215               (jde-insert-menu-in-xemacs-menubar))))
1216
1217
1218 (defun jde-insert-menu-in-xemacs-menubar ()
1219   "Insert JDE menu in the XEmacs menu bar."
1220   (if (and 
1221        (not (featurep 'infodock))
1222        (not (memq 'infodock c-emacs-features))
1223        (boundp 'current-menubar)
1224        current-menubar)
1225       (if (fboundp 'add-submenu)
1226           (add-submenu nil jde-menu-definition)
1227         (add-menu nil "JDE" (cdr jde-menu-definition)))))
1228
1229
1230 (defcustom jde-new-buffer-menu 
1231   (list
1232    "JDE New"
1233    ["Class..."         jde-gen-class-buffer t]
1234    ["Interface..."     jde-gen-interface-buffer t]
1235    ["Console..."       jde-gen-console-buffer t]
1236    ["Bean..."          jde-gen-bean-buffer t]
1237    ["Unit Test..."     jde-junit-test-class-buffer t]
1238    (list
1239     "EJB"
1240     ["Session Bean"    jde-ejb-session-bean-buffer t]
1241     ["Entity Bean"     jde-ejb-entity-bean-buffer t])
1242    ["Other..."         jde-gen-buffer t]
1243    )
1244   "*The JDE New buffer menu"
1245   :group 'jde-project
1246   :type 'sexp
1247   :set '(lambda (sym val)
1248           (set-default sym val)
1249           (if jde-xemacsp
1250               (unless (featurep 'infodock)
1251                 (when (fboundp 'add-submenu) 
1252                   (add-submenu '("File") val "Insert File...")))
1253             (let* ((menu (if (fboundp 'easy-menu-create-menu)
1254                              (easy-menu-create-menu 
1255                               (car val) (cdr val))))
1256                    (menu-name (car val)))
1257               (define-key-after menu-bar-file-menu [jde-new]
1258                 (cons menu-name menu)
1259                   'open-file)))))
1260
1261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1262 ;;                                                                            ;;
1263 ;; Classpaths                                                                 ;;
1264 ;;                                                                            ;;
1265 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1266
1267 (defun jde-cygpath (path &optional direction)
1268   "If `system-type' is cygwin or cygwin32, converts PATH from cygwin
1269 to DOS form (if DIRECTION is nil) or to cygwin form (if DIRECTION is
1270 nonnil). The converion requires that cygpath be in your path. If the
1271 `system-type' is not cygwin or cygwin32, returns PATH unchanged."
1272   (interactive "sPath: ")
1273   (if (member system-type '(cygwin32 cygwin))
1274       (if (executable-find "cygpath")
1275           (save-excursion
1276             (let ((buf-name "*cygwin-output*")
1277                   (output-type (if direction "-u" "-w")))
1278               (shell-command 
1279                (concat "cygpath " output-type " -p '" path "'") buf-name)
1280               (set-buffer buf-name)
1281               (let ((output (buffer-substring (point-min) (point-max))))
1282                 (kill-buffer buf-name)
1283                 (substitute ?\/ ?\\ (remove ?\n output)))))
1284         (error "Cannot find cygpath executable."))
1285     path))
1286
1287 (defvar jde-cygwin-root-cache nil
1288   "Cache of converted cygwin root directory paths.")
1289
1290 (defun jde-cygwin-path-converter-cygpath (path)
1291   (interactive "sPath: ")
1292   (if (string-match "^[a-zA-Z]:" path)
1293       path
1294     (cond
1295      ((string-match "^/\\(cygdrive\\)?/\\([a-zA-Z]\\)/" path)
1296       (concat 
1297        (substring
1298         path
1299         (match-beginning 2)
1300         (match-end 2))
1301        ":/"
1302        (substring path (match-end 0))))
1303      ((string-match "^/[^/]*" path)
1304        (let* ((root (substring 
1305                     path (match-beginning 0) (match-end 0)))
1306               (rest (substring path (match-end 0)))
1307               (converted-root (cdr (assoc root jde-cygwin-root-cache))))
1308          (if (not converted-root)
1309            (progn
1310              (setq converted-root (jde-cygpath root))
1311              (if converted-root
1312                  (add-to-list 'jde-cygwin-root-cache 
1313                               (cons root converted-root))
1314                (error "Cannot convert %s" path))))       
1315          (if (string= rest "")
1316              converted-root
1317            (concat converted-root rest))))
1318      (t
1319       (error "Cannot convert %s" path)))))
1320                  
1321
1322 (defun jde-cygwin-path-converter-internal (path)
1323   "Convert cygwin style PATH to a form acceptable to java vm.  Basically
1324 converts paths of the form: '//C/dir/file' or '/cygdrive/c/dir/file' to
1325 'c:/dir/file'.  This function will not modify standard unix style paths
1326 unless they begin with '//[a-z]/' or '/cygdrive/[a-z]/'."
1327   (interactive "sPath: ")
1328   (if (fboundp 'mswindows-cygwin-to-win32-path)
1329       (substitute ?/ ?\\ (mswindows-cygwin-to-win32-path path))
1330     (let* ((path-re "/\\(cygdrive\\)?/\\([a-zA-Z]\\)/")
1331            (subexpr 2)
1332            (index1 (* 2 subexpr))
1333            (index2 (1+ index1)))
1334       (if (string-match (concat "^" path-re) path)
1335           (let ((new-path
1336                  (concat (substring path 
1337                                     (nth index1 (match-data)) 
1338                                     (nth index2 (match-data)))
1339                          ":/" 
1340                          (substring path (match-end 0)))))
1341             (while (string-match (concat ":" path-re) new-path)
1342               (setq new-path
1343                     (concat
1344                      (substring new-path 0 (match-beginning 0))
1345                      ";"
1346                      (substring new-path 
1347                                 (nth index1 (match-data)) 
1348                                 (nth index2 (match-data)))
1349                      ":/" 
1350                      (substring new-path (match-end 0)))))
1351             (substitute ?\\ ?\/ new-path))
1352         path))))
1353
1354 (defcustom jde-cygwin-path-converter '(jde-cygwin-path-converter-internal)
1355   "Function to use to convert cygwin paths to DOS paths.  
1356 Choose jde-cygwin-path-converter-internal, jde-cygwin-path-converter-cygpath,
1357 or \"custom-function.\" jde-cygwin-path-converter-cygpath handles all
1358 cygwin-style paths, including mount points, e.g.,/bin. 
1359 jde-cygwin-path-converter-internal does not handle mount
1360 paths. However, it is much faster as it does not require running a
1361 subprocess every time the JDE needs to convert a path. Choose
1362 \"custom-function\" if you want the JDE to use a function that you
1363 supply. Replace \"custom-function\" with the name of the function that
1364 you want to use."
1365   :group 'jde-project
1366   :type  '(list
1367            (radio-button-choice :format "%t \n%v"
1368                                :tag "Converter: "
1369                                :entry-format "  %b %v"
1370                                (const jde-cygwin-path-converter-internal)
1371                                (const jde-cygwin-path-converter-cygpath)
1372                                (function custom-function))))
1373                        
1374
1375 (defun jde-convert-cygwin-path (path &optional separator)
1376   "Convert cygwin style PATH to a form acceptable to java vm, using
1377 the conversion function specified by `jde-cygwin-path-converter'."
1378   (interactive "sPath: ")
1379   (funcall (car jde-cygwin-path-converter) 
1380            (if separator (substitute ?\: (string-to-char separator) path) path)))
1381
1382 (defcustom jde-resolve-relative-paths-p t
1383   "If this variable is non-nil, the JDE converts relative paths to 
1384 absolute paths. The JDE does this by appending the relative path to the path
1385 of the project file for the current source buffer, if such
1386 a file exists. Otherwise, the JDE appends the relative path to the path
1387 of the current directory."
1388   :group 'jde-project
1389   :type 'boolean)
1390
1391 (defun jde-normalize-path (path &optional symbol) 
1392   "This function performs the following transformation on PATH:
1393
1394   * Replaces environment variables of the form $VAR or ${VAR} with
1395     their values. Note that you must use the Unix notation for
1396     environment variables on the native Windows versions of Emacs and
1397     XEmacs.
1398
1399   * Replaces the tilde character with the value of the home directory,
1400     typically specified by the HOME environment variable.
1401
1402   * Converts Cygwin style paths to DOS notation on Windows.
1403
1404   * Converts relative paths to absolute paths if
1405     `jde-resolve-relative-paths-p' is non-nil.  Paths are resolved
1406     according to the location of the deepest project file found, or if
1407     optional SYMBOL is non-nil, paths are resolved to the location of
1408     the deepest project file found that defines SYMBOL.
1409
1410 Note: PATH can either be a path string or a symbol corresponding to a
1411 variable that holds a path string, in which case the optional arg
1412 SYMBOL is unnecessary."
1413   (if (symbolp path)
1414       (setq symbol path
1415             path (symbol-value symbol)))
1416   (let* ((directory-sep-char ?/)
1417          (p (substitute-in-file-name path))
1418         (len (length p)))
1419     (if (and
1420          jde-resolve-relative-paths-p
1421          (> len 0)
1422          (eq (aref p 0) ?.))
1423         (let* (prj-file-path
1424                (dir (file-name-directory (or (buffer-file-name)
1425                                              default-directory))))
1426           ;; find the deepest originating project for the symbol
1427           ;; based on the current directory, and resolve to that
1428           ;; project's directory
1429           (if symbol
1430               (let ((prjs (get symbol 'jde-project))
1431                     (sort-fn
1432                      (lambda (x1 x2) 
1433                        (let* ((dir1 (file-name-directory (car x1)))
1434                               (dir2 (file-name-directory (car x2)))
1435                               match1 match2)
1436                          (if (null dir1)
1437                              (null dir2)
1438                            (if (null dir2)
1439                                t
1440                              (setq match1 (compare-strings
1441                                            dir1 0 (length dir1)
1442                                            dir 0 (length dir1)))
1443                              (setq match2 (compare-strings
1444                                            dir2 0 (length dir2)
1445                                            dir 0 (length dir2))))
1446                            (cond
1447                             ((not (eq match1 t))
1448                              (if (eq match2 t)
1449                                  nil
1450                                (> (length dir1) (length dir2))))
1451                             ((not (eq match2 t))
1452                              t)
1453                             ((> (length dir1) (length dir2)))))))))
1454                 (setq prjs (sort prjs sort-fn))
1455                 (setq prj-file-path (caar prjs))
1456                 (if (string= prj-file-path "default")
1457                     ;; Case where the project file that sets symbol
1458                     ;; is the user's .emacs file. Assume that the
1459                     ;; user wants the relative path in the .emacs 
1460                     ;; file to be the default relative path for
1461                     ;; projects that do not specify a
1462                     ;; relative path.
1463                     (setq prj-file-path
1464                           (jde-find-project-file dir))))
1465             (setq prj-file-path 
1466                   (jde-find-project-file dir)))
1467           (if prj-file-path
1468               (setq dir (file-name-directory prj-file-path))
1469             (setq dir default-directory))
1470           (if (and (> len 1)
1471                    (eq (aref p 1) ?.))
1472               ;; path actually begins with `..', so normalize to one
1473               ;; directory up
1474               (save-match-data
1475                 (string-match "\\.+/?" p)
1476                 (setq p (expand-file-name (substring p (match-end 0))
1477                                           (expand-file-name (concat dir "../")))))
1478             (setq p (expand-file-name p dir))))
1479       ;; Do tilde expansion but not relative path expansion when
1480       ;; jde-resolve-relative-paths-p is false.
1481       (if (not 
1482            (or
1483             (string= p ".")
1484             (string-match "[.]/" p)))
1485           (setq p (expand-file-name p))))
1486     (setq p (jde-convert-cygwin-path p))
1487     p))
1488
1489
1490 (defun jde-expand-directory (dir include-regexp exclude-regexps symbol)
1491   "Get all the files in DIR whose names match INCLUDE-REGEXP except those whose
1492 root names match EXCLUDE-REGEXPS. Return the files normalized against SYMBOL."
1493   (mapcar
1494    (lambda (included-file)
1495      (jde-normalize-path included-file symbol))
1496    (remove-if
1497     (lambda (file-path)
1498       (let ((file-name 
1499               (file-name-nondirectory file-path)))
1500         (catch 'match
1501             (loop for regexp in exclude-regexps do
1502                   (if (string-match regexp file-name)
1503                       (throw 'match t))))))
1504     (directory-files dir t include-regexp))))
1505
1506
1507 (defun jde-expand-classpath (classpath &optional symbol)
1508   "If `jde-expand-classpath-p' is nonnil, replaces paths to 
1509 directories that match `jde-lib-directory-names' with paths to jar or
1510 zip files in those directories, excepting those specified by
1511 `jde-lib-excluded-file-names'. This function assumes that the
1512 existing paths are already normalized."
1513   (if jde-expand-classpath-p
1514       (let (paths)
1515         (loop for path in classpath do
1516               (if (and 
1517                    (file-exists-p path)
1518                    (file-directory-p path)
1519                    (let ((dir-name (file-name-nondirectory path)))
1520                      (member-if 
1521                       (lambda (lib-name)
1522                         (string-match lib-name dir-name))
1523                       jde-lib-directory-names)))
1524                   (progn
1525                     (setq paths 
1526                           (append 
1527                            paths
1528                            (jde-expand-directory
1529                             path 
1530                             "\\.jar$"
1531                             jde-lib-excluded-file-names
1532                             symbol)))
1533                     (setq paths
1534                           (append 
1535                            paths 
1536                            (jde-expand-directory
1537                             path 
1538                             "\\.zip$"
1539                             jde-lib-excluded-file-names
1540                             symbol))))
1541                 (setq paths (append paths (list path)))))
1542         paths)
1543     classpath))
1544
1545
1546 (defun jde-build-classpath (paths &optional symbol quote-path-p)
1547   "Builds a classpath from PATHS.  PATHS is a either list of paths or
1548 a symbol whose value is a list of paths, in which case the optional
1549 arg SYMBOL is unnecessary. If QUOTE-PATH-P is nonnil, quote paths
1550 that contain spaces."
1551   (if (symbolp paths)
1552       (setq symbol paths
1553             paths (symbol-value symbol)))
1554   (mapconcat
1555    (lambda (path)
1556      path)
1557     (jde-expand-classpath 
1558      (mapcar
1559       (lambda (path)
1560         (jde-normalize-path path symbol))
1561       paths)
1562      symbol)
1563    jde-classpath-separator))
1564
1565 (defun jde-global-classpath ()
1566   "Builds a classpath string from the path entries in
1567 `jde-global-classpath'."
1568   (jde-build-classpath 'jde-global-classpath))
1569
1570
1571 (defun jde-build-path-arg (arg path-list &optional quote symbol)
1572 "Build a command-line path argument from a list of paths."
1573   (let ((path (jde-build-classpath path-list symbol)))
1574     (if quote
1575         (setq path (concat "\"" path "\"")))
1576     (setq path (concat arg " " path))))
1577
1578
1579 (defun jde-build-classpath-arg (path-list &optional quote symbol)
1580 "Build a classpath from a list of paths."
1581  (jde-build-path-arg "-classpath" path-list quote symbol))
1582
1583 (defun jde-root-dir-p (dir)
1584   "Return nonnil if DIR is a root directory." 
1585   (let ((parent (expand-file-name  ".." dir)))
1586     (cond 
1587      ((and
1588        (fboundp 'ange-ftp-ftp-name)
1589        (ange-ftp-ftp-name dir))
1590       (ange-ftp-get-file-entry parent))
1591      ((eq system-type 'windows-nt)
1592       ;; If the current directory tree is on a 
1593       ;; virtual drive created by the subst command
1594       ;;
1595       ;;  (not (file-exists-p parent)) 
1596       ;;  
1597       ;; fails. Hence, the following hack contributed
1598       ;; by Nat Goodspeed.
1599       (or 
1600        (string= parent "//") ; for paths like //host/d/prj/src
1601        (string= parent "\\\\") ; for paths like \\host\d\prj\src
1602        (string= parent dir) ;; for paths like d:/ on emacs 22
1603        (string= (substring parent -3) "/.."))) ;; for paths like d:/ on emacs 21
1604      ((member system-type '(cygwin32 cygwin))
1605       (or (string= (file-truename dir) (file-truename "/"))
1606           (string= parent "//") ; for paths like //host/d/prj/src
1607           (string= parent "\\\\") ; for paths like \\host\d\prj\src
1608           (and (> (length parent) 3) ; for paths like d:/prj/src
1609                (string= (substring parent -3) "/.."))
1610           (not (file-exists-p (file-truename dir)))))
1611      (t
1612       (or (or (not (file-readable-p dir))
1613               (not (file-readable-p parent)))
1614           (and 
1615            (string= (file-truename dir) "/")
1616            (string= (file-truename parent) "/")))))))
1617
1618 (defun jde-get-global-classpath () 
1619   "Return the value of `jde-global-classpath', if defined, otherwise
1620 the value of the CLASSPATH environment variable converted to a list,
1621 of normalized paths, i.e., with . and ~ characters expanded and backslashes
1622 replaces with slashes."
1623   (if jde-global-classpath 
1624       jde-global-classpath
1625     (let ((cp (getenv "CLASSPATH")))
1626       (if (stringp cp)
1627           (mapcar
1628            (lambda (path)
1629              (let ((directory-sep-char ?/))
1630                    (expand-file-name path)))
1631            (split-string cp jde-classpath-separator))))))
1632
1633
1634
1635 (defvar jde-entering-java-buffer-hook 
1636   '(jde-reload-project-file 
1637     jde-which-method-update-on-entering-buffer)
1638    "*Lists functions to run when entering a jde-mode source buffer from another
1639 jde-mode buffer. Note that these functions do not run when reentering the same
1640 jde-mode buffer from a non-jde-mode buffer. You should use this hook only for
1641 functions that need to be run when you switch from one jde-mode buffer to
1642 a different jde-mode buffer. Use `jde-mode-hook' if the function needs to run
1643 only once, when the buffer is created.")
1644
1645 (defvar jde-current-buffer (current-buffer)
1646   "*Internal JDE variable that holds the current active buffer.")
1647
1648 (defun jde-detect-java-buffer-activation ()
1649   "Detects when a user activates a buffer.
1650 If the activated buffer is a Java buffer, runs the 
1651 `jde-entering-java-buffer-hook' hooks."
1652   (let ((curr-buff (current-buffer)))
1653     (unless (equal curr-buff jde-current-buffer)
1654       (setq jde-current-buffer curr-buff)
1655       (if (eq major-mode 'jde-mode)
1656           (condition-case err
1657               (run-hooks 'jde-entering-java-buffer-hook)
1658             (error 
1659              (message "jde-entering-java-buffer-hook error: %s" 
1660                       (error-message-string err))))))))
1661
1662 (defun jde-monitor-post-command-hook ()
1663   "Checks whether `post-command-hook' includes all hooks required
1664 by JDEE. If not, it adds the required hooks."
1665   (if (eq major-mode 'jde-mode)
1666       (dolist (hook (list 'jde-detect-java-buffer-activation))
1667         (when (not (member hook post-command-hook))
1668           (add-hook 'post-command-hook hook)))))
1669
1670 (defvar jde-monitor-post-command-hook-timer nil
1671 "Timer that runs `jde-monitor-post-command-hook' during
1672 idle moments.")
1673
1674 (defun jde-count-open-java-buffers ()
1675   "Returns non-nil if any java buffers are open."
1676   (count 
1677    ".java"
1678    (buffer-list)
1679    :test
1680    (lambda (file-type buffer)
1681      (let ((file-name (buffer-file-name buffer)))
1682        (if file-name
1683            (save-match-data
1684             (string-match file-type file-name)))))))
1685          
1686
1687 (defun jde-clean-up-after-jde ()
1688   "Removes `jde-detect-java-buffer-activation-hook' when
1689 all Java source buffers have been closed."
1690   (if  (eq major-mode 'jde-mode)
1691       (unless  (> (jde-count-open-java-buffers) 1)
1692         (remove-hook 'post-command-hook 'jde-detect-java-buffer-activation)
1693         (when jde-monitor-post-command-hook-timer
1694           (cancel-timer jde-monitor-post-command-hook-timer)
1695           (setq jde-monitor-post-command-hook-timer nil))
1696         (remove-hook 'kill-buffer-hook 'jde-clean-up-after-jde))))
1697
1698
1699 ;; JDE help
1700 (defun jde-find-jde-doc-directory ()
1701   "Return the path of the JDE documentation directory.
1702 Returns  nil if the directory cannot be found. At some
1703 point, XEmacs will include the JDE. Versions of XEmacs
1704 that include JDE will store the JDE doc in a data
1705 directory called jde. On all other Emacs versions, the JDE
1706 expects to find the documentation in a subdirectory 
1707 named doc of the directory that contains the file
1708 jde.el."
1709   (jde-find-jde-data-directory))
1710
1711 ;;;###autoload
1712 (defun jde-show-help ()
1713   "Displays the JDE User's Guide in a browser."
1714   (interactive)
1715   (let* ((jde-dir (jde-find-jde-doc-directory))
1716          (jde-help
1717           (if jde-dir
1718               (expand-file-name "doc/html/jde-ug/jde-ug.html" jde-dir))))      
1719     (if (and
1720          jde-help
1721          (file-exists-p jde-help))
1722         (browse-url (concat "file://" (jde-convert-cygwin-path jde-help))
1723                     (if (boundp 'browse-url-new-window-flag)
1724                         'browse-url-new-window-flag
1725                       browse-url-new-window-p))
1726       (signal 'error '("Cannot find JDE help file.")))))
1727
1728
1729 ;;
1730 ;; Problem reporting functions contributed by Phillip Lord <plord@hgmp.mrc.ac.uk>.
1731 ;;
1732 (defvar jde-problem-report-mail-address "pkinnucan@comcast.net" )
1733
1734 (defun jde-submit-problem-report()
1735   "Submit a problem report for the JDEE." 
1736   (interactive)
1737   (require 'reporter)
1738   (and 
1739    (y-or-n-p "Do you want to submit a problem report on the JDEE? ")
1740    (progn
1741      (message "Preparing problem report...")
1742      ;;prepare the basic buffer
1743      (reporter-submit-bug-report
1744       jde-problem-report-mail-address
1745       (format "JDE version %s\nRequired packages: cedet-%s\n"
1746               jde-version cedet-version)
1747       (jde-problem-report-list-all-variables)
1748       nil
1749       'jde-problem-report-post-hooks
1750       "Please enter the details of your bug report here" )
1751      (message "Preparing bug report...done"))))
1752
1753
1754 (defun jde-problem-report-post-hooks()
1755   "Function run the reporter package done its work.
1756 It looks for a JDEBug buffer and inserts the contents of that, and then prompts 
1757 for insertion of the .emacs file"
1758   (save-excursion 
1759     (goto-char (point-max))
1760     (let* ((debug-buffer (get-buffer "*JDEbug*"))
1761            (messages-buffer 
1762             (get-buffer
1763              (if jde-xemacsp " *Message-Log*" "*Messages*")))
1764            (backtrace-buffer (get-buffer "*Backtrace*"))
1765            (jde-log-buffer (get-buffer "*jde-log*"))
1766            (process 
1767             (let ((proc (jde-dbs-get-target-process)))
1768               (if (not proc)
1769                   (let ((dead-proc-alist 
1770                          (oref jde-dbs-the-process-morgue proc-alist)))
1771                     (if dead-proc-alist
1772                         (setq proc (cdr (car dead-proc-alist))))))
1773               proc))
1774            (cli-buffer (if (and process (slot-boundp process 'cli-buf))
1775                            (oref process cli-buf)))
1776            (locals-buffer (if (and process (slot-boundp process 'locals-buf))
1777                               (oref process locals-buf))))
1778      
1779
1780       ;;insert the contents of the debug buffer if it is there. 
1781       (if debug-buffer
1782           (progn
1783             (insert-string "\n\n\nThe contents of the *JDEBug* buffer were\n\n")
1784             (insert-buffer debug-buffer)
1785             (goto-char (point-max))
1786             (insert-string "\n\n\nEnd Insert *JDEbug* buffer" ))
1787         (insert-string "\n\n\nThere was no *JDEBug* buffer" ))
1788
1789       ;;insert the contents of the CLI buffer if it exists.
1790       (if cli-buffer
1791           (progn
1792             (insert-string "\n\n\nThe contents of the CLI buffer are\n\n")
1793             (insert-buffer cli-buffer)
1794             (goto-char (point-max))
1795             (insert-string "\n\n\nEnd Insert CLI buffer" ))
1796         (insert-string "\n\n\nThere is no CLI buffer" ))
1797
1798
1799       ;;insert the contents of the locals buffer if it exists.
1800       (if locals-buffer
1801           (progn
1802             (insert-string "\n\n\nThe contents of the locals buffer are\n\n")
1803             (insert-buffer locals-buffer)
1804             (goto-char (point-max))
1805             (insert-string "\n\n\nEnd Insert locals buffer" ))
1806         (insert-string "\n\n\nThere is no locals buffer" ))
1807
1808       ;;insert the contents of the backtrace buffer if it is there. 
1809       (if backtrace-buffer
1810           (progn
1811             (insert-string "\n\n\nThe contents of the *Backtrace* buffer were\n\n")
1812             (insert-buffer backtrace-buffer)
1813             (goto-char (point-max))
1814             (insert-string "\n\n\nEnd Insert *Backtrace* buffer" ))
1815         (insert-string "\n\n\nThere was no *Backtrace* buffer" ))
1816
1817
1818       ;;insert the contents of the messages buffer if it is there. 
1819       (if messages-buffer
1820           (progn
1821             (insert-string "\n\n\nThe contents of the *Messages* buffer were\n\n")
1822             (insert-buffer messages-buffer)
1823             (goto-char (point-max))
1824             (insert-string "\n\n\nEnd Insert *Messages* buffer" ))
1825         (insert-string "\n\n\nThere was no *Messages* buffer" ))
1826
1827       ;;insert the contents of the jde-log buffer if it is there. 
1828       (if jde-log-buffer
1829           (progn
1830             (insert-string "\n\n\nThe contents of the *jde-log* buffer were\n\n")
1831             (insert-buffer jde-log-buffer)
1832             (goto-char (point-max))
1833             (insert-string "\n\n\nEnd Insert *jde-log* buffer" ))
1834         (insert-string "\n\n\nThere was no *jde-log* buffer" )))
1835
1836     (when process-environment
1837       (insert-string "\n\n\nProcess environment: \n\n")
1838       (insert-string (mapconcat (lambda (var) var) process-environment "\n")))
1839
1840     (let* ((init-file-name (if (featurep 'xemacs) "init.el" ".emacs"))
1841            (buf (get-buffer-create 
1842                  (format "*Insert %s*" init-file-name)))
1843            (mail-buf (current-buffer)))
1844       
1845       (set-buffer buf)
1846
1847       (widget-insert 
1848        (format       "You should include the entire contents of your %s file.\n"
1849                init-file-name))
1850
1851       (widget-insert
1852        (format       "This is because often parts of the %s file that appear\n"
1853                init-file-name))
1854         
1855       (widget-insert "not to be JDEE-related do in fact contain the cause of\n")
1856       (widget-insert "reported bugs.\n\n")
1857
1858       (widget-insert 
1859        (format "If you choose not to send your %s file or the file loads many\n" 
1860                init-file-name))
1861
1862       (widget-insert 
1863        (format "other files, please attempt to replicate the bug, using the\n" 
1864                init-file-name))
1865
1866       (widget-insert 
1867        (format "minimal %s file suggested in the JDEE documentation, and note\n" 
1868                init-file-name))
1869
1870       (widget-insert "that you have done this in this bug report.\n")
1871       (switch-to-buffer buf)
1872       
1873       (set-buffer mail-buf)
1874       (goto-char (point-max))
1875
1876       (if (y-or-n-p 
1877            (format "Insert your %s file into the problem report? " 
1878                    init-file-name))
1879           (progn
1880             (insert-string 
1881              (format "\n\n\nThe contents of the %s file was\n\n\n"
1882                      init-file-name))
1883
1884             (if (featurep 'xemacs) 
1885                 (insert-file "~/.xemacs/init.el")
1886               (insert-file "~/.emacs"))
1887             (goto-char (point-max))
1888             (insert-string 
1889              (format "\n\n\n=====end inserted %s file"
1890                      init-file-name)))
1891         (insert-string 
1892          (format "\n\n\nThe user choose not to insert their %s file\n" 
1893                  init-file-name)))
1894
1895       ;;clean up the prompt buffer
1896       (kill-buffer buf))))
1897
1898 (defun jde-problem-report-list-all-variables()
1899   "List all variables starting with `jde' or `bsh'."
1900   (let (vars)
1901     (mapatoms
1902      (lambda (symbol)
1903        (if  (jde-symbol-p symbol)
1904          (setq vars (cons symbol vars)))))
1905     vars))
1906
1907
1908 ;; Line numbering support.
1909 (eval-when (compile)
1910   (require 'setnu))
1911
1912 (defvar jde-setnu-deletion-check t "deletion check")
1913 (make-variable-buffer-local 'jde-setnu-deletion-check)
1914
1915 (defun jde-setnu-after-change (start end length)
1916  "When in setnu-mode, toggles setnu-mode off and on."
1917    (if setnu-mode
1918        (if (or
1919             (and
1920              (> length 0)
1921              jde-setnu-deletion-check)
1922             (string-match 
1923                   "[\n\r]" 
1924                   (buffer-substring-no-properties start end)))
1925            (run-with-timer 
1926             0.001 nil
1927             ;; setnu toggler      
1928            (lambda () (setnu-mode) (setnu-mode))))
1929      (setq jde-setnu-deletion-check nil)))
1930
1931 (defun jde-setnu-before-change (start end) 
1932   "Determines whether any newlines were deleted."
1933    (if setnu-mode
1934        (if (> end start) 
1935            (setq jde-setnu-deletion-check 
1936                  (string-match "[\n\r]" (buffer-substring-no-properties start end))))))
1937
1938
1939 (defcustom jde-setnu-mode-threshold 20000
1940  "Maximum number of bytes in a file (buffer) that can result in
1941 automatic line numbering."
1942  :group 'jde-project
1943  :type 'integer)
1944
1945 (defcustom jde-setnu-mode-enable nil
1946  "Enable numbering of lines in Java source buffers."
1947  :group 'jde-project
1948  :type 'boolean
1949  :set '(lambda (sym val)
1950          (if val
1951              (progn
1952                (require 'setnu)
1953                (add-hook 
1954                 'after-change-functions 
1955                 'jde-setnu-after-change)
1956                (add-hook 
1957                 'before-change-functions 
1958                 'jde-setnu-before-change)
1959                (mapc
1960                 (lambda (buf)
1961                   (save-excursion
1962                     (set-buffer buf)
1963                     (if (and
1964                          (not setnu-mode)
1965                          (< (point-max) jde-setnu-mode-threshold))
1966                         (setnu-mode 1))))
1967                   (jde-get-java-source-buffers)))
1968            (progn
1969              (mapc 
1970               (lambda (buf)
1971                 (save-excursion
1972                   (set-buffer buf)
1973                   (if (and (boundp 'setnu-mode)
1974                            setnu-mode)
1975                       (setnu-mode))))
1976               (jde-get-java-source-buffers))))   
1977          (set-default sym val)))
1978
1979 ;; jde-describe-map is Ehud Karni's describe map with jde prepended.
1980 (defun jde-keymap-test (var)           ; internal function for keymap checking
1981        (and (boundp var)
1982             (keymapp (symbol-value var))))
1983
1984 (defun jde-describe-map (map)          ; display map binding
1985  "Display binding for MAP which must be a quoted keymap variable"
1986   (interactive
1987        (let ((map (intern (completing-read "Key map: " obarray 'jde-keymap-test 1))))
1988            (list map)))
1989        (let ((val (symbol-value map)))
1990            (or (keymapp val)
1991                (error "%s is not a keymap !" (symbol-name map)))
1992            (with-output-to-temp-buffer "*Help*"
1993                (princ (format "Binding for keymap %s is:\n" (symbol-name map)))
1994                (princ (substitute-command-keys "\\{val}" ))
1995                (print-help-return-message))))
1996
1997 (defun jde-keys ()
1998   "Displays JDE key bindings. Use `jde-bug-keys' to display JDEbug keybindings ."
1999   (interactive)
2000   (jde-describe-map 'jde-mode-map))
2001
2002
2003 ;; Contributed by John Ciolfi, jciolfi@mathworks.com.
2004 (defun jde-compile-file-if-necessary (file)
2005   "Compile the JDE file FILE if necessary.
2006 This is done if FILE.el is newer than FILE.elc or if FILE.elc doesn't exist."
2007   (if (string= (file-name-extension file) "el")
2008       (let* ((root (file-name-sans-extension file))
2009              (elc-file (concat root ".elc")))
2010         (if (and
2011              (or (not (file-exists-p elc-file))
2012                 (file-newer-than-file-p file  elc-file))
2013              (or (not (string= root "jde-xemacs"))
2014                  (featurep 'xemacs)))
2015             (progn
2016               (message (format "Byte-compiling %s..." 
2017                                (file-name-nondirectory file)))
2018               (byte-compile-file file))))))
2019
2020 ;;;###autoload
2021 (defun jde-compile-jde ()
2022   "Byte-compile all uncompiled files of jde."
2023
2024   ;; Be sure to have . in load-path since a number of files in jde
2025   ;; depend on other files and we always want the newer one even if
2026   ;; a previous version of jde exists.
2027
2028   (interactive)
2029   (require 'jde-compat)
2030   (let ((load-path (append '(".") load-path))
2031         (jde-lisp-directory (expand-file-name "lisp" (jde-find-jde-data-directory))))
2032     (save-excursion 
2033       (mapcar 
2034        (function jde-compile-file-if-necessary)
2035        (directory-files jde-lisp-directory t)))))
2036
2037 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2038 ;;                                                                            ;; 
2039 ;; Find command                                                               ;;
2040 ;;                                                                            ;;
2041 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2042
2043 (defcustom jde-find-case-sensitive nil
2044   "*Specifies whether the jde-find command performs a case-sensitive search.
2045 If non-nil, the search is case-sensitive; otherwise, the search ignores case."
2046   :group 'jde-project
2047   :type 'boolean
2048 )
2049
2050 ;; (makunbound 'jde-find-granularity)
2051 (defcustom jde-find-granularity '("Character")
2052   "*Specifies the granularity of the expression search
2053 conducted by `jde-find': Character (expression starting
2054 on any character), Word (match words only), Line
2055 (match lines only)."
2056   :group 'jde-project
2057   :type  '(list
2058            (radio-button-choice
2059             :format "%t \n%v"
2060             :tag "Search granularity:"
2061             (item "Character")
2062             (item "Word")
2063             (item "Line"))))
2064
2065
2066 (defcustom jde-find-file-regexp '("*.java")
2067   "*Specifies the regular expression that the jde-find command uses
2068 to select files to be searched. You can use any regular expression  
2069 supported by the -name option of the GNU find command."
2070   :group 'jde-project
2071   :type '(repeat (string :tag "Find regexp"))
2072 )
2073
2074 (defclass jde-find-dialog (efc-dialog)
2075   ((expr-field     :initarg :expr-field
2076                    :documentation "Edit field for expression to find.")
2077    (expression     :initarg :expression
2078                    :type string
2079                    :initform ""
2080                    :documentation "Regular expression to find.")
2081    (dir-fields     :initarg :dir-fields
2082                    :documentation "List of directory path fields.")
2083    (dirs           :initarg :dirs
2084                    :type list
2085                    :documentation "Directories to search recursively.")
2086    (file-fields    :initarg :file-fields
2087                    :documentation "Regular expression fields for files to search.")
2088    (files          :initarg :files
2089                    :type list
2090                    :initform ("*.java")
2091                    :documentation "Files to search.")
2092    (ignore-case-cb :initarg :ignore-case
2093                    :documentation "Ignore case check box.")
2094    (ignore-case-p  :initarg :ignore-case-p
2095                    :type boolean
2096                    :initform t
2097                    :documentation "If true, ignore case when searching.")
2098    (grain-rbs      :initarg :grain-rbs
2099                    :documentation "Granularity radio buttons.")
2100    (grain          :initarg :grain
2101                    :type string
2102                    :initform "Character"
2103                    :documentation "Search granularity: Character, Word, Line")
2104    (ok             :initarg :ok
2105                    :type boolean
2106                    :initform nil
2107                    :documentation "True if user clicked the OK button.")
2108    (the-dialog     :type (or null jde-find-dialog)
2109                    :allocation :class
2110                    :initform nil
2111                    :documentation
2112                    "The only instance of the find expression dialog buffer."))
2113   "Dialog displayed by `jde-find' command.")
2114
2115 (defmethod initialize-instance ((this jde-find-dialog) &rest fields)
2116   "Find options dialog constructor."
2117   (oset this title "Find Dialog")
2118   (call-next-method))
2119
2120 (defmethod efc-dialog-create ((this jde-find-dialog))
2121  
2122   (widget-insert "Find Expression Options\n\n")
2123
2124   (oset this expr-field
2125         (widget-create
2126          (list
2127           'text
2128           :tab-order 1
2129           :format "%t %v"
2130           :tag "Expression:"
2131           :value (oref this expression))))
2132
2133   (widget-insert "\n")
2134
2135   (oset this dir-fields
2136         (widget-create
2137          (list
2138           'repeat 
2139           :tag "Directories to search recursively"
2140           :value (if (slot-boundp this 'dirs)
2141                      (oref this dirs)
2142                    (mapcar
2143                     (lambda (p)
2144                       (jde-normalize-path p 'jde-sourcepath))
2145                     jde-sourcepath))
2146           (list 'file :tag "Path"))))
2147   (widget-insert "\n")
2148
2149   (oset this file-fields
2150         (widget-create
2151          (list
2152           'repeat 
2153           :tag "File types to search"
2154           :value (oref this files)
2155           (list 'file :tag "File regexp"))))
2156
2157   (widget-insert "\n")
2158
2159   (oset this ignore-case-cb
2160         (widget-create
2161          (list 'checkbox 
2162                :format "%[%v%] %t" 
2163                :tag "Ignore case"
2164                :value (oref this ignore-case-p)
2165                )))
2166
2167   (widget-insert "\n\n")
2168
2169   (oset this grain-rbs
2170         (widget-create
2171          (list
2172           'radio-button-choice
2173           :format "%t\n%v"
2174           :tag "Search granularity:"
2175           :value (oref this grain)
2176           :args (list
2177                  (list 'item "Character")
2178                  (list 'item "Word")
2179                  (list 'item "Line")))))
2180                        
2181   (widget-insert "\n"))
2182
2183
2184 (defmethod efc-dialog-show ((this jde-find-dialog))
2185   "Shows the options dialog buffer. After showing the dialog buffer,
2186 this method invokes recursive-edit to emulate the behavior of a modal
2187 dialog. This suspends the current command until the user has selected
2188 an option or canceled the dialog. See `efc-dialog-ok' and
2189 `efc-dialog-cancel' for more information."
2190   (call-next-method)
2191   (recursive-edit))
2192
2193
2194 (defmethod efc-dialog-ok ((this jde-find-dialog))
2195   "Invoked when the user selects the OK button on the options
2196 dialog. Sets the :dirs field of THIS to the search paths chosen by the
2197 user, kills the dialog buffer, and exits recursive-edit mode."
2198   
2199   (oset this 
2200         expression
2201         (widget-value (oref this expr-field)))
2202
2203   (oset this 
2204         dirs
2205         (widget-value (oref this dir-fields)))
2206
2207   (oset this
2208         files
2209         (widget-value (oref this file-fields)))
2210
2211   (oset this 
2212         ignore-case-p
2213         (widget-value (oref this ignore-case-cb)))
2214
2215   (oset this
2216         grain
2217         (widget-value (oref this grain-rbs)))
2218
2219   (oset this ok t)
2220
2221   (delete-window)
2222   (kill-buffer (oref this buf))
2223   (pop-to-buffer (oref this initbuf))
2224   (set-buffer (oref this initbuf))
2225
2226   (exit-recursive-edit))
2227
2228 (defmethod efc-dialog-cancel ((this jde-find-dialog))
2229   "Invoked when the user clicks the dialog's Cancel button.  Invokes
2230 the default cancel method, sets the :selection field of THIS to nil,
2231 and then exits recursive edit mode."
2232   (call-next-method)
2233   (oset this ok nil)
2234   (exit-recursive-edit))
2235
2236
2237
2238 (defvar jde-find-root-history nil
2239   "History of directory trees searched in this session.")
2240
2241 (defvar jde-find-regexp-history nil
2242   "History of search expressions used in this session.")
2243
2244 (defun jde-find-grep-internal (regexp files &optional dirs no-case grain)
2245   "Find a regular expression REGEXP in files of type FILES in
2246  DIRS, where DIRS is a string of space-separated paths of
2247 directories to search recursively. If NO-CASE is nonnil, ignore
2248 case. GRAIN is a string that indicates the granularity of the search,
2249 i.e., match any \"Character\" string, a \"Word\" only, or a \"Line\"
2250 only."
2251   (if (not (executable-find 
2252             ;; Hack required by faulty XEmacs implementation of executable-find.
2253             (if (eq system-type 'windows-nt) "grep.exe" "grep")))
2254       (error "This command requires the Unix grep utility."))
2255   (if (not (executable-find 
2256             (if (eq system-type 'windows-nt) "find.exe" "find")))
2257       (error (list "This command requires the Unix find utility.")))
2258   (let* ((directories-option
2259           (if dirs dirs "."))
2260          (case-sensitive-option 
2261           (if no-case  "-i" ""))
2262          (granularity-option
2263           (cond
2264            ((and grain (string= grain "Word"))
2265             "-w")
2266            ((and grain (string= grain "Line"))
2267             "-x")
2268            (t
2269             " ")))          
2270           (file-regexp-option 
2271            (mapconcat 
2272             (lambda (x) 
2273               (format "-name \"%s\"" x)) 
2274             files
2275             " -or "))
2276           (cmd 
2277            (format "find %s %s -type f | xargs grep %s %s -n \"%s\" /dev/null" 
2278                   directories-option
2279                   file-regexp-option
2280                   case-sensitive-option
2281                   granularity-option
2282                   regexp)))
2283     (grep cmd)))
2284
2285
2286 (defun jde-find (&optional regexp)
2287   "Find a regular expression REGEXP in all of the files in the
2288 current JDE project. Tests each of the following path variables
2289 `jde-sourcepath', `jde-compile-option-sourcepath',
2290 `jde-compile-option-classpath', or `jde-global-classpath' and uses the
2291 directories specified by the first path variable that has a nonnil
2292 value. The `jde-find-case-sensitive' variable controls case
2293 sensitivity, `jde-find-granularity' determines the granularity of the
2294 search (character, word, line), and `jde-find-file-regexp' determines
2295 the type of files to be searched. Use `jde-find-dlg' if you want to
2296 set case sensitivity, granularity, or file types interactively. This
2297 command requires that the Unix grep and find utilities be installed on
2298 your system in the Emacs command path. The Cygwin package contains
2299 Windows versions of both utilities."
2300   (interactive)
2301   (let ((regexp 
2302          (if (and (boundp 'regexp) regexp) 
2303              regexp
2304            (read-from-minibuffer 
2305             "Search for regexp: "
2306             (if (boundp 'jde-find-regexp-history) 
2307                 (car jde-find-regexp-history)
2308               nil)
2309             nil nil 'jde-find-regexp-history)))
2310         (search-path 
2311          (read-from-minibuffer 
2312            "Search directories: "
2313            (cons 
2314             (mapconcat 
2315              (lambda (x) x)
2316              (cond
2317               (jde-sourcepath
2318                (mapcar 
2319                 (lambda (path)
2320                   (jde-normalize-path path 'jde-sourcepath))
2321                 jde-sourcepath))
2322               (jde-compile-option-sourcepath 
2323                (mapcar 
2324                 (lambda (path)
2325                   (jde-normalize-path path 'jde-compile-option-sourcepath))
2326                 jde-compile-option-sourcepath))
2327               (jde-compile-option-classpath 
2328                (mapcar 
2329                 (lambda (path)
2330                   (jde-normalize-path path 'jde-compile-option-classpath))
2331                 jde-compile-option-classpath))
2332               (jde-global-classpath 
2333                (mapcar 
2334                 (lambda (path)
2335                   (jde-normalize-path path 'jde-global-classpath))
2336                 jde-global-classpath))
2337               (t
2338                (list default-directory)))       
2339              " ")
2340             0)
2341            nil nil 'jde-find-root-history)))
2342     (jde-find-grep-internal
2343      regexp
2344      jde-find-file-regexp
2345      search-path
2346      (not jde-find-case-sensitive)
2347      (car jde-find-granularity))))
2348
2349 (defun jde-find-dlg ()
2350   "Displays a dialog buffer that allows you to set all search options
2351 interactively. Pressing the dialog's OK button initiates the
2352 search. Use `jde-find' if you need to set only the expression to be
2353 found and the directories to be searched and prefer using the
2354 minibuffer."
2355   (interactive)
2356   (let ((dialog 
2357          (progn
2358            (if (not (oref 'jde-find-dialog the-dialog))
2359                (oset-default 'jde-find-dialog the-dialog (jde-find-dialog "find dialog")))
2360            (oref 'jde-find-dialog the-dialog))))
2361     (efc-dialog-show dialog)
2362     (when (oref dialog ok)
2363       (jde-find-grep-internal
2364        (oref dialog expression)
2365        (oref dialog files)
2366        (mapconcat
2367         'jde-normalize-path
2368         (oref dialog dirs)
2369         " ")
2370        (oref dialog ignore-case-p)
2371        (oref dialog grain)))))
2372
2373 (defun jde-create-prj-values-str ()
2374   "Create Java expression that updates the JDEE's class list
2375 to include all the classes on `jde-global-classpath', if
2376 defined, otherwise the classpath specified by the CLASSPATH
2377 environment variable."
2378   (let* ((directory-sep-char ?/)  ;; Override NT/XEmacs setting
2379          (classpath 
2380               (jde-build-path-arg nil (jde-get-global-classpath) t)))
2381     (format "jde.util.JdeUtilities.setProjectValues(\"%s\", %s);"
2382             jde-current-project 
2383             classpath)))
2384
2385 (defclass jde-bsh-buffer (bsh-comint-buffer) ()
2386   "JDEE's beanshell buffer")
2387
2388 (defmethod initialize-instance ((this jde-bsh-buffer) &rest fields)
2389   (oset this buffer-name "*JDEE bsh*")
2390   (call-next-method))
2391
2392 (defclass jde-bsh (bsh)
2393   ((bsh-cmd-dir      :initarg :bsh-cmd-dir
2394                      :type string
2395                      :documentation
2396                      "Path of the BeanShell commmand directory.")
2397
2398    (checkstyle-jar  :initarg :checkstyle-jar
2399                     :type string
2400                     :documentation
2401                     "Path of the Checkstyle jar.")
2402
2403    (regexp-jar      :initarg :regexp-jar
2404                     :type string
2405                     :documentation
2406                     "Path of the Jakarta regexp jar.")
2407
2408    (jde-jar         :initarg :jde-jar
2409                     :type string
2410                     :documentation
2411                     "Path of the JDEE jar.")
2412
2413    (jde-classes-dir :initarg :jde-classes-dir
2414                     :type string
2415                     :documentation
2416                     "Path of the JDEE classes directory.")
2417
2418
2419    (the-bsh        :type jde-bsh
2420                    :allocation :class
2421                    :documentation
2422                    "The single instance of the JDEE's BeanShell."))
2423   "Class of JDEE BeanShells. There is only one per Emacs session.")
2424
2425 (defmethod initialize-instance ((this jde-bsh) &rest fields)
2426   "Constructor for the JDEE BeanShell instance."
2427   (call-next-method)
2428   (let* ((jde-java-directory
2429           (concat
2430            (jde-find-jde-data-directory)
2431            "java/")))
2432
2433     (oset this bsh-cmd-dir (expand-file-name "bsh-commands" jde-java-directory))
2434     (oset this checkstyle-jar  (expand-file-name "lib/checkstyle-all.jar" jde-java-directory))
2435     (oset this regexp-jar (expand-file-name "lib/jakarta-regexp.jar" jde-java-directory))
2436     (oset this jde-classes-dir (expand-file-name "classes" jde-java-directory))
2437     (oset this jde-jar (expand-file-name "lib/jde.jar" jde-java-directory))
2438     (oset this jar  (expand-file-name "lib/bsh.jar" jde-java-directory))
2439     (oset-default 'jde-bsh the-bsh this)))
2440
2441 (defmethod bsh-create-buffer ((this jde-bsh))
2442   "Creates the JDEE's beanshell buffer."
2443   (oset this buffer (jde-bsh-buffer "JDEE bsh buffer")))
2444
2445 (defmethod bsh-build-classpath-argument ((this jde-bsh))
2446   (jde-build-classpath (oref this cp) 'jde-global-classpath t))
2447
2448 (defmethod bsh-launch :BEFORE ((this jde-bsh) &optional display-buffer)
2449   "Sets the vm and classpath to the vm and classpath for the current project before
2450 the PRIMARY launch method is invoked."
2451   (let* ((project-ant-home
2452           ;; Code referring to jde-ant variables uses symbols to
2453           ;; avoid causing compilation errors since jde-ant is not required.
2454           (jde-get-project 'jde-ant-home jde-current-project))
2455          (ant-home (if (and (boundp 'jde-ant-home)
2456                             (not (string= (symbol-value 'jde-ant-home) "")))
2457                        (symbol-value 'jde-ant-home)     ;jde-ant loaded
2458                      (if (and project-ant-home
2459                               (not (string= project-ant-home "")))
2460                          project-ant-home ; jde-ant not loaded but
2461                                         ; jde-ant-home set in project
2462                                         ; file
2463                        (getenv "ANT_HOME")))) ; jde-ant-home not set in
2464                                         ; project file and not
2465                                         ; customized
2466          )
2467
2468     (oset this vm (oref (jde-run-get-vm) :path))
2469     (oset  this  cp (delq
2470                      nil
2471                      (append
2472                       (list
2473                        (oref this jar)
2474                        (oref this bsh-cmd-dir)
2475                        (oref this checkstyle-jar)
2476                        (oref this regexp-jar)
2477                        (if jde-devel-debug
2478                            (oref this jde-classes-dir))
2479                        (oref this jde-jar)       
2480                        (jde-get-tools-jar)
2481                        (if ant-home (expand-file-name "lib" ant-home)))
2482                       (jde-pi-get-bsh-classpath)
2483                       (jde-expand-classpath (jde-get-global-classpath)))))))
2484
2485 ;; Create the BeanShell wrapper object.
2486 (jde-bsh "JDEE BeanShell")
2487
2488 (defun jde-bsh-running-p ()
2489   "Returns t if the JDEE's BeanShell instance is running."
2490   (bsh-running-p (oref 'jde-bsh the-bsh)))
2491
2492
2493 (defun jde-jeval (java-statement &optional eval-return)
2494   "Uses the JDEE's instance of the BeanShell
2495 Java interpreter to evaluate the Java expression EXPR.  If the
2496 BeanShell is not running, the JDEE starts an instance. This function
2497 returns any text output by the Java interpreter's standard out or
2498 standard error pipes.  If EVAL-RETURN is non-nil, this function
2499 returns the result of evaluating the Java output as a Lisp
2500 expression."
2501   (let ((the-bsh (oref 'jde-bsh the-bsh)))
2502    
2503     (when (not (bsh-running-p the-bsh))
2504       (bsh-launch the-bsh)
2505       (bsh-eval the-bsh (jde-create-prj-values-str)))
2506
2507     (bsh-eval the-bsh java-statement eval-return)))
2508
2509 (defun jde-jeval-r (java-statement)
2510   "Uses the JDEE's instance of the BeanShell to 
2511 evaluate JAVA-STATEMENT and then uses the Emacs Lisp
2512 interpreter to evaluate the result. This function
2513 is intended to be used to implement Emacs extensions
2514 coded in Java and executed by the BeanShell. The function 
2515 assumes that the Java extension interacts with Emacs
2516 by printing Lisp forms to the BeanShell's standard output \
2517 port."
2518   (jde-jeval java-statement t))
2519
2520
2521 (defun jde-jeval-cm (java-expr &optional buffer-head finish-fcn)
2522   "Evaluate JAVA-EXPR and display the result in a compilation-mode buffer.
2523 The optional argument BUFFER-HEAD specifies text to appear at the head of
2524 the compilation buffer. The optional argument FINISH-FCN specifies a
2525 function to be called when the compilation is finished. This function
2526 is intended to be used to invoke Java development utilities, such as 
2527 source code style checkers, that emit compiler-like error messages.
2528 Displaying the output in a compilation-mode buffer enables the user to
2529 use compilation-mode's error message navigation and hyperlinking 
2530 capabilities.
2531
2532 The following example uses this function to invoke the javac compiler on
2533 a file in the current directory:
2534
2535  (jde-bsh-compile-mode-eval \"jde.util.CompileServer.compile(\\\"Test.java\\\");\" 
2536    \"Compile Test.java\" 'jde-compile-finish-kill-buffer)"
2537   (let* ((buffer-obj (bsh-compilation-buffer "buffer"))
2538          (native-buf (oref buffer-obj buffer))
2539          (bufwin (display-buffer native-buf)))
2540
2541     (compilation-set-window-height bufwin)
2542
2543     (save-some-buffers (not compilation-ask-about-save) nil)
2544
2545     (if finish-fcn 
2546         (lexical-let ((finish finish-fcn))
2547           (setq compilation-finish-function 
2548                 (lambda (buf msg) 
2549                   (funcall finish buf msg)
2550                   (setq compilation-finish-function nil)))))
2551
2552
2553     (if (not (featurep 'xemacs))
2554         (if compilation-process-setup-function
2555           (funcall compilation-process-setup-function)))  
2556
2557
2558     (if (not (featurep 'xemacs))
2559         (if compilation-process-setup-function
2560           (funcall compilation-process-setup-function)))     
2561
2562
2563     (save-excursion
2564       (set-buffer native-buf)
2565
2566       (if buffer-head
2567           (insert buffer-head)
2568         (insert java-expr))
2569
2570       (insert "\n")
2571  
2572
2573       (if (not (jde-bsh-running-p))
2574           (progn
2575             (bsh-launch (oref 'jde-bsh the-bsh))
2576             (bsh-eval (oref 'jde-bsh the-bsh) (jde-create-prj-values-str))))
2577
2578
2579       (bsh-buffer-eval 
2580        (oref 'jde-bsh the-bsh)
2581        java-expr
2582        buffer-obj)
2583     
2584     (set-buffer-modified-p nil)  
2585     (setq compilation-last-buffer native-buf))))
2586
2587
2588 ;;;###autoload
2589 (defun jde-bsh-run()
2590   "*Starts the JDEE version of the BeanShell."
2591   (interactive)
2592   (bsh-launch (oref 'jde-bsh the-bsh) t))
2593
2594 (defun jde-bsh-exit ()
2595   "Closes the existing beanshell process"
2596   (interactive)
2597   (if (jde-bsh-running-p)
2598       (let ((process (bsh-get-process (oref 'jde-bsh the-bsh))))
2599         (if (and
2600              (boundp 'jde-ant-invocation-method) ;; ant package may not be loaded.
2601              (string= (car (symbol-value 'jde-ant-invocation-method)) "Ant Server"))
2602             (process-send-string process "jde.util.JdeUtilities.exit();\n")
2603           (process-send-string process "exit();\n")))
2604     (message "The beanshell is not running")))
2605
2606
2607 (defun jde-show-speedbar ()
2608   "Show the speedbar after first checking whether the correct
2609 version of speedar is installed."
2610   (interactive)
2611   (require 'speedbar)
2612   (speedbar-frame-mode))
2613     
2614 (defun jde-autoload-update ()
2615   "Updates autoload definitions in jde-autoload.el."
2616   (interactive)
2617   (let* ((default-directory (expand-file-name "lisp" (jde-find-jde-data-directory)))
2618          (generated-autoload-file (expand-file-name "jde-autoload.el" default-directory)))
2619     (mapc 'update-file-autoloads (directory-files "." nil "\\.el$"))
2620     (save-excursion
2621       (set-buffer  "jde-autoload.el")
2622       (save-buffer))
2623     (kill-buffer "jde-autoload.el")))
2624
2625
2626 (defun jde-browse-class-at-point ()
2627   "Displays the class of the object at point in the BeanShell Class
2628 Browser. Point can be in a variable name, class name, method name, or field name).
2629 This command has the  same requirements to work as the field/method-completion
2630 feature in JDE (see `jde-complete-at-point')."
2631   (interactive)
2632   (if (jde-open-functions-exist)
2633       (let* ((thing-of-interest (thing-at-point 'symbol))
2634              (pair (save-excursion (end-of-thing 'symbol)
2635                                    (jde-parse-java-variable-at-point)))
2636              (class-to-open (jde-open-get-class-to-open
2637                              pair thing-of-interest)))
2638         (if (and class-to-open (stringp class-to-open))
2639             (progn
2640               (bsh-eval
2641                (oref 'jde-bsh the-bsh)
2642                (concat "exploreClass(\"" class-to-open "\");")))
2643           (error "Can not parse the thing at point!")))
2644     (message "You need JDE >= 2.2.6 and Senator for using this feature!")))
2645
2646
2647 (eval-when-compile
2648   ;; This code will not appear in the compiled (.elc) file
2649   (defun jde-self-test () 
2650     "Runs jde self tests."
2651     (interactive)
2652     (require 'jde-junit)
2653     (jde-junit-self-test)
2654     (jde-dbs-self-test)))
2655
2656
2657 ;; This must come after all JDEE customization variables have been
2658 ;; defined.
2659 (jde-custom-adjust-groups)
2660
2661 (provide 'jde)
2662
2663 ;; Change History 
2664
2665 ;;
2666 ;; $Log: jde.el,v $
2667 ;; Revision 1.357.2.4  2006/03/09 04:19:37  paulk
2668 ;; Fix bug in jde-earlier-versionp.
2669 ;;
2670 ;; Revision 1.357.2.3  2006/03/01 04:11:03  paulk
2671 ;; Add support for Java annotations.
2672 ;;
2673 ;; Revision 1.357.2.2  2006/02/22 04:58:44  paulk
2674 ;; "Emacs 22 compatibility fix: fix max-lisp-eval-depth error caused by change in behavior of expand-file-name that breaks jde-root-dir-p. Thanks to Phillip Lord [Phillip.Lord@newcastle.ac.uk].
2675 ;;
2676 ;; Revision 1.357.2.1  2006/02/21 04:03:20  paulk
2677 ;; Update jde-earlier-versionp to handle cedet pre releases.
2678 ;;
2679 ;; Revision 1.357  2004/12/13 05:55:46  paulk
2680 ;; Updated submit problem report command to include an XEmac user's init.el file.
2681 ;;
2682 ;; Revision 1.356  2004/12/06 05:40:14  paulk
2683 ;; Moved jde-debugger-running-p package to jde-db.el.
2684 ;;
2685 ;; Revision 1.355  2004/11/12 12:19:03  paulk
2686 ;; Remove dead code. Thanks to Jason Rumney.
2687 ;;
2688 ;; Revision 1.354  2004/11/12 04:32:30  paulk
2689 ;; Update to reflect change of files menu to file menu. Thanks to Jason Rumney.
2690 ;;
2691 ;; Revision 1.353  2004/10/18 03:14:42  paulk
2692 ;; Bump version number. Add self-test infrastructure.
2693 ;;
2694 ;; Revision 1.352  2004/10/15 05:41:24  paulk
2695 ;; Bumped version number to 2.3.4beta7. Added Unit Test to JDE New menu.
2696 ;;
2697 ;; Revision 1.351  2004/10/11 03:35:43  paulk
2698 ;; Back out junit jar.
2699 ;;
2700 ;; Revision 1.350  2004/09/21 05:17:41  paulk
2701 ;; Created an Import submenu under the Code Generation menu. The submenu contains all import-related commands.
2702 ;;
2703 ;; Revision 1.349  2004/09/20 05:31:40  paulk
2704 ;; Changes needed to make restructured debugging code work for applets.
2705 ;;
2706 ;; Revision 1.348  2004/08/25 12:30:04  paulk
2707 ;; Add menu item to display Beanshell help.
2708 ;;
2709 ;; Revision 1.347  2004/07/06 01:49:28  paulk
2710 ;; Optionally enable jde-electric-return-mode when buffer is loaded.
2711 ;;
2712 ;; Revision 1.346  2004/06/23 04:40:39  paulk
2713 ;; Update to require cedet 1.0beta2.
2714 ;;
2715 ;; Revision 1.345  2004/06/07 15:28:43  paulk
2716 ;; Make jde-bsh-run autoloadable.
2717 ;;
2718 ;; Revision 1.344  2004/06/07 05:47:40  paulk
2719 ;; - Made jde-entering-java-buffer-hook non-customizable. This variable is part
2720 ;;   of the project-switching machinery and therefore should not itself be
2721 ;;   customizable.
2722 ;;
2723 ;; - Made various changes intended to make the JDEE's project-switching
2724 ;;   code more robust.
2725 ;;
2726 ;; Revision 1.343  2004/06/05 04:17:43  paulk
2727 ;; Change jde-submit-problem-report to report the cedet version.
2728 ;;
2729 ;; Revision 1.342  2004/06/03 12:56:45  paulk
2730 ;; Restore make-local-hook for post-command-hook. Needed for XEmacs compatibility. Thanks to David Ponce.
2731 ;;
2732 ;; Revision 1.341  2004/06/03 03:05:39  paulk
2733 ;; Change radio button items on JDE menu to toggle button items. Thanks to Jens Lautenbacher.
2734 ;;
2735 ;; Revision 1.340  2004/06/03 02:40:11  paulk
2736 ;; Add Remove item to Documentation submenu.
2737 ;;
2738 ;; Revision 1.339  2004/06/03 02:27:09  paulk
2739 ;; Check for cedet not installed. Thanks to David Ponce.
2740 ;;
2741 ;; Revision 1.338  2004/05/28 12:16:08  paulk
2742 ;; Change required package version checking to check for cedet instead of semantic/eieio.
2743 ;;
2744 ;; Revision 1.337  2004/05/16 04:26:08  paulk
2745 ;; Fix require order error.
2746 ;;
2747 ;; Revision 1.336  2004/05/16 04:22:49  paulk
2748 ;; Move custom-set-default definition before library requires.
2749 ;;
2750 ;; Revision 1.335  2004/05/16 03:23:52  paulk
2751 ;; Change call to jdw-wiz-tostring to jde-wiz-tostring.
2752 ;;
2753 ;; Revision 1.334  2004/05/14 03:24:01  paulk
2754 ;; - Compatibility fix to make cflow abbreviations work in XEmacs.
2755 ;;   Thanks to Martin Schwamberger.
2756 ;; - Provide a new JDE->Code Generation->Modes menu with items for
2757 ;;   enabling abbrev mode and electric return mode.
2758 ;;
2759 ;; Revision 1.333  2004/05/04 04:42:20  paulk
2760 ;; jde-init-abbrev-table gives t as expansion. This avoids downcasing of abbreviations used in comments. Thanks
2761 ;; to Martin Schwamberger.
2762 ;;
2763 ;; Revision 1.332  2004/05/03 02:39:02  paulk
2764 ;; Cosmetic change.
2765 ;;
2766 ;; Revision 1.331  2004/05/03 02:37:11  paulk
2767 ;; Adds toString method wizard to Wizards menu.
2768 ;;
2769 ;; Revision 1.330  2004/04/30 05:44:18  paulk
2770 ;; Add Electric Return item to the code generation menu.
2771 ;;
2772 ;; Revision 1.329  2004/04/29 02:39:52  paulk
2773 ;; Fix regressions caused by enhancement to jde-expand-directory.
2774 ;;
2775 ;; Revision 1.328  2004/03/21 03:24:57  paulk
2776 ;; Added jde-import-all to the JDEE menu and to the key binding table.
2777 ;;
2778 ;; Revision 1.327  2004/03/04 05:22:19  paulk
2779 ;; Update the jde-key-bindings variable to bind the Return key in Java buffers
2780 ;; to jde-gen-embrace, a function that closes the opening brace at point.
2781 ;;
2782 ;; Revision 1.326  2004/03/03 03:54:34  paulk
2783 ;; Moved project-related stuff to jde-project-file.el.
2784 ;;
2785 ;; Revision 1.325  2004/02/24 05:59:25  paulk
2786 ;; Adds support for customization variable enhancements.
2787 ;;
2788 ;; Revision 1.324  2004/02/09 06:48:41  paulk
2789 ;; Moved project-file code to a new package: jde-project-file.el.
2790 ;;
2791 ;; Revision 1.323  2004/02/02 07:25:53  paulk
2792 ;; Added a Bean item to the JDE NEW menu. The item creates a skeleton Java bean in a new buffer.
2793 ;;
2794 ;; Revision 1.322  2003/12/28 14:47:06  paulk
2795 ;; Semantic 2.0 compatibility fix.
2796 ;;
2797 ;; Revision 1.321  2003/11/29 05:28:26  paulk
2798 ;; Change abbreviation for throws from throw to thro to avoid inadvertent completion of throw to throws.
2799 ;;
2800 ;; Revision 1.320  2003/11/25 06:48:02  paulk
2801 ;; Fix regression that was causing abbrev-mode to be enabled for JDEE buffers even when jde-enable-abbrev-mode was set to nil. Also, enable abbrev-mode in all open JDEE buffers for the current project as a side effect of setting jde-enable-abbrev-mode on.
2802 ;;
2803 ;; Revision 1.319  2003/10/23 03:53:22  paulk
2804 ;; Added fix for compatibility with old versions of XEmacs. Thanks to Len Trigg.
2805 ;;
2806 ;; Revision 1.318  2003/10/14 05:07:40  paulk
2807 ;; jde-count-open-java-buffers now saves match data before doing a string-match. This fixes compatibility problem with emacs-w3m.
2808 ;;
2809 ;; Revision 1.317  2003/09/28 05:09:38  paulk
2810 ;; Created a new buffer-local variable, jde-buffer-project-file, that stores
2811 ;; the path of the project file for the current Java buffer. Updated
2812 ;; jde-get-current-project-buffers to use this variable to test whether
2813 ;; a given buffer is part of the current project. This should improve
2814 ;; the performance of this function and hence loading of project files,
2815 ;; which depends on it.
2816 ;;
2817 ;; Revision 1.316  2003/09/24 05:13:15  paulk
2818 ;; Changed jde-normalize-path to support use of relative paths in .emacs
2819 ;; files.  Previously, if a relative path appeared in a variable, e.g.,
2820 ;; jde-global-path, that was set for the current project by the user's
2821 ;; .emacs file (as opposed to a project file), jde-normalize-path would
2822 ;; resolve the variable relative to the source buffer directory. Now
2823 ;; jde-normalize-path resolves it relative to the location of the nearest
2824 ;; project file in the source buffer directory tree. If the directory
2825 ;; tree does not contain a project file, jde-normalize-path resolves the
2826 ;; path relative to the source buffer directory.
2827 ;;
2828 ;; Revision 1.315  2003/08/25 05:33:13  paulk
2829 ;; Added item to the Documentation submenu to display the Javadoc Tool Reference.
2830 ;;
2831 ;; Revision 1.314  2003/07/11 14:35:54  paulk
2832 ;; Makes jde-cygpath a noop if system-type is not cygwin.
2833 ;;
2834 ;; Revision 1.313  2003/07/08 05:54:16  paulk
2835 ;; Add documentation for jde-jeval- functions.
2836 ;;
2837 ;; Revision 1.312  2003/07/01 05:10:58  paulk
2838 ;; Adds a jde-bsh-compile-mode-eval function. This function
2839 ;; is intended to be used by plugins to invoke Java development
2840 ;; utilities, such as source code style checkers, that emit
2841 ;; compiler-like error messages.  Displaying the output in a
2842 ;; compilation-mode buffer enables the user to use compilation-mode's
2843 ;; error message navigation and hyperlinking capabilities.
2844 ;;
2845 ;; Revision 1.311  2003/06/26 05:36:13  paulk
2846 ;; Fix regression introduced by changes to jde-root-dir-p in previous version.
2847 ;;
2848 ;; Revision 1.310  2003/06/26 04:45:36  paulk
2849 ;; - Now requires jde-autoloads for XEmacs installations that use
2850 ;;   the independently distributed version of the JDEE rather than
2851 ;;   the version that is packaged with XEmacs.
2852 ;;
2853 ;; - Provides a workaround for a bug in file-exists-p in the cygwin
2854 ;;   version of XEmacs that prevented the JDEE from finding project
2855 ;;   files. The bug is that file-exists-p denies the existence of
2856 ;;   files whose native Windows paths (file-truename) end in a slash.
2857 ;;
2858 ;; Revision 1.309  2003/06/24 04:08:44  paulk
2859 ;; - Update jde-symbol-p to recognize variables defined by autoloaded packages
2860 ;;   that have not yet been loaded. Thanks to Martin Schwamberger.
2861 ;;
2862 ;; - Fix jde-compile-jde to compile jde-xemacs.el only on Xemacs.
2863 ;;
2864 ;; Revision 1.308  2003/06/18 10:49:20  paulk
2865 ;; Enhance jde-autoload-update to save and kill jde-autload.el buffer.
2866 ;;
2867 ;; Revision 1.307  2003/06/17 06:11:45  paulk
2868 ;; - Change JDE->Documentation->Generate to Generate All.
2869 ;; - Add JDE->Documentation->Generate Buffer.
2870 ;;
2871 ;; Revision 1.306  2003/05/03 09:01:55  paulk
2872 ;; Require jde-class package.
2873 ;;
2874 ;; Revision 1.305  2003/04/28 04:49:57  paulk
2875 ;; jde-mode now installs plugin menu if any plugins are installed on the user's system and the plugins have menus. beanshell startup now includes plugin classpaths in the beanshell classpath.
2876 ;;
2877 ;; Revision 1.304  2003/04/17 16:56:39  jslopez
2878 ;; Points C-c C-v C-k from jde-bsh to jde-bsh-run.
2879 ;;
2880 ;; Revision 1.303  2003/04/16 04:15:26  paulk
2881 ;; Restore require for jde-plugins package. This package is now in the CVS repository.
2882 ;;
2883 ;; Revision 1.302  2003/04/11 22:53:08  jslopez
2884 ;; Removes require clause for missing library, jde-plugins. It was
2885 ;; breaking the byte compilation.
2886 ;;
2887 ;; Revision 1.301  2003/04/09 04:03:23  paulk
2888 ;; Moved jde-find-jde-data-directory to jde-util package.
2889 ;;
2890 ;; Revision 1.300  2003/04/06 07:34:43  paulk
2891 ;; Renamed jde-bsh to jde-bsh-run to avoid conflict with class name.
2892 ;;
2893 ;; Revision 1.299  2003/03/28 05:33:30  andyp
2894 ;; XEmacs optimizations for JDEbug and efc.
2895 ;;
2896 ;; Revision 1.298  2003/03/04 10:15:07  paulk
2897 ;; Updated to use the new bsh-get-process method provided
2898 ;; by bsh to get its process. This is necessary to insulate
2899 ;; clients from the fact that bsh now uses a bsh-buffer
2900 ;; object to wrap the Emacs Lisp buffer object that specifies
2901 ;; the associated process.
2902 ;;
2903 ;; Revision 1.297  2003/02/25 16:00:30  jslopez
2904 ;; Fixes typo.
2905 ;;
2906 ;; Revision 1.296  2003/02/25 06:58:07  paulk
2907 ;; - Moved jde-debug command to jde-db.el and reimplemented it so that
2908 ;;   it works for both jdb and JDEbug.
2909 ;;
2910 ;; - Changing jde-mode-abbreviations now updates all the Java source
2911 ;;   buffers in the current project.
2912 ;;
2913 ;; Revision 1.295  2003/02/18 02:09:39  jslopez
2914 ;; Fixes regression bugs.
2915 ;;
2916 ;; Revision 1.294  2003/02/17 08:13:05  paulk
2917 ;; Changes required to support new package-independent version of beanshell.el
2918 ;;
2919 ;; Revision 1.293  2003/02/10 13:59:35  jslopez
2920 ;; Fixes regression bug. Readds jde-debug method.
2921 ;;
2922 ;; Revision 1.292  2003/01/27 06:36:55  paulk
2923 ;; jde-get-jdk-dir now uses javac instead of java as the JDK program to look
2924 ;; for when searching exec-path for the JDK. This eliminates false hits on
2925 ;; instances of java that were not installed as part of a JDK.
2926 ;;
2927 ;; Revision 1.291  2003/01/26 16:40:37  paulk
2928 ;; Fix jde-get-global-classpath to normalize the value of CLASSPATH using
2929 ;; the standard interpretation of the relative path character (.) rather
2930 ;; than the project-relative interpretation.
2931 ;;
2932 ;; Revision 1.290  2003/01/26 08:09:46  paulk
2933 ;; Fix to jde-create-prj-values-str to handle the case where the CLASSPATH
2934 ;; has backslashes. Thanks to Martin Schwamberger.
2935 ;;
2936 ;; Revision 1.289  2003/01/21 14:21:57  jslopez
2937 ;; Adds jde-gen-change-listener to the listeners submenu.
2938 ;;
2939 ;; Revision 1.288  2003/01/21 05:37:01  paulk
2940 ;; - Adds jde-browse-class-at-point command. This command displays
2941 ;;   the class at point in the BeanShell class browser.
2942 ;;
2943 ;; - Replaces Speedbar menu item with a Browse submenu
2944 ;;   containing the items Browse->Source and
2945 ;;   Browse->Class at Point. The first displays the
2946 ;;   speedbar. The second invokes the
2947 ;;   jde-browse-class-at-point command.
2948 ;;
2949 ;; Revision 1.287  2003/01/02 07:37:19  paulk
2950 ;; Fixed typo in binding for jde-jdb-menu-debug-applet.
2951 ;; Thanks to Matt Watson.
2952 ;;
2953 ;; Revision 1.286  2002/12/30 05:25:24  paulk
2954 ;; Minor tweaks for JDEE 2.3.2
2955 ;;
2956 ;; Revision 1.285  2002/12/26 06:43:49  paulk
2957 ;; - Removed the obsolete function jde-set-compiler.
2958 ;; - Fixed jde-set-global-classpath to set jde-global-classpath correctly.
2959 ;;
2960 ;; Revision 1.284  2002/12/21 08:58:36  paulk
2961 ;; Fix docstring for jde-global-classpath.
2962 ;;
2963 ;; Revision 1.283  2002/12/19 06:35:59  paulk
2964 ;; Changed to permit autoloading of jde-package.el file.
2965 ;;
2966 ;; Revision 1.282  2002/12/06 03:47:33  ahyatt
2967 ;; Changes to support Mac OS X, which does not use tools.jar
2968 ;;
2969 ;; Revision 1.281  2002/12/03 04:49:21  paulk
2970 ;; Fixes infinite recursion bug when a project file specifies
2971 ;; jde-ant-build as the jde-build-function.
2972 ;;
2973 ;; Revision 1.280  2002/11/30 04:48:10  paulk
2974 ;; Bumped revision number to 2.3.0.
2975 ;;
2976 ;; Revision 1.279  2002/11/27 06:06:09  paulk
2977 ;; Replaced the alias jde-javadoc-generate-javadoc-template with
2978 ;; its real name: jde-javadoc-autodoc-at-line.
2979 ;;
2980 ;; Revision 1.278  2002/11/26 06:11:37  paulk
2981 ;; Fixed regression bug introduced in JDEE 2.2.9.2 that caused symbols to
2982 ;; be listed more than once in the jde-symbol-list variable under some
2983 ;; circumstances. This in turn caused a symbol to be set multiple times
2984 ;; in a prj.el file.
2985 ;;
2986 ;; Revision 1.277  2002/11/25 04:56:34  paulk
2987 ;; Updated jde-create-prj-values-str to use the CLASSPATH environment variable if
2988 ;; jde-global-classpath is nil.
2989 ;;
2990 ;; Revision 1.276  2002/11/23 07:58:39  ahyatt
2991 ;; Display helpful error message when no correct mapping is found in the
2992 ;; jde-jdk-registry
2993 ;;
2994 ;; Revision 1.275  2002/11/22 07:44:44  paulk
2995 ;; Correct the docstring for jde-get-jdk-dir.
2996 ;;
2997 ;; Revision 1.274  2002/11/21 04:05:38  paulk
2998 ;; The following changes provide the infrastructure to ensure registration
2999 ;; and initialization of customization variables defined by autoloaded
3000 ;; JDEE packages:
3001 ;;   - Provide an argument to jde-symbol-list to force regeneration of the list.
3002 ;;   - Define jde-update-autoloaded-symbols function.
3003 ;;
3004 ;; Revision 1.273  2002/11/14 06:07:56  paulk
3005 ;; Bumped JDEE version to 2.2.9.1 to accommodate some minor bug fixes.
3006 ;;
3007 ;; Revision 1.272  2002/11/06 04:52:45  paulk
3008 ;; Fixed bug that I introduced into jde-get-jdk-prog.
3009 ;;
3010 ;; Revision 1.271  2002/11/05 07:27:55  paulk
3011 ;; Define jde-get-jdk-prog function. Thanks to Andrew Hyatt.
3012 ;;
3013 ;; Revision 1.270  2002/10/25 05:02:42  paulk
3014 ;; Use file-truename in jde-reload-project-file to eliminate symbolic links. Thanks to
3015 ;; "mark a. foltz" <mfoltz@ai.mit.edu>.
3016 ;;
3017 ;; Revision 1.269  2002/10/22 05:04:16  paulk
3018 ;; Remove require for jde-make package (now autoloaded) and add a menu item for displaying the jde-make customization buffer to the JDEE menu.
3019 ;;
3020 ;; Revision 1.268  2002/10/21 04:49:34  paulk
3021 ;; - Remove require for ant package. This package is now autloaded.
3022 ;; - Defer version checking for speedbar until it is used.
3023 ;;
3024 ;; Revision 1.267  2002/10/16 05:04:24  paulk
3025 ;; Fixes regression where the JDEE was not honoring jde-project-context-switching-enabled-p when loading Java files. Thanks to Andy Piper.
3026 ;;
3027 ;; Revision 1.266  2002/10/11 06:17:56  paulk
3028 ;; Use add-to-list instead of setq to add the jde to auto-mode-alist. This avoids multiple entries. Thanks to Klaus Berndl for suggesting this change.
3029 ;;
3030 ;; Revision 1.265  2002/10/11 05:53:19  paulk
3031 ;; Added more packages to the list of packages that are demand loaded. This is intended to reduce the startup time for the JDEE.
3032 ;;
3033 ;; Revision 1.264  2002/09/30 05:21:07  paulk
3034 ;; Removed require forms for the following packages: jde-ejb, jde-javadoc,
3035 ;; and jde-checkstyle. These packages are now loaded only if the user
3036 ;; access one of the commands that they define.
3037 ;;
3038 ;; Revision 1.263  2002/09/26 06:17:34  paulk
3039 ;; Added templates to the JDE New menu for creating EJB session and entity beans.
3040 ;; The templates were created by David T. Smith.
3041 ;;
3042 ;; Revision 1.262  2002/09/16 05:05:56  paulk
3043 ;; Cygwin Emacs compatibility fix. Check for Cygwin Emacs when processing paths. Thanks
3044 ;; to Klaus Berndl.
3045 ;;
3046 ;; Revision 1.261  2002/09/11 03:40:05  paulk
3047 ;; * Adds jde-devel-debug variable. This variable is intended to enable
3048 ;;   features that facilitate debugging the JDEE itself.
3049 ;;
3050 ;; * Bumps JDEE's version number 2.2.9beta12
3051 ;;
3052 ;; Revision 1.260  2002/09/06 12:58:05  paulk
3053 ;; Adds a Check Style command to the JDE menu. This command requires that
3054 ;; checkstyle-all.jar be in the JDEE's java/lib directory.
3055 ;;
3056 ;; Revision 1.259  2002/09/02 05:16:55  paulk
3057 ;; Fixed a bug in jde-normalize-path whereby it was expanding a relative path
3058 ;; even when jde-resolve-relative-paths-p was false.
3059 ;;
3060 ;; Revision 1.258  2002/08/30 20:58:26  jslopez
3061 ;; Adds key bindings for jde-gen-try-finally-wrapper, jde-gen-try-catch-wrapper,
3062 ;; jde-wiz-extend-abstract-class, and jde-wiz-override-method.
3063 ;;
3064 ;; Revision 1.257  2002/08/27 05:28:02  paulk
3065 ;; Fixed cygwin support bug in jde-root-dir-p. Thanks to Andy Piper.
3066 ;;
3067 ;; Revision 1.256  2002/08/07 06:36:14  paulk
3068 ;; Removed code intended to eliminate spurious warnings when byte-compiling the JDEE. The
3069 ;; removed code now resides in a separate package, jde-compat.el. Thanks to Andy Piper
3070 ;; for suggesting this restructuring. Also fixed a number of compiler warnings caused
3071 ;; by genuine bugs.
3072 ;;
3073 ;; Revision 1.255  2002/06/21 05:15:19  paulk
3074 ;; Conditioned the :set-after option out of jde-jdk for versions of Emacs
3075 ;; earlier than Emacs 21. This is so users will not need Emacs 21 to run
3076 ;; the JDEE. Thanks to YAMANO Yuji.
3077 ;;
3078 ;; Revision 1.254  2002/06/21 04:52:27  paulk
3079 ;; XEmacs compatibility fix: set directory sep character to be a forward slash
3080 ;; for project files. This fixes a project file save bug that corrupted
3081 ;; project files under some circumstances. Thanks to Hanson Char <HChar@realm.com>
3082 ;; for diagnosing this bug.
3083 ;;
3084 ;; Revision 1.253  2002/06/17 07:41:37  paulk
3085 ;; Updated version number.
3086 ;;
3087 ;; Revision 1.252  2002/06/17 07:24:07  paulk
3088 ;; Updated the JDEE's applet debugging command to
3089 ;; work with its new jdb interface.
3090 ;;
3091 ;; Revision 1.251  2002/06/12 06:58:42  paulk
3092 ;; XEmacs compatibility fix: removed unsupported :set-after clause from
3093 ;; the definition of jde-jdk. The result may be that JDK registry settings
3094 ;; may not persist in some cases on XEmacs. I will restore this clause
3095 ;; as soon as XEmacs supports it.
3096 ;;
3097 ;; Revision 1.250  2002/06/04 20:13:26  mnl
3098 ;; JDE menus are now defined by custom-variables. This allows especially
3099 ;; project specific menus that are automatically switched when changing
3100 ;; projects (as is usual with jde-... custom variables).
3101 ;;
3102 ;; Revision 1.249  2002/05/31 19:02:27  mnl
3103 ;; Added new template to generate a new interface from scratch.
3104 ;;
3105 ;; Revision 1.248  2002/05/29 04:47:30  paulk
3106 ;; jde-cygwin-path-converter-internal now substitutes forward slashes for
3107 ;; backslashes in paths returned by mswindows-cygwin-to-win32-path.
3108 ;;
3109 ;; Revision 1.247  2002/05/26 12:44:16  jslopez
3110 ;; Rebinds C-C C-v C-y from jde-show-class-source to
3111 ;; jde-open-class-at-point.
3112 ;;
3113 ;; Revision 1.246  2002/05/23 05:28:47  paulk
3114 ;; Patch jde-root-dir-p to support the Cygwin version of Xemacs 21.4.6, which
3115 ;; accepts native Windows path names. Thanks to Michael Lipp.
3116 ;;
3117 ;; Revision 1.245  2002/05/20 05:03:31  paulk
3118 ;; Used defcustom's :set-after option to specify that jde-jdk should be
3119 ;; set after jde-jdk-registry. This is necessary to prevent jde-jdk-registry
3120 ;; from resetting jde-jdk to the first registered jdk rather than the JDK
3121 ;; selected by the user.
3122 ;;
3123 ;; Revision 1.244  2002/05/11 23:02:40  jslopez
3124 ;; Removes control characters.
3125 ;;
3126 ;; Revision 1.243  2002/04/18 04:21:07  paulk
3127 ;; Rebound completion key bindings.
3128 ;;
3129 ;; Revision 1.242  2002/04/16 03:17:05  jslopez
3130 ;; Integrates jde-open-source.
3131 ;;
3132 ;; Revision 1.241  2002/04/15 02:59:28  jslopez
3133 ;; Updates jde-complete-select for jde-complete.
3134 ;;
3135 ;; Revision 1.240  2002/04/02 06:44:54  paulk
3136 ;; Rebinds C-v C-c C-. to jde-complete-select.
3137 ;;
3138 ;; Revision 1.239  2002/03/31 07:49:47  paulk
3139 ;; Renamed jde-db-source-directories. The new name is jde-sourcepath.
3140 ;;
3141 ;; Revision 1.238  2002/03/24 05:34:55  paulk
3142 ;; Patched jde-save-close-buffer and jde-save-variable to use find-buffer-visiting
3143 ;; to find the buffer containing the prj.elf file instead of looping through
3144 ;; the buffer list.
3145 ;;
3146 ;; Revision 1.237  2002/03/22 05:28:59  paulk
3147 ;; Updated doc for jde-build-function variable.
3148 ;; Updated my email address.
3149 ;;
3150 ;; Revision 1.236  2002/03/21 12:34:53  paulk
3151 ;; Fixes the jde-build-function variable to default to jde-make.
3152 ;;
3153 ;; Revision 1.235  2002/03/21 12:30:51  paulk
3154 ;; Removed jde-java-build-function. It never worked reliably.
3155 ;;
3156 ;; Revision 1.234  2002/03/12 04:40:44  paulk
3157 ;; Corrected minimum eieio version number.
3158 ;; Removed initarg for class slots to silence eieio warning.
3159 ;;
3160 ;; Revision 1.233  2002/03/12 04:14:12  paulk
3161 ;; Updated min and max version numbers for required packages.
3162 ;;
3163 ;; Revision 1.232  2002/03/05 10:30:32  paulk
3164 ;; Replaces jde-lib-directory-name with jde-lib-directory-names. Allows
3165 ;; you to specify multiple jar/zip directories in a classpath.
3166 ;;
3167 ;; Revision 1.231  2002/02/25 20:12:39  jslopez
3168 ;; Updates to reflect changes made to beanshell.el
3169 ;;
3170 ;; Revision 1.230  2002/02/21 05:32:04  paulk
3171 ;; Adds the following enhancements to the JDEE's expression
3172 ;; search functionality.
3173 ;;
3174 ;;   - A new customization variable, jde-find-granularity,
3175 ;;     that allows you to specify the granularity of the
3176 ;;     search (character, word, or line).
3177 ;;
3178 ;;   - A new command, JDE->Search->Expression... (jde-find-dlg),
3179 ;;     that allows you to set all search options interactively
3180 ;;     in a popup dialog buffer.
3181 ;;
3182 ;; Revision 1.229  2002/02/17 13:42:20  paulk
3183 ;; jde-submit-problem-report command now includes versions of required packages.
3184 ;;
3185 ;; Revision 1.228  2002/02/15 02:48:49  jslopez
3186 ;; Updates jde-jeval to pass accept 3 arguments.
3187 ;;
3188 ;; Revision 1.227  2002/01/22 05:38:28  paulk
3189 ;; - Bumped jde-version to 2.2.0beta9.
3190 ;; - Updated jde-semantic-min/max-version and eieio-min/max-version
3191 ;; - Modified jde-build function to use call-interactively to call
3192 ;;   the build function.
3193 ;;
3194 ;; Revision 1.226  2002/01/19 06:42:22  paulk
3195 ;; Minor updates.
3196 ;;
3197 ;; Revision 1.225  2002/01/18 12:49:42  paulk
3198 ;; Added a new hook, jde-project-hooks. This variable lists functions to be run
3199 ;; when the JDEE switches to a new project.
3200 ;;
3201 ;; Revision 1.224  2002/01/15 05:53:58  paulk
3202 ;; Now requires comint.
3203 ;; .
3204 ;; .
3205 ;; .
3206 ;; Old entries deleted to save space.
3207 ;;
3208 ;; Revision 1.8  1997/06/18 17:20:00  paulk
3209 ;; Initial checkin.
3210 ;;
3211
3212 ;; End of jde.el