Source

jde / jde-gen.el

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

;; Author: Paul Kinnucan <paulk@mathworks.com>
;; Maintainer: Paul Kinnucan
;; Keywords: java, tools

;; Copyright (C) 1997, 1998 Paul Kinnucan.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;

(require 'tempo)

(defgroup jde-gen nil
  "JDE Autocoder"
  :group 'jde
  :prefix "jde-gen-")


(defun jde-gen-lookup-named (name)
  "Lookup some saved data under the name NAME.
Returns the data if NAME was found, and nil otherwise."
  (cdr (assq name tempo-named-insertions)))

(defun jde-gen-read-template (strings)
  "Converts an autocode template represented as a list
of strings to a list of Lisp objects as required by
tempo."
  (let ((template-string "")
	(n (length strings))
	(i 0))
    (while (< i n)
      (setq template-string
		  (concat template-string " " (nth i strings)))
      (setq i (1+ i)))
      (setq template-string
	    (concat "'(" template-string ")"))
      (eval (car (read-from-string template-string)))))

(defcustom jde-gen-buffer-boilerplate nil
"*Lines of boilerplate text to put at the head of a buffer template."
  :group 'jde-gen
  :type '(repeat (string :tag "Line")))

(defcustom jde-gen-boilerplate-function 'jde-gen-create-buffer-boilerplate
"*Specifes buffer boilerplate text function.
This variable specifies a function to create boilerplate text for
insertion at the head of Java source buffers generated by JDE
templates. The specified function should take no arguments and should
return a text string.  The default value is
`jde-gen-create-buffer-boilerplate', which returns the lines of text
specified by `jde-gen-buffer-boilerplate'."
  :group 'jde-gen
  :type 'function)

(defun jde-gen-create-buffer-boilerplate ()
"This function creates buffer boilerplate from the
variable `jde-gen-buffer-boilerplate."
  (if jde-gen-buffer-boilerplate
      (let ((bp "")
	    (n (length jde-gen-buffer-boilerplate))
	    (i 0))
	(while (< i n)
	  (setq bp
		(concat bp (elt jde-gen-buffer-boilerplate i) "\n"))
	  (setq i (1+ i)))
	bp)))

(defun jde-gen-get-super-class ()
  (let ((super-class (read-from-minibuffer "extends: "))
	(interface (read-from-minibuffer "implements: ")))
    (cond 
     ((and
       (not (string= super-class ""))
       (not (string= interface "")))
      (concat "extends " super-class "\n"
	      "  implements " interface))
     ((not (string= super-class ""))
      (concat "extends " super-class))
     ((not (string= interface ""))
      (concat "implements " interface)))))

(defcustom jde-gen-class-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 class \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\" \" (jde-gen-get-super-class) \" {\" 'n> 'n>"
    "\"public \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\"() {\" 'n>"
    "'p 'n>"
    "\"}\" 'n>"
    "'n>"
    "\"} // \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "'n>")
  "*Template for new Java class.
Setting this variable defines a template instantiation
command `jde-gen-class', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-class
	    (tempo-define-template "java-class-buffer-template"
		       (jde-gen-read-template val)
                       nil
                       "Insert a generic Java class buffer skeleton."))
	  (set-default sym val)))

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



(defcustom jde-gen-console-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 class \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\" {\" 'n> 'n>"
    "\"public \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\"() {\" 'n>"
    "'n>"
    "\"}\" 'n>"
    "'n>"
    "\"public static void main(String[] args) {\" 'n>"
    "'p 'n>"
    "\"}\" 'n> 'n>"
    "\"} // \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "'n>")
  "*Template for new Java console app main class buffer.
Setting this variable defines a template instantiation
command `jde-gen-console', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-console
	    (tempo-define-template "java-console-buffer-template"
		       (jde-gen-read-template val)
                       nil
                       "Insert skeleton for a new Java console buffer"))
	  (set-default sym val)))

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


(defcustom jde-gen-jfc-app-buffer-template
  '(
    "(funcall jde-gen-boilerplate-function) 'n"
    "\"import java.awt.*;\" 'n"
    "\"import java.awt.event.*;\" 'n"
    "\"import com.sun.java.swing.*;\" 'n '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 class \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\" extends JFrame {\" 'n> 'n>"

    ;; Constructor
    "\"public \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\"() {\" 'n>"
    "\"super(\\\"\" (P \"Enter app title: \") \"\\\");\" 'n>"
    "\"setSize(600, 400);\" 'n>"
    "\"addWindowListener(new WindowAdapter() {\" 'n>"
    "\"public void windowClosing(WindowEvent e) {System.exit(0);}\" 'n>"
    "\"public void windowOpened(WindowEvent e) {}});\" 'n>"
    "\"}\" 'n>"
    "'n>"

    ;; Main method
    "\"public static void main(String[] args) {\" 'n>"
    "'n>"
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\" f = new \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "\"();\" 'n>"
    "\"f.show();\" 'n>"
    "'p 'n>"
    "\"}\" 'n> 'n>"
    "\"} // \""
    "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
    "'n>")
  "*Template for JFC (Swing) application buffer.
Setting this variable defines a template instantiation
command `jde-gen-jfc-app', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-jfc-app
	    (tempo-define-template "java-jfc-app-buffer-template"
		       (jde-gen-read-template val)
                       nil
                       "Insert skeleton for a JFC app buffer"))
	  (set-default sym val)))

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


