[[BackLinksMenu]] [[TicketQuery(summary=SEARCH_COMMONS_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|)]] = Analysis = == Overview == We need to provide the ability for the application to highlight parts of a text. In order to do so we need to have following things: * Start position * End position * Style * To make sure that the text is readable as well as that the highlight itself is visible The highlight itself will be used for: * text selection * search results * spell check The highlight should allow different styling for different functionality, for example: * red underline for spell check * different background as well as character color for selection and search results.(However text model shouldn't be changed) == Task requirements == Provide a search menu in sophie2 project. On clicking the "OK" button the typed word in the word is highlighted in the selected text element (if the word exists it is highlighted as manu times as it exists). == Task result == * The result should be source code == Implementation idea == * Create a highlight object that contains start position and end position as well as style. == Related == [wiki:TEXT_STABLE_SELECTION_R0][[BR]] [wiki:SEARCH_COMMONS_R0][[BR]] [wiki:TEXT_SPELL_CHECK_R0] == How to demo == * Run the application * Create new book * Insert text frame and populated with content * Select part of the text frame content = Design = In order to provide the search: * rename the existing class Highlight to HotHighlight and add an attribute ImmColor to it. * move the existing class Highlight in org.sophie2.base.model.text its logic the following classes are added in org.sophie2.main.app.commons.logic: * SearchLogic - the class providing the logic for the search menu. This class has findSearchedText method that provides the logic for searching a particular word in the selected views. This function uses java.util.regex.Pattern and java.util.regex.Matcher to find all places in the text from the selected view where the word is matched. For every matched word a new HotHighlight is inserted in the HotTextSceneElement Refactor the existing class QuickSearchPanel in order to support the searching of a particular word in the current text. In HotTextSceneElement class add a new property RwListProp highlight() that holds all the highlighted data in the HotTextSceneElement . The highlight always has >= 1 elements in it. The first HotHighlight in the highlight() is always the selected text in the HotTextSceneElement. The HotTextPlaceLogic and HotPlaceLogic are refactored to add and remove HotHighlights: * HotTextPlaceLogic : SELECT adds the first HotHighlight in the highlight()of the HotTextSceneElement. * HotTextPlaceLogic :DELETE_CHARS and HotTextPlaceLogic :USER_GO_OP clears all the existing highlights in the HotTextSceneElement. * HotTextLogic:INPUT_CHAR deletes all the existing highlights in the HotTextSceneElement. Modify the Atom:draw method with adding a new attribute ImmColor in order to set the color of the backgroung with the specific ImmColor of every HotHighlight. Modify the EdgeKind:draw with adding a new attribute List in order to draw all the highlights of the particular text. In HotTextPane:paintComponent method add a new HotHighlight - the Highlight that contains the selected text in the HotTextSceneElement. The test source can be found here:[4458][4486][4515] = Implementation = Done according to the design source code:[4458][4486][4515][4636][4652] Merged into the trunk [4655]. = Testing = ^(Place the testing results here.)^ = Comments = The test is different from the previous one because the ticket was changed and there is no search menu.