Version 16 (modified by boyan, 16 years ago) (diff) |
---|
Analysis
Overview
This task is about providing a book properties dialog. It should display the book title and page size. This dialog appears when a new book is created or when the book properties item is selected from the file menu.
Task requirements
- Provide a modal dialog with OK and Cancel buttons that displays the following properties which should be editable:
- Title
- Page width
- Page height
- The book properties dialog should be displayed when a new book is created.
- If the user clicks the Cancel button, no book is created.
- Otherwise a book with the specified properties is created.
- These properties can be changed later when the dialog is invoked from the file menu.
- The keyboard shortcut for opening the dialog should be Ctrl+Shift+B.
Task result
The result should be source code.
Implementation idea
A new BookInfo class can be created with the following properties:
- bookTitle
- pageWidth
- pageHeight
This is required because the dialog should be displayed before the new book is created and no book should be created if the user clicks Cancel (this means we cannot edit the properties of the book directly).
Related
How to demo
- Create a new book and set its title and page size.
- Change the title and page size by showing the dialog from the File menu.
Design
When a new book is created the dialog is displayed with default values for its fields. If the user clicks ok a new book is created with the valued of the fields in the BookPropertiesDialog. Otherwise no book is created. If you display the dialog when the book is already opened it should display the information about it and allow editing it.
A new class BookInfo is created with three value properties in order to keep the values of the book info. If a new book is created new instance of the BookInfo class is created with default values for its fields. Otherwise the new instance of the BookInfo class holds the properties of the current book. If a new book is created the book properties dialog appears and if the user clicks cancel the getInfo method in BookInfo class returns null and a new book is not created, if the user clicks ok, getInfo method returns an instance of the BookInfo class and a new book with the desired prperties is created.
Implementation
Done according to the design. The page width and height are set differently because they are in one property. (changeset [2913])
Testing
Comments
(Write comments for this or later revisions here.)