diff --git a/drjava/.classpath b/drjava/.classpath new file mode 100644 index 000000000..35fe83078 --- /dev/null +++ b/drjava/.classpath @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drjava/.gitignore b/drjava/.gitignore index 4c8e5864d..9ac7b4a64 100644 --- a/drjava/.gitignore +++ b/drjava/.gitignore @@ -1,3 +1,4 @@ drjava.jar classes/ +/bin/ diff --git a/drjava/.project b/drjava/.project new file mode 100644 index 000000000..4ec8e1aa9 --- /dev/null +++ b/drjava/.project @@ -0,0 +1,35 @@ + + + drjava + + + submit + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + ${java8-tools} + 2 + /home/dimalit/java/drjava_git/drjava/${java8-tools} + + + base + 2 + /home/dimalit/java/drjava_git/drjava/classes/base + + + src + 2 + /home/dimalit/java/drjava_git/drjava/src + + + diff --git a/drjava/GlobalModelJUnitTest.txt b/drjava/GlobalModelJUnitTest.txt new file mode 100644 index 000000000..a20b3e444 --- /dev/null +++ b/drjava/GlobalModelJUnitTest.txt @@ -0,0 +1,156 @@ +16 Feb 2017 14:33:20 GMT: Log 'GlobalModelJUnitTest.txt' opened: 16 Feb 2017 14:33:20 GMT with name /home/dimalit/java/drjava_git/drjava/GlobalModelJUnitTest.txt +16 Feb 2017 14:33:26 GMT: ----testResultOfNonPublicTestCase----- +16 Feb 2017 14:33:28 GMT: After test +16 Feb 2017 14:33:28 GMT: testResultOfNonPublicTestCase completed +16 Feb 2017 14:33:30 GMT: ----testJUnit4MultiTest----- +16 Feb 2017 14:33:32 GMT: errors: [] +16 Feb 2017 14:33:32 GMT: testJUnit4SMultiTest completed +16 Feb 2017 14:33:34 GMT: ----testRealError----- +16 Feb 2017 14:33:35 GMT: testRealError completed +16 Feb 2017 14:33:37 GMT: ----testNoJUnitErrors----- +16 Feb 2017 14:33:38 GMT: errors: class edu.rice.cs.drjava.model.junit.JUnitErrorModel: + +16 Feb 2017 14:33:38 GMT: testNoJUnitErrors completed +16 Feb 2017 14:33:40 GMT: ----testJUnit4NoTest----- +16 Feb 2017 14:33:42 GMT: after test +16 Feb 2017 14:33:42 GMT: testJUnit4NoTest completed +16 Feb 2017 14:33:43 GMT: ----testCorrectFilesAfterIncorrectChanges----- +16 Feb 2017 14:33:43 GMT: In testCorrectFilesAfterIncorrectChanges, DJTest.java = +import junit.framework.TestCase; class A { } class B /* with syntax error */ { public void foo(int x) { } } public class DJTest extends TestCase { public void testAB() { assertTrue("this is true", true); } } +16 Feb 2017 14:33:45 GMT: after test +16 Feb 2017 14:33:45 GMT: testCorrectFilesAfterIncorrectChanges completed +16 Feb 2017 14:33:47 GMT: ----testJUnit4TwoMethod1Test----- +16 Feb 2017 14:33:50 GMT: errors: [] +16 Feb 2017 14:33:50 GMT: testJUnit4TwoMethod1Test completed +16 Feb 2017 14:33:52 GMT: -----testUnsavedAndUnCompiledChanges----- +16 Feb 2017 14:33:52 GMT: Untitled file is named: (Untitled) +16 Feb 2017 14:33:52 GMT: Ordinary compile completed +16 Feb 2017 14:33:54 GMT: document changed; modifiedSinceSave = true +16 Feb 2017 14:33:55 GMT: JUnit completed +16 Feb 2017 14:33:55 GMT: after test +16 Feb 2017 14:33:55 GMT: testUnsavedAndUnCompiledChanges completed +16 Feb 2017 14:33:57 GMT: ----testNonTestCaseError----- +16 Feb 2017 14:33:59 GMT: after test +16 Feb 2017 14:33:59 GMT: testNonTestCaseError completed +16 Feb 2017 14:34:01 GMT: ----testNoClassFile----- +16 Feb 2017 14:34:03 GMT: after test +16 Feb 2017 14:34:03 GMT: testNoClassFile completed +16 Feb 2017 14:34:06 GMT: ----testOneJUnitError----- +16 Feb 2017 14:34:07 GMT: testOneJUnitError completed +16 Feb 2017 14:34:10 GMT: ----testElspethOneJUnitError----- +16 Feb 2017 14:34:11 GMT: testElspethOneJUnitError completed +16 Feb 2017 14:34:13 GMT: ----testInfiniteLoop----- +16 Feb 2017 14:34:14 GMT: Compilation of infinite loop completed +16 Feb 2017 14:34:14 GMT: CheckCompile completed +16 Feb 2017 14:34:14 GMT: Starting JUnit +16 Feb 2017 14:34:16 GMT: ResetDone +16 Feb 2017 14:34:16 GMT: after test +16 Feb 2017 14:34:16 GMT: Reached Test End +16 Feb 2017 14:34:16 GMT: testInfiniteLoop completed +16 Feb 2017 14:34:18 GMT: ----testJUnit4StyleTestWorks----- +16 Feb 2017 14:34:20 GMT: errors: [] +16 Feb 2017 14:34:20 GMT: ----testJUnit4StyleTestWorks completed +16 Feb 2017 18:02:36 GMT: Log 'GlobalModelJUnitTest.txt' opened: 16 Feb 2017 18:02:36 GMT with name /home/dimalit/java/drjava_git/drjava/GlobalModelJUnitTest.txt +16 Feb 2017 18:02:42 GMT: ----testResultOfNonPublicTestCase----- +16 Feb 2017 18:02:44 GMT: After test +16 Feb 2017 18:02:44 GMT: testResultOfNonPublicTestCase completed +16 Feb 2017 18:02:46 GMT: ----testJUnit4MultiTest----- +16 Feb 2017 18:02:47 GMT: errors: [] +16 Feb 2017 18:02:47 GMT: testJUnit4SMultiTest completed +16 Feb 2017 18:02:49 GMT: ----testRealError----- +16 Feb 2017 18:02:50 GMT: testRealError completed +16 Feb 2017 18:02:52 GMT: ----testNoJUnitErrors----- +16 Feb 2017 18:02:53 GMT: errors: class edu.rice.cs.drjava.model.junit.JUnitErrorModel: + +16 Feb 2017 18:02:53 GMT: testNoJUnitErrors completed +16 Feb 2017 18:02:55 GMT: ----testJUnit4NoTest----- +16 Feb 2017 18:02:56 GMT: after test +16 Feb 2017 18:02:56 GMT: testJUnit4NoTest completed +16 Feb 2017 18:02:58 GMT: ----testCorrectFilesAfterIncorrectChanges----- +16 Feb 2017 18:02:58 GMT: In testCorrectFilesAfterIncorrectChanges, DJTest.java = +import junit.framework.TestCase; class A { } class B /* with syntax error */ { public void foo(int x) { } } public class DJTest extends TestCase { public void testAB() { assertTrue("this is true", true); } } +16 Feb 2017 18:02:59 GMT: after test +16 Feb 2017 18:02:59 GMT: testCorrectFilesAfterIncorrectChanges completed +16 Feb 2017 18:03:00 GMT: ----testJUnit4TwoMethod1Test----- +16 Feb 2017 18:03:03 GMT: errors: [] +16 Feb 2017 18:03:03 GMT: testJUnit4TwoMethod1Test completed +16 Feb 2017 18:03:04 GMT: -----testUnsavedAndUnCompiledChanges----- +16 Feb 2017 18:03:04 GMT: Untitled file is named: (Untitled) +16 Feb 2017 18:03:04 GMT: Ordinary compile completed +16 Feb 2017 18:03:05 GMT: document changed; modifiedSinceSave = true +16 Feb 2017 18:03:05 GMT: JUnit completed +16 Feb 2017 18:03:05 GMT: after test +16 Feb 2017 18:03:05 GMT: testUnsavedAndUnCompiledChanges completed +16 Feb 2017 18:03:07 GMT: ----testNonTestCaseError----- +16 Feb 2017 18:03:08 GMT: after test +16 Feb 2017 18:03:08 GMT: testNonTestCaseError completed +16 Feb 2017 18:03:10 GMT: ----testNoClassFile----- +16 Feb 2017 18:03:11 GMT: after test +16 Feb 2017 18:03:11 GMT: testNoClassFile completed +16 Feb 2017 18:03:13 GMT: ----testOneJUnitError----- +16 Feb 2017 18:03:14 GMT: testOneJUnitError completed +16 Feb 2017 18:03:15 GMT: ----testElspethOneJUnitError----- +16 Feb 2017 18:03:17 GMT: testElspethOneJUnitError completed +16 Feb 2017 18:03:19 GMT: ----testInfiniteLoop----- +16 Feb 2017 18:03:20 GMT: Compilation of infinite loop completed +16 Feb 2017 18:03:20 GMT: CheckCompile completed +16 Feb 2017 18:03:20 GMT: Starting JUnit +16 Feb 2017 18:03:22 GMT: ResetDone +16 Feb 2017 18:03:22 GMT: after test +16 Feb 2017 18:03:22 GMT: Reached Test End +16 Feb 2017 18:03:22 GMT: testInfiniteLoop completed +16 Feb 2017 18:03:23 GMT: ----testJUnit4StyleTestWorks----- +16 Feb 2017 18:03:25 GMT: errors: [] +16 Feb 2017 18:03:25 GMT: ----testJUnit4StyleTestWorks completed +16 Feb 2017 18:13:06 GMT: Log 'GlobalModelJUnitTest.txt' opened: 16 Feb 2017 18:13:06 GMT with name /home/dimalit/java/drjava_git/drjava/GlobalModelJUnitTest.txt +16 Feb 2017 18:13:11 GMT: ----testResultOfNonPublicTestCase----- +16 Feb 2017 18:13:14 GMT: After test +16 Feb 2017 18:13:14 GMT: testResultOfNonPublicTestCase completed +16 Feb 2017 18:13:15 GMT: ----testJUnit4MultiTest----- +16 Feb 2017 18:13:17 GMT: errors: [] +16 Feb 2017 18:13:17 GMT: testJUnit4SMultiTest completed +16 Feb 2017 18:13:19 GMT: ----testRealError----- +16 Feb 2017 18:13:20 GMT: testRealError completed +16 Feb 2017 18:13:22 GMT: ----testNoJUnitErrors----- +16 Feb 2017 18:13:23 GMT: errors: class edu.rice.cs.drjava.model.junit.JUnitErrorModel: + +16 Feb 2017 18:13:23 GMT: testNoJUnitErrors completed +16 Feb 2017 18:13:24 GMT: ----testJUnit4NoTest----- +16 Feb 2017 18:13:25 GMT: after test +16 Feb 2017 18:13:25 GMT: testJUnit4NoTest completed +16 Feb 2017 18:13:27 GMT: ----testCorrectFilesAfterIncorrectChanges----- +16 Feb 2017 18:13:27 GMT: In testCorrectFilesAfterIncorrectChanges, DJTest.java = +import junit.framework.TestCase; class A { } class B /* with syntax error */ { public void foo(int x) { } } public class DJTest extends TestCase { public void testAB() { assertTrue("this is true", true); } } +16 Feb 2017 18:13:28 GMT: after test +16 Feb 2017 18:13:28 GMT: testCorrectFilesAfterIncorrectChanges completed +16 Feb 2017 18:13:30 GMT: ----testJUnit4TwoMethod1Test----- +16 Feb 2017 18:13:32 GMT: errors: [] +16 Feb 2017 18:13:32 GMT: testJUnit4TwoMethod1Test completed +16 Feb 2017 18:13:34 GMT: -----testUnsavedAndUnCompiledChanges----- +16 Feb 2017 18:13:34 GMT: Untitled file is named: (Untitled) +16 Feb 2017 18:13:34 GMT: Ordinary compile completed +16 Feb 2017 18:13:35 GMT: document changed; modifiedSinceSave = true +16 Feb 2017 18:13:35 GMT: JUnit completed +16 Feb 2017 18:13:35 GMT: after test +16 Feb 2017 18:13:35 GMT: testUnsavedAndUnCompiledChanges completed +16 Feb 2017 18:13:37 GMT: ----testNonTestCaseError----- +16 Feb 2017 18:13:38 GMT: after test +16 Feb 2017 18:13:38 GMT: testNonTestCaseError completed +16 Feb 2017 18:13:40 GMT: ----testNoClassFile----- +16 Feb 2017 18:13:41 GMT: after test +16 Feb 2017 18:13:41 GMT: testNoClassFile completed +16 Feb 2017 18:13:42 GMT: ----testOneJUnitError----- +16 Feb 2017 18:13:44 GMT: testOneJUnitError completed +16 Feb 2017 18:13:45 GMT: ----testElspethOneJUnitError----- +16 Feb 2017 18:13:47 GMT: testElspethOneJUnitError completed +16 Feb 2017 18:13:48 GMT: ----testInfiniteLoop----- +16 Feb 2017 18:13:49 GMT: Compilation of infinite loop completed +16 Feb 2017 18:13:49 GMT: CheckCompile completed +16 Feb 2017 18:13:49 GMT: Starting JUnit +16 Feb 2017 18:13:51 GMT: ResetDone +16 Feb 2017 18:13:51 GMT: after test +16 Feb 2017 18:13:51 GMT: Reached Test End +16 Feb 2017 18:13:51 GMT: testInfiniteLoop completed +16 Feb 2017 18:13:53 GMT: ----testJUnit4StyleTestWorks----- +16 Feb 2017 18:13:54 GMT: errors: [] +16 Feb 2017 18:13:54 GMT: ----testJUnit4StyleTestWorks completed diff --git a/drjava/lib/platform.jar b/drjava/lib/platform.jar index bcc0ab906..c21e11454 100644 Binary files a/drjava/lib/platform.jar and b/drjava/lib/platform.jar differ diff --git a/drjava/lib/platform.jar.orig b/drjava/lib/platform.jar.orig new file mode 100644 index 000000000..bcc0ab906 Binary files /dev/null and b/drjava/lib/platform.jar.orig differ diff --git a/drjava/lib/submit_client.jar b/drjava/lib/submit_client.jar new file mode 100755 index 000000000..08f36b135 Binary files /dev/null and b/drjava/lib/submit_client.jar differ diff --git a/drjava/lib/weblaf-complete-1.28.jar b/drjava/lib/weblaf-complete-1.28.jar new file mode 100644 index 000000000..860d0569f Binary files /dev/null and b/drjava/lib/weblaf-complete-1.28.jar differ diff --git a/drjava/src/edu/rice/cs/drjava/DrJavaRoot.java b/drjava/src/edu/rice/cs/drjava/DrJavaRoot.java index 5819ce1d4..ca00421c6 100644 --- a/drjava/src/edu/rice/cs/drjava/DrJavaRoot.java +++ b/drjava/src/edu/rice/cs/drjava/DrJavaRoot.java @@ -69,7 +69,7 @@ import static edu.rice.cs.plt.debug.DebugUtil.debug; /** Main class for DrJava. - * @version $Id: DrJavaRoot.java 5611 2012-07-25 15:03:33Z rcartwright $ + * @version $Id$ */ public class DrJavaRoot { /** Class to probe to see if the debugger is available */ @@ -98,6 +98,14 @@ public static void main(final String[] args) { // Platform-specific UI setup. PlatformFactory.ONLY.beforeUISetup(); +/* try { + Class.forName("com.alee.laf.WebLookAndFeel"); + javax.swing.UIManager.installLookAndFeel(new UIManager.LookAndFeelInfo("WebLookAndFeel", "com.alee.laf.WebLookAndFeel")); + } catch (ClassNotFoundException e) { + // TODO: better log message! + e.printStackTrace(); + } +*/ // Utilities.show("DrJavaRoot started with args = " + Arrays.toString(args)); // let DrJava class handle command line arguments if (!DrJava.handleCommandLineArgs(args)) { diff --git a/drjava/src/edu/rice/cs/drjava/config/FileConfiguration.java b/drjava/src/edu/rice/cs/drjava/config/FileConfiguration.java index dae62dbac..3ba293da8 100644 --- a/drjava/src/edu/rice/cs/drjava/config/FileConfiguration.java +++ b/drjava/src/edu/rice/cs/drjava/config/FileConfiguration.java @@ -78,7 +78,7 @@ public void saveConfiguration() throws IOException { */ public void saveConfiguration(final String header) throws IOException { FileOps.saveFile(new FileOps.DefaultFileSaver(file) { - public void saveTo(OutputStream os) throws IOException { saveConfiguration(os,header); } + public void saveTo(Writer wr) throws IOException { saveConfiguration(wr,header); } public boolean shouldBackup() { return false; } }); } diff --git a/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java b/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java index 397500e65..7325d36b5 100644 --- a/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java +++ b/drjava/src/edu/rice/cs/drjava/config/OptionConstants.java @@ -623,31 +623,25 @@ public static Vector vector(KeyStroke... ks) { public static final VectorOption KEY_GOTO_FILE = new VectorOption("key.goto.file", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_G, MASK|KeyEvent.SHIFT_MASK))); - - /** The key binding for goto this file. */ - public static final VectorOption KEY_GOTO_FILE_UNDER_CURSOR = - new VectorOption("key.goto.file.under.cursor", - new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0))); - + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_E, MASK))); + /** The key binding for open Javadoc. */ public static final VectorOption KEY_OPEN_JAVADOC = new VectorOption("key.open.javadoc", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F6, KeyEvent.SHIFT_MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK))); /** The key binding for open Javadoc under cursor. */ public static final VectorOption KEY_OPEN_JAVADOC_UNDER_CURSOR = new VectorOption("key.open.javadoc.under.cursor", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F6, MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F1, MASK))); /** The key binding for complete file. */ public static final VectorOption KEY_COMPLETE_FILE = new VectorOption("key.complete.file", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, MASK|KeyEvent.SHIFT_MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, MASK))); // /** The key binding for indenting */ // public static final VectorOption KEY_INDENT = @@ -671,13 +665,13 @@ public static Vector vector(KeyStroke... ks) { public static final VectorOption KEY_PREVIOUS_DOCUMENT = new VectorOption("key.previous.document", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, MASK))); /** The key binding for selecting next document */ public static final VectorOption KEY_NEXT_DOCUMENT = new VectorOption("key.next.document", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, MASK))); /** The key binding for changing the focus to the previous pane */ public static final VectorOption KEY_PREVIOUS_PANE = @@ -707,13 +701,13 @@ public static Vector vector(KeyStroke... ks) { public static final VectorOption KEY_BROWSE_FORWARD = new VectorOption("key.browse.forward", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ALT_MASK|SHIFT_MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ALT_MASK))); /** The key binding for jumping to the previous location in the browser history */ public static final VectorOption KEY_BROWSE_BACK = new VectorOption("key.browse.back", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ALT_MASK|SHIFT_MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ALT_MASK))); /** The key binding for going to the next region in the tabbed pane */ public static final VectorOption KEY_TABBED_NEXT_REGION = @@ -1042,31 +1036,31 @@ public static Vector vector(KeyStroke... ks) { public static final VectorOption KEY_DEBUG_RESUME = new VectorOption("key.debug.resume", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0))); /** The key binding for automatically tracing through each line of a program*/ public static final VectorOption KEY_DEBUG_AUTOMATIC_TRACE = - new VectorOption("key.debug.automatic.trace", - new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0))); + new VectorOption("key.debug.automatic.trace", + new KeyStrokeOption("",null), + to.vector()); /** The key binding for stepping into in the debugger */ public static final VectorOption KEY_DEBUG_STEP_INTO = new VectorOption("key.debug.step.into", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0))); /** The key binding for stepping over in the debugger. */ public static final VectorOption KEY_DEBUG_STEP_OVER = new VectorOption("key.debug.step.over", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0))); /** The key binding for stepping out in the debugger. */ public static final VectorOption KEY_DEBUG_STEP_OUT = new VectorOption("key.debug.step.out", new KeyStrokeOption("",null), - to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F12, SHIFT_MASK))); + to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_F7, SHIFT_MASK))); /** The key binding for toggling a breakpoint. */ public static final VectorOption KEY_DEBUG_BREAKPOINT_TOGGLE = @@ -1169,6 +1163,10 @@ public static Vector vector(KeyStroke... ks) { public static final VectorOption KEY_CODE_COVERAGE = new VectorOption("key.code.coverage", new KeyStrokeOption("",null), to.vector()); + /** The same for Submit Client - no key */ + public static final VectorOption KEY_SUBMIT = + new VectorOption("key.code.coverage", new KeyStrokeOption("",null), to.vector()); + /* ---------- Find Replace Options ---------- */ public static final BooleanOption FIND_MATCH_CASE = diff --git a/drjava/src/edu/rice/cs/drjava/config/ResourceBundleConfiguration.java b/drjava/src/edu/rice/cs/drjava/config/ResourceBundleConfiguration.java index fafb60e0d..8d920ae51 100644 --- a/drjava/src/edu/rice/cs/drjava/config/ResourceBundleConfiguration.java +++ b/drjava/src/edu/rice/cs/drjava/config/ResourceBundleConfiguration.java @@ -241,8 +241,8 @@ public void loadConfiguration(InputStream is) throws IOException { * are written in the same way as the about dialog. * Values equal to their defaults are not written to disk. */ - public void saveConfiguration(OutputStream os, String header) throws IOException { - _shadowed.saveConfiguration(os,header); + public void saveConfiguration(Writer wr, String header) throws IOException { + _shadowed.saveConfiguration(wr,header); } /** Adds an OptionListener to the given Option, to be notified each time the option changes. diff --git a/drjava/src/edu/rice/cs/drjava/config/SavableConfiguration.java b/drjava/src/edu/rice/cs/drjava/config/SavableConfiguration.java index 1ca58aad3..dc1557130 100644 --- a/drjava/src/edu/rice/cs/drjava/config/SavableConfiguration.java +++ b/drjava/src/edu/rice/cs/drjava/config/SavableConfiguration.java @@ -67,8 +67,8 @@ public void loadConfiguration(InputStream is) throws IOException { * @param header the header to be written * @throws IOException if an IO operation fails */ - public void saveConfiguration(OutputStream os, String header) throws IOException { - PrintWriter w = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os))); + public void saveConfiguration(Writer wr, String header) throws IOException { + PrintWriter w = new PrintWriter(new BufferedWriter(wr)); //Properties p = new Properties(); // String tmpString; // StringBuffer buff; diff --git a/drjava/src/edu/rice/cs/drjava/config/SavableConfigurationTest.java b/drjava/src/edu/rice/cs/drjava/config/SavableConfigurationTest.java index 961602d10..d59549ff5 100644 --- a/drjava/src/edu/rice/cs/drjava/config/SavableConfigurationTest.java +++ b/drjava/src/edu/rice/cs/drjava/config/SavableConfigurationTest.java @@ -39,6 +39,7 @@ import edu.rice.cs.drjava.DrJavaTestCase; import java.io.ByteArrayOutputStream; +import java.io.CharArrayWriter; import java.io.IOException; import java.text.SimpleDateFormat; import java.text.ParseException; @@ -53,11 +54,11 @@ public class SavableConfigurationTest extends DrJavaTestCase { */ SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); - ByteArrayOutputStream outputBytes = null; + CharArrayWriter outputChars = null; public void setUp() throws Exception { super.setUp(); - outputBytes = new ByteArrayOutputStream(); + outputChars = new CharArrayWriter(); } /** Tests the saveConfiguration method with no configuration data @@ -66,9 +67,9 @@ public void setUp() throws Exception { public void testEmptyConfiguration() throws IOException { SavableConfiguration emptyConfig = new SavableConfiguration(new DefaultOptionMap()); - emptyConfig.saveConfiguration(outputBytes, "header"); + emptyConfig.saveConfiguration(outputChars, "header"); - String outputString = outputBytes.toString(); + String outputString = outputChars.toString(); String[] lines = outputString.split(System.getProperty("line.separator")); assertTrue("Data exists", outputString.length() > 0); @@ -97,9 +98,9 @@ public void testNonEmptyConfiguration() throws IOException { SavableConfiguration nonEmptyConfig = new SavableConfiguration(optionsMap); - nonEmptyConfig.saveConfiguration(outputBytes, "header"); + nonEmptyConfig.saveConfiguration(outputChars, "header"); - String outputString = outputBytes.toString(); + String outputString = outputChars.toString(); String[] lines = outputString.split(System.getProperty("line.separator")); assertTrue("Data exists", outputString.length() > 0); diff --git a/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java b/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java index 22b46eee8..d5b10808d 100644 --- a/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java +++ b/drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java @@ -53,7 +53,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringReader; - +import java.io.Writer; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; @@ -3273,10 +3273,10 @@ public boolean saveFileAs(FileSaveSelector com) throws IOException { // System.err.println("Calling FileOps.saveFile to save it"); FileOps.saveFile(new FileOps.DefaultFileSaver(file) { /** Only runs in event thread so no read lock is necessary. */ - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { DefinitionsDocument dd = getDocument(); try { - _editorKit.write(os, dd, 0, dd.getLength()); + _editorKit.write(wr, dd, 0, dd.getLength()); // Utilities.show ("Wrote file containing:\n" + doc.getText()); } catch (BadLocationException docFailed) { throw new UnexpectedException(docFailed); } diff --git a/drjava/src/edu/rice/cs/drjava/model/GlobalModelCompileTest.java b/drjava/src/edu/rice/cs/drjava/model/GlobalModelCompileTest.java index 6143288b4..9f18d7950 100644 --- a/drjava/src/edu/rice/cs/drjava/model/GlobalModelCompileTest.java +++ b/drjava/src/edu/rice/cs/drjava/model/GlobalModelCompileTest.java @@ -50,7 +50,7 @@ * @version $Id$ */ public final class GlobalModelCompileTest extends GlobalModelTestCase { - protected static final Log _log = new Log("/home/cork/GlobalModelTest.txt", false); + protected static final Log _log = new Log("GlobalModelTest.txt", false); /** Tests calling compileAll with no source files works. Does not reset interactions. * @throws BadLocationException if attempts to reference an invalid location diff --git a/drjava/src/edu/rice/cs/drjava/model/GlobalModelJUnitTest.java b/drjava/src/edu/rice/cs/drjava/model/GlobalModelJUnitTest.java index 1ba356791..740e6fb9d 100644 --- a/drjava/src/edu/rice/cs/drjava/model/GlobalModelJUnitTest.java +++ b/drjava/src/edu/rice/cs/drjava/model/GlobalModelJUnitTest.java @@ -52,7 +52,7 @@ */ public final class GlobalModelJUnitTest extends GlobalModelTestCase { - private static Log _log = new Log("/home/cork/GlobalModelJUnitTest.txt", true); + private static Log _log = new Log("GlobalModelJUnitTest.txt", true); /** Whether or not to print debugging output. */ static final boolean printMessages = true; diff --git a/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java b/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java index 55069ff00..e413e8c37 100644 --- a/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java +++ b/drjava/src/edu/rice/cs/drjava/model/GlobalModelTestCase.java @@ -75,7 +75,7 @@ */ public abstract class GlobalModelTestCase extends MultiThreadedTestCase { - public static final Log _log = new Log("/home/cork/GlobalModelTest.txt", false); + public static final Log _log = new Log("GlobalModelTest.txt", false); protected volatile DefaultGlobalModel _model; protected volatile InteractionsController _interactionsController; @@ -1027,7 +1027,7 @@ public void updateCurrentLocationInDoc() { /* this event is not directly tested } public static class InteractionListener extends TestListener { - public static Log _log = new Log("/home/cork/GlobalModelTest.txt", false); + public static Log _log = new Log("GlobalModelTest.txt", false); private static final int WAIT_TIMEOUT = 20000; // time to wait for _interactionDone or _resetDone private volatile CompletionMonitor _interactionDone; private volatile CompletionMonitor _resetDone; diff --git a/drjava/src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java b/drjava/src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java index 5e31ac858..272fc229b 100644 --- a/drjava/src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java +++ b/drjava/src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java @@ -422,7 +422,9 @@ private void _rawJUnitOpenDefDocs(List lod, final boole final Box sourceName = new SimpleBox(); new ClassReader(IOUtil.toByteArray(entry)).accept(new ClassVisitor(Opcodes.ASM4) { public void visit(int version, int access, String name, String sig, String sup, String[] inters) { - className.set(name.replace('/', '.')); + name = name.replace('/', '.'); + name = name.replace(File.separatorChar, '.'); + className.set(name); } public void visitSource(String source, String debug) { sourceName.set(source); @@ -439,8 +441,12 @@ public void visitEnd() { } File rootDir = classDirsAndRoots.get(dir); /** The canonical pathname for the file (including the file name) */ - String javaSourceFileName = getCanonicalPath(rootDir) + File.separator + sourceName.value(); - + String canonicalRoot = getCanonicalPath(rootDir); + // !! remove extra trailing slash(es) + while(canonicalRoot.endsWith(File.separator)) + canonicalRoot = canonicalRoot.substring(0, canonicalRoot.length()-1); + String javaSourceFileName = canonicalRoot + File.separator + sourceName.value(); + // System.err.println("Full java source fileName = " + javaSourceFileName); /* The index in fileName of the dot preceding the extension ".java", ".dj", ".dj0*, ".dj1", or ".dj2" */ diff --git a/drjava/src/edu/rice/cs/drjava/model/repl/History.java b/drjava/src/edu/rice/cs/drjava/model/repl/History.java index edefd8542..b0e986cda 100644 --- a/drjava/src/edu/rice/cs/drjava/model/repl/History.java +++ b/drjava/src/edu/rice/cs/drjava/model/repl/History.java @@ -46,6 +46,7 @@ import edu.rice.cs.util.OperationCanceledException; import java.io.Serializable; +import java.io.Writer; import java.io.IOException; import java.io.File; import java.io.OutputStreamWriter; @@ -241,10 +242,9 @@ public static void writeToFile(FileSaveSelector selector, final String editedVer if (c != null) { if (! c.exists() || selector.verifyOverwrite(c)) { FileOps.DefaultFileSaver saver = new FileOps.DefaultFileSaver(c) { - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(os); - BufferedWriter bw = new BufferedWriter(osw); + BufferedWriter bw = new BufferedWriter(wr); String file = HISTORY_FORMAT_VERSION_2 + editedVersion; bw.write(file, 0, file.length()); bw.close(); diff --git a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java index a38f21a3e..3ec5e34ac 100644 --- a/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java +++ b/drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java @@ -839,14 +839,6 @@ public void actionPerformed( ActionEvent ae) { /* Go to this file... */ _popMenu.addSeparator(); - JMenuItem gotoFileUnderCursorItem = new JMenuItem("Go to File Under Cursor"); - gotoFileUnderCursorItem.addActionListener ( new AbstractAction() { - public void actionPerformed( ActionEvent ae) { - updateCurrentLocationInDoc(); - _mainFrame._gotoFileUnderCursor(); - } - }); - _popMenu.add(gotoFileUnderCursorItem); /* Toggle bookmark */ JMenuItem toggleBookmarkItem = new JMenuItem("Toggle Bookmark"); @@ -860,7 +852,7 @@ public void actionPerformed( ActionEvent ae) { _popMenu.add(toggleBookmarkItem); if (_mainFrame.getModel().getDebugger().isAvailable()) { - _popMenu.addSeparator(); +// _popMenu.addSeparator(); // Breakpoint JMenuItem breakpointItem = new JMenuItem("Toggle Breakpoint"); diff --git a/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java b/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java index 332bdd21c..84563e7e0 100644 --- a/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java +++ b/drjava/src/edu/rice/cs/drjava/ui/MainFrame.java @@ -65,6 +65,8 @@ import java.util.StringTokenizer; import java.util.Vector; import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -118,6 +120,8 @@ import edu.rice.cs.util.swing.*; import edu.rice.cs.util.text.ConsoleDocument; import edu.rice.cs.util.text.SwingDocument; +import ua.khnu.dimalit.drjava.SubmitClient; +import ua.khnu.dimalit.drjava.SubmitForm; import edu.rice.cs.util.UnexpectedException; import edu.rice.cs.util.XMLConfig; import static edu.rice.cs.drjava.config.OptionConstants.KEY_NEW_CLASS_FILE; @@ -220,6 +224,7 @@ public class MainFrame extends SwingFrame implements ClipboardOwner, DropTargetL private volatile JButton _junitButton; private volatile JButton _errorsButton; private volatile JButton _coverageButton; + private volatile JButton _submitButton; private final JToolBar _toolBar = new JToolBar(); private final JFileChooser _interactionsHistoryChooser = new JFileChooser(); @@ -249,6 +254,7 @@ public class MainFrame extends SwingFrame implements ClipboardOwner, DropTargetL private volatile AboutDialog _aboutDialog; private volatile RecentDocFrame _recentDocFrame; /** Holds/shows the history of documents for ctrl-tab. */ private volatile CoverageFrame _coverageFrame; + private volatile SubmitForm _submitFrame; // private ProjectPropertiesFrame _projectPropertiesFrame; @@ -1172,6 +1178,21 @@ public void showCoverageFrame() { _coverageFrame.toFront(); } + /** Show Submit Client dialog */ + private volatile AbstractAction _submitAction = new AbstractAction("Submit") { + public void actionPerformed(ActionEvent ae) { + // try to re-connect if possible + if(_submitFrame.getServer()==null){ + _submitFrame = SubmitClient.createSubmitForm(SubmitClient.prepareServer()); + if(_submitFrame.getServer()==null) + return; + } + String text = _model.getActiveDocument().getText(); + _submitFrame.setText(text); + _submitFrame.setVisible(true); + } + }; + /** Default cut action. Returns focus to the correct pane. */ final Action cutAction = new DefaultEditorKit.CutAction() { public void actionPerformed(ActionEvent e) { @@ -1603,34 +1624,6 @@ public void actionPerformed(ActionEvent ae) { } }; - /** Goes to the file specified by the word the cursor is on. */ - void _gotoFileUnderCursor() { -// _log.log("Calling gotoFileUnderCursor()"); - OpenDefinitionsDocument odd = getCurrentDefPane().getOpenDefDocument(); - String mask = ""; - int loc = getCurrentDefPane().getCaretPosition(); - String s = odd.getText(); - // find start - int start = loc; - while(start > 0) { - if (! Character.isJavaIdentifierPart(s.charAt(start-1))) { break; } - --start; - } - while((start=0) && (end initOpenJavadocDialog() { + return Executors.newSingleThreadExecutor().submit(new Runnable() { public void run() { if (_openJavadocDialog == null) { PredictiveInputFrame.InfoSupplier info = @@ -1828,7 +1821,7 @@ public static Set _generateJavaAPISet(URL url) { final int classNameStartPos = (aPos < 0) ? 0 : line.indexOf(classNamePrefix) + prefixLength; final int classNameEndPos = line.toLowerCase().indexOf(hText, classNameStartPos); if ((classNameStartPos > 0) && (classNameEndPos > 0)) { // class link found - String link = line.substring(aPos + aTextLength, classNameEndPos + hTextLength); + String link = line.substring(aPos + aTextLength, classNameEndPos + hTextLength-2); // -2 for " and space String classNamePath = line.substring(classNameStartPos, classNameEndPos); String fullClassName = classNamePath.replace('/', '.'); String simpleClassName = fullClassName; @@ -1956,24 +1949,30 @@ else if (linkVersion.equals(JAVADOC_1_8_TEXT)) { volatile Set _javaAPISet = new HashSet(); /** Action that asks the user for a file name and goes there. Only executes in the event thread. */ - private volatile Action _openJavadocAction = new AbstractAction("Open Java API Javadoc...") { - public void actionPerformed(ActionEvent ae) { - hourglassOn(); - new Thread() { - public void run() { - // run this in a thread other than the main thread - initOpenJavadocDialog(); - Utilities.invokeLater(new Runnable() { - public void run() { - // but now run this in the event thread again - _openJavadocDialog.setItems(true, getJavaAPISet()); // ignore case - _openJavadocDialog.setVisible(true); - } - }); - } - }.start(); - } - }; + private volatile Action _openJavadocAction = new AbstractAction("Open Java API Javadoc...") { + public void actionPerformed(ActionEvent ae) { + hourglassOn(); + new Thread() { + public void run() { + // run this in a thread other than the main thread + try { + initOpenJavadocDialog().get(); + Utilities.invokeLater(new Runnable() { + public void run() { + // but now run this in the event thread again + _openJavadocDialog.setItems(true, getJavaAPISet()); // ignore + // case + _openJavadocDialog.setVisible(true); + } + }); + } catch (InterruptedException | ExecutionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } // catch + }// run + }.start(); + } + }; /** Opens the Javadoc specified by the word the cursor is on. Only executes in the event thread. */ private void _openJavadocUnderCursor() { @@ -2068,9 +2067,14 @@ public void run() { hourglassOff(); } else { - initOpenJavadocDialog(); - _openJavadocDialog.setModel(true, pim); // ignore case - _openJavadocDialog.setVisible(true); + try { + initOpenJavadocDialog().get(); + _openJavadocDialog.setModel(true, pim); // ignore case + _openJavadocDialog.setVisible(true); + } catch (InterruptedException | ExecutionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } // wait until ok!! } } } @@ -2301,11 +2305,11 @@ public File getFile() throws OperationCanceledException { if (! file.getCanonicalFile().exists() || selector.verifyOverwrite(file)) { // confirm that existing file can be overwritten FileOps.saveFile(new FileOps.DefaultFileSaver(file) { /** Only runs in event thread so no read lock is necessary. */ - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { final String text = doc.getText(); - OutputStreamWriter osw = new OutputStreamWriter(os); - osw.write(text,0,text.length()); - osw.flush(); + //OutputStreamWriter osw = new OutputStreamWriter(os); + wr.write(text,0,text.length()); + wr.flush(); } }); } @@ -3504,7 +3508,7 @@ public void setCurrentDirectory(File dir) { // initialize menu bar and actions _setUpActions(); - _setUpMenuBar(_menuBar, _fileMenu, _editMenu, _toolsMenu, _projectMenu, _debugMenu, _languageLevelMenu, _helpMenu); + _setUpMenuBar(_menuBar, _fileMenu, _editMenu, _toolsMenu, _projectMenu, _debugMenu, /*_languageLevelMenu*/null, _helpMenu); setJMenuBar(_menuBar); // _setUpDocumentSelector(); @@ -3786,6 +3790,14 @@ public void optionChanged(OptionEvent oce) { _editExternalDialog = new EditExternalDialog(MainFrame.this); _jarOptionsDialog = new JarOptionsDialog(MainFrame.this); + // false = hide error messages + //_submitFrame = SubmitClient.createSubmitForm(SubmitClient.prepareServer(false)); + // create with null server - but re-create after - when trying to submit + // TODO: better just set whole frame to null.. + //no effect: System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", "1000"); + //System.setProperty("sun.rmi.transport.tcp.responseTimeout", "1000"); + _submitFrame = SubmitClient.createSubmitForm(null); + initTabbedPanesFrame(); initDebugFrame(); initJarOptionsDialog(); @@ -6506,8 +6518,6 @@ private void _setUpActions() { _setUpAction(_findPrevAction, "Find Previous", "Repeats the last find in the opposite direction"); _setUpAction(_gotoLineAction, "Go to line", "Go to a line number in the document"); _setUpAction(_gotoFileAction, "Go to File", "Go to a file specified by its name"); - _setUpAction(_gotoFileUnderCursorAction, "Go to File Under Cursor", - "Go to the file specified by the word the cursor is located on"); _setUpAction(_switchToPrevAction, "Previous Document", "Up", "Switch to the previous document"); _setUpAction(_switchToNextAction, "Next Document", "Down", "Switch to the next document"); @@ -6531,6 +6541,7 @@ private void _setUpActions() { _setUpAction(_junitAllAction, "Test", "Run JUnit over all open JUnit tests"); _setUpAction(_coverageAction, "Code Coverage", "Generate code coverage reports"); + _setUpAction(_submitAction, "Submit Code", "Submit code to course repository"); if (_model.getJavadocModel().isAvailable()) { _setUpAction(_javadocAllAction, "Javadoc", "Create and save Javadoc for the packages of all open documents"); @@ -6654,7 +6665,7 @@ void _setUpMenuBar(JMenuBar menuBar) { _setUpMenuBar(menuBar, _setUpFileMenu(mask, false), _setUpEditMenu(mask, false), _setUpToolsMenu(mask, false), _setUpProjectMenu(mask, false), _showDebugger?_setUpDebugMenu(mask, false):null, - _setUpLanguageLevelMenu(mask, false), _setUpHelpMenu(mask, false)); + /*_setUpLanguageLevelMenu(mask, false)*/null, _setUpHelpMenu(mask, false)); } void _setUpMenuBar(JMenuBar menuBar, JMenu fileMenu, JMenu editMenu, JMenu toolsMenu, JMenu projectMenu, @@ -6665,7 +6676,8 @@ void _setUpMenuBar(JMenuBar menuBar, JMenu fileMenu, JMenu editMenu, JMenu tools menuBar.add(toolsMenu); menuBar.add(projectMenu); if (_showDebugger && (debugMenu != null)) menuBar.add(debugMenu); - menuBar.add(languageLevelMenu); + if(languageLevelMenu != null) + menuBar.add(languageLevelMenu); menuBar.add(helpMenu); // Plastic-specific style hints if (Utilities.isPlasticLaf()) { @@ -6838,15 +6850,14 @@ public void propertyChange(PropertyChangeEvent evt) { editMenu.addSeparator(); _addMenuItem(editMenu, _switchToPrevAction, KEY_PREVIOUS_DOCUMENT, updateKeyboardManager); _addMenuItem(editMenu, _switchToNextAction, KEY_NEXT_DOCUMENT, updateKeyboardManager); - _addMenuItem(editMenu, _browseBackAction, KEY_BROWSE_BACK, updateKeyboardManager); - _addMenuItem(editMenu, _browseForwardAction, KEY_BROWSE_FORWARD, updateKeyboardManager); +// _addMenuItem(editMenu, _browseBackAction, KEY_BROWSE_BACK, updateKeyboardManager); +// _addMenuItem(editMenu, _browseForwardAction, KEY_BROWSE_FORWARD, updateKeyboardManager); editMenu.addSeparator(); // Go to final JMenu goToMenu = _newJMenu("Go To"); _addMenuItem(goToMenu, _gotoLineAction, KEY_GOTO_LINE, updateKeyboardManager); _addMenuItem(goToMenu, _gotoFileAction, KEY_GOTO_FILE, updateKeyboardManager); - _addMenuItem(goToMenu, _gotoFileUnderCursorAction, KEY_GOTO_FILE_UNDER_CURSOR, updateKeyboardManager); _addMenuItem(goToMenu, _gotoOpeningBraceAction, KEY_OPENING_BRACE, updateKeyboardManager); _addMenuItem(goToMenu, _gotoClosingBraceAction, KEY_CLOSING_BRACE, updateKeyboardManager); editMenu.add(goToMenu); @@ -6968,6 +6979,7 @@ private JMenu _setUpToolsMenu(int mask, boolean updateKeyboardManager) { // Code Coverage _addMenuItem(toolsMenu, _coverageAction, KEY_CODE_COVERAGE, updateKeyboardManager); + _addMenuItem(toolsMenu, _submitAction, KEY_SUBMIT, updateKeyboardManager); toolsMenu.addSeparator(); // Javadoc @@ -6984,7 +6996,7 @@ private JMenu _setUpToolsMenu(int mask, boolean updateKeyboardManager) { _addMenuItem(historyMenu, _loadHistoryScriptAction, KEY_LOAD_HISTORY_SCRIPT, updateKeyboardManager); _addMenuItem(historyMenu, _saveHistoryAction, KEY_SAVE_HISTORY, updateKeyboardManager); _addMenuItem(historyMenu, _clearHistoryAction, KEY_CLEAR_HISTORY, updateKeyboardManager); - toolsMenu.add(historyMenu); + //toolsMenu.add(historyMenu); // Interactions, console final JMenu interMenu = _newJMenu("Interactions & Console"); @@ -7000,14 +7012,14 @@ private JMenu _setUpToolsMenu(int mask, boolean updateKeyboardManager) { if (DrJava.getConfig().getSetting(SHOW_DEBUG_CONSOLE).booleanValue()) { toolsMenu.add(_showDebugConsoleAction); } - toolsMenu.add(interMenu); +// toolsMenu.add(interMenu); final JMenu extMenu = _newJMenu("External Processes"); _addMenuItem(extMenu, _executeExternalProcessAction, KEY_EXEC_PROCESS, updateKeyboardManager); final JMenuItem execItem = extMenu.getItem(0); extMenu.addSeparator(); extMenu.add(_editExternalProcessesAction); - toolsMenu.add(extMenu); +// toolsMenu.add(extMenu); final int savedCount = DrJava.getConfig().getSetting(OptionConstants.EXTERNAL_SAVED_COUNT); final int namesCount = DrJava.getConfig().getSetting(OptionConstants.EXTERNAL_SAVED_NAMES).size(); @@ -7068,13 +7080,13 @@ public void actionPerformed(ActionEvent ae) { _addMenuItem(advancedMenu, _newDrJavaInstanceAction, KEY_NEW_DRJAVA_INSTANCE, updateKeyboardManager); toolsMenu.add(advancedMenu); - toolsMenu.addSeparator(); +// toolsMenu.addSeparator(); - _addMenuItem(toolsMenu, _bookmarksPanelAction, KEY_BOOKMARKS_PANEL, updateKeyboardManager); - _addMenuItem(toolsMenu, _toggleBookmarkAction, KEY_BOOKMARKS_TOGGLE, updateKeyboardManager); +// _addMenuItem(toolsMenu, _bookmarksPanelAction, KEY_BOOKMARKS_PANEL, updateKeyboardManager); +// _addMenuItem(toolsMenu, _toggleBookmarkAction, KEY_BOOKMARKS_TOGGLE, updateKeyboardManager); - toolsMenu.addSeparator(); - _addMenuItem(toolsMenu, _followFileAction, KEY_FOLLOW_FILE, updateKeyboardManager); +// toolsMenu.addSeparator(); +// _addMenuItem(toolsMenu, _followFileAction, KEY_FOLLOW_FILE, updateKeyboardManager); // Add the listener that changes the "Run Main" menu item OptionListener runMainListener = new OptionListener() { @@ -7442,9 +7454,9 @@ private void _setUpToolBar() { // Cut, copy, paste _toolBar.addSeparator(); - _toolBar.add(_createToolBarButton(cutAction)); - _toolBar.add(_createToolBarButton(copyAction)); - _toolBar.add(_createToolBarButton(pasteAction)); +// _toolBar.add(_createToolBarButton(cutAction)); +// _toolBar.add(_createToolBarButton(copyAction)); +// _toolBar.add(_createToolBarButton(pasteAction)); // Undo, redo // Simple workaround, for now, for bug # 520742: @@ -7471,7 +7483,8 @@ private void _setUpToolBar() { _toolBar.add(_runButton = _createToolBarButton(_runAction)); _toolBar.add(_junitButton = _createToolBarButton(_junitAllAction)); _toolBar.add(_createToolBarButton(_javadocAllAction)); - _toolBar.add(_coverageButton = _createToolBarButton(_coverageAction)); + _toolBar.add(_coverageButton = _createToolBarButton(_coverageAction)); + _toolBar.add(_submitButton = _createToolBarButton(_submitAction)); // DrJava Errors _toolBar.addSeparator(); @@ -10604,16 +10617,21 @@ public void run() { /** Reset the position of the "Open Javadoc" dialog. */ public void resetAutoImportDialogPosition() { - _initAutoImportDialog(); - _autoImportDialog.setFrameState("default"); + try { + _initAutoImportDialog().get(); + _autoImportDialog.setFrameState("default"); + } catch (InterruptedException | ExecutionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (DrJava.getConfig().getSetting(DIALOG_AUTOIMPORT_STORE_POSITION).booleanValue()) { DrJava.getConfig().setSetting(DIALOG_AUTOIMPORT_STATE, "default"); } } /** Initialize dialog if necessary. Runs asynchronously. */ - private void _initAutoImportDialog() { - Executors.newSingleThreadExecutor().submit(new Runnable() { + private Future _initAutoImportDialog() { + return Executors.newSingleThreadExecutor().submit(new Runnable() { public void run() { if (_autoImportDialog == null) { _autoImportPackageCheckbox = new JCheckBox("Import Package"); @@ -10764,12 +10782,17 @@ public void run() { PredictiveInputModel pim = new PredictiveInputModel(true, new PrefixStrategy(), autoImportList); pim.setMask(s); - _initAutoImportDialog(); + try { + _initAutoImportDialog().get(); // int size = (autoImportList == null) ? -1 : autoImportList.size(); // _log.log("***** Adding an autoImportList list of size: " + size); - _autoImportDialog.setModel(true, pim); // ignore case - _autoImportPackageCheckbox.setSelected(false); - _autoImportDialog.setVisible(true); + _autoImportDialog.setModel(true, pim); // ignore case + _autoImportPackageCheckbox.setSelected(false); + _autoImportDialog.setVisible(true); + } catch (InterruptedException | ExecutionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } }); } diff --git a/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java b/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java index c5eb60483..46c981a16 100644 --- a/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java +++ b/drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java @@ -789,205 +789,5 @@ protected File tempFile(String fileName) throws IOException { f.deleteOnExit(); return f; } - - /** Tests that "go to file under cursor" works if unique. - * @throws IOException if an IO operation fails - */ - public void testGotoFileUnderCursor() throws IOException { -// Utilities.show("Running testGotoFileUnderCursor"); - String user = System.getProperty("user.name"); - _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); - - final File goto1_file = new File(_tempDir, "GotoFileUnderCursor1.java"); - final String goto1_string = "GotoFileUnderCursorTest"; - IOUtil.writeStringToFile(goto1_file, goto1_string); - goto1_file.deleteOnExit(); - - final File goto2_file = new File(_tempDir, "GotoFileUnderCursorTest.java"); - String goto2_string = "GotoFileUnderCursor1"; - IOUtil.writeStringToFile(goto2_file, goto2_string); - goto2_file.deleteOnExit(); - - Utilities.invokeAndWait(new Runnable() { - public void run() { - _frame.pack(); - _frame.open(new FileOpenSelector() { - public File[] getFiles() { return new File[] { goto1_file, goto2_file }; } - }); - } - }); - - Utilities.invokeAndWait(new Runnable() { - public void run() { - _frame.initGotoFileDialog(); - _frame._gotoFileDialog.addWindowListener(new WindowListener() { - public void windowActivated(WindowEvent e) { throw new RuntimeException("Should not activate _gotoFileDialog"); } - public void windowClosed(WindowEvent e) { throw new RuntimeException("Should not close _gotoFileDialog"); } - public void windowClosing(WindowEvent e) { throw new RuntimeException("Should not be closing _gotoFileDialog"); } - public void windowDeactivated(WindowEvent e) { throw new RuntimeException("Should not deactivate _gotoFileDialog"); } - public void windowDeiconified(WindowEvent e) { throw new RuntimeException("Should not deiconify _gotoFileDialog"); } - public void windowIconified(WindowEvent e) { throw new RuntimeException("Should not iconify _gotoFileDialog"); } - public void windowOpened(WindowEvent e) { throw new RuntimeException("Should not open _gotoFileDialog"); } - }); - }}); - - Utilities.clearEventQueue(); - Utilities.invokeAndWait(new Runnable() { public void run() { - SingleDisplayModel model = _frame.getModel(); - try { - OpenDefinitionsDocument goto1_doc = model.getDocumentForFile(goto1_file); - OpenDefinitionsDocument goto2_doc = model.getDocumentForFile(goto2_file); - model.setActiveDocument(model.getDocumentForFile(goto1_file)); - assertEquals("Document contains the incorrect text", goto1_string, model.getActiveDocument().getText()); - - _frame._gotoFileUnderCursor(); - - assertEquals("Incorrect active document; did not go to?", goto2_doc, model.getActiveDocument()); - - _frame._gotoFileUnderCursor(); - - assertEquals("Incorrect active document; did not go to?", goto1_doc, model.getActiveDocument()); - } - catch(IOException ioe) { throw new UnexpectedException(ioe); } - } }); - _log.log("gotoFileUnderCursor completed"); - } - - /** Tests that "go to file under cursor" works if unique after appending ".java" - * @throws IOException if an IO operation fails - */ - public void testGotoFileUnderCursorAppendJava() throws IOException { - String user = System.getProperty("user.name"); - _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); - - final File goto1_file = new File(_tempDir, "GotoFileUnderCursor2Test.java"); - final String goto1_string = "GotoFileUnderCursor2"; - IOUtil.writeStringToFile(goto1_file, goto1_string); - goto1_file.deleteOnExit(); - - final File goto2_file = new File(_tempDir, "GotoFileUnderCursor2.java"); - String goto2_string = "GotoFileUnderCursor2Test"; - IOUtil.writeStringToFile(goto2_file, goto2_string); - goto2_file.deleteOnExit(); - - Utilities.invokeAndWait(new Runnable() { - public void run() { - _frame.pack(); - _frame.open(new FileOpenSelector() { - public File[] getFiles() { - return new File[] { goto1_file, goto2_file }; - } - }); - } - }); - - Utilities.clearEventQueue(); - - Utilities.invokeAndWait(new Runnable() { - public void run() { - _frame.initGotoFileDialog(); - _frame._gotoFileDialog.addWindowListener(new WindowListener() { - public void windowActivated(WindowEvent e) { throw new RuntimeException("Should not activate _gotoFileDialog"); } - public void windowClosed(WindowEvent e) { throw new RuntimeException("Should not close _gotoFileDialog"); } - public void windowClosing(WindowEvent e) { throw new RuntimeException("Should not be closing _gotoFileDialog"); } - public void windowDeactivated(WindowEvent e) { throw new RuntimeException("Should not deactivate _gotoFileDialog"); } - public void windowDeiconified(WindowEvent e) { throw new RuntimeException("Should not deiconify _gotoFileDialog"); } - public void windowIconified(WindowEvent e) { throw new RuntimeException("Should not iconify _gotoFileDialog"); } - public void windowOpened(WindowEvent e) { throw new RuntimeException("Should not open _gotoFileDialog"); } - }); - }}); - - Utilities.clearEventQueue(); - - Utilities.invokeAndWait(new Runnable() { public void run() { - SingleDisplayModel model = _frame.getModel(); - try { - OpenDefinitionsDocument goto1_doc = model.getDocumentForFile(goto1_file); - OpenDefinitionsDocument goto2_doc = model.getDocumentForFile(goto2_file); - model.setActiveDocument(model.getDocumentForFile(goto1_file)); - assertEquals("Document contains the incorrect text", goto1_string, model.getActiveDocument().getText()); - - _frame._gotoFileUnderCursor(); - - assertEquals("Incorrect active document; did not go to?", goto2_doc, model.getActiveDocument()); - - _frame._gotoFileUnderCursor(); - - assertEquals("Incorrect active document; did not go to?", goto1_doc, model.getActiveDocument()); - } - catch(IOException ioe) { throw new UnexpectedException(ioe); } - } }); - - _log.log("gotoFileUnderCursorAppendJava completed"); - } - - /** Tests that "go to file under cursor" displays the dialog if choice is not unique - * @throws IOException if an IO operation fails - */ - public void testGotoFileUnderCursorShowDialog() throws IOException { -// Utilities.show("Running testGotoFileUnderCursorShowDialog()"); - String user = System.getProperty("user.name"); - _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); - - final File goto1_file = new File(_tempDir, "GotoFileUnderCursor3.java"); - final String goto1_string = "GotoFileUnderCursor"; - IOUtil.writeStringToFile(goto1_file, goto1_string); - goto1_file.deleteOnExit(); - - final File goto2_file = new File(_tempDir, "GotoFileUnderCursor4.java"); - String goto2_string = "GotoFileUnderCursor3"; - IOUtil.writeStringToFile(goto2_file, goto2_string); - goto2_file.deleteOnExit(); - - Utilities.invokeAndWait(new Runnable() { - public void run() { - _frame.pack(); - _frame.open(new FileOpenSelector() { - public File[] getFiles() { return new File[] { goto1_file, goto2_file }; } - }); - } - }); - - final int[] count = new int[2]; - Utilities.invokeAndWait(new Runnable() { - public void run() { - _frame.initGotoFileDialog(); - _frame._gotoFileDialog.addWindowListener(new WindowListener() { - public void windowActivated(WindowEvent e) { ++count[0]; } - public void windowClosed(WindowEvent e) { throw new RuntimeException("Should not close _gotoFileDialog"); } - public void windowClosing(WindowEvent e) { throw new RuntimeException("Should not be closing _gotoFileDialog"); } - public void windowDeactivated(WindowEvent e) { /* throw new RuntimeException("Should not deactivate _gotoFileDialog"); */ } - public void windowDeiconified(WindowEvent e) { throw new RuntimeException("Should not deiconify _gotoFileDialog"); } - public void windowIconified(WindowEvent e) { throw new RuntimeException("Should not iconify _gotoFileDialog"); } - public void windowOpened(WindowEvent e) { ++count[1]; } - }); - } - }); - - Utilities.clearEventQueue(); - - Utilities.invokeAndWait(new Runnable() { public void run() { - SingleDisplayModel model = _frame.getModel(); - try { - model.setActiveDocument(model.getDocumentForFile(goto1_file)); - - assertEquals("Document contains the incorrect text", goto1_string, model.getActiveDocument().getText()); - } - catch(IOException ioe) { throw new UnexpectedException(ioe); } - } }); - - Utilities.invokeAndWait(new Runnable() { public void run() { _frame._gotoFileUnderCursor(); } }); - Utilities.clearEventQueue(); // wait for any asynchronous actions to complete - - - /* The following test was commented out before test following it was. It presumably fails even if - * the "MainFrame.this.isVisible()" test mentioned below is removed from _gotoFileUnderCursor */ -// assertEquals("Did not activate _gotoFileDialog", 1, count[0]); - /* The following test was commented out after suppressing this display when _frame is not visible. If it is - * uncommented, then the "MainFrame.this.isVisible()" test in _gotoFileDialog must be removed. */ -// assertEquals("Did not open _gotoFileDialog", 1, count[1]); - - _log.log("gotoFileUnderCursorShowDialog completed"); - } } diff --git a/drjava/src/edu/rice/cs/util/FileOps.java b/drjava/src/edu/rice/cs/util/FileOps.java index 296d259e9..4ce16fc03 100644 --- a/drjava/src/edu/rice/cs/util/FileOps.java +++ b/drjava/src/edu/rice/cs/util/FileOps.java @@ -417,9 +417,10 @@ public boolean accept(File f){ * @throws IOException if an IO operation fails */ public static String readFileAsSwingText(final File file) throws IOException { - FileReader reader = null; + Reader reader = null; try { - reader = new FileReader(file); + // reader = new FileReader(file); + reader = new InputStreamReader(new FileInputStream(file), "UTF8"); final StringBuilder buf = new StringBuilder(); char pred = (char) 0; // initialize as null character @@ -446,9 +447,10 @@ public static String readFileAsSwingText(final File file) throws IOException { * instead, which provides the same functionality. */ @Deprecated public static String readFileAsString(final File file) throws IOException { - FileReader reader = null; + Reader reader = null; try { - reader = new FileReader(file); + //reader = new FileReader(file); + reader = new InputStreamReader(new FileInputStream(file), "UTF8"); final StringBuilder buf = new StringBuilder(); while (reader.ready()) { @@ -507,9 +509,10 @@ public static String readFileAsSwingText(final File file) throws IOException { * @deprecated Use the equivalent {@link edu.rice.cs.plt.io.IOUtil#writeStringToFile(File, String, boolean)} instead */ @Deprecated public static void writeStringToFile(File file, String text, boolean append) throws IOException { - FileWriter writer = null; + Writer writer = null; try { - writer = new FileWriter(file, append); + //writer = new FileWriter(file, append); + writer = new OutputStreamWriter(new FileOutputStream(file, append), "UTF8"); writer.write(text); } finally { if (writer != null) writer.close(); } @@ -767,10 +770,12 @@ public static void saveFile(FileSaver fileSaver) throws IOException { else throw new IOException("Could not create temp file " + tempFile + " in attempt to save " + file); } BufferedOutputStream bos = new BufferedOutputStream(fos); - fileSaver.saveTo(bos); + Writer wr; + wr = new OutputStreamWriter(bos, "UTF8"); + fileSaver.saveTo(wr); // System.err.println(bos + " written"); // System.err.println("Closing " + bos + " and " + fos); - bos.close(); + wr.close(); // fos.close(); // System.err.println("Wrote: " + tempFile); @@ -832,7 +837,7 @@ public interface FileSaver { * @param os the OutputStream to write to * @throws IOException when saving fails for any reason */ - public abstract void saveTo(OutputStream os) throws IOException; + public abstract void saveTo(Writer os) throws IOException; /** This method specifies the file for saving. It should return the * canonical name of the file, resolving symlinks. Otherwise, the saver diff --git a/drjava/src/edu/rice/cs/util/FileOpsTest.java b/drjava/src/edu/rice/cs/util/FileOpsTest.java index 930ca3268..168d7882e 100644 --- a/drjava/src/edu/rice/cs/util/FileOpsTest.java +++ b/drjava/src/edu/rice/cs/util/FileOpsTest.java @@ -122,9 +122,9 @@ public void testSaveFile() throws IOException { File backup = new File(writeTo.getPath() + "~"); FileOps.saveFile(new FileOps.DefaultFileSaver(writeTo) { - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { String output = "version 1"; - os.write(output.getBytes()); + wr.write(output); } public boolean shouldBackup() { return false; @@ -134,9 +134,9 @@ public boolean shouldBackup() { assertEquals("save w/o backup did not backup", false, backup.exists()); FileOps.saveFile(new FileOps.DefaultFileSaver(writeTo) { - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { String output = "version 2"; - os.write(output.getBytes()); + wr.write(output); } }); assertEquals("save2 w backup", "version 2", FileOps.readFileAsString(writeTo)); @@ -144,9 +144,9 @@ public void saveTo(OutputStream os) throws IOException { FileOps.readFileAsString(backup)); FileOps.saveFile(new FileOps.DefaultFileSaver(writeTo) { - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { String output = "version 3"; - os.write(output.getBytes()); + wr.write(output); } }); assertEquals("save3 w backup on", "version 3", FileOps.readFileAsString(writeTo)); @@ -157,9 +157,9 @@ public void saveTo(OutputStream os) throws IOException { /* Now see what happens when saving fails and we were not making a backup. Nothing should change. */ try { FileOps.saveFile(new FileOps.DefaultFileSaver(writeTo) { - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { String output = "version 4"; - os.write(output.getBytes()); + wr.write(output); throw new IOException(); } }); @@ -177,9 +177,9 @@ public void saveTo(OutputStream os) throws IOException { public boolean shouldBackup () { return true; } - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { String output = "version 5"; - os.write(output.getBytes()); + wr.write(output); throw new IOException(); } }); @@ -201,9 +201,9 @@ public void saveTo(OutputStream os) throws IOException { try { FileOps.saveFile(new FileOps.DefaultFileSaver(writeTo) { public boolean shouldBackup () { return true; } - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { String output = "version 6"; - os.write(output.getBytes()); + wr.write(output); } }); fail("The file to be saved was read-only!"); diff --git a/drjava/src/edu/rice/cs/util/text/ConsoleDocument.java b/drjava/src/edu/rice/cs/util/text/ConsoleDocument.java index bc2cace4b..1d0ed64d8 100644 --- a/drjava/src/edu/rice/cs/util/text/ConsoleDocument.java +++ b/drjava/src/edu/rice/cs/util/text/ConsoleDocument.java @@ -373,11 +373,11 @@ public void saveCopy(FileSaveSelector selector) throws IOException { if (! file.exists() || selector.verifyOverwrite(file)) { // confirm that existing file can be overwritten FileOps.saveFile(new FileOps.DefaultFileSaver(file) { /** Only runs in event thread so no read lock is necessary. */ - public void saveTo(OutputStream os) throws IOException { + public void saveTo(Writer wr) throws IOException { final String text = getDocText(0, getLength()); - OutputStreamWriter osw = new OutputStreamWriter(os); - osw.write(text,0,text.length()); - osw.flush(); + //OutputStreamWriter osw = new OutputStreamWriter(os); + wr.write(text,0,text.length()); + wr.flush(); } }); } diff --git a/platform/build.xml b/platform/build.xml index 06dfdb455..e9f1dc57c 100644 --- a/platform/build.xml +++ b/platform/build.xml @@ -12,6 +12,7 @@ --> + @@ -34,7 +35,6 @@ - diff --git a/platform/src-eclipse/edu/rice/cs/drjava/model/compiler/EclipseCompiler.java b/platform/src-eclipse/edu/rice/cs/drjava/model/compiler/EclipseCompiler.java index 33954733f..a033a2659 100644 --- a/platform/src-eclipse/edu/rice/cs/drjava/model/compiler/EclipseCompiler.java +++ b/platform/src-eclipse/edu/rice/cs/drjava/model/compiler/EclipseCompiler.java @@ -197,6 +197,7 @@ private Iterable _createOptions(List classPath, List0) options.add(e.getValue()); } options.add("-g"); + options.add("-encoding"); options.add("UTF8"); if (classPath != null) { options.add("-classpath"); options.add(IOUtil.pathToString(classPath)); } if (sourcePath != null) { options.add("-sourcepath"); options.add(IOUtil.pathToString(sourcePath)); } diff --git a/platform/src-jdk7/edu/rice/cs/drjava/model/compiler/Javac170Compiler.java b/platform/src-jdk7/edu/rice/cs/drjava/model/compiler/Javac170Compiler.java index 99ceda3c4..4e7bd8b98 100644 --- a/platform/src-jdk7/edu/rice/cs/drjava/model/compiler/Javac170Compiler.java +++ b/platform/src-jdk7/edu/rice/cs/drjava/model/compiler/Javac170Compiler.java @@ -198,6 +198,7 @@ private Iterable _createOptions(List classPath, List0) options.add(e.getValue()); } options.add("-g"); + options.add("-encoding"); options.add("UTF8"); if (classPath != null) { options.add("-classpath"); options.add(IOUtil.pathToString(classPath)); } if (sourcePath != null) { options.add("-sourcepath"); options.add(IOUtil.pathToString(sourcePath)); }