Ticket #2260: copy-paste-text-in-stickies.patch

File copy-paste-text-in-stickies.patch, 9.8 KB (added by deni, 15 years ago)
  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/element/ElementLogic.java

    ### Eclipse Workspace Patch 1.0
    #P sophie
     
    175175                                // prepare the child models and refs in final ImmLists to use in the AutoAction 
    176176                                ResourceAccess fakeParentAccess = locator.create(fakeParentRef, null , head); 
    177177                                ResourceRefList resourcesToPaste = ResourceR4.KEY_CHILDREN.getRefs(fakeParentAccess); 
     178                                if (resourcesToPaste == null) { 
     179                                        return false; 
     180                                } 
     181                                 
    178182                                ImmList<ResourceModel> childModels = ImmTreeList.<ResourceModel>empty(); 
    179183                                ImmList<ResourceRefR4> childRefs = ImmTreeList.<ResourceRefR4>empty(); 
    180184                                for (ResourceRefR4 ref : resourcesToPaste) { 
  • modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/view/TextFrameLogic.java

     
    44import org.sophie2.base.commons.structures.ImmTreeMap; 
    55import org.sophie2.base.commons.util.ImmMap.ImmEntry; 
    66import org.sophie2.base.commons.util.position.ImmPoint; 
    7 import org.sophie2.base.dnd.SophieDragDropHandler; 
    87import org.sophie2.base.model.book.MouseLinkTriggers; 
    98import org.sophie2.base.model.book.links.LinkTrigger; 
    109import org.sophie2.base.model.resources.r4.access.ResourceAccess; 
    1110import org.sophie2.base.model.text.Attachment; 
    1211import org.sophie2.base.model.text.mvc.TextView; 
    13 import org.sophie2.base.model.text.mvc.TextViewFlow; 
    1412import org.sophie2.base.model.text.smart.HotPos; 
    1513import org.sophie2.base.model.text.smart.ImmHotText; 
    1614import org.sophie2.base.model.text.smart.layout.HotLayoutPoint; 
    1715import org.sophie2.base.model.text.smart.position.HotInterval; 
    18 import org.sophie2.base.visual.VisualElement; 
    1916import org.sophie2.base.visual.interaction.InputEventR3; 
    2017import org.sophie2.base.visual.interaction.MouseButton; 
    2118import org.sophie2.core.mvc.EventFilterBuilder; 
    2219import org.sophie2.core.mvc.LogicR3; 
    2320import org.sophie2.core.mvc.OperationDef; 
    24 import org.sophie2.core.mvc.SortKey; 
    2521import org.sophie2.core.mvc.events.EventR3; 
    2622import org.sophie2.main.app.commons.frame.FrameView; 
    2723import org.sophie2.main.app.commons.links.LinkAttachment; 
    2824import org.sophie2.main.app.commons.links.LinkProcessorLogic; 
    29 import org.sophie2.main.app.halos.common.AppHaloUtil; 
    3025import org.sophie2.main.func.text.model.HotTextResourceH; 
    3126 
    3227/** 
     
    3631 * @author pap 
    3732 */ 
    3833public enum TextFrameLogic implements OperationDef { 
    39          
    40         /** 
    41          *      Handles "copy" regarding text.  
    42          */ 
    43         @SortKey("mmm-copy-text") 
    44         ON_COPY { 
    4534 
    46                 public void defineFilter(EventFilterBuilder filter) { 
    47                         filter.setEventId(SophieDragDropHandler.TransferEventIds.COPY); 
    48                         filter.setSourceClass(VisualElement.class); 
    49                 } 
    50  
    51                 public boolean handle(EventR3 event) { 
    52                         VisualElement source = event.getSource(VisualElement.class); 
    53                         TextFrameView selectedFrame = AppHaloUtil.getSingleSelected(source, TextFrameView.class); 
    54                         if (selectedFrame != null) { 
    55                                 TextView textView = selectedFrame.textView().get(); 
    56                                 TextViewFlow flow = selectedFrame.textFlow().get(); 
    57                                 //TODO : This comparator sucks. The interval seems to have an idea about the 
    58                                 //ImmHotText it is part of. 
    59                                 if ( !flow.getSelectionInterval().isEmpty(flow.getText().getPosComparator()) ) { 
    60                                         return LogicR3.fire(textView, null, null, event, TextView.EventIds.COPY); 
    61                                 } 
    62                         } 
    63                          
    64                         return false; 
    65                 } 
    66                  
    67         }, 
    68          
    6935        /** 
    70          * Handles "Cut" regarding text  
    71          */ 
    72         @SortKey("mmm-cut-text") 
    73         ON_CUT { 
    74  
    75                 public void defineFilter(EventFilterBuilder filter) { 
    76                         filter.setEventId(SophieDragDropHandler.TransferEventIds.CUT); 
    77                         filter.setSourceClass(VisualElement.class); 
    78                 } 
    79  
    80                 public boolean handle(EventR3 event) { 
    81                         VisualElement source = event.getSource(VisualElement.class); 
    82                         TextFrameView selectedFrame = AppHaloUtil.getSingleSelected(source, TextFrameView.class); 
    83                         if (selectedFrame != null) { 
    84                                 TextView textView = selectedFrame.textView().get(); 
    85                                 TextViewFlow flow = selectedFrame.textFlow().get(); 
    86                                 //TODO : This comparator sucks. The interval seems to have an idea about the 
    87                                 //ImmHotText it is part of. 
    88                                 if ( !flow.getSelectionInterval().isEmpty(flow.getText().getPosComparator()) ) { 
    89                                         return LogicR3.fire(textView, null, null, event, TextView.EventIds.CUT); 
    90                                 } 
    91                         } 
    92                          
    93                         return false; 
    94                 } 
    95                  
    96                  
    97         }, 
    98          
    99         /** 
    100          * Handles pasting of text. 
    101          */ 
    102         @SortKey("mmm-paste-text") 
    103         ON_PASTE { 
    104  
    105                 public void defineFilter(EventFilterBuilder filter) { 
    106                         filter.setEventId(SophieDragDropHandler.TransferEventIds.PASTE); 
    107                         filter.setSourceClass(VisualElement.class); 
    108                 } 
    109  
    110                 public boolean handle(EventR3 event) { 
    111                         VisualElement source = event.getSource(VisualElement.class); 
    112                         TextFrameView selectedFrame = AppHaloUtil.getSingleSelected(source, TextFrameView.class); 
    113                         if (selectedFrame != null) { 
    114                                 TextView textView = selectedFrame.textView().get(); 
    115                                 return LogicR3.fire(textView, null, null, event, TextView.EventIds.PASTE); 
    116                         } 
    117                          
    118                         return false; 
    119                 } 
    120                  
    121  
    122         }, 
    123  
    124         /** 
    12536         * Takes care of highlighting hovered text links  
    12637         * and firing {@link LinkProcessorLogic.LinkEvent#LINK_ACTION_TRIGGERED} event 
    12738         * if the {@link MouseLinkTriggers}'s MOUSE_ENTER or MOUSE_LEAVE triggers have been evoked. 
  • modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/view/HotTextLogic.java

     
    2727import org.sophie2.base.model.text.smart.position.HotInterval; 
    2828import org.sophie2.base.model.text.smart.style.HotStyleDef; 
    2929import org.sophie2.base.visual.BaseVisualElement; 
     30import org.sophie2.base.visual.VisualElement; 
    3031import org.sophie2.core.mvc.EventFilterBuilder; 
    3132import org.sophie2.core.mvc.LogicR3; 
    3233import org.sophie2.core.mvc.OperationDef; 
     
    3839import org.sophie2.main.app.commons.book.panels.QuickSearchPanel; 
    3940import org.sophie2.main.app.commons.element.ElementView; 
    4041import org.sophie2.main.app.commons.page.PageWorkArea; 
     42import org.sophie2.main.app.halos.common.AppHaloUtil; 
    4143import org.sophie2.main.func.text.model.HotTextResourceH; 
    4244import org.sophie2.main.func.text.model.HotTextResourceR4; 
    4345import org.sophie2.main.func.text.rtf.RtfTextImportManager; 
     
    241243                         
    242244                        return false; 
    243245                } 
     246        }, 
     247         
     248        /** 
     249         *      Handles "copy" regarding text.  
     250         */ 
     251        @SortKey("mmm-copy-text") 
     252        ON_MENU_COPY { 
     253 
     254                public void defineFilter(EventFilterBuilder filter) { 
     255                        filter.setEventId(SophieDragDropHandler.TransferEventIds.COPY); 
     256                        filter.setSourceClass(VisualElement.class); 
     257                } 
     258 
     259                public boolean handle(EventR3 event) { 
     260                        VisualElement source = event.getSource(VisualElement.class); 
     261                        ElementView selectedElement = AppHaloUtil.getSingleSelected(source, ElementView.class); 
     262                        if (selectedElement != null && selectedElement instanceof TextElement) { 
     263                                TextView textView = ((TextElement) selectedElement).textView().get(); 
     264                                TextViewFlow flow = textView.textFlow().get(); 
     265                                //TODO : This comparator sucks. The interval seems to have an idea about the 
     266                                //ImmHotText it is part of. 
     267                                if ( !flow.getSelectionInterval().isEmpty(flow.getText().getPosComparator()) ) { 
     268                                        return LogicR3.fire(textView, null, null, event, TextView.EventIds.COPY); 
     269                                } 
     270                        } 
     271                         
     272                        return false; 
     273                } 
     274                 
     275        }, 
     276         
     277        /** 
     278         * Handles "Cut" regarding text  
     279         */ 
     280        @SortKey("mmm-cut-text") 
     281        ON_MENU_CUT { 
     282 
     283                public void defineFilter(EventFilterBuilder filter) { 
     284                        filter.setEventId(SophieDragDropHandler.TransferEventIds.CUT); 
     285                        filter.setSourceClass(VisualElement.class); 
     286                } 
     287 
     288                public boolean handle(EventR3 event) { 
     289                        VisualElement source = event.getSource(VisualElement.class); 
     290                        ElementView selectedElement = AppHaloUtil.getSingleSelected(source, ElementView.class); 
     291                        if (selectedElement != null && selectedElement instanceof TextElement) { 
     292                                TextView textView = ((TextElement)selectedElement).textView().get(); 
     293                                TextViewFlow flow = textView.textFlow().get(); 
     294                                //TODO : This comparator sucks. The interval seems to have an idea about the 
     295                                //ImmHotText it is part of. 
     296                                if ( !flow.getSelectionInterval().isEmpty(flow.getText().getPosComparator()) ) { 
     297                                        return LogicR3.fire(textView, null, null, event, TextView.EventIds.CUT); 
     298                                } 
     299                        } 
     300                         
     301                        return false; 
     302                } 
     303                 
     304                 
     305        }, 
     306         
     307        /** 
     308         * Handles pasting of text. 
     309         */ 
     310        @SortKey("mmm-paste-text") 
     311        ON_MENU_PASTE { 
     312 
     313                public void defineFilter(EventFilterBuilder filter) { 
     314                        filter.setEventId(SophieDragDropHandler.TransferEventIds.PASTE); 
     315                        filter.setSourceClass(VisualElement.class); 
     316                } 
     317 
     318                public boolean handle(EventR3 event) { 
     319                        VisualElement source = event.getSource(VisualElement.class); 
     320                        ElementView selectedElement = AppHaloUtil.getSingleSelected(source, ElementView.class); 
     321                        if (selectedElement != null && selectedElement instanceof TextElement) { 
     322                                TextView textView = ((TextElement)selectedElement).textView().get(); 
     323                                LogicR3.fire(textView, null, null, event, TextView.EventIds.PASTE); 
     324                                return true; 
     325                        } 
     326                         
     327                        return false; 
     328                } 
     329                 
     330 
    244331        }; 
    245332         
    246333        /**