#acl YoonKyungKoo:read,write All:read

== JDEE Resources ==
 * [http://jdee.sunsite.dk/ JDEE Home]
 * [http://maven.apache.org/reference/plugins/jdee/index.html Maven JDEE Plugin]
 * [http://lists.gnu.org/archive/html/gnu-emacs-sources/2004-05/msg00032.html jde-maven.el]
 * http://homepages.cs.ncl.ac.uk/phillip.lord/download/emacs/jserial.el inserting serial version statement

== using unzip with JDEE in win32 ==
Should set archive-zip-use-pkzip to be nil before loading jde.
The order is important especially if the jde version is 2.3.5 or later

{{{#!cplusplus
;; should come before jde loaded
;; use unzip instead of pkunzip
(setq archive-zip-use-pkzip nil)

;; ...
;; ...
(require 'jde)
}}}

== My JDEE emacs lisp functions ==
{{{#!cplusplus
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ToString Wizard - yoonforh edition ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defcustom jde-wiz-tostring-sort-variables nil
  "*Specifies whether or not to sort the list of variables in the
  generated method or list them in the order defined in the file."
  :group 'jde-wiz
  :type 'boolean)

(defcustom jde-wiz-tostring-stringbuffer-size "100"
  "*Specifies the initial size of the StringBuffer used to create the
  result for the toString(). It is best to set this to a value large
  enough for most of your work to prevent expansion of the
  StringBuffer at runtime. You can always change the value in the
  generated code to a smaller or larger one as needed."
  :group 'jde-wiz-tostring
  :type 'string)

(defcustom jde-wiz-tostring-variable-separator "\", \""
  "*Specifies the string between each variable to separate them.
  Examples: 2 spaces (the default), a comma and a space, newline, or a
  method call (as long as the return value is a String).

  Note: Remember this must result in a String in Java!"
  :group 'jde-wiz-tostring
  :type 'string)

(defcustom jde-wiz-tostring-static-members nil
  "If on (nonnil), `jde-wiz-tostring' generates information of
 static members of the class in the current buffer."
  :group 'jde-wiz
  :type 'boolean)

(defun jde-wiz-tostring()
  "Generates a toString() method for tbe class at point. The method
returns a string comprising the values of the member variables defined
by the class. The string lists the variables in alphabetical
order if `jde-wiz-tostring-sort-variables' is on. The string uses the
string specified by `jde-wiz-tostring-variable-separator' to separate
the variables. The generated method uses a string buffer of the size
specified by `jde-wiz-tostring-stringbuffer-size' to build the string."
 (interactive)
 (let* ((class-name
  (jde-parse-get-unqualified-name
   (jde-parse-get-class-at-point)))
 (variables
  (semantic-find-nonterminal-by-token
   'variable
   (jde-wiz-get-class-parts
    class-name
    (semantic-find-nonterminal-by-token
     'type
     (semantic-bovinate-toplevel t)
     ))))
 (method
  (concat
   "/**\n"
   " * {@inheritDoc}\n"
   " */\n"
   "public String toString()"
   (if jde-gen-k&r " {\n" "\n{\n")
   "return \"" class-name "(")))

   (setq variables (jde-wiz-filter-variables-by-typemodifier variables))

   (if jde-wiz-tostring-sort-variables
       (setq variables (semantic-sort-tokens-by-name-increasing variables)))

   (setq size (length variables))

   (while variables
     (let* ((var (car variables))
    (name (semantic-token-name var)) ;;variable name
    (type (semantic-token-type var)) ;;variable type i.e. boolean
    (staticp
     (member "static"
      (semantic-token-variable-modifiers var))) ;;is it static
    (finalp
     (member "final"
                   (semantic-token-variable-modifiers var)))) ;;is it final

       (if (or (not staticp) jde-wiz-tostring-static-members)
    (if (> (length variables) 1)
        (setq method (concat method name " - \" + " name "\n+ \", "))
      (setq method
     (concat method name " - \" + " name "\n+ \")\";\n}\n")))
         (progn
           (setq size (- size 1))
           (if (= (length variables) 1)
               (setq method ;; remove preceding ", "
                     (concat (substring method 0 (- (length method) 2)) ")\";\n}\n"))
               )
           )
         )

       (setq variables (cdr variables))))
   (if (= size 0)
       (setq method
             (concat method ")\";\n}\n")))

   (insert method))

 (jde-wiz-indent (point)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; jde-wiz-constructor - by yoonforh ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun jde-wiz-constructor()
  "Generates a constructor() method for tbe class at point. The method
returns a string comprising the values of the member variables defined
by the class."
 (interactive)
 (let* ((class-name
  (jde-parse-get-unqualified-name
   (jde-parse-get-class-at-point)))
 (variables
  (semantic-find-nonterminal-by-token
   'variable
   (jde-wiz-get-class-parts
    class-name
    (semantic-find-nonterminal-by-token
     'type
     (semantic-bovinate-toplevel t)
     ))))
 (method
  (concat
   "public " class-name "("))
        (body)
        )

   (setq variables (jde-wiz-filter-variables-by-typemodifier variables))

   (if jde-wiz-tostring-sort-variables
       (setq variables (semantic-sort-tokens-by-name-increasing variables)))

   (setq size (length variables))

   (while variables
     (let* ((var (car variables))
    (name (semantic-token-name var)) ;;variable name
    (type (semantic-token-type var)) ;;variable type i.e. boolean
    (staticp
     (member "static"
      (semantic-token-variable-modifiers var))) ;;is it static
    (finalp
     (member "final"
                   (semantic-token-variable-modifiers var)))) ;;is it final

       (if (or (not staticp) jde-wiz-tostring-static-members)
           (progn
                   (if (> (length variables) 1)
                       (setq method (concat method type " " name ", "))
                     (setq method
                           (concat method type " " name (if jde-gen-k&r ") {\n" ")\n{\n")))
                     )
                   (setq body (concat body "this." name " = " name ";\n"))
                   ))
       (if staticp (setq size (- size 1)))
       (if finalp (setq size (- size 1)))

       (setq variables (cdr variables))))
   (if (= size 0)
       (setq method
             (concat method (if jde-gen-k&r ") {\n" ")\n{\n"))))
   (setq method
         (concat method body "}\n"))

   (insert method))

 (jde-wiz-indent (point)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; jde-wiz-log-method - by yoonforh ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun jde-wiz-log-method()
  "insert logger statement of a method or constructor"
  (interactive)
  (if (not (eq major-mode 'jde-mode))
      (error "Major mode must be 'jde-mode'"))
  (let ((found (jde-yoonforh-nonterminal-at-line)))
    (if (not found)
        (error "No tag found at point")
      (let* ((modifiers (semantic-tag-modifiers found))
            (type (semantic-tag-type found))
            (name (semantic-tag-name found))
            (arguments (semantic-tag-function-arguments found))
            (throws (semantic-tag-function-throws found))
        (string
  (concat
   "if (logger.isLoggable(Level.FINEST))"
   (if jde-gen-k&r " {\n" "\n{\n")
   "logger.finest(\""
          name
          "(")))

        (setq size (length arguments))

        (while arguments
          (let* ((arg (car arguments))
                 (name (semantic-tag-name arg)) ;;argument name
                 (type (semantic-tag-type arg)) ;;argument type i.e. boolean
                 )

            (if (> (length arguments) 1)
                (setq string (concat string name " - \" + " name " + \", "))
              (setq string
                    (concat string name " - \" + " name " + \")\");\n}\n\n")))

            (setq arguments (cdr arguments))))
        (if (= size 0)
            (setq string
                  (concat string ")\");\n}\n\n")))
        (insert string)
        ))

    (jde-wiz-indent (point))
    ))

(defun jde-yoonforh-nonterminal-at-line ()
  "Search the bovine table for the tag at the current line."
  (save-excursion
    ;; Preserve current tags when the lexer fails (when there is an
    ;; unclosed block or an unterminated string for example).
    (let ((semantic-flex-unterminated-syntax-end-function
           #'(lambda (syntax &rest ignore)
               (throw 'jde-yoonforh-flex-error syntax))))
      (catch 'jde-yoonforh-flex-error
        (semantic-fetch-tags))))
  (save-excursion
    ;; Move the point to the first non-blank character found. Skip
    ;; spaces, tabs and newlines.
    (beginning-of-line)
    (forward-comment (point-max))
    (semantic-current-tag)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; jde-wiz-logger-decl - by yoonforh ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun jde-wiz-logger-decl()
  "insert logger declaration statement of current class"
  (interactive)
  (if (not (eq major-mode 'jde-mode))
      (error "Major mode must be 'jde-mode'"))
  (let* ((class-name
  (jde-parse-get-unqualified-name
   (jde-parse-get-class-at-point)))
        (package (jde-wiz-get-package-name)))
    (progn
      (if (not package)
          (setq string (concat "private static Logger logger = Logger.getLogger(" class-name ".class.getName());\n\n"))
         (setq string (concat "private static final Logger logger = Logger.getLogger(\"" package "\");\n\n"))
;; (setq string (concat "private static Logger logger = Logger.getLogger(" class-name ".class.getPackage().getName());\n\n"))
        (insert string)
        (jde-wiz-indent (point))
      )
    ))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; jde-wiz-assign-args - by yoonforh ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun jde-wiz-assign-args()
  "insert assign statements for each args of a method or constructor"
  (interactive)
  (if (not (eq major-mode 'jde-mode))
      (error "Major mode must be 'jde-mode'"))
  (let ((found (jde-yoonforh-nonterminal-at-line)))
    (if (not found)
        (error "No tag found at point")
      (let* ((modifiers (semantic-tag-modifiers found))
            (type (semantic-tag-type found))
            (name (semantic-tag-name found))
            (arguments (semantic-tag-function-arguments found))
            (throws (semantic-tag-function-throws found)))
        (while arguments
          (let* ((arg (car arguments))
                 (name (semantic-tag-name arg)) ;;argument name
                 (type (semantic-tag-type arg)) ;;argument type i.e. boolean
                 )

            (insert (concat "this." name " = " name ";\n"))
            (setq arguments (cdr arguments))))
        ))

    (jde-wiz-indent (point))
    ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; jde-wiz-serial-ver - by yoonforh ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun jde-wiz-serial-ver()
  "insert serialver statement of current class"
  (interactive)
  (if (not (eq major-mode 'jde-mode))
      (error "Major mode must be 'jde-mode'"))
  (let* ((class-name
          (jde-parse-get-unqualified-name
           (jde-parse-get-class-at-point)))
         (package (jde-wiz-get-package-name))
         )
    (progn
      (setq serial-ver (jde-jeval
                        (concat "print(\" private static final long serialVersionUID = \" + java.io.ObjectStreamClass.lookup(Class.forName(\""
                                (if (not package)
                                    class-name
                                  (concat package "." class-name))
                                "\")).getSerialVersionUID() + \"L;\\n\");")
                        ))
      (if (= 0 (length serial-ver))
          (error "Cannot get serial version value")
        (insert serial-ver))
      (jde-wiz-indent (point))
      )
    )
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; jde-wiz-delegate-impl - by yoonforh ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun jde-wiz-delegate-impl()
  "insert impl delegate statement of a method or constructor"
  (interactive)
  (if (not (eq major-mode 'jde-mode))
      (error "Major mode must be 'jde-mode'"))
  (let ((found (jde-yoonforh-nonterminal-at-line)))
    (if (not found)
        (error "No tag found at point")
      (let* ((modifiers (semantic-tag-modifiers found))
             (method-type (semantic-tag-type found))
             (method-name (semantic-tag-name found))
             (arguments (semantic-tag-function-arguments found))
             (throws (semantic-tag-function-throws found))
             )
        (if (not (string= method-type "void"))
            (setq string (concat "return impl." method-name "("))
          (setq string (concat "impl." method-name "(")))

        (setq size (length arguments))

        (while arguments
          (let* ((arg (car arguments))
                 (name (semantic-tag-name arg)) ;;argument name
                 (type (semantic-tag-type arg)) ;;argument type i.e. boolean
                 )
            (if (> (length arguments) 1)
                (setq string (concat string name ", "))
              (setq string
                    (concat string name ");")))

            (setq arguments (cdr arguments))))
        (if (= size 0)
            (setq string
                  (concat string ");")))
        (insert string)
        ))

    (jde-wiz-indent (point))
    ))

(global-set-key [?\C-c?\C-v?l] 'jde-wiz-log-method)
(global-set-key [?\C-c?\C-v?s] 'jde-wiz-tostring)
(global-set-key [?\C-c?\C-v?a] 'jde-wiz-assign-args)
(global-set-key [?\C-c?\C-v?c] 'jde-wiz-constructor)
(global-set-key [?\C-c?\C-v?p] 'jde-wiz-logger-decl)
(global-set-key [?\C-c?\C-v?d] 'jde-wiz-delegate-impl)
}}}

== Binding for keymap jde-mode-map ==
As of JDEE 2.3.4

{{{
key binding
--- -------

<f4> html-script-release-region
C-c Prefix Command
/ c-electric-slash
* c-electric-star
, c-electric-semi&comma
DEL c-electric-backspace
C-d c-electric-delete-forward
TAB c-indent-command
ESC Prefix Command
) c-electric-paren
( c-electric-paren
: c-electric-colon
# c-electric-pound
; c-electric-semi&comma
} c-electric-brace
{ c-electric-brace

C-c C-v Prefix Command
C-c . c-set-style
C-c C-t c-toggle-auto-hungry-state
C-c C-s c-show-syntactic-information
C-c C-o c-set-offset
C-c C-d c-toggle-hungry-state
C-c C-c comment-region
C-c C-b c-submit-bug-report
C-c C-a c-toggle-auto-state
C-c C-\ c-backslash-region
C-c C-q c-indent-defun
C-c C-u c-up-conditional
C-c C-p c-backward-conditional
C-c C-n c-forward-conditional

ESC q c-fill-paragraph
ESC j c-indent-new-comment-line
ESC C-j c-indent-new-comment-line
ESC e c-end-of-statement
ESC a c-beginning-of-statement
ESC C-q c-indent-exp
ESC C-h c-mark-function

C-c C-v . jde-complete-in-line
C-c C-v C-. jde-complete
C-c C-v C-] jde-run-etrace-next
C-c C-v ESC jde-run-etrace-prev
C-c C-v z jde-import-all
C-c C-v t jde-gen-try-catch-wrapper
C-c C-v o jde-wiz-override-method
C-c C-v j jde-javadoc-autodoc-at-line
C-c C-v i jde-wiz-implement-interface
C-c C-v f jde-gen-try-finally-wrapper
C-c C-v e jde-wiz-extend-abstract-class
C-c C-v C-z jde-import-find-and-import
C-c C-v C-y jde-open-class-at-point
C-c C-v C-x jde-show-superclass-source
C-c C-v C-w jde-help-symbol
C-c C-v C-t jde-jdb-menu-debug-applet
C-c C-v C-s speedbar-frame-mode
C-c C-v C-r jde-run
C-c C-v C-q jde-wiz-update-class-list
C-c C-v C-p jde-save-project
C-c C-v C-n jde-help-browse-jdk-doc
C-c C-v C-l jde-gen-println
C-c C-v C-k jde-bsh-run
C-c C-v C-g jde-open-class-at-point
C-c C-v C-f jde-find
C-c C-v C-d jde-debug
C-c C-v C-c jde-compile
C-c C-v C-b jde-build
C-c C-v C-a jde-run-menu-run-applet
}}}