(defcustom jde-gen-buffer-templates 
  (list (cons "Class" 'jde-gen-class)
	(cons "Console" 'jde-gen-console)
	(cons "Swing App" 'jde-gen-jfc-app))
  "*Specifies available autocode templates for creating buffers.
The value of this variable is an association list. The car of
each element specifies the template's title. The cdr specifies 
a command that inserts the template into a buffer. See the function
`tempo-define-template' for any easy way to create a template
insertion command."
  :group 'jde-gen
  :type '(repeat
	  (cons :tag "Template"
	   (string :tag "Title")
	   (function :tag "Command")))
  :set '(lambda (sym val)
	  (let ((n (length val))
		(i 0))
	    (setq jde-gen-buffer-template-names (list))
	    (while (< i n)
	      (setq jde-gen-buffer-template-names
		    (append
		     jde-gen-buffer-template-names
		     (list (cons (car (nth i val)) (1+ i)))))
	      (setq i (1+ i))))
	  (set-default sym val)))

;;;###autoload
(defun jde-gen-buffer (template file)
  "Create a new Java buffer containing a code template.
This command inserts the specified template at the beginning
of the buffer."
  (interactive 
   (list (completing-read "Template: " jde-gen-buffer-template-names)
	 (read-file-name "File: ")))
  (find-file file)
  (funcall (cdr (assoc template jde-gen-buffer-templates)))
  (beginning-of-buffer)
  (search-forward "{")
  (backward-char 1)
  (c-indent-exp))

(defun jde-gen-init-cap (name)
  (concat (upcase (substring name 0 1)) (substring name 1)))

(defcustom jde-gen-get-set-var-template
  '(
    "'n>"
    "(P \"Variable type: \" type) \" \""
    "(P \"Variable name: \" name) \";\" 'n> 'n>"
    "\"/**\" 'n>"
    "\"* Get the value of \" (s name) \".\" 'n>"
    "\"* @return Value of \" (s name) \".\" 'n>"
    "\"*/\" 'n>"
    "\"public \" (s type) \" get\" (jde-gen-init-cap (jde-gen-lookup-named 'name))"
    "\"() {return \" (s name) \";}\" 'n> 'n>"
    "\"/**\" 'n>"
    "\"* Set the value of \" (s name) \".\" 'n>"
    "\"* @param v  Value to assign to \" (s name) \".\" 'n>"
    "\"*/\" 'n>"
    "\"public void set\" (jde-gen-init-cap (jde-gen-lookup-named 'name))"
    "\"(\" (s type) \"  v) {this.\" (s name) \" = v;}\" 'n>" 
    )
  "*Template for creating a get/set method pair.
Setting this variable defines a template instantiation
command `jde-gen-get-set', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-get-set
	    (tempo-define-template
	     "java-get-set-pair"
	     (jde-gen-read-template val)
	     nil
	     "Insert variable get-set method pair."))
	  (set-default sym val)))

(defcustom jde-gen-inner-class-template
  '(
    "'& \"class \" (P \"Class name: \" class)"
    "(P \"Superclass: \" super t)"
    "(let ((parent (jde-gen-lookup-named 'super)))"
        "(if (not (string= parent \"\"))"
           "(concat \" extends \" parent))) \" {\" 'n>"
    "\"public \" (s class) \"() {\" 'n> \"}\" 'n> \"}\" 'n>"
    )
"*Template that creates an empty private class at point."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-inner-class
	    (tempo-define-template
	     "java-inner-class"
	     (jde-gen-read-template val)
	     nil
	     "Insert inner class."))
	  (set-default sym val)))

