@@ -80,6 +80,9 @@ public class DrJava {
8080 * connecting to an already running instance. */
8181 static volatile boolean _forceNewInstance = false ;
8282
83+ /** true if the files that were specified on the command line contain project files */
84+ static volatile boolean _filesToOpenContainProjectFiles = false ;
85+
8386 /** Time in millisecond before restarting DrJava to change the heap size, etc. is deemed a success. */
8487 private static final int WAIT_BEFORE_DECLARING_SUCCESS = 5000 ;
8588
@@ -122,14 +125,10 @@ public static void main(final String[] args) {
122125 if (!_forceNewInstance &&
123126 DrJava .getConfig ().getSetting (edu .rice .cs .drjava .config .OptionConstants .REMOTE_CONTROL_ENABLED ) &&
124127 (_filesToOpen .size () > 0 )) {
125- // try {
126- // boolean ret = RemoteControlClient.openFile(null);
127- if (! RemoteControlClient .isServerRunning ()) {
128+ if (!RemoteControlClient .isServerRunning ()) {
128129 // server not running, display splash screen
129130 new SplashScreen ().flash ();
130131 }
131- // }
132- // catch(IOException ioe) { /* ignore */ }
133132 }
134133 else {
135134 // either forcing new instance or no files specified, display splash screen
@@ -300,6 +299,19 @@ else if (arg.equals("-help") || arg.equals("-?")) {
300299 else {
301300 // this is the first file to open, do not consume
302301 --argIndex ;
302+
303+ // check if any of the files to open is a project file
304+ _filesToOpenContainProjectFiles = false ;
305+ for (int tempIndex = argIndex ; tempIndex < len ; ++tempIndex ) {
306+ String currFileName = args [tempIndex ];
307+ boolean isProjectFile =
308+ currFileName .endsWith (OptionConstants .PROJECT_FILE_EXTENSION ) ||
309+ currFileName .endsWith (OptionConstants .PROJECT_FILE_EXTENSION2 ) ||
310+ currFileName .endsWith (OptionConstants .OLD_PROJECT_FILE_EXTENSION );
311+ _filesToOpenContainProjectFiles |= isProjectFile ;
312+ }
313+ // if a project file was specified, force a new instance
314+ if (_filesToOpenContainProjectFiles ) _forceNewInstance = true ;
303315 break ;
304316 }
305317 }
@@ -345,73 +357,6 @@ static void displayUsage() {
345357 System .out .println (" -D<name>[=<value>] set a Java property for the master DrJava JVM" );
346358 }
347359
348- // /** Prompts the user that the location of tools.jar needs to be specified to be able to use the compiler and/or the
349- // * debugger.
350- // * @param needCompiler whether DrJava needs tools.jar for a compiler
351- // * @param needDebugger whether DrJava needs tools.jar for the debugger
352- // */
353- // public static void promptForToolsJar(boolean needCompiler, boolean needDebugger) {
354- // File selectedFile = getConfig().getSetting(JAVAC_LOCATION);
355- // String selectedVersion = _getToolsJarVersion(selectedFile);
356- //
357- // final String[] text;
358- // if (selectedVersion==null) {
359- // text = new String[] {
360- // "DrJava cannot find a 'tools.jar' file for the version of Java ",
361- // "that is being used to run DrJava (Java version "+System.getProperty("java.version")+").",
362- // "Would you like to specify the location of the requisite 'tools.jar' file?",
363- // "If you say 'No', DrJava might be unable to compile or debug Java programs."
364- // };
365- // }
366- // else {
367- // text = new String[] {
368- // "DrJava cannot find a 'tools.jar' file for the version of Java ",
369- // "that is being used to run DrJava (Java version "+System.getProperty("java.version")+").",
370- // "The file you have selected appears to be for version "+selectedVersion+".",
371- // "Would you like to specify the location of the requisite 'tools.jar' file?",
372- // "If you say 'No', DrJava might be unable to compile or debug Java programs.)"
373- // };
374- // }
375- //
376- // int result = JOptionPane.showConfirmDialog(null, text, "Locate 'tools.jar'?", JOptionPane.YES_NO_OPTION);
377- //
378- // if (result == JOptionPane.YES_OPTION) {
379- // JFileChooser chooser = new JFileChooser();
380- // chooser.setFileFilter(new ClassPathFilter() {
381- // public boolean accept(File f) {
382- // if (f.isDirectory()) return true;
383- // String ext = getExtension(f);
384- // return ext != null && ext.equals("jar");
385- // }
386- // public String getDescription() { return "Jar Files"; }
387- // });
388- //
389- // // Loop until we find a good tools.jar or the user gives up
390- // do {
391- // if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
392- // File jar = chooser.getSelectedFile();
393- //
394- // if (jar != null) {
395- // // set the tools.jar property
396- // getConfig().setSetting(JAVAC_LOCATION, jar);
397- //
398- // // Adjust if we needed a compiler
399- // if (needCompiler && classLoadersCanFind(TEST_COMPILER_CLASS)) needCompiler = false;
400- //
401- // // Adjust if we need a debugger
402- // if (needDebugger && classLoadersCanFind(TEST_DEBUGGER_CLASS)) needDebugger = false;
403- // }
404- // }
405- //// Utilities.showDebug("need Compiler = " + needCompiler + "; needDebugger = " + needDebugger);
406- // }
407- // while ((needCompiler || needDebugger) && _userWantsToPickAgain());
408- //
409- // // Save config with good tools.jar if available
410- // if ((! needCompiler) && (! needDebugger)) _saveConfig();
411- // }
412- // }
413-
414-
415360 /** Switches the config object to use a custom config file. Ensures that Java source files aren't
416361 * accidentally used.
417362 */
0 commit comments