DrJava

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » DrJava 
DrJava
License:
URL:http://drjava.org/
Description:DrJava is a lightweight development environment for writing Java programs.
Package NameComment
edu.rice.cs.drjava This is the top-level package for DrJava. It contains {@link edu.rice.cs.drjava.DrJava} as an entry point to the program and {@link edu.rice.cs.drjava.IndentFiles} as a command-line interface to the indenting algorithm.

It also contains bookkeeping classes, such as {@link edu.rice.cs.drjava.Version}, which holds the version number information, and {@link edu.rice.cs.drjava.CodeStatus}, which indicates whether the current build is Stable or Development. These classes are automatically generated by the build process and should not be manually modified.

edu.rice.cs.drjava.config This package contains the code that allows for dynamically modifying the configuration options in DrJava. {@link edu.rice.cs.drjava.config.Configuration} is the primary class that maintains the config information, while {@link edu.rice.cs.drjava.config.OptionConstants} contains all the default values for the configurable options.
edu.rice.cs.drjava.model The model package is responsible for the majority of the logic and state in DrJava. It is independent of the presentation, allowing different user interfaces to be created for the same codebase. The interfaces and classes in this package maintain the state of all open documents, interface to the compiler and interaction components, and communicate with the user interface through public methods and GlobalModelListeners.

GlobalModel's Role

The GlobalModel is the central point of DrJava, coordinating all components and communicating with the user interface.

To maintain state, the GlobalModel keeps a list of the OpenDefinitionsDocuments, each of which is responsible for its own DefinitionsDocument object and document specific actions on that object, such as saving and compiling.

The GlobalModel also provides a set of public methods which allow it to communicate with the user interface. This gives the ui package access to the OpenDefinitionsDocuments, compiler, console, and interactions code.

To keep the user interface up-to-date, the GlobalModel fires events to all GlobalModelListeners which have registered with it. Events are fired after actions which can affect the user interface, such as the opening, saving, and closing of files, or the starting and ending of compilation or interaction.

Subpackages

  • The compiler package provides an interface between the model and the available compilers, allowing DrJava to compile documents and maintain any errors produced as a result.
  • The definitions package provides the model of the documents and editor kit, as well as the reducedmodel package for lightweight representation of a document for easy parenthesis matching and similar syntactic features.
  • The repl package contains the classes used for the Interactions window, allowing the dynamic execution of Java code from within DrJava.

edu.rice.cs.drjava.model.cache

The idea behind this new interface is that the rest of the model should not talk directly to the document cache but rather to an adapter to the cache. For example, in the old implementation, when the OpenDefinitionsDocument needed to get the DefinitionsDocument, the code would look like this:

DefinitionsDocument getDocument() {
  ... 
  return _cache.get(this);
  ...
}

public boolean isModifiedSinceSave() { 
  if(_cache.isDDocInCache(this)){ 
    return getDocument().isModifiedSinceSave();
  }
  else{
    return false; 
  }
}

But now the code looks like this:

DefinitionsDocument getDocument() { 
  
... 
  return _cacheAdapter.getDocument(); 
  ...
}

public boolean isModifiedSinceSave() { 
  if(_cacheAdpater.isReady()){ 
     return getDocument().isModifiedSinceSave(); 
  }
  else{
     return false; 
  }
}

On the inside of the cache, these DCacheAdapters serve as managers for the instances of the DefinitionsDocuments. They are responsible for storing the unique reference to the document. The cache that created it keeps an LRU of these managers/adapters and tells the manager to discard its document if its place in the LRU has expired.

edu.rice.cs.drjava.model.compiler Contains adaptor code for invoking various Java compilers.
edu.rice.cs.drjava.model.debug Contains the code for DrJava's JPDA-based debugger.
edu.rice.cs.drjava.model.debug.jpda
edu.rice.cs.drjava.model.definitions Provides the data model for storing Java source code. The primary class here is {@link edu.rice.cs.drjava.model.definitions.DefinitionsDocument}. This is an extension of {@link javax.swing.text.PlainDocument} that contains a "reduced model", which allows the ability to match parentheses, do indentation, and highlight various kinds of text (syntactically) very efficiently. @see edu.rice.cs.drjava.model.definitions.reducedmodel
edu.rice.cs.drjava.model.definitions.indent Provides a decision tree used to correctly indent the current line.

