WRIGHT STATE UNIVERSITY
Department of Computer Science
and Engineering
   CEG860 Winter 2009                                                                                                    Prasad

Java Programming (25 pts) (Due: February 28, 2008)


You are required to design and implement a Java class browser in this assignment, which will familiarize you with Java Swing APIs.   You are given a Java program, javaParseTag.jar, distributed as a jar-file, which when run on a Java 2 source file outputs a "tags" file containing a sequence of lines, each line containing a defined name and its "location" in the source file. 

    cmd> java -jar javaParseTag.jar SOURCE.java 

Specifically, each line of the output file contains the defined name and its kind, the enclosing name and its kind, and the line number in the source file where the definition appears, as shown below:

    <KIND> <NAME> IN <enclosing_KIND> <enclosing_NAME> AT <LINE-NUMBER>

 

KIND

enclosing_KIND

class package
nestedclass class
innerclass method
interface package
nestedinterface class
method class
method interface
variable class
localvariable method
parameter method

In order to simplify dealing with constructs that can contain nested blocks, an "endscope"-line is emitted when a method, class, innerclass, or nestedclass scope is exited. It is assumed that the entire program is defined in package anonymous.
 


1.  You are required to build a Java front-end using Swing that reads in a Java 2 source file, creates the corresponding tags file if necessary, and then displays a tree of defined names in the left pane and the source code in the right pane as illustrated by running the Java program javaIDEBrowser.jar. The GUI resulting from "self-application" is shown in the figure below. Furthermore, when a defined name in the left pane is double clicked, the right pane scrolls to the corresponding source line. Beyond this, you can add additional functionality and bells and whistles by attempting to mimic the general look and feel of the various IDEs on the market such as Visual Studio.NET, Eclipse, NetBeans, etc. (The demo included here is only for illustrative purposes; you are encouraged to improve upon it.) 

2. Incorporate multi-level undo-redo facility. Chapter 21 of Meyer's OOSC book (on pages: 695-718) describes the design of a general purpose undo-redo facility that can be incorporated into an interactive system (and explores the specifics in the context of text editor design).

 


                       

 


FYI: Practical Advice

cmd> java antlr.Tool javar.g
cmd> javac *.java
cmd> copy antlr.jar javaParseTag.jar
cmd> jar -umf Manifest javaParseTag.jar *.class

cmd> java -jar javaParseTag.jar SOURCE.java

The output can be redirected to SOURCE.tags.

cmd> javac -classpath .\javaParseTag.jar BrowseDefn.java

cmd> copy javaParseTag.jar javaIDEBrowser.jar

cmd> jar -umf Manifest1 javaIDEBrowser.jar *.class *.gif

cmd> java -jar javaIDEBrowser.jar SOURCE.java

        This command creates a sample IDE GUI that displays a tree of names defined in the source file in the left pane and the source text in the right pane. Observe that hovering over a name in the left pane briefly displays the line number where it is defined in the source file, double clicking the name causes the right pane to scroll to the appropriate definition, etc. (You can also use "Load File" menu option to load a file and construct the GUI, in case there are "transient" initialization problems.)


What to hand in?

    Turnin your solution program with its semi-formal functional requirement specification as a single jar archive plus a suitable Readme.txt by executing the following command on unixapps1.wright.edu:

    tcsh> /common/public/tkprasad/ceg860/turnin-pa2  <Jar-File>  Readme.txt

    Note that the jar file must include Java sources and class files that can be directly executable (without extraction).


T. K. Prasad   ( 12/04/2008 )