edu.rice.cs.drjava
Class DrJava

java.lang.Object
  |
  +--edu.rice.cs.drjava.DrJava
All Implemented Interfaces:
OptionConstants

public class DrJava
extends Object
implements OptionConstants

Main class for DrJava.

Version:
$Id: DrJava.java,v 1.40 2002/09/06 05:37:04 csreis Exp $

Field Summary
private static FileConfiguration _config
          Configuration object with all customized and default values.
private static PrintStream _consoleErr
           
private static PrintStream _consoleOut
           
private static String[] _filesToOpen
           
private static PreventExitSecurityManager _manager
           
private static File _propertiesFile
          Properties file used by the configuration object.
 
Fields inherited from interface edu.rice.cs.drjava.config.OptionConstants
COMPILER_ERROR_COLOR, DEBUG_BREAKPOINT_COLOR, DEBUG_SHOW_THREADS, DEBUG_SOURCEPATH, DEBUG_STEP_DRJAVA, DEBUG_STEP_INTERPRETER, DEBUG_STEP_JAVA, DEBUG_THREAD_COLOR, DEFINITIONS_BACKGROUND_COLOR, DEFINITIONS_COMMENT_COLOR, DEFINITIONS_DOUBLE_QUOTED_COLOR, DEFINITIONS_KEYWORD_COLOR, DEFINITIONS_MATCH_COLOR, DEFINITIONS_NORMAL_COLOR, DEFINITIONS_NUMBER_COLOR, DEFINITIONS_SINGLE_QUOTED_COLOR, DEFINITIONS_TYPE_COLOR, EXTRA_CLASSPATH, FONT_DOCLIST, FONT_MAIN, FONT_TOOLBAR, HISTORY_MAX_SIZE, INDENT_LEVEL, INTERACTIONS_EXIT_PROMPT, JAVAC_ALLOW_ASSERT, JAVAC_LOCATION, JSR14_COLLECTIONSPATH, JSR14_LOCATION, KEY_BACKWARD, KEY_BEGIN_DOCUMENT, KEY_BEGIN_LINE, KEY_CLOSE_FILE, KEY_COMPILE, KEY_COMPILE_ALL, KEY_COPY, KEY_CUT, KEY_CUT_LINE, KEY_DEBUG_BREAKPOINT_TOGGLE, KEY_DEBUG_MODE_TOGGLE, KEY_DEBUG_RESUME, KEY_DEBUG_STEP_INTO, KEY_DEBUG_STEP_OUT, KEY_DEBUG_STEP_OVER, KEY_DELETE_NEXT, KEY_DELETE_PREVIOUS, KEY_DOWN, KEY_END_DOCUMENT, KEY_END_LINE, KEY_FIND_NEXT, KEY_FIND_REPLACE, KEY_FORWARD, KEY_GOTO_LINE, KEY_NEW_FILE, KEY_NEXT_DOCUMENT, KEY_NEXT_WORD, KEY_OPEN_FILE, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_PASTE, KEY_PREVIOUS_DOCUMENT, KEY_PREVIOUS_WORD, KEY_PRINT, KEY_PRINT_PREVIEW, KEY_QUIT, KEY_REDO, KEY_SAVE_FILE, KEY_SAVE_FILE_AS, KEY_SELECT_ALL, KEY_UNDO, KEY_UP, LINEENUM_ENABLED, mask, QUIT_PROMPT, RECENT_FILES, RECENT_FILES_MAX_SIZE, TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, WORKING_DIRECTORY
 
Constructor Summary
DrJava()
           
 
Method Summary
private static boolean _userWantsToPickAgain()
           
static void beginProgram(String[] args)
          Starts running DrJava.
static PrintStream consoleErr()
          Get the actual System.err stream.
static PrintStream consoleOut()
          Get the actual System.out stream.
static void disableSecurityManager()
           
(package private) static void displayUsage()
          Displays a usage message about the available options.
static void enableSecurityManager()
           
static FileConfiguration getConfig()
          Returns the configuration object with all customized and default values.
static File getPropertiesFile()
          Returns the properties file used by the configuration object.
