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
175 175 // prepare the child models and refs in final ImmLists to use in the AutoAction 176 176 ResourceAccess fakeParentAccess = locator.create(fakeParentRef, null , head); 177 177 ResourceRefList resourcesToPaste = ResourceR4.KEY_CHILDREN.getRefs(fakeParentAccess); 178 if (resourcesToPaste == null) { 179 return false; 180 } 181 178 182 ImmList<ResourceModel> childModels = ImmTreeList.<ResourceModel>empty(); 179 183 ImmList<ResourceRefR4> childRefs = ImmTreeList.<ResourceRefR4>empty(); 180 184 for (ResourceRefR4 ref : resourcesToPaste) { -
modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/view/TextFrameLogic.java
4 4 import org.sophie2.base.commons.structures.ImmTreeMap; 5 5 import org.sophie2.base.commons.util.ImmMap.ImmEntry; 6 6 import org.sophie2.base.commons.util.position.ImmPoint; 7 import org.sophie2.base.dnd.SophieDragDropHandler;8 7 import org.sophie2.base.model.book.MouseLinkTriggers; 9 8 import org.sophie2.base.model.book.links.LinkTrigger; 10 9 import org.sophie2.base.model.resources.r4.access.ResourceAccess; 11 10 import org.sophie2.base.model.text.Attachment; 12 11 import org.sophie2.base.model.text.mvc.TextView; 13 import org.sophie2.base.model.text.mvc.TextViewFlow;14 12 import org.sophie2.base.model.text.smart.HotPos; 15 13 import org.sophie2.base.model.text.smart.ImmHotText; 16 14 import org.sophie2.base.model.text.smart.layout.HotLayoutPoint; 17 15 import org.sophie2.base.model.text.smart.position.HotInterval; 18 import org.sophie2.base.visual.VisualElement;19 16 import org.sophie2.base.visual.interaction.InputEventR3; 20 17 import org.sophie2.base.visual.interaction.MouseButton; 21 18 import org.sophie2.core.mvc.EventFilterBuilder; 22 19 import org.sophie2.core.mvc.LogicR3; 23 20 import org.sophie2.core.mvc.OperationDef; 24 import org.sophie2.core.mvc.SortKey;25 21 import org.sophie2.core.mvc.events.EventR3; 26 22 import org.sophie2.main.app.commons.frame.FrameView; 27 23 import org.sophie2.main.app.commons.links.LinkAttachment; 28 24 import org.sophie2.main.app.commons.links.LinkProcessorLogic; 29 import org.sophie2.main.app.halos.common.AppHaloUtil;30 25 import org.sophie2.main.func.text.model.HotTextResourceH; 31 26 32 27 /** … … 36 31 * @author pap 37 32 */ 38 33 public enum TextFrameLogic implements OperationDef { 39 40 /**41 * Handles "copy" regarding text.42 */43 @SortKey("mmm-copy-text")44 ON_COPY {45 34 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 the58 //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 69 35 /** 70 * Handles "Cut" regarding text71 */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 the87 //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 /**125 36 * Takes care of highlighting hovered text links 126 37 * and firing {@link LinkProcessorLogic.LinkEvent#LINK_ACTION_TRIGGERED} event 127 38 * 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
27 27 import org.sophie2.base.model.text.smart.position.HotInterval; 28 28 import org.sophie2.base.model.text.smart.style.HotStyleDef; 29 29 import org.sophie2.base.visual.BaseVisualElement; 30 import org.sophie2.base.visual.VisualElement; 30 31 import org.sophie2.core.mvc.EventFilterBuilder; 31 32 import org.sophie2.core.mvc.LogicR3; 32 33 import org.sophie2.core.mvc.OperationDef; … … 38 39 import org.sophie2.main.app.commons.book.panels.QuickSearchPanel; 39 40 import org.sophie2.main.app.commons.element.ElementView; 40 41 import org.sophie2.main.app.commons.page.PageWorkArea; 42 import org.sophie2.main.app.halos.common.AppHaloUtil; 41 43 import org.sophie2.main.func.text.model.HotTextResourceH; 42 44 import org.sophie2.main.func.text.model.HotTextResourceR4; 43 45 import org.sophie2.main.func.text.rtf.RtfTextImportManager; … … 241 243 242 244 return false; 243 245 } 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 244 331 }; 245 332 246 333 /**