Changes between Version 10 and Version 11 of TEXT_CHAIN_AUTO_R0


Ignore:
Timestamp:
12/01/09 18:39:51 (15 years ago)
Author:
mira
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TEXT_CHAIN_AUTO_R0

    v10 v11  
    5353The KEY_CHAIN_MODE should be holding value from this enum. [[BR]] [[BR]] 
    5454 
    55 The chaing hud elements would no longer be of the ResourceH class, since there are two special elements to add - for turning on and off auto-chainig. Create  
     55The chaing hud elements would no longer be of the ResourceH class, since there are two special elements to add - for turning on and off auto-chainig. Create a class ChainHudElement in org.sophie2.main.func.text.chaining package that holds a ResourceRefR4 and a String representation of the object. It would be immutable. There will be two special elements holding NONE-REF and the strings "AUTO-CHAIN" and "NO CHAIN". Other elements should not be created withh NONE resource ref. So the constructor should be private and there will be a create method to validate the given refs. [[BR]] [[BR]] 
    5656 
    57 a class ChainHudElement in org.sophie2.main.func.text.chaining package that holds a ResourceRefR4 and a String representation of the object. It would be  
     57In TextChainingLogic::ON_CHAIN_TEXT_FRAME check what elements was choosen and if it is with none ref change HeadTextFrameR4.KEY_CHAIN_MODE corespondingly, otherwise chain the frame pointed by the resource ref held in the element to the head of the current frame. This hsould always change the chain mode to manual. [[BR]][[BR]] 
    5858 
    59 immutable. There will be two special elements holding NONE-REF and the strings "AUTO-CHAIN" and "NO CHAIN". Other elements should not be created withh NONE  
    60  
    61 resource ref. So the constructor should be private and there will be a create method to validate the given refs. [[BR]] [[BR]] 
    62  
    63 In TextChainingLogic::ON_CHAIN_TEXT_FRAME check what elements was choosen and if it is with none ref change HeadTextFrameR4.KEY_CHAIN_MODE corespondingly,  
    64  
    65 otherwise chain the frame pointed by the resource ref held in the element to the head of the current frame. This hsould always change the chain mode to  
    66  
    67 manual. [[BR]][[BR]] 
    68  
    69 In org.sophie2.main.app.commons.util package create a util class named TemplateUtil. It will contain helper methods for the page and frame templating and for  
    70  
    71 the creating of new templates. There is a difference in code of templating those elements since the templating of sub elements is not yet final.[[BR]] 
     59In org.sophie2.main.app.commons.util package create a util class named TemplateUtil. It will contain helper methods for the page and frame templating and for the creating of new templates. There is a difference in code of templating those elements since the templating of sub elements is not yet final.[[BR]] 
    7260 - createTemplate - creates a template from a given element view. It should check whether it is page or frame.[[BR]] 
    7361 - applyPageTemplate - apply given template to the given page. That is - set all keys to null, except the sub-entries one. [[BR]]  
    7462 - applyFrameTemplate -  Set all given templated keys to null. If it is setting the main-resource, change the kind corespondingly.[[BR]][[BR]] 
    7563 
    76 Write better dryRun method in the HotLayout class that takes in mind the number of chianed areas in the last page. It should also check if there are extra  
     64Write better dryRun method in the HotLayout class that takes in mind the number of chianed areas in the last page. It should also check if there are extra pages and return -1.[[BR]][[BR]] 
    7765 
    78 pages and return -1.[[BR]][[BR]] 
     66In TextChainHud change the existing TextChainComboBox class to extend BoundComboBox<ChainHudElement> and change the addFrames method to get a list of ChainHudElements constructed by the resource ref of the frame and its name (for string representation). Remove the AutoChain button and all its logic.[[BR]][[BR]] 
    7967 
    80 In TextChainHud change the existing TextChainComboBox class to extend BoundComboBox<ChainHudElement> and change the addFrames method to get a list of  
     68The TextChainUtils should be quite extended to hold the helper methods used by the chaing logic. Some of them are moved from the TextChainingLogic. The method used for auto-chaining will be called reflowText. It would get a head frame view as argument and basically handle all auto-fitting of its text flow (creatin, deletion of pages). It should get all frame views in this head frame`s chain. Then it gets the number of frames on the last page and runs the HotLayout.dryrun method with them. If the result is 0 - there is nothing more to do. If the result is -1 this means that the last page is empty. There should be a separate method that hamdles the deletion of extra pages. Its name should be reduceChain. If the result is an positive int this is the number of pages exactly as the first one to be added. This should be done by the method expandChain.[[BR]] 
    8169 
    82 ChainHudElements constructed by the resource ref of the frame and its name (for string representation). Remove the AutoChain button and all its  
     70 * expandChain - The chain should be expanded with pages that use templates made from the last page in the current chain and children that use templates made from the children of the last page`s children. The last page should also be made to use this template so that wnem it is changd it chanes just like the others in the chain. Those templates are added to the library just like regular ones. There are some x-cases:[[BR]] 
     71 - when there is another auto-chain in the page - the new frames are made the next in their chain. [[BR]] 
     72 - if there is an head frame (that is not autochained) its copy uses the same text resource. [[BR]] 
     73 - when there is a tail frame (or head frame that is auto-chained), its copy is the next in the chain of the source. Its chain order is also placing it before any other frame of this chain.[[BR]] 
     74 - ... 
    8375 
    84 logic.[[BR]][[BR]] 
    85  
    86 The TextChainUtils should be quite extended to hold the helper methods used by the chaing logic. Some of them are moved from the TextChainingLogic. The  
    87  
    88 method used for auto-chaining will be called reflowText. It would get a head frame view as argument and basically handle all auto-fitting of its text flow  
    89  
    90 (creatin, deletion of pages). It should get all frame views in this head frame`s chain. Then it gets the number of frames on the last page and runs the  
    91  
    92 HotLayout.dryrun method with them. If the result is 0 - there is nothing more to do. If the result is -1 this means that the last page is empty. There should  
    93  
    94 be a ceparate method that hamdles the deletion of extra pages. Its name should be reduceChain. If the result is an positive int this is the number of pages  
    95  
    96 exactly as the first one to be added. This should be done by the method expandChain.[[BR]] 
    97  
    98  * expandChain - The chain should be expanded with pages that use templates made from the last page in the current chain and children that use templates made  
    99  
    100 from the children of the last page`s children. The last page should also be made to use this template so that wnem it is changd it chanes just like the  
    101  
    102 others in the chain. Those templates are added to the library just like regular ones. There are some x-cases:[[BR]] 
    103  - When there is another auto-chain in the page - the new frames are made the next in their chain. [[BR]] 
    104  - If there is an head frame (that is not autochained) its copy uses the same text resource. [[BR]] 
    105  - when there is a tail frame (or head frame that is auto-chained), its copy is the next in the chain of the source. Its chain order is also placing it  
    106  
    107 before any other frame of this chain.[[BR]] 
    108  
    109  * reduceChain - Checks all pages starting from the last one for pages that are all templated. This means that their templated keys should be templated and  
    110  
    111 all their children should also be templated. Also all of its tail text frames should be empty. If such page is found it is deleted. If there is no more an  
    112  
    113 empty page in the end of the chain the job is done, otherwise we continue looking ofr pages to remove from the previous page.   [[BR]][[BR]] 
     76 * reduceChain - Checks all pages starting from the last one for pages that are all templated. This means that their templated keys should be templated and all their children should also be templated. Also all of its tail text frames should be empty. If such page is found it is deleted. If there is no more an empty page in the end of the chain the job is done, otherwise we continue looking ofr pages to remove from the previous page.   [[BR]][[BR]] 
    11477 
    11578There will be needed some helper methods:[[BR]] 
    11679 - TEXT_VIEW_COMP - Comparator for thext views. It compares views from the same chain by their chain-order strings.  
    117  - isAllPageTemplated - checks if all the templatable keys from the given page along with the keys of it's subelements(frames) are in TEMPLATE mode. This is  
    118  
    119 not the best way to see whther the whole page is templated but it would do before implementatin of the sub-elements templating.[[BR]] 
     80 - isAllPageTemplated - checks if all the templatable keys from the given page along with the keys of it's subelements(frames) are in TEMPLATE mode. This is not the best way to see whther the whole page is templated but it would do before implementatin of the sub-elements templating.[[BR]] 
    12081 - isPageTemplated - checks if all the templatable keys(for now except sub-entries) are in TEMPLATE mode, i.e. are their raw values null. [[BR]] 
    12182and others.[[BR]] 
    12283 - ... 
    12384 
    124 In HeadTextFrameView in the class textFlow used for a the resource property with the same name crate a class named ReflowThread. Its run method will be quite  
    125  
    126 simple. It should sleep for a second and then invoke later in the event dispatching thread the method TextChainUtils.reflowText giving it this  
    127  
    128 HeadTextFrameView object. he Headin getTextLayout method that extends Thread and delays the invoking of the TextChainUtils.reflowText method. Now the only  
    129  
    130 thing that is left is to start the thread and this will happen every time the method getTextLayout() is called on an autochained head view. It would check if  
    131  
    132 there is a thread runing and if not - strat one. Otherwise its job is done. For optimization there may be a check whether the text flow is going to be the  
    133  
    134 same as the last time the thread was called. [[BR]][[BR]] 
     85In HeadTextFrameView in the class textFlow used for a the resource property with the same name crate a class named ReflowThread. Its run method will be quite simple. It should sleep for a second and then invoke later in the event dispatching thread the method TextChainUtils.reflowText giving it this HeadTextFrameView object. he Headin getTextLayout method that extends Thread and delays the invoking of the TextChainUtils.reflowText method. Now the only thing that is left is to start the thread and this will happen every time the method getTextLayout() is called on an autochained head view. It would check if there is a thread runing and if not - strat one. Otherwise its job is done. For optimization there may be a check whether the text flow is going to be the same as the last time the thread was called. [[BR]][[BR]] 
    13586 
    13687There will be some additional fixes of bugs in the current chainig logic: [[BR]] 
    137  
    138 Now the logic assumes that in a chain there are never same chain orders. But this is not always this way. when there are same chain orders the order of the  
    139  
    140 pages and the z order are taken in consideration. Also this is the reason why the getChainedFrames() helper method can not return a map - since there is not  
    141  
    142 always a single TailFrameH corresponding to a chain order. [[BR]]  
    143 The logic of the two buttons for unchain (previous and next) should be unified. There will be a common method splitChain that they will use. It would make  
    144  
    145 the given frame - head of a new chain and all after it would be chained to it. It could use the same text resource as the previous one or get a new empty  
    146  
    147 one. This should be specified by an flag argument. [[BR]] 
    148 This method will also be used when deleting pages. Its logic was broken if deleting from the button but it was ok if deleting by 'del' or backspace. The  
    149  
    150 delete page button should have the same event as the others (its source should be the PagePreviewPalette). Now before the page is deleted the chains that  
    151  
    152 start in it are split to the first frame that is not in this page.  [[BR]][[BR]] 
     88Now the logic assumes that in a chain there are never same chain orders. But this is not always this way. when there are same chain orders the order of the pages and the z order are taken in consideration. Also this is the reason why the getChainedFrames() helper method can not return a map - since there is not always a single TailFrameH corresponding to a chain order. [[BR]]  
     89The logic of the two buttons for unchain (previous and next) should be unified. There will be a common method splitChain that they will use. It would make the given frame - head of a new chain and all after it would be chained to it. It could use the same text resource as the previous one or get a new empty one. This should be specified by an flag argument. [[BR]] 
     90This method will also be used when deleting pages. Its logic was broken if deleting from the button but it was ok if deleting by 'del' or backspace. The delete page button should have the same event as the others (its source should be the PagePreviewPalette). Now before the page is deleted the chains that start in it are split to the first frame that is not in this page.  [[BR]][[BR]] 
    15391 
    15492Also there are a couple of bugs in the base functionality of the resources. [[BR]] 
    155 First one is in the ModelResourceChanger. When an key is set to null and get in the same auto-action the get returns wrong value - the old one from the  
     93First one is in the ModelResourceChanger. When an key is set to null and get in the same auto-action the get returns wrong value - the old one from the model. This could only be found while developing and I don`t think there is an ticket for it.[[BR]] 
    15694 
    157 model. This could only be found while developing and I don`t think there is an ticket for it.[[BR]] 
    158  
    159 The other one is in the modify method of the ResourceModel. The problem occures when creating template from templated frame. There is an exception thrown but  
    160  
    161 there is no ticket also. It this case the values of some of the keys are already null and there is no need for them to be set to null but their 'locked-key's  
    162  
    163 are still set to false. The moidfy method relies on the fact that when modifing a node corresponding to a key there are chanes meant for it if the sub map of  
    164  
    165 chanes for entries whose keys start with this key is not empty. This is not true for the case of templated keys though since their locked keys idd start  
    166  
    167 exactly the same as their ids. This method hsould not rely on such assumptions. [[BR]]   
    168   
    169   
     95The other one is in the modify method of the ResourceModel. The problem occures when creating template from templated frame. There is an exception thrown but there is no ticket also. It this case the values of some of the keys are already null and there is no need for them to be set to null but their 'locked-key's are still set to false. The moidfy method relies on the fact that when modifing a node corresponding to a key there are chanes meant for it if the sub map of changes for entries whose keys start with this key is not empty. This is not true for the case of templated keys though since their locked keys idd start exactly the same as their ids. This method hsould not rely on such assumptions. [[BR]]   
    17096 
    17197= Implementation =