static PreventExitSecurityManager getSecurityManager()
           
(package private) static boolean handleCommandLineArgs(String[] args)
          Handles any command line arguments that have been specified.
(package private) static void initConfig()
          Initializes the configuration object with the current notion of the properties file.
private static Method loadMainMethod()
          private static Class loadClass(ClassLoader cl, String name) { try { return cl.loadClass(name); } catch(Exception e) { System.err.println("Error in attempt to load "+name+" using "+cl); System.err.println(e.toString()); System.err.println(); System.err.println(); } return null; } private static void testCL(ClassLoader cl) { loadClass(cl,"edu.rice.cs.drjava.DrJava"); loadClass(cl,"com.sun.jdi.Bootstrap"); }
static void main(String[] args)
          Main method for DrJava.
(package private) static void openCommandLineFiles(MainFrame mf, String[] filesToOpen)
          Handle the list of files specified on the command line.
(package private) static void setPropertiesFile(String filename)
          Switches the config object to use a custom config file.
(package private) static void setupCompilerIfNeeded()
          Implements feature req #523222: Prompt user for compiler if none found.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

_consoleOut

private static final PrintStream _consoleOut

_consoleErr

private static final PrintStream _consoleErr

_manager

private static PreventExitSecurityManager _manager

_filesToOpen

private static String[] _filesToOpen

_propertiesFile

private static File _propertiesFile
Properties file used by the configuration object. Defaults to ".drjava" in the user's home directory.

_config

private static FileConfiguration _config
Configuration object with all customized and default values.
Constructor Detail

DrJava

public DrJava()
Method Detail

getPropertiesFile

public static File getPropertiesFile()
Returns the properties file used by the configuration object.

getConfig

public static FileConfiguration getConfig()
Returns the configuration object with all customized and default values.

main

public static void main(String[] args)
                 throws Throwable
Main method for DrJava. Uses a custom class loader to start the program.

loadMainMethod

private static Method loadMainMethod()
                              throws NoSuchMethodException,
                                     SecurityException
private static Class loadClass(ClassLoader cl, String name) { try { return cl.loadClass(name); } catch(Exception e) { System.err.println("Error in attempt to load "+name+" using "+cl); System.err.println(e.toString()); System.err.println(); System.err.println(); } return null; } private static void testCL(ClassLoader cl) { loadClass(cl,"edu.rice.cs.drjava.DrJava"); loadClass(cl,"com.sun.jdi.Bootstrap"); }

beginProgram

public static void beginProgram(String[] args)
Starts running DrJava. Not done in the actual main method so a custom class loader can be used.

handleCommandLineArgs

static boolean handleCommandLineArgs(String[] args)
Handles any command line arguments that have been specified.
Returns:
true if DrJava should load, false if not

displayUsage

static void displayUsage()
Displays a usage message about the available options.

setPropertiesFile

static void setPropertiesFile(String filename)
Switches the config object to use a custom config file. Ensures that Java source files aren't accidentally used.

initConfig

static void initConfig()
                throws IllegalStateException
Initializes the configuration object with the current notion of the properties file.
Throws:
IllegalStateException - if config has already been assigned

openCommandLineFiles

static void openCommandLineFiles(MainFrame mf,
                                 String[] filesToOpen)
Handle the list of files specified on the command line. Feature request #509701. If file exists, open it in DrJava. Otherwise, ignore it. Is there a better way to handle nonexistent files? Dialog box, maybe?

setupCompilerIfNeeded

static void setupCompilerIfNeeded()
Implements feature req #523222: Prompt user for compiler if none found.

_userWantsToPickAgain

private static boolean _userWantsToPickAgain()

getSecurityManager

public static PreventExitSecurityManager getSecurityManager()

enableSecurityManager

public static void enableSecurityManager()

disableSecurityManager

public static void disableSecurityManager()

consoleErr

public static PrintStream consoleErr()
Get the actual System.err stream.
Returns:
System.err

consoleOut

public static PrintStream consoleOut()
Get the actual System.out stream.
Returns:
System.out