1 ;;; jde-plugins.el -- Support for JDEE plugins
2 ;; $Revision: 1.7 $ $Date: 2004/09/21 04:33:33 $
4 ;; Author: Paul Kinnucan <pkinnucan@attbi.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
8 ;; Copyright (C) 2003, 2004 Paul Kinnucan.
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)
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.
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.
32 (defcustom jde-plugins-directory (expand-file-name "plugins" (jde-root))
33 "Location of the JDEE's plugins directory."
37 (defclass jde-plugin ()
38 ((bsh-cp :initarg :bsh-cp
40 :documentation "Beanshell classpath for this plugin.")
41 (menu-spec :initarg :menu-spec
43 :documentation "Specifies menu for this plugin.")
48 "Installed plugins."))
52 (defun jde-pi-register (plugin)
53 "Register PLUGIN, which must be an object of
58 (cons plugin (oref 'jde-plugin plugins))))
61 (defun jde-pi-get-plugin-dir (plugin)
62 "Returns the path of the directory containing PLUGIN."
63 (expand-file-name plugin jde-plugins-directory))
66 (defun jde-pi-load-plugin (plugin)
67 "Loads the plugin named PLUGIN. This function assumes that the plugin resides
68 in a subdirectory of the JDEE's plugins directory named PLUGIN and that this
69 subdirectory contains a subdirectory name lisp that contains
70 a file named jde-PLUGIN.el. This function loads jde-PLUGIN.el."
71 (let* ((plugin-dir (expand-file-name plugin jde-plugins-directory))
72 (plugin-lisp-dir (expand-file-name "lisp" plugin-dir))
73 (plugin-lisp-package-name (concat "jde-" plugin))
74 (plugin-lisp-file-name (concat plugin-lisp-package-name ".el"))
79 (if (file-exists-p plugin-lisp-file)
81 (add-to-list 'load-path plugin-lisp-dir)
82 (require (intern plugin-lisp-package-name)))
83 (error "JDEE plugin Lisp file %s missing" plugin-lisp-file-name))))
86 (defun jde-pi-load-plugins ()
87 "Loads the plugins in the JDEE's plugins directory."
89 (if (file-exists-p jde-plugins-directory)
95 (let ((file-name (file-name-nondirectory file)))
97 (file-directory-p file)
98 (not (string= file-name "."))
99 (not (string= file-name ".."))
100 (not (string= file-name "CVS"))
101 (not (string= file-name "RCS")))
103 (directory-files jde-plugins-directory t)))))
104 (loop for plugin in plugins do
105 (jde-pi-load-plugin plugin)))))
107 (jde-pi-load-plugins)
109 (defun jde-pi-get-bsh-classpath ()
110 "Get the plugin directories and jar files to include in the Beanshell classpath."
111 (let ((plugins (oref 'jde-plugin plugins))
113 (loop for plugin in plugins do
114 (setq classpath (append classpath (oref plugin bsh-cp))))
118 (defun jde-pi-install-plugins ()
119 "This command installs any plugin distributables that it
120 finds in the JDEE's plugins directory. It assumes that
121 the distributables are in jar or zip format and that the
122 jar program is on the system path."
125 (assert (executable-find "jar") nil
126 "Cannot find the jar program on the system path.")
129 (directory-files jde-plugins-directory nil ".*[.]\\(zip\\|jar\\)")))
132 (let ((buf (get-buffer-create "*plugins*")))
133 (with-current-buffer buf
135 (insert "JDEE Plugin Installation Log")
137 (cd jde-plugins-directory)
138 (loop for zip-file in zip-files do
140 (shell-command-to-string
141 (concat "jar xvf " zip-file))))
143 (insert (format "Installing %s ..."
144 (file-name-sans-extension zip-file)))
147 (insert "\n\nInstallation complete"))))))
150 (defun jde-plugin-make-menu-spec ()
151 (if (oref 'jde-plugin plugins)
158 (oref plugin menu-spec))
159 (oref 'jde-plugin plugins))))))
161 (defvar jde-plugin-mode-map
162 (let ((km (make-sparse-keymap))
163 (menu-spec (jde-plugin-make-menu-spec)))
165 (easy-menu-define jde-plugin-menu km "JDEE Plugin Minor Mode Menu"
168 "Keymap for JDEE plugin minor mode.")
170 (defvar jde-plugin-minor-mode nil
171 "Non-nil if JDEE plugin minor mode is enabled.")
173 (make-variable-buffer-local 'jde-plugin-minor-mode)
175 (defun jde-plugin-minor-mode (&optional arg)
176 "Toggle JDEE plugin minor mode.
177 With prefix argument ARG, turn on if positive, otherwise off..
179 \\{jde-plugin-mode-map}"
181 (list (or current-prefix-arg
182 (if jde-plugin-minor-mode 0 1))))
184 (setq jde-plugin-minor-mode
187 (prefix-numeric-value arg)
189 (not jde-plugin-minor-mode)))
191 (if (featurep 'xemacs)
192 (let ((menu-spec (jde-plugin-make-menu-spec)))
194 (if jde-plugin-minor-mode
195 (easy-menu-add menu-spec jde-plugin-mode-map)
196 (easy-menu-remove menu-spec))))))
198 (semantic-add-minor-mode 'jde-plugin-minor-mode " plugin" jde-plugin-mode-map)
201 (provide 'jde-plugins)
206 ;; $Log: jde-plugins.el,v $
207 ;; Revision 1.7 2004/09/21 04:33:33 paulk
208 ;; Teach JDEE to ignore a CVS or RCS directory in the plugins directory.
210 ;; Revision 1.6 2004/02/21 07:59:20 paulk
211 ;; Fixed nasty bug in jde-pi-get-bsh-classpath.
213 ;; Revision 1.5 2003/06/21 09:01:43 paulk
214 ;; Fix typo. Thanks to Martin Schamberg.
216 ;; Revision 1.4 2003/06/18 05:05:30 paulk
217 ;; Fix bug in jde-plugin-minor-mode's menu-installing code for XEmacs.
219 ;; Revision 1.3 2003/06/09 05:45:26 paulk
220 ;; Test for nonexistence of plugins directory.
222 ;; Revision 1.2 2003/04/28 04:47:02 paulk
223 ;; Implemented installation of menus and beanshell classpath for plugins.
225 ;; Revision 1.1 2003/04/16 04:08:46 paulk
230 ;; End of jde-plugins.el