The tree is composed of {@link edu.rice.cs.drjava.model.definitions.indent.IndentRule}s, and asks a series of yes or no questions about the current position before determining the appropriate action. All nodes use helper methods from {@link edu.rice.cs.drjava.model.definitions.DefinitionsDocument} and the {@link edu.rice.cs.drjava.model.definitions.reducedmodel Reduced Model} package for context.

The tree itself is built in the {@link edu.rice.cs.drjava.model.definitions.indent.Indenter} class, where a singleton instance is made available to DefinitionsDocument for using on a single line. An outline of the tree is given below.

  • 1. QuestionInsideComment
    • 2. Yes: QuestionPrevLineStartsComment
      • 3. Yes: QuestionCurrLineEmptyOrEnterPress
        Starting first line of a mutli-line comment
        • 4. Yes (no auto-close): ActionStartPrevLinePlus(" * ")
          Without auto-close comments, we always do the same thing.
        • 42. Yes (auto-close): QuestionFollowedByStar
          • 4. Yes: ActionStartPrevLinePlus(" * ")
            We are already inside a comment - no need to close it.
          • 41. No: ActionStartPrevLinePlusMultiline
                      (new String[] { " * \n", " */" }, 0, 3)
            We are starting a new block comment - close it.
        • 5. No: ActionStartPrevLinePlus(" ")
          Revisiting first line of a mutli-line comment
      • 6. No: QuestionPrevLineStartsWith("*")
        • 7. Yes: QuestionCurrLineStartsWith("*")
          • 8. Yes: ActionStartPrevLinePlus("") (Goto 12)
            Revisiting middle line of a mutli-line comment (with star)
          • 9. No: QuestionCurrLineEmptyOrEnterPress
            • 10. Yes: ActionStartPrevLinePlus("* ")
              Starting middle line of a mutli-line comment
            • 11. No: ActionStartPrevLinePlus("") (Goto 12)
              Revisiting middle line of a mutli-line comment (without star)
        • 12. No: ActionStartPrevLinePlus("")
          Following a line with no start in a mutli-line comment
    • 13. No: QuestionBraceIsParenOrBracket
      • 14. Yes: QuestionNewParenPhrase
        • 15. Yes: ActionBracePlus(" ")
        • 16. No: ActionBracePlus(" " + 1 level)
      • 17. No: QuestionBraceIsCurly
        • 18. Yes: QuestionCurrLineStartsWithSkipComments("}")
          • 19. Yes: ActionStartStmtOfBracePlus("")
          • 20. No: QuestionStartAfterOpenBrace
            • 21. Yes: ActionStartStmtOfBracePlus(1 level) (Goto 36)
            • 22. No: QuestionHasCharPrecedingOpenBrace
              • 23. Yes: ActionStartStmtOfBracePlus(1 level) (Goto 36)
              • 24. No: Goto 25.
        • 25. No: QuestionStartingNewStmt
          • 26. Yes: QuestionLineContains(":")
            • 27. Yes: QuestionExistsCharInStmt("?", ":")
              • 28. Yes: ActionStartPrevStmtPlus("", false) (Goto 30)
              • 29. No: ActionStartStmtOfBracePlus(1 level) (Goto 36)
            • 30. No: ActionStartPrevStmtPlus("", true)
          • 31. No: QuestionCurrLineStartsWithSkipComments("{")
            • 32. Yes: ActionStartCurrStmtPlus("")
            • 33. No: QuestionLineContains(":")
              • 34. Yes: QuestionExistsCharInStmt("?", ":")
                • 35. Yes: ActionStartCurrStmtPlus(1 level) (Goto 37)
                • 36. No: ActionStartStmtOfBracePlus(1 level)
              • 37. No: ActionStartCurrStmtPlus(1 level)