(defcustom jde-gen-action-listener-template
  '(
    "'& (P \"Component name: \")"
    "\".addActionListener(new ActionListener() {\" 'n>" 
    "\"public void actionPerformed(ActionEvent e) {\" 'n>"
    "\"}});\" 'n>"
    )
  "*Template for generating an action listener.
Setting this variable defines a template instantiation
command, `jde-gen-action-listener', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-action-listener
	    (tempo-define-template
	     "java-action-listener"
	     (jde-gen-read-template val)
	     nil
	     "Insert skeleton action listener."))
	  (set-default sym val)))

(defcustom jde-gen-window-listener-template
  '(
    "'& (P \"Window name: \")"
    "\".addWindowListener(new WindowAdapter() {\" 'n>"
    "\"public void windowActivated(WindowEvent e) {}\" 'n>"
    "\"public void windowClosed(WindowEvent e) {}\" 'n>"
    "\"public void windowClosing(WindowEvent e) {System.exit(0);}\" 'n>"
    "\"public void windowDeactivated(WindowEvent e) {}\" 'n>"
    "\"public void windowDeiconified(WindowEvent e) {}\" 'n>"
    "\"public void windowIconified(WindowEvent e) {}\" 'n>"
    "\"public void windowOpened(WindowEvent e) {}});\" 'n>"
    )
  "*Template for generating a window listener.
Setting this variable defines a template instantiation
command, `jde-gen-window-listener', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-window-listener
	    (tempo-define-template
	     "java-window-listener"
	     (jde-gen-read-template val)
	     nil
	     "Insert skeleton window listener."))
	  (set-default sym val)))



(defcustom jde-gen-mouse-listener-template
  '(
    "'& (P \"Component name: \")"
    "\".addMouseListener(new MouseAdapter() {\" 'n>"
    "\"public void mouseClicked(MouseEvent e) {}\" 'n>"
    "\"public void mouseEntered(MouseEvent e) {}\" 'n>"
    "\"public void mouseExited(MouseEvent e) {}\" 'n>"
    "\"public void mousePressed(MouseEvent e) {}\" 'n>"
    "\"public void mouseReleased(MouseEvent e) {}});\" 'n>"
    )
  "*Template for generating a mouse listener.
Setting this variable defines a template instantiation
command, `jde-gen-mouse-listener', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-mouse-listener
	    (tempo-define-template
	     "java-mouse-listener"
	     (jde-gen-read-template val)
	     nil
	     "Insert skeleton mouse listener."))
	  (set-default sym val)))

(defcustom jde-gen-mouse-motion-listener-template
  '(
    "'& (P \"Component name: \")"
    "\".addMouseMotionListener(new MouseMotionAdapter() {\" 'n>"
    "\"public void mouseDragged(MouseEvent e) {}\" 'n>"
    "\"public void mouseMoved(MouseEvent e) {}});\" 'n>"
    )
  "*Template for generating a mouse listener.
Setting this variable defines a template instantiation
command, `jde-gen-mouse-motion-listener', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-mouse-motion-listener
	    (tempo-define-template
	     "java-mouse-motion-listener"
	     (jde-gen-read-template val)
	     nil
	     "Insert skeleton mouse motion listener."))
	  (set-default sym val)))



