|
|
1.1 root 1: {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;\f1\fmodern Ohlfs;}
2: \paperw15100
3: \paperh12580
4: \margl120
5: \margr120
6: {\colortbl;\red0\green0\blue0;}
7: \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b\i0\ulnone\fs36\fc0\cf0 BARCHART\
8:
9: \b0\fs28 by Joe Freeman, NeXT Systems Engineer\
10: \
11:
12: \b Overview\
13:
14: \b0 This palette demonstrates how to use your custom UI objects with the DBKit. It illustrates in particular the DBCustomAssociation protocol which allows you to retrieve or set values to your database via a custom view object (here the ChartOfMatrix view). Note that instead of a custom UI object, you can also connect the nib's file owner to an attribute of your DBModule, and create a custom association in this way.\
15: \
16:
17: \b Other peculiarities\
18:
19: \b0 When compiling this example, you'll notice the compiler warnings about conflicting declarations for the methods
20: \b maxValue
21: \b0 and
22: \b minValue
23: \b0 . This is a known problem, which will be fixed in a future release of NeXTSTEP.
24: \b \
25:
26: \b0 \
27:
28: \b How to use this example
29: \b0 \
30: \
31:
32: \b Demo
33: \b0 without DBKit\
34: 1) Load the
35: \b palette
36: \b0 and create a
37: \b New Application.
38: \b0 \
39: 2) Drag a
40: \b plotter
41: \b0 into the
42: \b Window.
43: \b0 \
44: 3) Drag off a Slider and create a matrix of
45: \b Sliders.
46: \b0 \
47: 4) Connect the
48: \b matrix
49: \b0 to the action method
50: \b plotFromMatrix
51: \b0 of the
52: \b plotter
53: \b0 .\
54: 5) Go into
55: \b Test Interface
56: \b0 mode.\
57: 6) Move the sliders and watch the bars move.\
58: 7) End
59: \b Test
60: \b0 mode.\
61: 8) Drag two
62: \b TextFields
63: \b0 into the window.\
64: 9) Connect the
65: \b minField
66: \b0 and
67: \b maxField
68: \b0 outlets of the
69: \b plotter
70: \b0 to the
71: \b TextFields.\
72:
73: \b0 10) Go back into
74: \b TestInterface
75: \b0 mode.\
76: 11) Move the sliders and watch the values displayed in the textfields.\
77: \
78: \
79:
80: \b Demo
81: \b0 with DBKit using the OracleDemo.dbmodel supplied in /NextDeveloper/Examples/DatabaseKit/Models\
82: 1) Load the
83: \b palette
84: \b0 and create a
85: \b New Application.\
86:
87: \b0 2) Drag a
88: \b plotter
89: \b0 into the
90: \b Window.\
91:
92: \b0 3) Drag a
93: \b DBModule
94: \b0 onto the Objects icon of the NIB file.\
95: 4) Drag a
96: \b DBTableView
97: \b0 into the
98: \b Window.\
99:
100: \b0 5) Select OracleDemo, Employee in the module inspector. \
101: 6) Connect the
102: \b Employee.name
103: \b0 and
104: \b Employee.job
105: \b0 to the
106: \b DBTableView.\
107:
108: \b0 7) Connect
109: \b Employee.salary
110: \b0 to the
111: \b plotter
112: \b0 .\
113: 8) Connect the
114: \b min
115: \b0 and
116: \b max
117: \b0 outlets on the
118: \b Plotter
119: \b0 to two
120: \b TextFields
121: \b0 .
122: \b \
123:
124: \b0 9) Connect the
125: \b Button
126: \b0 target to the DBModule
127: \b fetchAllRecords:
128: \b0 method.\
129: 10) Connect
130: \b Employee.salary
131: \b0 to a
132: \b Slider
133: \b0 . Set the
134: \b Slider
135: \b0 min to 4000 and max to 6000 via the IB Inspector panel.\
136: 11) Connect the
137: \b Slider
138: \b0 target
139: \b
140: \b0 to the DBModule
141: \b takeValueFrom:
142: \b0 method.\
143: 12) Go into
144: \b TestInterface
145: \b0 mode.\
146: 13) Press the button to fetch all records.\
147: 14) Select different rows in the table view and watch the colored bar move.\
148: 15) Move the Slider and watch the colored selected bar move.\
149: 16) Mouse down on one of the bars in the graph and that row will be selected.\
150: \
151:
152: \pard\tx1340\tx2680\tx4020\tx5360\tx6720\tx8060\tx9400\tx10740\tx12080\tx13440\b\fc1\cf1 Topics of Interest\
153:
154: \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\b0\fc1\cf1 Besides showing you how to create a custom palette, this particular example also illustrates the use of the DBCustomAssociation protocol to make your UI object (here the custom view palette) respond to changes in the DBModule and DBFetchGroup. To make your UI object (custom view) respond to this protocol, you'll need to connect it with a DBModule attribute (here Employee.salary).\
155: \
156: See File ChartOfMatrix.m for more details:\
157: \
158: @interface Object(DBCustomAssociation)\
159:
160: \i // Called when DBModule/FetchGroup fetches a batch of new values\
161:
162: \i0 - associationContentsDidChange:association;\
163: \
164:
165: \i // Called when DBFetchGroup selection changes \
166: // e.g., when a new record is selected in a TableView\
167:
168: \i0 - associationSelectionDidChange:association;\
169: \
170:
171: \i // Called when a property value changes elsewhere in the DBFetchGroup, \
172: // (usually via editing in the UI) \
173:
174: \i0 - association:association setValue:(DBValue *)value;\
175: \
176:
177: \i // Called when the DBFetchGroup needs to get a value,\
178: // e.g., when the associated UI object calls takeValueFrom:\
179:
180: \i0 - association:association getValue:(DBValue *)value;\
181: @end\
182:
183: \pard\tx1340\tx2680\tx4020\tx5360\tx6720\tx8060\tx9400\tx10740\tx12080\tx13440\b\fc1\cf1 \
184:
185: \b0 Last Edited - Mai Nguyen, 17/ February /1993
186: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.