@see edu.rice.cs.drjava.model.definitions @see edu.rice.cs.drjava.model.definitions.reducedmodel

edu.rice.cs.drjava.model.definitions.reducedmodel This package contains the code for the "reduced model": a model of the text in the definitions pane designed for quickly locating matching parentheses, quotation marks, and comment delimiters.
edu.rice.cs.drjava.model.javadoc
edu.rice.cs.drjava.model.junit Contains the code for integration of the JUnit testing facility.
edu.rice.cs.drjava.model.print Provides the ability to print source code listed in the definitions pane.
edu.rice.cs.drjava.model.repl Contains the adapter code for the interpreter, as well as the code for managing the history of interactions, the handling of exceptions thrown by the interpreter, etc.
edu.rice.cs.drjava.model.repl.newjvm Manages the creation and invocation of the separate JVM used by the interactions pane.
edu.rice.cs.drjava.platform

This package provides a framework for abstracting platform-specific calls away from the platform-independent DrJava codebase. The main code tree contains platform-independent code to access and execute the platform-specific implementations, which are kept in separate code trees.

The PlatformSupport interface defines the calls which must be supported by all platform implementations. DefaultPlatform provides a platform-independent implementation. For convenience, all platform implementations extend DefaultPlatform, inheriting default implementations for all methods that are not tailored for that platform. PlatformFactory is a factory class which contains all logic for identifying the host platform and instantiating the appropriate PlatformSupport implementation. This is performed statically, and the result is stored as a singleton field for easy access. Client code can access platform-specific calls like so: PlatformFactory.ONLY.method(). PlatformFactory currently differentiates between Windows, Mac OS X, and the default platform. Note that in order to reference a new platform implementation, it must already be compiled and added to the classpath. The current platforms are built with special ant targets which add the class files to platforms.jar in the lib directory.