(defcustom jde-gen-to-string-method-template
  '(
    "'&"
    "\"public String toString() {\" 'n>" 
    "\"return super.toString();\" 'n>"
    "\"}\" 'n>"
    )
  "*Template for generating a toString method.
Setting this variable defines a template instantiation
command, `jde-gen-to-string-method', as a side-effect."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-to-string-method
	    (tempo-define-template
	     "toString method"
	     (jde-gen-read-template val)
	     nil
	     "Insert skeleton toString method."))
	  (set-default sym val)))

(defcustom  jde-gen-println 
  '(
    "'&"
    "\"System.out.println(\" (P \"Print out: \") \");\" 'n>" 
   )
  "*Template for generating a System.out.println statement."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-println
	    (tempo-define-template
	     "println statement"
	     (jde-gen-read-template val)
	     nil
	     "Insert println statement."))
	  (set-default sym val)))

(defcustom  jde-gen-property-change-support 
  '(
    "'&"

    "\"protected PropertyChangeSupport pcs =  new PropertyChangeSupport(this);\" 'n>"


    "\"/**\" 'n>\"* Adds a PropertyChangeListener to the listener list.\" 'n>"
    "\"* The listener is registered for all properties.\" 'n>"
    "\"*\" 'n> \"* @param listener The PropertyChangeListener to be added\" 'n> \"*/\" 'n>"
    "\"public void addPropertyChangeListener(PropertyChangeListener listener) {\" 'n>"
    "\"pcs.addPropertyChangeListener(listener);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Removes a PropertyChangeListener from the listener list.\" 'n>"
    "\"* This removes a PropertyChangeListener that was registered for all properties.\" 'n>"
    "\"*\" 'n> \"* @param listener The PropertyChangeListener to be removed\" 'n> \"*/\" 'n>"
    "\"public void removePropertyChangeListener(PropertyChangeListener listener) {\" 'n>"
    "\"pcs.removePropertyChangeListener(listener);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Adds a PropertyChangeListener for a specific property.\" 'n>"
    "\"* The listener will be invoked only when a call on firePropertyChange\" 'n>"
    "\"* names that specific property.\" 'n>"
    "\"*\" 'n> \"* @param propertyName The name of the property to listen on\" 'n>"
    "\"* @param listener The PropertyChangeListener to be added\" 'n> \"*/\" 'n>"
    "\"public void addPropertyChangeListener(String propertyName,\" 'n>"
    "\"PropertyChangeListener listener) {\" 'n>"
    "\"pcs.addPropertyChangeListener(propertyName, listener);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Removes a PropertyChangeListener for a specific property.\" 'n>"
    "\"*\" 'n> \"* @param propertyName The name of the property that was listened on\" 'n>"
    "\"* @param listener The PropertyChangeListener to be removed\" 'n> \"*/\" 'n>"
    "\"public void removePropertyChangeListener(String propertyName,\" 'n>"
    "\"PropertyChangeListener listener) {\"  'n>"
    "\"pcs.removePropertyChangeListener(propertyName, listener);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Reports a bound property update to any registered listeners. \" 'n>"
    "\"* No event is fired if old and new are equal and non-null.\" 'n>"
    "\"*\" 'n> \"* @param propertyName The programmatic name of the property that was changed\" 'n>"
    "\"* @param oldValue The old value of the property\" 'n>"
    "\"* @param newValue The new value of the property.\" 'n> \"*/\" 'n>"
    "\"public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {\" 'n>"
    "\"pcs.firePropertyChange(propertyName, oldValue, newValue);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Reports a bound property update to any registered listeners. \" 'n>"
    "\"* No event is fired if old and new are equal and non-null.\" 'n>"
    "\"* This is merely a convenience wrapper around the more general\" 'n>"
    "\"* firePropertyChange method that takes Object values.\" 'n>"
    "\"* No event is fired if old and new are equal and non-null.\" 'n>"
    "\"*\" 'n> \"* @param propertyName The programmatic name of the property that was changed\" 'n>"
    "\"* @param oldValue The old value of the property\" 'n>"
    "\"* @param newValue The new value of the property.\" 'n> \"*/\" 'n>"
    "\"public void firePropertyChange(String propertyName, int oldValue, int newValue) {\" 'n>"
    "\"pcs.firePropertyChange(propertyName, oldValue, newValue);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Reports a bound property update to any registered listeners. \" 'n>"
    "\"* No event is fired if old and new are equal and non-null.\" 'n>"
    "\"* This is merely a convenience wrapper around the more general\" 'n>"
    "\"* firePropertyChange method that takes Object values.\" 'n>"
    "\"* No event is fired if old and new are equal and non-null.\" 'n>"
    "\"*\" 'n> \"* @param propertyName The programmatic name of the property that was changed\" 'n>"
    "\"* @param oldValue The old value of the property\" 'n>"
    "\"* @param newValue The new value of the property.\" 'n> \"*/\" 'n>"
    "\"public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {\" 'n>"
    "\"pcs.firePropertyChange(propertyName, oldValue, newValue);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Fires an existing PropertyChangeEvent to any registered listeners.\" 'n>"
    "\"* No event is fired if the given event's old and new values are equal and non-null. \" 'n>"
    "\"*\" 'n> \"* @param evt The PropertyChangeEvent object.\" 'n>\"*/\" 'n>"
    "\"public void firePropertyChange(PropertyChangeEvent evt) {\" 'n>"
    "\"pcs.firePropertyChange(evt);\" 'n> \"}\" 'n> 'n>"

    "\"/**\" 'n>\"* Checks if there are any listeners for a specific property.\" 'n>"
    "\"*\" 'n> \"* @param evt The PropertyChangeEvent object.\" 'n>"
    "\"* @return <code>true</code>if there are one or more listeners for the given property\" 'n>"
    "\"*/\" 'n>"
    "\"public boolean hasListeners(String propertyName) {\" 'n>"
    "\"return pcs.hasListeners(propertyName);\" 'n> \"}\" 'n> 'n>"
   )
  "*Template for adding property change support to a class."
  :group 'jde-gen
  :type '(repeat string)
  :set '(lambda (sym val)
	  (defalias 'jde-gen-property-change-support
	    (tempo-define-template
	     "property change support template"
	     (jde-gen-read-template val)
	     nil
	     "Insert property change support template."))
	  (set-default sym val)))

(defcustom jde-gen-code-templates 
  (list (cons "Get Set Pair" 'jde-gen-get-set)
	(cons "toString method" 'jde-gen-to-string-method)
	(cons "Action Listener" 'jde-gen-action-listener)
	(cons "Window Listener" 'jde-gen-window-listener)
	(cons "Mouse Listener" 'jde-gen-mouse-listener)
	(cons "Mouse Motion Listener" 'jde-gen-mouse-motion-listener)
	(cons "Inner Class" 'jde-gen-inner-class)
	(cons "println" 'jde-gen-println)
	(cons "property change support" 'jde-gen-property-change-support)
	)
  "*Specifies available autocode templates.
The value of this variable is an association list. The car of
each element specifies a template name. The cdr specifies 
a command that inserts the template into a buffer. See the function
`tempo-define-template' for any easy way to create a template
insertion command."
  :group 'jde-gen
  :type '(repeat
	  (cons :tag "Template"
	   (string :tag "Name")
	   (function :tag "Command")))
  :set '(lambda (sym val)
	  (let ((n (length val))
		(i 0))
	    (setq jde-gen-template-names (list))
	    (while (< i n)
	      (setq jde-gen-template-names
		    (append
		     jde-gen-template-names
		     (list (cons (car (nth i val)) (1+ i)))))
	      (setq i (1+ i))))
	  (set-default sym val)))

