wiki:BOOK_PROPERTIES_DIALOG_R0
Last modified 16 years ago Last modified on 06/05/09 12:37:35

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=BOOK_PROPERTIES_DIALOG_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

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).

BOOK_PROPERTIES_DIALOG

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

End user behaviour

When a new book is created, a dialog showing a default title and page size is displayed. The user is able to edit these and accept them by clicking OK. In this case, a new book is created with the given title and page size. If Cancel is clicked, no book is created. The dialog can be displayed again by selecting the Book Properties item in the File menu or by pressing Ctrl+Shift+B from the keyboard. In this case, the title and page size of the current book are displayed and can be edited. Clicking OK now saves the changes, while clicking Cancel discards them.

Internal design

A new class BookInfo will be created in the org.sophie2.base.model.book module. It will contain three properties, holding the values for the title, the page width and the page height. These should be set with the following default initial values:

  • Title - "New Book A"
  • Page width - 640
  • Page height - 480

There will be two constructors of this class. The first takes no arguments and is invoked when a new book is created. The second takes title,width and height as arguments and sets it's properties to the corresponding values of the given ones. In the BookPropertiesDialog class a new static class is created: SwingDialog. SwingDialog hold's the swing elements of the dialog. The book properties dialog will provide a JPanel that shows the information from the BookInfo class. Based on the user input (OK/Cancel clicked) and the currentBook property of BookInfo (whether it is null or not), one of the above mentioned actions will be taken.

An initial test can be found here: branches/private/diana/sophie2-platform/modules/org.sophie2.main.app.commons/src/test/java/org/sophie2/main/app/commons/dialogs/BookPropertiesDialogTest.java [3095]

Implementation

Done according to the design.

branches/private/diana/sophie2-platform/modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/dialogs/BookInfo.java [3193]

branches/private/diana/sophie2-platform/modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/dialogs/BookPropertiesDialog.java[3193]

branches/private/diana/sophie2-platform/modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/logic/AppLogic.java[3193]

branches/private/diana/sophie2-platform/modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/logic/BookLogic.java[3193]

Implementation merged to the trunk in [3229].

Testing

Comments

  • In the next revision, we might provide several pre-set values for the page size (as in Sophie1). --boyan@2009-05-29