[index]
Task: Autosave (A-T1)
This task involves planning a change to jEdit's autosave feature.
You will need to first familiarize yourself with JEdit and one of
its feature: autosave.
Overview of JEdit, Buffers, and Autosave
- Launch JEdit to check it out. From the Eclipse Run
configurations menu, choose jEdit-4-1-pre6. JEdit will
appear momentarily. Some warning messages will be displayed in the
console: this is normal. Do not close JEdit.
- 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.
- 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 the Utilities>Global
Options dialog box;
- In JEdit, set the autosave frequency to 5 seconds.
- Open the file C:\temp\Test.txt
- Add a character to the file and do not save the file.
- Look in C:\temp. You should see the autosave file.
- Save the test buffer in JEdit. The autosave file should disappear.
- Add a character to the test buffer and do not save it. Wait
5 seconds.
- Kill JEdit using the terminate button on the Eclipse console
(the button with the red square).
- 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 are to create a a plan for performing the following task.
This involves identifying the relevant program elements that need
to be changed and how they should be changed, and those program elements
that are necessary to understand for the change. NOTE: You are not
actually required perform the changes. Rather you should identify the
particular classes and methods to be used describe any new classes
required. These instructions should be appropriate for giving to a
first-year coop student to rapidly turn to working code.
Change Task: Modify the application so that the users
can explicitly disable the autosave feature. The modified version
should meet the following requirements:
- 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.
- The state of the autosave feature should persist between
different executions of the tool.
- When the autosave feature is disabled, all autosave backup
files for existing buffers shall be immediately deleted from
disk.
- When the autosave feature is enabled, all dirty buffers should
be saved within the specified autosave frequency.
- 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.sp.jedit.options.LoadSaveOptionPane
to enable/disable the autosave. The autosave timer is in
org.gjt.sp.jedit.Autosave.
Test Cases
To help understand the possible interactions, consider the following
tests:
- With autosave enabled, modify a buffer.
The buffer should be autosaved within the specified time.
- Save the buffer. The autosave file
should be deleted.
- Modify the buffer. The buffer should be
autosaved within the specified time. Disable the
autosave feature. The autosave file should be
deleted.
- Enable the autosave feature. The buffer
should be autosaved within the specified time.
- Disable the autosave feature. The
autosave file should be deleted. Modify the buffer.
No autosave file should appear.
- Enable autosave. Close JEdit. Launch JEdit.
Autosave should be enabled.
- 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.
- 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
- You must make no change to the source
code. You are not allowed to perform temporary changes, or
try out different alternatives.
- Do not use the debugger.
Please notify the investigator when you are ready to commence.