(defun jde-gen-code (name)
  "Insert the code template specified by NAME at point.
The template must be one of those specified by the
variable `jde-gen-code-templates'."
  (interactive
   (list
    (completing-read "Template name: " jde-gen-template-names)))
  (funcall (cdr (assoc name jde-gen-code-templates))))

(defun jde-gen-doc-method() 
  "Document method at point."
  (interactive) 
  (catch 'error
    (save-excursion
      (let* (start-of-function
	     start-of-function-name
	     start-of-arg-list
	     end-of-arg-list
	     start-of-function-body)

	(beginning-of-line)
	(setq start-of-function (point))

	(setq start-of-arg-list
	      (search-forward "(" nil t nil))

	(backward-char)
	(setq end-of-arg-list
	      (forward-list))

	(goto-char start-of-arg-list)
	(setq start-of-function-name
	      (search-backward " " nil t nil))

	(setq function-name
	      (buffer-substring start-of-function-name
				(- start-of-arg-list 1)))

	(message (concat "Arg list: "
			 (buffer-substring start-of-arg-list
					   (- end-of-arg-list 1))))

	(forward-line -1)
	(insert
	 (concat
	  "/**\n"
	  " *\n"
	  "**/"
	  ))

      ))))

(provide 'jde-gen)

;; $Log$
;; Revision 1.17  1998/09/16 22:55:51  paulk
;; Added template for Java bean property change support.
;;
;; Revision 1.16  1998/09/13 00:34:28  paulk
;; Added a template for generating a System.out.println statement.
;;
;; Revision 1.15  1998/07/22 00:28:04  paulk
;; Modified class buffer creation templates to use tempo-marks
;; to mark initial position for user to insert code. Thanks
;; to David Hull <david.hull@trw.com> for suggesting this.
;;
;; Revision 1.14  1998/07/06 06:39:42  paulk
;; class buffer template now prompts for super class and
;; interface
;;
;; Revision 1.13  1998/07/06 05:06:13  paulk
;; Added boilerlate to other buffer generation templates.
;;
;; Revision 1.12  1998/07/01 03:54:40  paulk
;; Added source file boilerplate support.
;;
;; Revision 1.11  1998/06/27 03:04:46  paulk
;; Fixed capitalization on get-set method pair. Thanks to Jere_McDevitt@HomeDepot.COM
;;
;; Revision 1.10  1998/06/17 03:49:21  paulk
;; Fixed bug that caused jfc-app to be generated instead of console app.
;; Added a mouse motion listener template.
;; Added a toString method template.
;;
;; Revision 1.9  1998/05/27 05:55:20  paulk
;; Added autoload comments.
;;
;; Revision 1.8  1998/05/27 05:51:20  paulk
;; *** empty log message ***
;;
;; Revision 1.7  1998/05/17 06:20:37  paulk
;; Added templates for a Swing application and an inner class.
;;
;; Fixed a bug in jde-gen-buffer
;;
;; Revision 1.6  1998/04/18 14:08:55  kinnucan
;; Fixes some bugs in the generated code.
;;
;; Revision 1.5  1998/04/10 02:55:00  kinnucan
;; * Updated some of the doc strings.
;;
;; Revision 1.4  1998/04/09 04:51:09  kinnucan
;; * Added the capability to define your own custom autocode templates.
;;   The facility consists of the following items:
;;
;;   - jde-gen-code-templates
;;
;;     Defines a list of templates for code inserted at point. The
;;     list by default contains the templates defined by the JDE.
;;     You can define your own templates and add them to the list,
;;     using the Emacs customization feature. See tempo.el for
;;     information on creating templates.
;;
;;   - jde-gen-buffer-templates
;;
;;     Defines a list of templates for code to be inserted in a
;;     newly created Java buffer.
;;
;;   - jde-gen-code (JDE->Generate->Custom)
;;
;;     This command inserts a specified code template at point.
;;
;;   - jde-gen-buffer (Files->JDE New->Custom)
;;
;;     This command creates the specified buffer and inserts
;;     a specified template at the beginning of the buffer.
;;
;; Revision 1.3  1998/04/08 04:38:16  kinnucan
;; * Provided each template variable with a set function that regenerates
;;   the corresponding template command whenever the template is changed.
;;
;; Revision 1.2  1998/04/06 03:47:20  kinnucan
;; * Added jde-gen-class-buffer and jde-gen-console-buffer functions.
;;
;; Revision 1.1  1998/04/01 05:33:43  kinnucan
;; Initial revision
;;

;; End of jde-gen.el