Hi everyone!

I have some enhancement suggestions. First, in the "Files | JDE New"
menu, there is no option for automatic generation of interfaces.
Ofcourse one could always generate a class and then modify it so it
becomes an interface, but after doing this a number of times, at least I
get fed up with it. ;)

So below I have included some code which adds the capability for
automatic generation of interfaces. Perhaps this will be included in the
next release?
Perhaps even the definition of the jde-new-buffer-menu menu should be
customizable?

-------------- jde.el ---------------------------
(defvar jde-new-buffer-menu
  (list
   "JDE New"
   ["Class..."         jde-gen-class-buffer t]
   ["Interface..."     jde-gen-interface-buffer t]
   ["Console..."       jde-gen-console-buffer t]
   ["Other..."         jde-gen-buffer t]
   )
  "Menu for creating new Java buffers.")
-------------- jde.el ---------------------------

-------------- jde-gen.el ---------------------------
(defun jde-gen-get-super-interface ()
  (let ((super-class (read-from-minibuffer "extends: "))
        )
    (cond 
     ((not (string= super-class ""))
      (concat "extends " super-class)))))

(defcustom jde-gen-interface-buffer-template
  '(
    "(funcall jde-gen-boilerplate-function) 'n"
    "\"/**\" 'n"
    "\" * \"" 
    "(file-name-nondirectory buffer-file-name) 'n"
    "\" *\" 'n"
    "\" *\" 'n"
    "\" * Created: \" (current-time-string) 'n"
    "\" *\" 'n"
    "\" * @author \" (user-full-name) 'n"
    "\" * @version\" 'n"
    "\" */\" 'n>"
    "'n>"
    "\"public interface \""
    "(file-name-sans-extension (file-name-nondirectory
buffer-file-name))"
    "\" \" (jde-gen-get-super-interface) \" {\" 'n> 'p 'n>"
    "\"} // \""
    "(file-name-sans-extension (file-name-nondirectory
buffer-file-name))"
    "'n>")
  "*Template for new Java interface.
Setting this variable defines a template instantiation
command `jde-gen-interface', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
          (defalias 'jde-gen-interface
            (tempo-define-template "java-interface-buffer-template"
                       (jde-gen-read-template val)
                       nil
                       "Insert a generic Java interface buffer
skeleton."))
          (set-default sym val)))

;;;###autoload
(defun jde-gen-interface-buffer (file)
  "Create a new Java buffer containing an interface of the same name.
This command inserts the class template generated by
`jde-gen-interface'.
It then moves the point to the location of the constructor."
  (interactive "F")
  (find-file file)
  (jde-gen-interface)
  (beginning-of-buffer)
  (search-forward "{")
  (backward-char 1)
  (c-indent-exp)
  (tempo-forward-mark))
-------------- jde-gen.el ---------------------------


My next improvement suggestion is this (I have just upgraded from JDE
2.1.4 to JDE 2.1.6.beta14 so I don't know if this has already been
implemented). When you work in a large project, and the project is run
within a large company like Ericsson, the package names tend to be quite
long, e.g. se.ericsson.rns.om.em.eem.pm.client.gui.management, and each
time you create a new class within a package you have to remember to add
a package statement at the top. It would be very nice if the autocoding
would add this package statement, for instance by using a variable
defining a package root and the directory where the new file is placed?


/John

-- 
LM/ERA/LVA/KD John Olsson  mailto:[EMAIL PROTECTED] 
   Ericsson Radio Systems AB, Box 1248, S-581 12 Linkoping
-------------------------------------------------------------
  Phone: +46 13 321070   ECN: 868 1070   Fax: +46 13 287370
-------------------------------------------------------------
I was doing object-oriented assembly when I was 1 year old...  
For some reason my mom insists on calling it "Playing with blocks"

Reply via email to