wiki:GROUP_PLAIN_AND_RTF_RESOURCES_R0

Version 5 (modified by diana, 16 years ago) (diff)

--

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

Error: Macro TicketQuery(summary=GROUP_PLAIN_AND_RTF_RESOURCES_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

The user should be able to insert Plain text and RTF as resources in a book. For this revision only plain text is needed.

  • When inserted, the resource should create a frame on the existing page with it's content.

Task requirements

  • Provide Text document in the Insert menu
  • Provide a file dialog for text files (*.txt)
  • Provide RTF document in the Insert menu
  • Provide a file dialog for RTF files (*.rtf)
  • Make sure the book with inserted plain and rtf resources is saveable.

Task result

Code

Implementation idea

See TEXT_RESOURCE_HTML_R0

TEXT_RESOURCE_HTML_R0

How to demo

  • Insert a plain text
  • Insert a RTF file
  • Save and reload the book

Design

Two new modules are created: one for importing plain text documents and the other - for importing rtf documents. The html modole is extended with functionality for importing html documents. A new abstract class ImportUtil is created with the following methods:

  • handleHelper - helper fo the handle function of each newly created modules.
  • insertFrame - inserts a new Frame in the current book
  • createHotTextBookResource - creates HotTextBookResource for insert operation.
  • abstract method createRes - fills the HotTextBookResource with appropriate content for each import module.

Each module has RtfImportUtil/HtmlImportUtil/PlainTextImportUtil which extends this class and cretes appropriate content for the newly added HotTextBookResource. The module for importing rtf documents and the module for importing html documents have the following class:

  • ApplyRtfStyles/ApplyHtmlStyles - use AttributedPair class to get the corresponding CommonAttr for each

pair tag/attribute.Each one has the following methods:

  • applyStyles - apply styles recurselively to its HotText parameter according to the html/rtf tags.

Each of the modules for importing rtf/html uses RTFEditorKit/HTMLEditorKit to get the attributes from the html/rtf document.

  • getCorrespondingVal - returns the corresponding CommonAttr with value for each tag in html/rtf document.

ApplyRtfStyles uses the root element of the created StyledDocument and javax.swing.text.rtf.RTFEditorKit to obtain the attributes of the StyledDocument. ApplyHtmlStyles uses the root view of the created HTMLDocument and javax.swing.text.html.HTMLEditorKit to obtain the attributes of the HTMLDocument. Tests can be found here: [3990][3975][3989][3991][3993][3984][3983]

Implementation

Done according to the design. Source code:[3990][3975][3989][3991][3993][3984][3983]

Testing

(Place the testing results here.)

Comments

In the next revision the function getCorrespondingVal should be removed. Some kind of AttributedIterator may be used to obtain the values directly.