1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.ui;
20 import net.wotonomy.foundation.NSArray;
21
22 /***
23 * This master detail association synchronizes the contents
24 * and selection of the master group into the detail group.
25 */
26 public class MirrorDetailAssociation extends MasterDetailAssociation{
27
28 /***
29 * Standard constructor specifying the detail display group.
30 * @param displayGroup the detail display group of this
31 * Master-Detail Association
32 */
33 public MirrorDetailAssociation(EODisplayGroup displayGroup){
34 super(displayGroup);
35 }
36
37 /***
38 * Called by subjectChanged() to requalify the controlled
39 * display group with the indexed object and the bound key.
40 * This implementation ignores both and sets the object array
41 * of the detail group to the displayed objects of the master
42 * and sets the selection to match.
43 */
44 protected void requalify()
45 {
46 EODisplayGroup detail = (EODisplayGroup) object();
47 EODisplayGroup master =
48 displayGroupForAspect( ParentAspect );
49
50 if ( master != null )
51 {
52 NSArray masterObjects = master.displayedObjects();
53 NSArray detailObjects = detail.displayedObjects();
54 int size = masterObjects.size();
55 boolean different = false;
56
57
58 if ( size == detailObjects.size() )
59 {
60 for ( int i = 0; i < size; i++ )
61 {
62 if ( masterObjects.objectAtIndex(i)
63 != detailObjects.objectAtIndex(i) )
64 {
65 different = true;
66 break;
67 }
68 }
69 }
70 else
71 {
72 different = true;
73 }
74
75
76 if ( different )
77 {
78 detail.setObjectArray( masterObjects );
79 detail.setSelectionIndexes( master.selectionIndexes() );
80 }
81 else
82 if ( master.selectionChanged() )
83 {
84 detail.setSelectionIndexes( master.selectionIndexes() );
85 }
86 }
87 else
88 {
89 detail.setObjectArray( null );
90 }
91 }
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106