This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: importing java packages


> Feature request for your consideration:  import-java-package
> 
> (import-java-package <java.awt>)
> (import-java-package <javax.swing>)
> 
> ;; e.g.:
> (let* ((f (make <JFrame>))
>        (root :: <Container> (invoke f 'getContentPane)))
>   (invoke root 'setLayout <BorderLayout>)
>   (invoke root 'add
> 	  (make <JLabel> "hello")
> 	  (static-field <BorderLayout> 'CENTER)))
> 
> This would be exceptionally convenient for apps that make 
> heavy use of the Java APIs.  By importing a java package, all 
> the names from that package become available as types.

I completely agree with you. I use SWT a lot these days and having to write
all those namespace declarations is a pain.  That's why I wrote a few 
Kawa-specific extensions to  SchemeScript, my Scheme Eclipse plugin. 
These extensions make heavy use of the Eclipse JDT (Java Development 
Tools) to introspect all known classes (compiled and source). These
extensions are:

  - type name expansion: type the name of a class, then hit
ALT-CTRL-SHIFT-T.
    The type name is replaced by its fully-qualified name, enclosed in <>.
(*)

  - namespace expansion: type the name of a class, then hit
ALT-CTRL-SHIFT-N.
    The type name is replaced by a 'define-namespace' clause for the
corresponding
    class.

  - package expansion: type the name of a package, then hit
ALT-CTRL-SHIFT-P.
    The package name is replaced by 'define-namespace' clauses for all
public
    type names in the given package.

[The environment also keeps track of all Kawa module names and exported
symbols. 
Hitting CTR-SHIFT-M on a symbol defined in another module will automatically
add 
the corresponding 'require' clause (unless it is already there).]

(*) If the type name exists in several packages (like List), then you will
be asked to 
     select the appropriate package.

Regards, 

Dominique
The SchemeWay Project
http://schemeway.sourceforge.net





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]