### Eclipse Workspace Patch 1.0
#P sophie2-platform
|
|
|
5 | 5 | import org.sophie2.base.bound.BoundControl; |
6 | 6 | import org.sophie2.base.bound.ComboInput; |
7 | 7 | import org.sophie2.base.commons.util.ImmMap; |
| 8 | import org.sophie2.base.commons.util.NaiveImmList; |
8 | 9 | import org.sophie2.base.commons.util.ImmMap.ImmEntry; |
9 | 10 | import org.sophie2.base.halos.HaloButton; |
10 | 11 | import org.sophie2.base.model.book.BookH; |
| 12 | import org.sophie2.base.model.book.FrameH; |
11 | 13 | import org.sophie2.base.model.book.PageH; |
12 | 14 | import org.sophie2.base.model.book.frame.FrameR4; |
13 | 15 | import org.sophie2.base.model.book.interfaces.ResourceFrame; |
… |
… |
|
19 | 21 | import org.sophie2.base.model.resources.r4.access.ResourceAccess; |
20 | 22 | import org.sophie2.base.model.resources.r4.changes.AutoAction; |
21 | 23 | import org.sophie2.base.model.resources.r4.changes.ResourceChanger; |
| 24 | import org.sophie2.base.model.resources.r4.keys.TemplatedKey; |
22 | 25 | import org.sophie2.base.model.resources.r4.resources.ResourceH; |
23 | 26 | import org.sophie2.base.model.resources.r4.resources.ResourceR4; |
24 | 27 | import org.sophie2.base.model.text.mvc.TextViewFlow; |
25 | 28 | import org.sophie2.base.model.text.smart.ImmHotText; |
26 | 29 | import org.sophie2.base.model.text.smart.position.HotInterval; |
| 30 | import org.sophie2.core.logging.SophieLog; |
27 | 31 | import org.sophie2.core.mvc.EventFilterBuilder; |
28 | 32 | import org.sophie2.core.mvc.OperationDef; |
29 | 33 | import org.sophie2.core.mvc.SortKey; |
… |
… |
|
34 | 38 | import org.sophie2.main.app.halos.frame.FrameRemoveHaloButton; |
35 | 39 | import org.sophie2.main.app.layout.left.pages.PagePreviewPalette; |
36 | 40 | import org.sophie2.main.app.layout.left.pages.PagePreviewPalette.PageItem; |
| 41 | import org.sophie2.main.app.layout.right.library.LibraryTabLogic; |
37 | 42 | import org.sophie2.main.func.text.chaining.TextChainHud.AutoChainButton; |
38 | 43 | import org.sophie2.main.func.text.chaining.TextChainHud.TextChainComboBox; |
39 | 44 | import org.sophie2.main.func.text.model.HeadTextFrameH; |
… |
… |
|
111 | 116 | |
112 | 117 | int curIndex = book.getIndexOf(curPage); |
113 | 118 | int chainIndex = 1; |
| 119 | |
| 120 | |
| 121 | |
114 | 122 | |
115 | 123 | // ----- start templating stuff ------- |
116 | 124 | final ResourceRefR4 frameRef = selFrameView.model().get().getRef(); |
… |
… |
|
160 | 168 | ResourceRefR4 toChainRef = HeadTextFrameH.createTextFrameAction( |
161 | 169 | book, page, ImmHotText.empty(), ResourceRefR4.NONE_REF.toUri(), |
162 | 170 | null, "Insert text frame", false); |
| 171 | |
| 172 | |
163 | 173 | |
164 | 174 | chainTextFrame(selFrameView, toChainRef, chainIndex, false, templateRef); |
165 | 175 | |
… |
… |
|
392 | 402 | * Whether the action for chaining the frame is significant. |
393 | 403 | * Should be false when this is used in auto chaining, for |
394 | 404 | * example. |
395 | | * @param template |
| 405 | * @param templateRef |
396 | 406 | * The template to use for the newly created frame. |
397 | 407 | * @return |
398 | 408 | * True if the chaining operation was successful, false otherwise. |
399 | 409 | */ |
400 | 410 | static final boolean chainTextFrame(TextFrameView prevView, final ResourceRefR4 toChainRef, |
401 | | int offset, boolean significant, final ResourceRefR4 template) { |
| 411 | int offset, boolean significant, final ResourceRefR4 templateRef) { |
402 | 412 | |
403 | 413 | BookView bookView = prevView.getBookView(); |
404 | 414 | ResourceAccess bookAccess = bookView.getAccess(); |
… |
… |
|
461 | 471 | }} |
462 | 472 | }.register(bookView.getAccess()); |
463 | 473 | } |
| 474 | |
| 475 | if (!ResourceRefR4.NONE_REF.equals(templateRef)) { |
| 476 | FrameH template = ResourceH.getHelper(toChainAccess.open(templateRef, null), FrameH.class); |
| 477 | |
| 478 | final String templateKind = template.getAccess().getRaw(ResourceR4.KEY_KIND); |
| 479 | |
| 480 | SophieLog.debug("Applying frame template from " + templateRef); |
| 481 | |
| 482 | final NaiveImmList<TemplatedKey<?>> immKeys = template.getApplicableTemplatedKeys(); |
| 483 | |
| 484 | new AutoAction("Apply frame template", false) { |
| 485 | |
| 486 | @Override |
| 487 | public void performAuto() { |
| 488 | LibraryTabLogic.applyFrameTemplate(getChanger(), immKeys, templateRef, false, templateKind); |
| 489 | } |
| 490 | |
| 491 | }.register(toChainAccess); |
| 492 | } |
464 | 493 | |
465 | 494 | new AutoAction("Chain text frame", significant) { |
466 | 495 | |
… |
… |
|
471 | 500 | frameCh.setRaw(ResourceR4.KEY_KIND, TailTextFrameR4.KIND); |
472 | 501 | frameCh.setRaw(TailTextFrameR4.KEY_HEAD_REFERENCE, headFrameRef); |
473 | 502 | frameCh.setRaw(TailTextFrameR4.KEY_CHAIN_ORDER, chainOrder); |
474 | | frameCh.setRaw(ResourceR4.KEY_TEMPLATE, template); |
475 | 503 | } |
476 | 504 | |
477 | 505 | }.register(bookAccess); |