Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
MirrorDetailAssociation |
|
| 4.0;4 |
1 | /* |
|
2 | Wotonomy: OpenStep design patterns for pure Java applications. |
|
3 | Copyright (C) 2001 Intersect Software Corporation |
|
4 | ||
5 | This library is free software; you can redistribute it and/or |
|
6 | modify it under the terms of the GNU Lesser General Public |
|
7 | License as published by the Free Software Foundation; either |
|
8 | version 2.1 of the License, or (at your option) any later version. |
|
9 | ||
10 | This library is distributed in the hope that it will be useful, |
|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 | Lesser General Public License for more details. |
|
14 | ||
15 | You should have received a copy of the GNU Lesser General Public |
|
16 | License along with this library; if not, see http://www.gnu.org |
|
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 | 0 | super(displayGroup); |
35 | 0 | } |
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 | 0 | EODisplayGroup detail = (EODisplayGroup) object(); |
47 | 0 | EODisplayGroup master = |
48 | 0 | displayGroupForAspect( ParentAspect ); |
49 | ||
50 | 0 | if ( master != null ) |
51 | { |
|
52 | 0 | NSArray masterObjects = master.displayedObjects(); |
53 | 0 | NSArray detailObjects = detail.displayedObjects(); |
54 | 0 | int size = masterObjects.size(); |
55 | 0 | boolean different = false; |
56 | ||
57 | // see if lists contain the same object instances |
|
58 | 0 | if ( size == detailObjects.size() ) |
59 | { |
|
60 | 0 | for ( int i = 0; i < size; i++ ) |
61 | { |
|
62 | 0 | if ( masterObjects.objectAtIndex(i) |
63 | 0 | != detailObjects.objectAtIndex(i) ) |
64 | { |
|
65 | 0 | different = true; |
66 | 0 | break; |
67 | } |
|
68 | } |
|
69 | 0 | } |
70 | else // different sizes |
|
71 | { |
|
72 | 0 | different = true; |
73 | } |
|
74 | ||
75 | // if different, sync contents and selection with master |
|
76 | 0 | if ( different ) |
77 | { |
|
78 | 0 | detail.setObjectArray( masterObjects ); |
79 | 0 | detail.setSelectionIndexes( master.selectionIndexes() ); |
80 | 0 | } |
81 | else // if selection changed, sync selection with master |
|
82 | 0 | if ( master.selectionChanged() ) |
83 | { |
|
84 | 0 | detail.setSelectionIndexes( master.selectionIndexes() ); |
85 | } |
|
86 | 0 | } |
87 | else // no bound display group, clear |
|
88 | { |
|
89 | 0 | detail.setObjectArray( null ); |
90 | } |
|
91 | 0 | } |
92 | } |
|
93 | /* |
|
94 | * $Log$ |
|
95 | * Revision 1.1 2006/02/16 13:22:22 cgruber |
|
96 | * Check in all sources in eclipse-friendly maven-enabled packages. |
|
97 | * |
|
98 | * Revision 1.2 2001/07/05 22:13:28 mpowers |
|
99 | * Now only updating if master has actually changed. |
|
100 | * |
|
101 | * Revision 1.1 2001/05/29 19:57:47 mpowers |
|
102 | * Added some neglected files. |
|
103 | * |
|
104 | * |
|
105 | */ |
|
106 |