|
@@ -1,19 +1,16 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.GWT.client.widgets.nonpublic; |
3 |
3 |
|
|
|
4 |
+ |
import org.litesoft.commonfoundation.typeutils.Objects; |
4 |
5 |
|
import org.litesoft.commonfoundation.typeutils.*; |
|
6 |
+ |
import org.litesoft.core.simpletypes.*; |
5 |
7 |
|
|
6 |
8 |
|
import java.util.*; |
7 |
9 |
|
|
8 |
|
- |
import org.litesoft.core.simpletypes.*; |
9 |
|
- |
import org.litesoft.commonfoundation.typeutils.Objects; |
10 |
|
- |
|
11 |
10 |
|
import static org.litesoft.core.simpletypes.nonpublic.EqualSupport.*; |
12 |
11 |
|
|
13 |
|
- |
public class InjectionPointSelectorController<T extends Synopsisable> |
14 |
|
- |
{ |
15 |
|
- |
public interface View<U extends Synopsisable> |
16 |
|
- |
{ |
|
12 |
+ |
public class InjectionPointSelectorController<T extends Synopsisable> { |
|
13 |
+ |
public interface View<U extends Synopsisable> { |
17 |
14 |
|
public void injectBetween( U pLowerBound, U pUpperBound ); |
18 |
15 |
|
|
19 |
16 |
|
public void show( DrillDownSet pDrillDownSet ); |
|
@@ -21,57 +18,46 @@ |
21 |
18 |
|
public void notEnoughVisibleEntries(); |
22 |
19 |
|
} |
23 |
20 |
|
|
24 |
|
- |
public static abstract class ViewEntry<U extends Synopsisable> |
25 |
|
- |
{ |
|
21 |
+ |
public static abstract class ViewEntry<U extends Synopsisable> { |
26 |
22 |
|
private String mText; |
27 |
23 |
|
|
28 |
|
- |
protected ViewEntry( String pText ) |
29 |
|
- |
{ |
|
24 |
+ |
protected ViewEntry( String pText ) { |
30 |
25 |
|
mText = Strings.assertNotNullNotEmpty( "Text", pText ); |
31 |
26 |
|
} |
32 |
27 |
|
|
33 |
|
- |
public U getUpperReference() |
34 |
|
- |
{ |
|
28 |
+ |
public U getUpperReference() { |
35 |
29 |
|
return null; |
36 |
30 |
|
} |
37 |
31 |
|
|
38 |
|
- |
public U getLowerReference() |
39 |
|
- |
{ |
|
32 |
+ |
public U getLowerReference() { |
40 |
33 |
|
return null; |
41 |
34 |
|
} |
42 |
35 |
|
|
43 |
36 |
|
/** |
44 |
37 |
|
* If Selectable, then is NOT a reference, but one of: Between, There, Top, or Bottom |
45 |
38 |
|
*/ |
46 |
|
- |
public boolean isSelectable() |
47 |
|
- |
{ |
|
39 |
+ |
public boolean isSelectable() { |
48 |
40 |
|
return false; |
49 |
41 |
|
} |
50 |
42 |
|
|
51 |
|
- |
public boolean isBetween() |
52 |
|
- |
{ |
|
43 |
+ |
public boolean isBetween() { |
53 |
44 |
|
return false; |
54 |
45 |
|
} |
55 |
46 |
|
|
56 |
|
- |
public boolean isSelected() |
57 |
|
- |
{ |
|
47 |
+ |
public boolean isSelected() { |
58 |
48 |
|
return false; |
59 |
49 |
|
} |
60 |
50 |
|
|
61 |
|
- |
public final String getText() |
62 |
|
- |
{ |
|
51 |
+ |
public final String getText() { |
63 |
52 |
|
return mText; |
64 |
53 |
|
} |
65 |
54 |
|
|
66 |
55 |
|
@Override |
67 |
|
- |
public boolean equals( Object o ) |
68 |
|
- |
{ |
69 |
|
- |
if ( this == o ) |
70 |
|
- |
{ |
|
56 |
+ |
public boolean equals( Object o ) { |
|
57 |
+ |
if ( this == o ) { |
71 |
58 |
|
return true; |
72 |
59 |
|
} |
73 |
|
- |
if ( (o == null) || !this.getClass().getName().equals( o.getClass().getName() ) ) |
74 |
|
- |
{ |
|
60 |
+ |
if ( (o == null) || !this.getClass().getName().equals( o.getClass().getName() ) ) { |
75 |
61 |
|
return false; |
76 |
62 |
|
} |
77 |
63 |
|
ViewEntry them = (ViewEntry) o; |
|
@@ -81,48 +67,39 @@ |
81 |
67 |
|
} |
82 |
68 |
|
|
83 |
69 |
|
@Override |
84 |
|
- |
public int hashCode() |
85 |
|
- |
{ |
|
70 |
+ |
public int hashCode() { |
86 |
71 |
|
return hashCodeEm( calcHashCode( getText() ), // |
87 |
72 |
|
calcHashCode( getUpperReference() ), // |
88 |
73 |
|
calcHashCode( getLowerReference() ) ); |
89 |
74 |
|
} |
90 |
75 |
|
} |
91 |
76 |
|
|
92 |
|
- |
public static class ViewSet |
93 |
|
- |
{ |
|
77 |
+ |
public static class ViewSet { |
94 |
78 |
|
private List<ViewEntry> mEntries; |
95 |
79 |
|
|
96 |
|
- |
public ViewSet( List<ViewEntry> pEntries ) |
97 |
|
- |
{ |
|
80 |
+ |
public ViewSet( List<ViewEntry> pEntries ) { |
98 |
81 |
|
mEntries = pEntries; |
99 |
82 |
|
} |
100 |
83 |
|
|
101 |
|
- |
public ViewSet( ViewEntry... pEntries ) |
102 |
|
- |
{ |
|
84 |
+ |
public ViewSet( ViewEntry... pEntries ) { |
103 |
85 |
|
mEntries = Arrays.asList( pEntries ); |
104 |
86 |
|
} |
105 |
87 |
|
|
106 |
|
- |
public ViewEntry[] getEntries() |
107 |
|
- |
{ |
|
88 |
+ |
public ViewEntry[] getEntries() { |
108 |
89 |
|
return mEntries.toArray( new ViewEntry[mEntries.size()] ); |
109 |
90 |
|
} |
110 |
91 |
|
|
111 |
92 |
|
@Override |
112 |
|
- |
public String toString() |
113 |
|
- |
{ |
|
93 |
+ |
public String toString() { |
114 |
94 |
|
return mEntries.toString(); |
115 |
95 |
|
} |
116 |
96 |
|
|
117 |
97 |
|
@Override |
118 |
|
- |
public boolean equals( Object o ) |
119 |
|
- |
{ |
120 |
|
- |
if ( this == o ) |
121 |
|
- |
{ |
|
98 |
+ |
public boolean equals( Object o ) { |
|
99 |
+ |
if ( this == o ) { |
122 |
100 |
|
return true; |
123 |
101 |
|
} |
124 |
|
- |
if ( (o == null) || !this.getClass().getName().equals( o.getClass().getName() ) ) |
125 |
|
- |
{ |
|
102 |
+ |
if ( (o == null) || !this.getClass().getName().equals( o.getClass().getName() ) ) { |
126 |
103 |
|
return false; |
127 |
104 |
|
} |
128 |
105 |
|
ViewSet them = (ViewSet) o; |
|
@@ -130,54 +107,45 @@ |
130 |
107 |
|
} |
131 |
108 |
|
|
132 |
109 |
|
@Override |
133 |
|
- |
public int hashCode() |
134 |
|
- |
{ |
|
110 |
+ |
public int hashCode() { |
135 |
111 |
|
return calcHashCode( mEntries ); |
136 |
112 |
|
} |
137 |
113 |
|
} |
138 |
114 |
|
|
139 |
|
- |
public static class DrillDownSet |
140 |
|
- |
{ |
|
115 |
+ |
public static class DrillDownSet { |
141 |
116 |
|
private ViewSet mHomeSet; |
142 |
117 |
|
private boolean mSomethingBetweenHomeAndPreviousSets; |
143 |
118 |
|
private ViewSet mPreviousSet; |
144 |
119 |
|
private ViewSet mCurrentSet; |
145 |
120 |
|
|
146 |
|
- |
public DrillDownSet( ViewSet pHomeSet, boolean pSomethingBetweenHomeAndPreviousSets, ViewSet pPreviousSet, ViewSet pCurrentSet ) |
147 |
|
- |
{ |
|
121 |
+ |
public DrillDownSet( ViewSet pHomeSet, boolean pSomethingBetweenHomeAndPreviousSets, ViewSet pPreviousSet, ViewSet pCurrentSet ) { |
148 |
122 |
|
mHomeSet = pHomeSet; |
149 |
123 |
|
mSomethingBetweenHomeAndPreviousSets = pSomethingBetweenHomeAndPreviousSets; |
150 |
124 |
|
mPreviousSet = pPreviousSet; |
151 |
125 |
|
mCurrentSet = pCurrentSet; |
152 |
126 |
|
} |
153 |
127 |
|
|
154 |
|
- |
public ViewSet getHomeSet() |
155 |
|
- |
{ |
|
128 |
+ |
public ViewSet getHomeSet() { |
156 |
129 |
|
return mHomeSet; |
157 |
130 |
|
} |
158 |
131 |
|
|
159 |
|
- |
public boolean isSomethingBetweenHomeAndPreviousSets() |
160 |
|
- |
{ |
|
132 |
+ |
public boolean isSomethingBetweenHomeAndPreviousSets() { |
161 |
133 |
|
return mSomethingBetweenHomeAndPreviousSets; |
162 |
134 |
|
} |
163 |
135 |
|
|
164 |
|
- |
public ViewSet getPreviousSet() |
165 |
|
- |
{ |
|
136 |
+ |
public ViewSet getPreviousSet() { |
166 |
137 |
|
return mPreviousSet; |
167 |
138 |
|
} |
168 |
139 |
|
|
169 |
|
- |
public ViewSet getCurrentSet() |
170 |
|
- |
{ |
|
140 |
+ |
public ViewSet getCurrentSet() { |
171 |
141 |
|
return mCurrentSet; |
172 |
142 |
|
} |
173 |
143 |
|
|
174 |
144 |
|
@Override |
175 |
|
- |
public String toString() |
176 |
|
- |
{ |
|
145 |
+ |
public String toString() { |
177 |
146 |
|
StringBuilder sb = new StringBuilder( "DrillDownSet:" ); |
178 |
147 |
|
add( sb, "Home", mHomeSet ); |
179 |
|
- |
if ( mSomethingBetweenHomeAndPreviousSets ) |
180 |
|
- |
{ |
|
148 |
+ |
if ( mSomethingBetweenHomeAndPreviousSets ) { |
181 |
149 |
|
sb.append( "\n ..." ); |
182 |
150 |
|
} |
183 |
151 |
|
add( sb, "Prev", mPreviousSet ); |
|
@@ -185,23 +153,18 @@ |
185 |
153 |
|
return sb.toString(); |
186 |
154 |
|
} |
187 |
155 |
|
|
188 |
|
- |
private void add( StringBuilder pSb, String pWhat, ViewSet pSet ) |
189 |
|
- |
{ |
190 |
|
- |
if ( pSet != null ) |
191 |
|
- |
{ |
|
156 |
+ |
private void add( StringBuilder pSb, String pWhat, ViewSet pSet ) { |
|
157 |
+ |
if ( pSet != null ) { |
192 |
158 |
|
pSb.append( '\n' ).append( pWhat ).append( ": " ).append( pSet ); |
193 |
159 |
|
} |
194 |
160 |
|
} |
195 |
161 |
|
|
196 |
162 |
|
@Override |
197 |
|
- |
public boolean equals( Object o ) |
198 |
|
- |
{ |
199 |
|
- |
if ( this == o ) |
200 |
|
- |
{ |
|
163 |
+ |
public boolean equals( Object o ) { |
|
164 |
+ |
if ( this == o ) { |
201 |
165 |
|
return true; |
202 |
166 |
|
} |
203 |
|
- |
if ( (o == null) || !this.getClass().getName().equals( o.getClass().getName() ) ) |
204 |
|
- |
{ |
|
167 |
+ |
if ( (o == null) || !this.getClass().getName().equals( o.getClass().getName() ) ) { |
205 |
168 |
|
return false; |
206 |
169 |
|
} |
207 |
170 |
|
DrillDownSet them = (DrillDownSet) o; |
|
@@ -212,22 +175,19 @@ |
212 |
175 |
|
} |
213 |
176 |
|
|
214 |
177 |
|
@Override |
215 |
|
- |
public int hashCode() |
216 |
|
- |
{ |
|
178 |
+ |
public int hashCode() { |
217 |
179 |
|
return hashCodeEm( calcHashCode( mHomeSet ), // |
218 |
180 |
|
calcHashCode( mPreviousSet ), // |
219 |
181 |
|
calcHashCode( mCurrentSet ) ); |
220 |
182 |
|
} |
221 |
183 |
|
} |
222 |
184 |
|
|
223 |
|
- |
static abstract class SelectionPointEntry<U extends Synopsisable> extends ViewEntry<U> |
224 |
|
- |
{ |
|
185 |
+ |
static abstract class SelectionPointEntry<U extends Synopsisable> extends ViewEntry<U> { |
225 |
186 |
|
private boolean mSelected; |
226 |
187 |
|
private U mUpperReference; |
227 |
188 |
|
private U mLowerReference; |
228 |
189 |
|
|
229 |
|
- |
protected SelectionPointEntry( boolean pSelected, String pText, U pUpperReference, U pLowerReference ) |
230 |
|
- |
{ |
|
190 |
+ |
protected SelectionPointEntry( boolean pSelected, String pText, U pUpperReference, U pLowerReference ) { |
231 |
191 |
|
super( pText ); |
232 |
192 |
|
mSelected = pSelected; |
233 |
193 |
|
mUpperReference = pUpperReference; |
|
@@ -235,131 +195,106 @@ |
235 |
195 |
|
} |
236 |
196 |
|
|
237 |
197 |
|
@Override |
238 |
|
- |
public U getUpperReference() |
239 |
|
- |
{ |
|
198 |
+ |
public U getUpperReference() { |
240 |
199 |
|
return mUpperReference; |
241 |
200 |
|
} |
242 |
201 |
|
|
243 |
202 |
|
@Override |
244 |
|
- |
public U getLowerReference() |
245 |
|
- |
{ |
|
203 |
+ |
public U getLowerReference() { |
246 |
204 |
|
return mLowerReference; |
247 |
205 |
|
} |
248 |
206 |
|
|
249 |
207 |
|
@Override |
250 |
|
- |
public boolean isSelectable() |
251 |
|
- |
{ |
|
208 |
+ |
public boolean isSelectable() { |
252 |
209 |
|
return true; |
253 |
210 |
|
} |
254 |
211 |
|
|
255 |
212 |
|
@Override |
256 |
|
- |
public boolean isSelected() |
257 |
|
- |
{ |
|
213 |
+ |
public boolean isSelected() { |
258 |
214 |
|
return mSelected; |
259 |
215 |
|
} |
260 |
216 |
|
|
261 |
217 |
|
@Override |
262 |
|
- |
public String toString() |
263 |
|
- |
{ |
|
218 |
+ |
public String toString() { |
264 |
219 |
|
return Strings.replace( getText(), '\n', "\\n" ) + ":" + addXtra(); |
265 |
220 |
|
} |
266 |
221 |
|
|
267 |
|
- |
protected String addXtra() |
268 |
|
- |
{ |
|
222 |
+ |
protected String addXtra() { |
269 |
223 |
|
return ""; |
270 |
224 |
|
} |
271 |
225 |
|
} |
272 |
226 |
|
|
273 |
227 |
|
@SuppressWarnings("EqualsAndHashcode") |
274 |
|
- |
static class Between<U extends Synopsisable> extends SelectionPointEntry<U> |
275 |
|
- |
{ |
276 |
|
- |
private Between( boolean pSelected, U pUpperReference, U pLowerReference ) |
277 |
|
- |
{ |
|
228 |
+ |
static class Between<U extends Synopsisable> extends SelectionPointEntry<U> { |
|
229 |
+ |
private Between( boolean pSelected, U pUpperReference, U pLowerReference ) { |
278 |
230 |
|
super( pSelected, "Between", pUpperReference, pLowerReference ); |
279 |
231 |
|
} |
280 |
232 |
|
|
281 |
|
- |
public static <V extends Synopsisable> Between<V> create( boolean pSelected, V pUpperReference, V pLowerReference ) |
282 |
|
- |
{ |
|
233 |
+ |
public static <V extends Synopsisable> Between<V> create( boolean pSelected, V pUpperReference, V pLowerReference ) { |
283 |
234 |
|
return new Between<V>( pSelected, pUpperReference, pLowerReference ); |
284 |
235 |
|
} |
285 |
236 |
|
|
286 |
|
- |
public Between<U> copyAsSelected() |
287 |
|
- |
{ |
|
237 |
+ |
public Between<U> copyAsSelected() { |
288 |
238 |
|
return isSelected() ? this : create( true, getUpperReference(), getLowerReference() ); |
289 |
239 |
|
} |
290 |
240 |
|
|
291 |
241 |
|
@Override |
292 |
|
- |
public boolean isBetween() |
293 |
|
- |
{ |
|
242 |
+ |
public boolean isBetween() { |
294 |
243 |
|
return true; |
295 |
244 |
|
} |
296 |
245 |
|
|
297 |
|
- |
protected String addXtra() |
298 |
|
- |
{ |
|
246 |
+ |
protected String addXtra() { |
299 |
247 |
|
return (isSelected() ? "(?Y)" : "(?N)"); |
300 |
248 |
|
} |
301 |
249 |
|
|
302 |
|
- |
@Override @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"}) |
303 |
|
- |
public boolean equals( Object o ) |
304 |
|
- |
{ |
|
250 |
+ |
@Override |
|
251 |
+ |
@SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"}) |
|
252 |
+ |
public boolean equals( Object o ) { |
305 |
253 |
|
return super.equals( o ) && (this.isSelected() == ((Between) o).isSelected()); |
306 |
254 |
|
} |
307 |
255 |
|
} |
308 |
256 |
|
|
309 |
|
- |
static class There<U extends Synopsisable> extends SelectionPointEntry<U> |
310 |
|
- |
{ |
311 |
|
- |
private There( U pUpperReference, U pLowerReference ) |
312 |
|
- |
{ |
|
257 |
+ |
static class There<U extends Synopsisable> extends SelectionPointEntry<U> { |
|
258 |
+ |
private There( U pUpperReference, U pLowerReference ) { |
313 |
259 |
|
super( false, "There", pUpperReference, pLowerReference ); |
314 |
260 |
|
} |
315 |
261 |
|
|
316 |
|
- |
public static <V extends Synopsisable> There<V> create( V pUpperReference, V pLowerReference ) |
317 |
|
- |
{ |
|
262 |
+ |
public static <V extends Synopsisable> There<V> create( V pUpperReference, V pLowerReference ) { |
318 |
263 |
|
return new There<V>( pUpperReference, pLowerReference ); |
319 |
264 |
|
} |
320 |
265 |
|
} |
321 |
266 |
|
|
322 |
|
- |
static class Top<U extends Synopsisable> extends SelectionPointEntry<U> |
323 |
|
- |
{ |
324 |
|
- |
private Top( U pLowerReference ) |
325 |
|
- |
{ |
|
267 |
+ |
static class Top<U extends Synopsisable> extends SelectionPointEntry<U> { |
|
268 |
+ |
private Top( U pLowerReference ) { |
326 |
269 |
|
super( false, "Top\n(There)", null, pLowerReference ); |
327 |
270 |
|
} |
328 |
271 |
|
|
329 |
|
- |
public static <V extends Synopsisable> Top<V> create( V pLowerReference ) |
330 |
|
- |
{ |
|
272 |
+ |
public static <V extends Synopsisable> Top<V> create( V pLowerReference ) { |
331 |
273 |
|
return new Top<V>( pLowerReference ); |
332 |
274 |
|
} |
333 |
275 |
|
} |
334 |
276 |
|
|
335 |
|
- |
static class Bottom<U extends Synopsisable> extends SelectionPointEntry<U> |
336 |
|
- |
{ |
337 |
|
- |
private Bottom( U pUpperReference ) |
338 |
|
- |
{ |
|
277 |
+ |
static class Bottom<U extends Synopsisable> extends SelectionPointEntry<U> { |
|
278 |
+ |
private Bottom( U pUpperReference ) { |
339 |
279 |
|
super( false, "Bottom\n(There)", pUpperReference, null ); |
340 |
280 |
|
} |
341 |
281 |
|
|
342 |
|
- |
public static <V extends Synopsisable> Bottom<V> create( V pUpperReference ) |
343 |
|
- |
{ |
|
282 |
+ |
public static <V extends Synopsisable> Bottom<V> create( V pUpperReference ) { |
344 |
283 |
|
return new Bottom<V>( pUpperReference ); |
345 |
284 |
|
} |
346 |
285 |
|
} |
347 |
286 |
|
|
348 |
|
- |
static class Reference<U extends Synopsisable> extends ViewEntry<U> |
349 |
|
- |
{ |
350 |
|
- |
private Reference( int pLines, U pReference ) |
351 |
|
- |
{ |
|
287 |
+ |
static class Reference<U extends Synopsisable> extends ViewEntry<U> { |
|
288 |
+ |
private Reference( int pLines, U pReference ) { |
352 |
289 |
|
super( pReference.getSynopsis( pLines ) ); |
353 |
290 |
|
} |
354 |
291 |
|
|
355 |
|
- |
public static <V extends Synopsisable> Reference<V> create( int pLines, V pReference ) |
356 |
|
- |
{ |
|
292 |
+ |
public static <V extends Synopsisable> Reference<V> create( int pLines, V pReference ) { |
357 |
293 |
|
return new Reference<V>( pLines, pReference ); |
358 |
294 |
|
} |
359 |
295 |
|
|
360 |
296 |
|
@Override |
361 |
|
- |
public String toString() |
362 |
|
- |
{ |
|
297 |
+ |
public String toString() { |
363 |
298 |
|
return "Ref: " + Strings.replace( getText(), '\n', "\\n" ); |
364 |
299 |
|
} |
365 |
300 |
|
} |
|
@@ -370,25 +305,20 @@ |
370 |
305 |
|
private int mCurrentEntriesVisible = -1; |
371 |
306 |
|
private List<Between<T>> mSelectedBetweens = new ArrayList<Between<T>>(); |
372 |
307 |
|
|
373 |
|
- |
public InjectionPointSelectorController( int pSynopsisLines, List<T> pInjectIns, View<T> pView ) |
374 |
|
- |
{ |
|
308 |
+ |
public InjectionPointSelectorController( int pSynopsisLines, List<T> pInjectIns, View<T> pView ) { |
375 |
309 |
|
mSynopsisLines = pSynopsisLines; |
376 |
310 |
|
mInjectIns = pInjectIns; |
377 |
311 |
|
mView = pView; |
378 |
312 |
|
} |
379 |
313 |
|
|
380 |
|
- |
public InjectionPointSelectorController( int pSynopsisLines, View<T> pView, T... pInjectIns ) |
381 |
|
- |
{ |
|
314 |
+ |
public InjectionPointSelectorController( int pSynopsisLines, View<T> pView, T... pInjectIns ) { |
382 |
315 |
|
this( pSynopsisLines, Arrays.asList( pInjectIns ), pView ); |
383 |
316 |
|
} |
384 |
317 |
|
|
385 |
|
- |
public void updateForEntriesVisible( int pCount ) |
386 |
|
- |
{ |
387 |
|
- |
if ( mCurrentEntriesVisible != pCount ) |
388 |
|
- |
{ |
|
318 |
+ |
public void updateForEntriesVisible( int pCount ) { |
|
319 |
+ |
if ( mCurrentEntriesVisible != pCount ) { |
389 |
320 |
|
DrillDownSet zDrillDownSet = updateDrillDownSetWhenEntriesVisibleChanges( pCount, mSelectedBetweens ); |
390 |
|
- |
if ( zDrillDownSet == null ) |
391 |
|
- |
{ |
|
321 |
+ |
if ( zDrillDownSet == null ) { |
392 |
322 |
|
mView.notEnoughVisibleEntries(); |
393 |
323 |
|
return; |
394 |
324 |
|
} |
|
@@ -397,31 +327,26 @@ |
397 |
327 |
|
} |
398 |
328 |
|
} |
399 |
329 |
|
|
400 |
|
- |
public void homeSelected() |
401 |
|
- |
{ |
|
330 |
+ |
public void homeSelected() { |
402 |
331 |
|
DrillDownSet zDrillDownSet = updateDrillDownSetWhenEntriesVisibleChanges( mCurrentEntriesVisible, mSelectedBetweens ); |
403 |
332 |
|
mView.show( zDrillDownSet ); |
404 |
333 |
|
} |
405 |
334 |
|
|
406 |
|
- |
public void previousSelected() |
407 |
|
- |
{ |
|
335 |
+ |
public void previousSelected() { |
408 |
336 |
|
mSelectedBetweens.remove( mSelectedBetweens.size() - 1 ); |
409 |
337 |
|
DrillDownSet zDrillDownSet = updateDrillDownSetWhenSelectedBetweensChange( mCurrentEntriesVisible, mSelectedBetweens ); |
410 |
338 |
|
mView.show( zDrillDownSet ); |
411 |
339 |
|
} |
412 |
340 |
|
|
413 |
|
- |
public void viewSelected( ViewEntry<T> pEntry ) |
414 |
|
- |
{ |
|
341 |
+ |
public void viewSelected( ViewEntry<T> pEntry ) { |
415 |
342 |
|
Objects.assertNotNull( "Entry", pEntry ); |
416 |
|
- |
if ( pEntry.isBetween() ) |
417 |
|
- |
{ |
|
343 |
+ |
if ( pEntry.isBetween() ) { |
418 |
344 |
|
mSelectedBetweens.add( ((Between<T>) pEntry).copyAsSelected() ); |
419 |
345 |
|
DrillDownSet zDrillDownSet = updateDrillDownSetWhenSelectedBetweensChange( mCurrentEntriesVisible, mSelectedBetweens ); |
420 |
346 |
|
mView.show( zDrillDownSet ); |
421 |
347 |
|
return; |
422 |
348 |
|
} |
423 |
|
- |
if ( pEntry.isSelectable() ) |
424 |
|
- |
{ |
|
349 |
+ |
if ( pEntry.isSelectable() ) { |
425 |
350 |
|
mView.injectBetween( pEntry.getLowerReference(), pEntry.getUpperReference() ); |
426 |
351 |
|
return; |
427 |
352 |
|
} |
|
@@ -433,10 +358,8 @@ |
433 |
358 |
|
* |
434 |
359 |
|
* @return null means that pCount was too small! |
435 |
360 |
|
*/ |
436 |
|
- |
public DrillDownSet updateDrillDownSetWhenEntriesVisibleChanges( int pCount, List<Between<T>> pSelectedBetweens ) |
437 |
|
- |
{ |
438 |
|
- |
if ( -1 == (pCount = checkIfNotEnoughVisibleEntries( makeOdd( pCount ) )) ) |
439 |
|
- |
{ |
|
361 |
+ |
public DrillDownSet updateDrillDownSetWhenEntriesVisibleChanges( int pCount, List<Between<T>> pSelectedBetweens ) { |
|
362 |
+ |
if ( -1 == (pCount = checkIfNotEnoughVisibleEntries( makeOdd( pCount ) )) ) { |
440 |
363 |
|
return null; |
441 |
364 |
|
} |
442 |
365 |
|
pSelectedBetweens.clear(); |
|
@@ -450,11 +373,9 @@ |
450 |
373 |
|
* |
451 |
374 |
|
* @return null means that pCount was too small! |
452 |
375 |
|
*/ |
453 |
|
- |
public DrillDownSet updateDrillDownSetWhenSelectedBetweensChange( int pCount, List<Between<T>> pSelectedBetweens ) |
454 |
|
- |
{ |
|
376 |
+ |
public DrillDownSet updateDrillDownSetWhenSelectedBetweensChange( int pCount, List<Between<T>> pSelectedBetweens ) { |
455 |
377 |
|
List<ViewSet> zViewSets = buildViewSets( makeOdd( pCount ), pSelectedBetweens ); |
456 |
|
- |
switch ( zViewSets.size() ) |
457 |
|
- |
{ |
|
378 |
+ |
switch ( zViewSets.size() ) { |
458 |
379 |
|
case 1: |
459 |
380 |
|
return new DrillDownSet( null, false, null, zViewSets.get( 0 ) ); |
460 |
381 |
|
case 2: |
|
@@ -466,33 +387,28 @@ |
466 |
387 |
|
} |
467 |
388 |
|
} |
468 |
389 |
|
|
469 |
|
- |
private int checkIfNotEnoughVisibleEntries( int pCount ) |
470 |
|
- |
{ |
|
390 |
+ |
private int checkIfNotEnoughVisibleEntries( int pCount ) { |
471 |
391 |
|
return ((pCount >= 5) || // 5 is enough for anything (more is better) |
472 |
392 |
|
((pCount == 3) && (mInjectIns.size() == 1))) ? // Special Case of just 1 InjectIn? |
473 |
393 |
|
pCount : // pCount is OK |
474 |
394 |
|
-1; // indicate pCount too small |
475 |
395 |
|
} |
476 |
396 |
|
|
477 |
|
- |
private int makeOdd( int pCount ) |
478 |
|
- |
{ |
|
397 |
+ |
private int makeOdd( int pCount ) { |
479 |
398 |
|
return ((pCount & 1) == 0) ? // Is Even? |
480 |
399 |
|
pCount - 1 : // Even, make Odd! |
481 |
400 |
|
pCount; // Already Odd |
482 |
401 |
|
} |
483 |
402 |
|
|
484 |
|
- |
private Between<T> getCurrentSelectedBetween( List<Between<T>> pSelectedBetweens, int pCurrentIndex ) |
485 |
|
- |
{ |
|
403 |
+ |
private Between<T> getCurrentSelectedBetween( List<Between<T>> pSelectedBetweens, int pCurrentIndex ) { |
486 |
404 |
|
return (pCurrentIndex < pSelectedBetweens.size()) ? pSelectedBetweens.get( pCurrentIndex ) : null; |
487 |
405 |
|
} |
488 |
406 |
|
|
489 |
|
- |
private boolean isSelected( Between<T> pSelectedBetween, T pLast, T pCurr ) |
490 |
|
- |
{ |
|
407 |
+ |
private boolean isSelected( Between<T> pSelectedBetween, T pLast, T pCurr ) { |
491 |
408 |
|
return (pSelectedBetween != null) && (pLast == pSelectedBetween.getUpperReference()) && (pCurr == pSelectedBetween.getLowerReference()); |
492 |
409 |
|
} |
493 |
410 |
|
|
494 |
|
- |
private List<ViewSet> buildViewSets( int pCount, List<Between<T>> pSelectedBetweens ) |
495 |
|
- |
{ |
|
411 |
+ |
private List<ViewSet> buildViewSets( int pCount, List<Between<T>> pSelectedBetweens ) { |
496 |
412 |
|
List<ViewSet> zViewSets = new ArrayList<ViewSet>(); |
497 |
413 |
|
|
498 |
414 |
|
buildHomeViewSet( zViewSets, pCount, pSelectedBetweens ); |
|
@@ -500,8 +416,7 @@ |
500 |
416 |
|
return zViewSets; |
501 |
417 |
|
} |
502 |
418 |
|
|
503 |
|
- |
private void buildHomeViewSet( List<ViewSet> pViewSets, int pCount, List<Between<T>> pSelectedBetweens ) |
504 |
|
- |
{ |
|
419 |
+ |
private void buildHomeViewSet( List<ViewSet> pViewSets, int pCount, List<Between<T>> pSelectedBetweens ) { |
505 |
420 |
|
Between<T> zSelectedBetween = getCurrentSelectedBetween( pSelectedBetweens, 0 ); |
506 |
421 |
|
|
507 |
422 |
|
int zInjectInsToAdd = mInjectIns.size() - 1; |
|
@@ -518,8 +433,7 @@ |
518 |
433 |
|
T zCurrT = mInjectIns.get( zCurrNdx ); |
519 |
434 |
|
zEntries.add( Top.create( zCurrT ) ); |
520 |
435 |
|
|
521 |
|
- |
while ( zCurrNdx < zThru ) |
522 |
|
- |
{ |
|
436 |
+ |
while ( zCurrNdx < zThru ) { |
523 |
437 |
|
zEntries.add( Reference.create( mSynopsisLines, zCurrT ) ); |
524 |
438 |
|
int zLastNdx = zCurrNdx; |
525 |
439 |
|
T zLastT = zCurrT; |
|
@@ -528,21 +442,15 @@ |
528 |
442 |
|
zInjectInsToAdd -= zHowMany; |
529 |
443 |
|
zCurrNdx += zHowMany; |
530 |
444 |
|
zCurrT = mInjectIns.get( zCurrNdx ); |
531 |
|
- |
if ( zHowMany == 1 ) |
532 |
|
- |
{ |
|
445 |
+ |
if ( zHowMany == 1 ) { |
533 |
446 |
|
// System.out.println( " Add There 1" ); |
534 |
447 |
|
zEntries.add( There.create( zLastT, zCurrT ) ); |
535 |
|
- |
} |
536 |
|
- |
else |
537 |
|
- |
{ |
|
448 |
+ |
} else { |
538 |
449 |
|
// System.out.println( " Add Between " + zHowMany ); |
539 |
|
- |
if ( isSelected( zSelectedBetween, zLastT, zCurrT ) ) |
540 |
|
- |
{ |
|
450 |
+ |
if ( isSelected( zSelectedBetween, zLastT, zCurrT ) ) { |
541 |
451 |
|
zEntries.add( zSelectedBetween ); |
542 |
452 |
|
buildSubsequentViewSet( pViewSets, pCount, zLastNdx, zCurrNdx, pSelectedBetweens, 1 ); |
543 |
|
- |
} |
544 |
|
- |
else |
545 |
|
- |
{ |
|
453 |
+ |
} else { |
546 |
454 |
|
zEntries.add( Between.create( false, zLastT, zCurrT ) ); |
547 |
455 |
|
} |
548 |
456 |
|
} |
|
@@ -553,8 +461,7 @@ |
553 |
461 |
|
} |
554 |
462 |
|
|
555 |
463 |
|
private void buildSubsequentViewSet( List<ViewSet> pViewSets, int pCount, int zUpperNdx, int zLowerNdx, List<Between<T>> pSelectedBetweens, |
556 |
|
- |
int pCurrentIndex ) |
557 |
|
- |
{ |
|
464 |
+ |
int pCurrentIndex ) { |
558 |
465 |
|
Between<T> zSelectedBetween = getCurrentSelectedBetween( pSelectedBetweens, pCurrentIndex ); |
559 |
466 |
|
|
560 |
467 |
|
int zInjectInsToAdd = zLowerNdx - zUpperNdx; |
|
@@ -570,8 +477,7 @@ |
570 |
477 |
|
int zThru = zLowerNdx; |
571 |
478 |
|
T zCurrT = mInjectIns.get( zCurrNdx ); |
572 |
479 |
|
|
573 |
|
- |
while ( zCurrNdx < zThru ) |
574 |
|
- |
{ |
|
480 |
+ |
while ( zCurrNdx < zThru ) { |
575 |
481 |
|
zEntries.add( Reference.create( mSynopsisLines, zCurrT ) ); |
576 |
482 |
|
int zLastNdx = zCurrNdx; |
577 |
483 |
|
T zLastT = zCurrT; |
|
@@ -580,21 +486,15 @@ |
580 |
486 |
|
zInjectInsToAdd -= zHowMany; |
581 |
487 |
|
zCurrNdx += zHowMany; |
582 |
488 |
|
zCurrT = mInjectIns.get( zCurrNdx ); |
583 |
|
- |
if ( zHowMany == 1 ) |
584 |
|
- |
{ |
|
489 |
+ |
if ( zHowMany == 1 ) { |
585 |
490 |
|
// System.out.println( " Add There 1" ); |
586 |
491 |
|
zEntries.add( There.create( zLastT, zCurrT ) ); |
587 |
|
- |
} |
588 |
|
- |
else |
589 |
|
- |
{ |
|
492 |
+ |
} else { |
590 |
493 |
|
// System.out.println( " Add Between " + zHowMany ); |
591 |
|
- |
if ( isSelected( zSelectedBetween, zLastT, zCurrT ) ) |
592 |
|
- |
{ |
|
494 |
+ |
if ( isSelected( zSelectedBetween, zLastT, zCurrT ) ) { |
593 |
495 |
|
zEntries.add( zSelectedBetween ); |
594 |
496 |
|
buildSubsequentViewSet( pViewSets, pCount, zLastNdx, zCurrNdx, pSelectedBetweens, pCurrentIndex + 1 ); |
595 |
|
- |
} |
596 |
|
- |
else |
597 |
|
- |
{ |
|
497 |
+ |
} else { |
598 |
498 |
|
zEntries.add( Between.create( false, zLastT, zCurrT ) ); |
599 |
499 |
|
} |
600 |
500 |
|
} |