[r9763]: ooDialog / trunk / examples / userGuide / exercises / Exercise07 / OrderMgr / OrderMgrView.rex Maximize Restore History

Download this file

OrderMgrView.rex    397 lines (326 with data), 17.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/*----------------------------------------------------------------------------*/
/* */
/* Copyright (c) 2011-2013 Rexx Language Association. All rights reserved. */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the Common Public License v1.0 which accompanies this */
/* distribution. A copy is also available at the following address: */
/* http://www.oorexx.org/license.html */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the distribution. */
/* */
/* Neither the name of Rexx Language Association nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*----------------------------------------------------------------------------*/
/* ooDialog User Guide
Exercise 07: OrderMgrView.rex v02-00 27Feb13
Contains: class: "OrderMgrView", "HRSomv"
Description: The Order Manager View class - the container for of the
Order Management application.
Pre-requisites: MVF.
Description: A sample Order Manager View class - part of the sample
Order Manager component.
Outstanding Problems: None reported.
Changes:
v01-00 07Jun12: First Version
v01-01 18Jan13: Version 1.1 - dialog sizing now uses resizingAdmin.
v02-00 20Feb13:
1. Added get id of ObjectMgr in init method.
2. Added menu item "Help - Person" to surface a Person Model in order to
illustrate MVF using Person class early in Chapter 7.
3. Added menu item "Help - Message Sender" to surface the Message Sender.
4. Updated 'showModel' method to use the MVF (via ObjectMgr) to surface
List Views that are populated with data read from disk (instead of data
hard-coded in the ListView) also give listview the instance name of "a"
to indicate an anonymous component to ObjectMgr.
5. Added methods "person" and "messageSender" which launch a PersonModel
and a Message Sender respectively.
27Feb13: Commented-out several 'say's.
------------------------------------------------------------------------------*/
-- Use the global .constDir for symbolic IDs - load them from OrderMgrView.h
.Application~addToConstDir("OrderMgr\OrderMgrView.h")
call "OrderMgr\RequiresList.rex"
::REQUIRES "ooDialog.cls"
/*//////////////////////////////////////////////////////////////////////////////
==============================================================================
OrderMgrView v02-00 20Feb13
--------------------
To the user, this class is the Order Management Application. It provides
access to the various functions required for managing Sales orders.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
::CLASS OrderMgrView SUBCLASS RcDialog PUBLIC INHERIT ResizingAdmin
::ATTRIBUTE lv PRIVATE -- The ListView that contains the icons.
/*----------------------------------------------------------------------------
Class Methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD newInstance CLASS PUBLIC
--say ".OrderMgrView-newInstance-01."
dlg = .OrderMgrView~new("OrderMgr\OrderMgrView.rc", IDD_ORDMGR)
dlg~activate
/*----------------------------------------------------------------------------
Instance Methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*----------------------------------------------------------------------------
Dialog Setup Methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD init
expose menuBar records idObjectMgr
--say "OrderMgrView-init-01; next stmt is 'forward class (super) continue'."
forward class (super) continue
--say "OrderMgrView-init-02."
menuBar = .ScriptMenuBar~new("OrderMgr\OrderMgrView.rc", IDR_ORDMGR_MENU, , , .true)
self~createIconList
records = self~initRecords
idObjectMgr = .local~my.ObjectMgr
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD defineDialog
--say "OrderMgrView-defineDialog-01."
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD activate UNGUARDED
--say "OrderMgrView-activate-01."
self~execute("SHOWTOP", IDI_DLG_OOREXX)
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD initDialog
expose menuBar records iconList
--say "OrderMgrView-initDialog-01."
menuBar~attachTo(self)
-- Create a proxy for the List View and store in instance variable 'lv'.
self~lv = self~newListView(IDC_ORDMGR_ICONS)
-- Add the Image List to the ListView:
self~lv~setImageList(iconList, NORMAL)
-- Add icons (i.e. records) to the ListView:
do i=1 to records~items
self~lv~addRow(, i-1, records[i]~name)
end
self~connectListViewEvent(IDC_ORDMGR_ICONS, "ACTIVATE", "onDoubleClick")
-- Following line required to allow icons to be dragged around the listview.
self~connectListViewEvent(IDC_ORDMGR_ICONS, "BEGINDRAG", "DefListDragHandler")
self~connectButtonEvent("IDC_ORDMGR_EXIT", "CLICKED",exitApp)
self~connectButtonEvent("IDC_ORDMGR_RESET","CLICKED",resetIcons)
self~setTitle(.HRSomv~WindowTitle) -- set dialog title.
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD defineSizing
--say "OrderMgrView-defineSizing-01."
-- Called automatically by ooDialog.
-- Order of arrays: left, top, right, bottom.
-- Order of array items: pinType, edge-of-other-window, id of other window
self~controlSizing(IDC_ORDMGR_RESET, -
.array~of('STATIONARY', 'LEFT' ), -
.array~of('STATIONARY', 'BOTTOM'), -
.array~of('MYLEFT', 'BOTTOM' ), -
.array~of('MYTOP', 'TOP' ) -
)
self~controlSizing(IDC_ORDMGR_EXIT, -
.array~of('STATIONARY', 'RIGHT' ), -
.array~of('STATIONARY', 'BOTTOM'), -
.array~of('MYLEFT', 'RIGHT' ), -
.array~of('MYTOP', 'TOP' ) -
)
self~controlSizing(IDC_ORDMGR_ICONS, -
.array~of('STATIONARY', 'LEFT' ), -
.array~of('STATIONARY', 'TOP' ), -
.array~of('STATIONARY', 'RIGHT' ), -
.array~of('STATIONARY', 'BOTTOM') -
)
return .false
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD createIconList PRIVATE
-- This method simulates getting the icon "data" for the OrderMgr view.
-- The icon data is loaded into 'iconList' which is an 'ImageList' as
-- required by the ListView control.
expose iconList
--say "OrderMgrView-createIconList."
imgCustList = .Image~getImage("customer\bmp\CustList.bmp")
imgProdList = .Image~getImage("product\res\ProdList.bmp")
imgOrderList = .Image~getImage("order\bmp\OrderList.bmp")
imgOrderForm = .Image~getImage("order\bmp\OrderForm.bmp")
iconList = .ImageList~create(.Size~new(64, 64), COLOR4, 4, 0)
-- Boldly assume no errors in creating the Image List or in the ~getImage statements.
iconList~add(imgCustList) -- item 0 in iconList (item 1 in records)
iconList~add(imgProdList) -- item 1 in iconList (item 2 in records)
iconList~add(imgOrderList) -- item 2 in iconList (item 3 in records)
iconList~add(imgOrderForm) -- item 3 in iconList (item 4 in records)
imgCustList~release
imgProdList~release
imgOrderList~release
imgOrderForm~release
return
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD initRecords PRIVATE
-- This method simulates getting the "data" for the OrderMgr view.
expose records
records = .array~new()
rec = .directory~new
rec~ID = "CustomerListModel" -- class name
rec~name = "Customer List"
records[1] = rec
rec = .directory~new
rec~ID = "ProductListModel"
rec~name = "Product List"
records[2] = rec
rec = .directory~new
rec~ID = "OrderListModel"
rec~name = "Sales Orders"
records[3] = rec
rec = .directory~new
rec~ID = "OrderFormModel"
rec~name = "New Order"
records[4] = rec
return records
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* ::METHOD initDialog
expose records iconList
--say "OrderMgrView-initDialog."
self~initDialog:super
-- Add the Image List to the ListView:
self~lv~setImageList(iconList, NORMAL)
-- Add icons (i.e. records) to the ListView:
do i=1 to records~items
self~lv~addRow(, i-1, records[i]~name)
end
*/
/*----------------------------------------------------------------------------
Event-Handler Methods - Menu Events
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*- - Orders - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD newOrder UNGUARDED
expose records
self~showModel(records[4])
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD orderList UNGUARDED
expose records
self~showModel(records[3])
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD orderSearch UNGUARDED
self~noMenuFunction(.HRSomv~OrdSrch)
/*- - Customers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD customerList UNGUARDED
expose records
self~showModel(records[1])
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD customerSearch UNGUARDED
self~noMenuFunction(.HRSomv~CustSrch)
/*- - Products - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD productList
expose records
self~showModel(records[2])
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD productSearch UNGUARDED
self~noMenuFunction(.HRSomv~ProdSrch)
/*- - New - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD product UNGUARDED
self~noMenuFunction(.HRSomv~NewProd)
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD customer UNGUARDED
self~noMenuFunction(.HRSomv~NewCust)
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD order UNGUARDED
self~newOrder
/*- - Help - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD about UNGUARDED
self~noMenuFunction(.HRSomv~HelpAbout)
/*- - Message Sender- - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD messageSender UNGUARDED
--say "OrderMgrView-messageSender."
.MessageSender~newInstance(self)
--self~noMenuFunction(.HRSomv~HelpAbout)
/*- - Message Sender- - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD person UNGUARDED
expose idObjectMgr
--say "OrderMgrView-Person."
objectMgr = .local.my.ObjectMgr
idObjectMgr~showModel("PersonModel","PA150", self)
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD noMenuFunction UNGUARDED
use arg title
ret = MessageDialog(.HRSomv~NoMenu, self~hwnd, title, 'WARNING')
/*----------------------------------------------------------------------------
Event-Handler Methods - Icon Double-Click
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD onDoubleClick UNGUARDED
expose records
--use arg id
--say "OrderMgrView-onDoubleClick-01."
-- Get the index of the item with the focus, use the index to retrieve
-- the item's record:
index = self~lv~focused -- lv is an attribute of the superclass.
record = records[index+1]
--say "OrderMgrView-onDoubleClick-02: Record ID =" record~ID
self~showModel(record)
/*----------------------------------------------------------------------------
Event-Handler Methods - PushButton Events
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD resetIcons
r = self~lv~arrange
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD exitApp UNGUARDED
--say "OrderMgrView-exitApp-01."
self~cancel
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD cancel
--say "OrderMgrView-cancel-01."
response = askDialog(.HRSomv~QExit, "N")
if response = 1 then forward class (super)
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD ok
-- Invoked when enter key pressed - if passed to superclass, cancels dialog.
return -- do not close dialog - appears as a no-op to the user.
/*----------------------------------------------------------------------------
Application Methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
::METHOD showModel UNGUARDED
/* Surface the view of an icon (i.e. view of the model represented by the icon).
Ideally, if already instantiated, surface it, else makeInstance.
In this version, get as many as you like - but all have the same data!.*/
expose idObjectMgr
use arg record -- record is a directory object.
className = record~ID
--say "OrderMgrView-showModel-01: className =" className -- Ex07
r = idObjectMgr~showModel(classname, "a", self) -- Ex07
/*============================================================================*/
/*//////////////////////////////////////////////////////////////////////////////
==============================================================================
HRSomv (Human-Readable Strings for OrderMgrView) v01-00 07Jun12
---
The HRSomv class provides constant character strings for user-visible messages
issued by the OrderMgrBaseView class.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
::CLASS HRSomv PRIVATE -- Human-Readable Strings
::CONSTANT QExit "Are you sure you want to close all windows and exit the application?"
::CONSTANT NoMenu "This menu item is not yet implemented."
::CONSTANT OM "Order Manager"
::CONSTANT OrdSrch "Order Search"
::CONSTANT CustSrch "Customer Search"
::CONSTANT ProdSrch "Product Search"
::CONSTANT NewCust "New Customer"
::CONSTANT NewProd "New Product"
::CONSTANT HelpAbout "Help - About"
::CONSTANT WindowTitle "Sales Order Management" -- Dialog Caption
::CONSTANT Reset "Reset Icons" -- PushButton
::CONSTANT ExitApp "Exit Application" -- PushButton
/*============================================================================*/