In order to add a new platform-specific feature to DrJava, you must follow these steps:

  1. Add a new method to PlatformSupport. Make sure it is properly documented.
  2. Provide a default implementation in DefaultPlatform. Often this will be an empty method body. Document why it does what it does (or doesn't).
  3. Privode a platform-specific implementation for the necessary platforms. Platforms which will use the default method do not need to be modified.
  4. Write a test case that reveals the platform-specific behavior, or ensures that all platforms produce expected results.
  5. Rebuild the modified platform code using the appropriate systems.

edu.rice.cs.drjava.project
edu.rice.cs.drjava.ui The ui package contains classes for the default user interface for DrJava. The interface allows multiple documents to be open, but requires that exactly one document is active at any time, since only one document is displayed in the GUI. This is enforced by subclassing the DefaultGlobalModel in the model package to add additional constraints to the logic and state of DrJava, while maintaining the separation from the pure user interface classes.

Additional Logic

The SingleDisplayModel is a subclass of DefaultGlobalModel, primarily providing the constraint that exactly one document is active at any time. It adds public methods for getting and setting the currently active document to the interface provided by GlobalModel, and fires a corresponding event through the SingleDisplayModelListener class, which is a subclass of GlobalModelListener.

Note that this behavior is not included in the DefaultGlobalModel because the notion of a single active document is specific to this user interface. Alternative GUIs might choose to display multiple documents simultaneously, eliminating the need for this additional constraint. Housing this logic in a subclass of DefaultGlobalModel, rather than in MainFrame itself, allows us to verify through unit tests that only one document can be active.

User Interface

The graphical user interface is implemented in Swing and is coordinated through the MainFrame class. The general layout and primary components of the interface are shown in the image below.

DrJava GUI

MainFrame

The MainFrame is the JFrame which houses all other components of the GUI. It is solely a means of displaying the state and logic kept within its SingleDisplayModel, and maintains as little state of its own as possible. The MainFrame consists of a JMenuBar containing the menus, current filename, and toolbar buttons, together with a collection of panes for displaying the various components of DrJava. These include a scrollable JList with the OpenDefinitionDocuments, a DefinitionsPane for displaying and editing the source code, and a tabbed pane at the bottom which houses the InteractionsPane, CompilerErrorPanel, and OutputPane.

In addition to setting up the GUI and passing action requests to the model, MainFrame is also responsible for listening to events fired by both the GlobalModel and the document itself, in order to keep the display current.

Other Components

  • The primary GUI component outside the MainFrame is the DefinitionsPane, which is a JEditorPane that is tied to a specific OpenDefinitionsDocument in the model. This pane handles all highlighting and text indenting for its document, as well as undoing actions specific to the document.
  • The InteractionsPane is held in the tabbed pane at the bottom of the interface and provides the actual interaction with the repl interpreter within the GlobalModel.
  • The CompilerErrorPanel is another tab in the tabbed pane, and contains both a JComboBox for selecting the compiler and an ErrorListPane for displaying all the errors from the most recent compilation, sorted by document. The ErrorListPane is an inner class of CompilerErrorPanel, and is responsible for highlighting errors in the list and in the source consistently.
  • The OutputPane is the third tab in the tabbed pane, and is simply where System.out and System.err are redirected when DrJava is run.
  • The FindReplaceDialog is a separate JDialog which handles the logic and state of finding and replacing text in the code, including highlighting and changing the source position as necessary. Only one FindReplaceDialog exists in the GUI, and it must be notified each time the active document is changed.

edu.rice.cs.drjava.ui.config Contains the GUI code for displaying and modifying configuration options.
edu.rice.cs.drjava.ui.predictive
edu.rice.cs.util A collection of utility classes and packages.
edu.rice.cs.util.classloader Some extensions of {@link java.lang.ClassLoader} for various purposes.
edu.rice.cs.util.docnavigation
edu.rice.cs.util.jar
edu.rice.cs.util.newjvm

This package is a system to allow the invocation and control of a new Java virtual machine. The two JVMs can communicate by using RMI.

To simply invoke a new JVM with no communications links, use the class {@link edu.rice.cs.util.newjvm.ExecJVM}. The rest of this page explains how to use this framework to create a new JVM and set up bidirectional communications using RMI. This system runs a second JVM using the same classpath as the current JVM (by invoking {@link edu.rice.cs.util.newjvm.ExecJVM#runJVMPropagateClassPath}).

  1. Create a remote interface that the master JVM will support, extending {@link edu.rice.cs.util.newjvm.MasterRemote}. This interface must specify of the methods that the slave JVM can call on the master JVM. All methods in this interface must be declared to throw {@link java.rmi.RemoteException.}
  2. Create a remote interface that the slave JVM will support, extending {@link edu.rice.cs.util.newjvm.SlaveRemote}. This interface must specify of the methods that the master JVM can call on the slave JVM. All methods in this interface must be declared to throw {@link java.rmi.RemoteException.}
  3. Create the master JVM implementation, which must extend {@link edu.rice.cs.util.newjvm.AbstractMasterJVM} and implement YourMasterInterface. Note that the super() call must pass to AbstractMasterJVM the fully-qualified class name of the slave JVM implementation.
  4. Create the slave JVM implementation, which must implement YourSlaveInterface. Don't forget to implement {@link edu.rice.cs.util.newjvm.SlaveRemote#quit()}, which is called when the main JVM requests the slave to quit, and {@link edu.rice.cs.util.newjvm.SlaveRemote#start(edu.rice.cs.util.newjvm.MasterRemote)}, which is called when the slave JVM is started.

Now you can create an instance of your master JVM class and use its {@link edu.rice.cs.util.newjvm.AbstractMasterJVM#invokeSlave()} method to start the slave JVM.

edu.rice.cs.util.sexp
edu.rice.cs.util.swing Some utility classes for working in Swing.
edu.rice.cs.util.text
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.