Project #5
(Managing Windows)
(Due 9 April 2008)
Windows XP must manage the windows on the desktop in a manner that is somewhat like a stack. The user can open any number of windows (each with an associated application); and as each window is opened, the new window becomes the top window, the one which responds to keyboard and mouse actions. When the top window is closed, the window that was most recently top before the closed window becomes top again. Thus, opening and closing a window are like pushing and popping a stack.
There is one action that a user can take that is not like a stack. The user can click on any window on the desktop and make it become the top window. This would be a bit like pulling an entry out of the middle of a stack and placing it on top.
You are to write a program which uses a stack to manage the windows on the desktop. Your program will receive simulated user actions by reading the lines of a script file. Each line of this file represents a user action; the format of each line is as follows:
User-action Auxiliary-Information
There is one space between the user action and the auxiliary information. There are four types of user actions, each with its own auxiliary information.
Action
Information
Activate
Name of the application to be made top window. The applications are
given unique names so that it is possible to run multiple copies of the
same program in different windows. Activate may open a new
window for an application or take a window that already exists and
make it the top window. The name of the application may consist
of several words
Close
No info - close the top window
Click
Name of the command action being performed. A click is meant to
represent a mouse action such as selecting a command or a menu
entry or some icon. The command action name may consist of
several words.
Enter
Information that is typed at the keyboard. An enter is used to
represent keyboard actions. The information entered may consist
of several words.
Two script files are provided for you to test your program. They are named script1.txt and script2.txt; both files can be found on the I: drive in I:\jlwolfe\310\s08 script1.txt begins like this:
Activate Windows Explorer I
Click My Computer
Click Disk G:
Activate Internet Explorer I
Activate WebCT
Click Login
Enter jlwolfe
Enter my password
Activate WordPerfect
Click Open File
Click follow-up-report.wpd
Here four windows are opened and several commands are entered. Your program is required to make sure the correct program gets the commands and keyboard entries. To verify that they are correct, your program must maintain a log of command and keyboard actions accepted for each window. After reading the entire script file, your program must display the log showing each application opened and all commands and keyboard input that were given to that program, in the order it was entered. For example, your program's log should show something like the following for script1.txt
Log of Window Actions - Listed in Order of Window Creation
Window Windows Explorer I Logged Events
Command: My Computer
Command: Disk G:
Command: workspace
Command: p5s08
Window Internet Explorer I Logged Events
Command: Newsletter
Command: Display Issue
Command: Back
Command: Back
Command: Picture
Window WebCT Logged Events
Command: Login
Typed: jlwolfe
Typed: my password
Command: COSC310JW
Command: Discussions
Command: main
Command: Compose Message
Typed: Subject: This is a test
Typed: Message: Are you ready out there?
Command: Post
Command: Logout
Window WordPerfect Logged Events
Command: Open File
Command: follow-up-report.wpd
Command: Open
Command: Advance Page
Typed: In conclusion, the software that you supplied is
not very useful.
Typed: Please do not sent any other software until you have
corrected the
Typed: the errors that I have noted above.
Typed: I will not pay for any more defective products from
your company.
Command: Save
Window script.txt (NotePad) Logged Events
Command: Advance Page
Typed: Close
Command: Save
Events in the log are labeled "Command" if they are the result of a Click action or "Typed" if they are the result of an Enter action. For both scripts, your program should assume that there are no open windows before the script starts. Both scripts are designed to leave no open windows by the end of the script. The listing of log entries must be organized as shown above, showing all actions for each window; it should not just be a chronological listing that matches what is in the script file.
Your program is required to use a stack
to manage the windows and must use only stack actions (push, pop, peek,
empty) on this stack. You
should choose an appropriate data structure to hold the log entries associated
with a particular window. Note: a single string would not be
regarded as an appropriate structure.
Hand in a printout of your well-documented
program, and a printout of the log displays for both script files (captured
from the screen). You must create a folder named p5 under
the folder named after you on the P: drive for COSC 310. Copy
into p5 all .java files that you created for this project.
The easiest way to capture the logs is to do a copy and paste from the
output window in Eclipse to a NotePad file. Do not put the logs in
the p5 folder; do not do a print screen to capture an exact image of the
screen - it will not show all of the log.