We ask you to make a change to the code of JEdit. JEdit is a programmer's text editor developed in Java. It allows users to open, modify, and save text files. In this part of the study, you will first familiarize yourself with JEdit and one of its feature: autosave. You will then be asked to prepare a change to the autosave feature.

JEdit

  1. Launch JEdit to check it out. From the Eclipse Run configurations menu, choose jEdit-4-1-pre6. You see JEdit appear. Some warning messages will be displayed in the console. This is normal. Do not close JEdit.
  2. In JEdit, an opened text file is called a Buffer. The following is an extract from the JEdit Manual (section 2.1):

    Several files can be opened and edited at once. Each open file is referred to as a buffer. The combo box above the text area selects the buffer to edit. Different emblems are displayed next to buffer names in the list, depending on the buffer's state; a red disk is shown for buffers with unsaved changes, a lock is shown for read-only buffers, and a spark is shown for new buffers which don't yet exist on disk.

  3. JEdit has an autosave feature. The following is an extract from the JEdit Manual (section 3.3.1):

    "The autosave feature protects your work from computer crashes and such. Every 30 seconds, all buffers with unsaved changes are written out to their respective file names, enclosed in hash ("#") characters. For example, program.c will be autosaved to #program.c#."

    JEdit will also generate backup files, which are terminated with a tilde (~) character. These have nothing to do with your task in this study. You can completely ignore them.

    Saving a buffer using one of the commands in the previous section automatically deleted the autosave file, so they will only ever be visible in the unlikely event of a JEdit (or operating system) crash.

    If an autosave file is found while a buffer is being loaded, jEdit will offer to recover the autosaved data.

    The autosave feature can be configured in the Loading and Saving pane of tthe Utilities>Global Options dialog box;

  4. In JEdit, set the autosave frequency to 5 seconds.
  5. Open the file C:\temp\Test.txt
  6. Add a character to the file and do not save the file.
  7. Look in C:\temp. You should see the autosave file.
  8. Save the test buffer in JEdit. The autosave file should disappear.
  9. Add a character to the test buffer and do not save it. Wait 5 seconds.
  10. Kill JEdit using the terminate button on the Eclipse console (the button with the red square).
  11. Launch jEdit again. JEdit will attempt to recover the autosave file. Click yes. ATTENTION: A bug in the code of JEdit will cause the program to hang if you do not click yes or no in the recovery dialog before the time in the autosave frequency. To avoid this, just click yes or no before the 5 seconds (or whatever) of the autosave frequency are over. If the program hangs, you can kill it using the terminate button on the console. You do not have to worry about this bug for the study. Your modification will pass the test cases even in the presence of this bug.
From a user perspective, that's all there is to the autosave feature. You can close JEdit now.

Change Request

You will need to implement the following change to jEdit:

Modify the application so that the users can explicitly disable the autosave feature. The modified version should meet the following requirements:

  1. jEdit shall have a checkbox labeled "Enable Autosave" above the autosave frequency field in the Loading and Saving pane of the global options. This checkbox shall control whether the autosave feature is enabled or not.
  2. The state of the autosave feature should persist between different executions of the tool.
  3. When the autosave feature is disabled, all autosave backup files for existing buffers shall be immediately deleted from disk.
  4. When the autosave feature is enabled, all dirty buffers should be saved within the specified autosave frequency.
  5. When the autosave feature is disabled, the tool should never attempt to recover from an autosave backup, if for some reason an autosave backup is present. In this case the autosave backup should be left as is.

Expert Knowledge

You are given the following expert knowledge about the source code: A checkbox should be added to org.gjt.jedit.options.LoadSaveOptionPane to enable/disable the autosave. The autosave timer is in org.gjt.sp.jedit.Autosave.

Test Cases

To determine whether or not you have successfully implemented the change, we will perform the following tests:
  1. With autosave enabled, modify a buffer. The buffer should be autosaved within the specified time.
  2. Save the buffer. The autosave file should be deleted.
  3. Modify the buffer. The buffer should be autosaved within the specified time. Disable the autosave feature. The autosave file should be deleted.
  4. Enable the autosave feature. The buffer should be autosaved within the specified time.
  5. Disable the autosave feature. The autosave file should be deleted. Modify the buffer. No autosave file should appear.
  6. Enable autosave. Close JEdit. Launch JEdit. Autosave should be enabled.
  7. Disable autosave. Close JEdit. Copy and rename the test file so it looks like an autosave file. Launch JEdit. No recovery should be attempted. Autosave should be disabled.
  8. Enable autosave. Close JEdit. Copy and rename the test file so it looks like an autosave file. Launch JEdit. Recovery should be attempted. Select YES within 5 seconds.

Task

  1. You must now investigate the code related to the change you must make. You can takes notes about the code to change, or other aspects you deem useful. These notes should be stored in the file Notes.txt in the JEdit project.
  2. You must make no change to the source code. You are not allowed to perform temporary changes, or try out different alternatives.
  3. Do not use the debugger.
  4. You have one hour to investigate the code. Use this time to learn as much as possible about the code you must change. You will need to rely on this knowledge to perform the change in the required time.
  5. If you are ready to go, please notify the investigator.