ANU The Australian National University



____________________________________________________

[ANU] [DCS] [COMP2100/2500] [Description] [Schedule] [Lectures] [Labs] [Homework] [Assignments] [COMP2500] [Assessment] [PSP] [Java] [Reading] [Help]

____________________________________________________

COMP2100/2500
Lecture 20: Project III

Summary

The third lecture on the project. Introduction to the second assignment, more or less.


Background

This year's Assignment 2 will mostly be based on a combination of questions from the corresponding assignments over the last two years:

You might want to have a look at these. I'll recycle some of the text from the questions.


The starting code

I will give you a very basic GUI that uses the code from Assignment 1 to read in and create a parse tree for an OpenOffice.org word processor document and displays it in a window. (This is the part that I haven't done yet. Hopefully Monday.)

The starting code will be based on my solution to Assignment 1, which is adequate, but not perfect. If you have a very strong desire to start from your submitted Assignment 1 code rather than mine, you need to let me know and we'll discuss it. This will make my job producing the printouts harder, among other things. You would want to have done extremely well on Assignment 1 before you consider this.


What you will be doing

You will have to add to the starting code in various ways:

  1. The starting code will just put all the text of the document in the window with no formatting at all. You will have to modify the code so that there is vertical space between some elements, different fonts for headings, italics, bold and so on, different margins for quotes, some things centred, indentation for some paragraphs (and not for others, depending on the paragraph style), replacement of some entities and special characters as appropriate.

  2. You will add a File menu with Open and Exit items. The Open item should pop up a standard file selection dialog box, and connect it up so that when the user selects a file, the application opens and displays it. (In the same window, or in a new window? I'll have to decide.)

  3. An Export item in that menu, with a submenu where the user chooses one of three export file formats: plain text, XML or HTML. This should pop up a file selection dialog again, and when the user selects a file it should run the appropriate renderer and save its output to that file. There will be details to sort out, to do with default file name extension, overwriting existing files etc.

  4. A Properties item that pops up an information dialog box displaying the document metadata: Title, Author's Name and Affiliation.

  5. A new display mode that shows the user a tree widget view of the document structure side by side with the ordinary “web browser” style view. I'll give you details of how this should be displayed: XML element names, attributes, data content and so on. This will be linked to a new View menu with radio button menu items for selecting which sorts of view are active (either one or both). When both views are active, selecting something in one of them should make the other one scroll to (and perhaps highlight/select) the same bit in the other view.

  6. I'd really like to ask you to make the tree view editable, so that users can modify the document through this application, but my gut feeling is that it's too hard. That's the sort of thing where you run into all sorts of unforseen questions as soon as you start working on it. I guess allowing the user to edit the contents of data elements, and perhaps the element attributes, or even element names, would be reasonable. Once you allow insertion, deletion and moving of elements in the tree view, I have a feeling that it becomes a nightmare.

  7. I'd like the application to have “mnemonics” for keyboard operation of the menus. I'd also like command-key equivalents for the commands (the sort of thing where Control-Q quits, Control-O opens a new document, and so on). This shouldn't be too hard.


What to do now

If you're really desperate to get started on this, you can do some preparation this weekend by working some more on the Swing Tutorial on the Sun website. (There are links in the notes for Lecture 12 and Lecture 13.) In particular you could usefully:


What is a tree widget?

Here's an image of a tree widget.

example of a GTK tree widget

That was from Eiffel/EXG/GTK. Here's an image of a Java Swing tree widget. (This is a slightly modified version of the TreeDemo program that you can find in the relevant section of the Swing Tutorial.

example of a Java tree widget

Java tree widgets look different on different platforms. On my Mac they display with those little triangles that point across when the node is closed, and down when it's open. Apparently on Windows they look a bit more like the GTK version above with the plus and minus signs in the little boxes (which I like a bit better... I think this version and the Mac version are both ugly, but there you go...). You can customise a tree widget so that it doesn't show the folder and document icons, or so that it shows different icons in their places. That would be a good idea for this assignment too. Question is, what icons are appropriate for representing XML container elements and XML data elements?

____________________________________________________

[ANU] [DCS] [COMP2100/2500] [Description] [Schedule] [Lectures] [Labs] [Homework] [Assignments] [COMP2500] [Assessment] [PSP] [Java] [Reading] [Help]

____________________________________________________

Copyright © 2005, Jim Grundy and Ian Barnes, The Australian National University
Version 2005.1, Friday, 29 April 2005, 12:28:33 +1000
Feedback & Queries to comp2100@cs.anu.edu.au