1 | ### Eclipse Workspace Patch 1.0 |
---|
2 | #P org.sophie2.base.model.text |
---|
3 | Index: src/main/java/org/sophie2/base/model/text/smart/layout/HotLayout.java |
---|
4 | =================================================================== |
---|
5 | --- src/main/java/org/sophie2/base/model/text/smart/layout/HotLayout.java (revision 8460) |
---|
6 | +++ src/main/java/org/sophie2/base/model/text/smart/layout/HotLayout.java (working copy) |
---|
7 | @@ -137,7 +137,7 @@ |
---|
8 | List<ImmArea> areas = this.layout.getAreas(); |
---|
9 | int lastIndex = areas.size() - 1; |
---|
10 | if (lastIndex == -1) { |
---|
11 | - return 0; |
---|
12 | + return -1; |
---|
13 | } |
---|
14 | int firstInLastPage = areas.size() - areasCount; |
---|
15 | ImmHotText hotText = this.getAreaContent(firstInLastPage); |
---|
16 | #P org.sophie2.base.model.resources.r4 |
---|
17 | Index: src/main/java/org/sophie2/base/model/resources/r4/access/DelegatingAccess.java |
---|
18 | =================================================================== |
---|
19 | --- src/main/java/org/sophie2/base/model/resources/r4/access/DelegatingAccess.java (revision 8460) |
---|
20 | +++ src/main/java/org/sophie2/base/model/resources/r4/access/DelegatingAccess.java (working copy) |
---|
21 | @@ -6,6 +6,7 @@ |
---|
22 | import org.sophie2.base.model.resources.r4.access.cacheKey.DelegatingAccessCacheKey; |
---|
23 | import org.sophie2.base.model.resources.r4.changes.Change; |
---|
24 | import org.sophie2.base.model.resources.r4.keys.Key; |
---|
25 | +import org.sophie2.base.model.resources.r4.keys.RootKey; |
---|
26 | import org.sophie2.base.model.resources.r4.model.ResourceRevision; |
---|
27 | import org.sophie2.base.model.resources.r4.model.RevisionId; |
---|
28 | import org.sophie2.base.model.resources.r4.resources.ResourceR4; |
---|
29 | @@ -20,6 +21,9 @@ |
---|
30 | */ |
---|
31 | public abstract class DelegatingAccess extends BaseResourceAccess { |
---|
32 | |
---|
33 | + private RootKey subKey = null; |
---|
34 | + |
---|
35 | + |
---|
36 | /** |
---|
37 | * The parent access that this inner delegates to. |
---|
38 | */ |
---|
39 | @@ -87,7 +91,14 @@ |
---|
40 | |
---|
41 | public <T> T getRaw(Key<T> key) { |
---|
42 | // security |
---|
43 | - return this.masterAccess.getRaw(ResourceR4.KEY_CHILDREN.sub(this.location).sub(key)); |
---|
44 | + return this.masterAccess.getRaw(getSubKey().sub(key)); |
---|
45 | + } |
---|
46 | + |
---|
47 | + private RootKey getSubKey() { |
---|
48 | + if (this.subKey == null) { |
---|
49 | + this.subKey = ResourceR4.KEY_CHILDREN.sub(this.location); |
---|
50 | + } |
---|
51 | + return this.subKey; |
---|
52 | } |
---|
53 | |
---|
54 | public void registerChange(Change change) { |
---|
55 | Index: src/main/java/org/sophie2/base/model/resources/r4/keys/Key.java |
---|
56 | =================================================================== |
---|
57 | --- src/main/java/org/sophie2/base/model/resources/r4/keys/Key.java (revision 8460) |
---|
58 | +++ src/main/java/org/sophie2/base/model/resources/r4/keys/Key.java (working copy) |
---|
59 | @@ -179,14 +179,15 @@ |
---|
60 | |
---|
61 | @Override |
---|
62 | public int hashCode() { |
---|
63 | - return getId() == null ? 0 : getId().hashCode(); |
---|
64 | + return getId() == null ? 0 : getParts().hashCode(); |
---|
65 | } |
---|
66 | |
---|
67 | @Override |
---|
68 | public boolean equals(Object obj) { |
---|
69 | if(obj instanceof Key<?>) { |
---|
70 | - String otherKey = ((Key<?>)obj).getId(); |
---|
71 | - return getId() == null ? otherKey == null : getId().equals(otherKey); |
---|
72 | + ImmList<String> otherKeyParts = ((Key<?>)obj).getParts(); |
---|
73 | + return getParts() == null ? otherKeyParts == null : |
---|
74 | + getParts().equals(otherKeyParts); |
---|
75 | } |
---|
76 | return false; |
---|
77 | } |
---|
78 | Index: src/main/java/org/sophie2/base/model/resources/r4/changes/SubResourceChanger.java |
---|
79 | =================================================================== |
---|
80 | --- src/main/java/org/sophie2/base/model/resources/r4/changes/SubResourceChanger.java (revision 8460) |
---|
81 | +++ src/main/java/org/sophie2/base/model/resources/r4/changes/SubResourceChanger.java (working copy) |
---|
82 | @@ -5,6 +5,7 @@ |
---|
83 | import org.sophie2.base.commons.util.ImmList; |
---|
84 | import org.sophie2.base.model.resources.r4.ResourceRefR4; |
---|
85 | import org.sophie2.base.model.resources.r4.keys.Key; |
---|
86 | +import org.sophie2.base.model.resources.r4.keys.RootKey; |
---|
87 | import org.sophie2.base.model.resources.r4.resources.ResourceR4; |
---|
88 | |
---|
89 | /** |
---|
90 | @@ -14,8 +15,10 @@ |
---|
91 | * @author mira, meddle |
---|
92 | */ |
---|
93 | public class SubResourceChanger extends ResourceChanger { |
---|
94 | + |
---|
95 | private final ResourceChanger parent; |
---|
96 | private final ResourceRefR4 prefix; |
---|
97 | + private final RootKey subKey; |
---|
98 | |
---|
99 | /** |
---|
100 | * Constructs a {@link SubResourceChanger} by its parent and prefix |
---|
101 | @@ -30,6 +33,7 @@ |
---|
102 | assert prefix != null; |
---|
103 | this.parent = parent; |
---|
104 | this.prefix = prefix; |
---|
105 | + this.subKey = ResourceR4.KEY_CHILDREN.sub(this.prefix); |
---|
106 | } |
---|
107 | |
---|
108 | @Override |
---|
109 | @@ -44,13 +48,12 @@ |
---|
110 | |
---|
111 | |
---|
112 | public <T> T getRaw(Key<T> key) { |
---|
113 | - return this.parent.getRaw( |
---|
114 | - ResourceR4.KEY_CHILDREN.sub(this.prefix).sub(key)); |
---|
115 | + return this.parent.getRaw(this.subKey.sub(key)); |
---|
116 | } |
---|
117 | |
---|
118 | @Override |
---|
119 | public <T> void setRaw(Key<T> key, T value) { |
---|
120 | - this.parent.setRaw(ResourceR4.KEY_CHILDREN.sub(this.prefix).sub(key), value); |
---|
121 | + this.parent.setRaw(this.subKey.sub(key), value); |
---|
122 | } |
---|
123 | |
---|
124 | @Override |
---|
125 | @@ -84,4 +87,5 @@ |
---|
126 | public boolean hasChild(ResourceRefR4 ref) { |
---|
127 | return this.parent.hasChild(this.prefix.sub(ref)); |
---|
128 | } |
---|
129 | + |
---|
130 | } |
---|
131 | \ No newline at end of file |
---|