1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
3 &Scoped-define WINDOW-NAME CURRENT-WINDOW
4 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
5 /*------------------------------------------------------------------------
7 ------------------------------------------------------------------------*/
11 /* *************************** Definitions
************************** */
13 DEF VAR last-id
AS ROWID NO-UNDO.
14 DEF VAR this-win
AS HANDLE NO-UNDO.
16 /* _UIB-CODE-BLOCK-END
*/
20 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
22 /* ******************** Preprocessor Definitions
******************** */
24 &Scoped-define PROCEDURE-TYPE SmartViewer
26 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
28 /* Name of first Frame and
/or Browse and
/or first Query
*/
29 &Scoped-define FRAME-NAME F-Main
31 /* Standard List Definitions
*/
32 &Scoped-Define ENABLED-OBJECTS tgl_topmost sel_avail btn_add sel_curr ~
34 &Scoped-Define DISPLAYED-OBJECTS tgl_topmost sel_avail sel_curr
36 /* Custom List Definitions
*/
37 /* ADM-CREATE-FIELDS
,ADM-ASSIGN-FIELDS
,List-3
,List-4
,List-5
,List-6
*/
39 /* _UIB-PREPROCESSOR-BLOCK-END
*/
43 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" V-table-Win _INLINE
44 /* Actions
: ? adm
/support
/keyedit.w ? ? ?
*/
50 GroupName|y|y|TTPL.UsrGroup.GroupName
53 **************************
54 * Set attributes related to FOREIGN
KEYS
56 RUN set-attribute-list
(
57 'Keys-Accepted
= "GroupName",
58 Keys-Supplied
= "GroupName"'
:U
).
59 /**************************
61 /* _UIB-CODE-BLOCK-END
*/
65 /* *********************** Control Definitions
********************** */
68 /* Definitions of the field level widgets
*/
79 DEFINE VARIABLE sel_avail
AS CHARACTER
80 VIEW-AS SELECTION-LIST SINGLE SORT SCROLLBAR-VERTICAL
84 DEFINE VARIABLE sel_curr
AS CHARACTER
85 VIEW-AS SELECTION-LIST SINGLE SORT SCROLLBAR-VERTICAL
89 DEFINE VARIABLE tgl_topmost
AS LOGICAL INITIAL no
96 /* ************************ Frame Definitions
*********************** */
99 tgl_topmost
AT ROW 1 COL 65
100 sel_avail
AT ROW 2 COL 2 NO-LABEL
101 btn_add
AT ROW 2 COL 33
102 sel_curr
AT ROW 2 COL 45 NO-LABEL
103 btn_rem
AT ROW 3.2 COL 33
104 "Available Users" VIEW-AS TEXT
105 SIZE 16 BY 1 AT ROW 1 COL 2
107 "Current Members" VIEW-AS TEXT
108 SIZE 13.72 BY 1 AT ROW 1 COL 45
110 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
111 SIDE-LABELS NO-UNDERLINE THREE-D
112 AT COL 1 ROW 1 SCROLLABLE .
115 /* *********************** Procedure Settings
************************ */
117 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
118 /* Settings for
THIS-PROCEDURE
120 Allow
: Basic
,DB-Fields
122 Add Fields to
: EXTERNAL-TABLES
123 Other Settings
: PERSISTENT-ONLY
COMPILE
126 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
127 /* then cleanup and return.
*/
128 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
129 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
130 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
134 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
136 /* ************************* Create Window
************************** */
138 &ANALYZE-SUSPEND _CREATE-WINDOW
139 /* DESIGN Window definition
(used by the UIB
)
140 CREATE WINDOW V-table-Win
ASSIGN
143 /* END WINDOW DEFINITION
*/
148 /* *************** Runtime Attributes and UIB Settings
************** */
150 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
151 /* SETTINGS
FOR WINDOW V-table-Win
152 VISIBLE,,RUN-PERSISTENT
*/
153 /* SETTINGS
FOR FRAME F-Main
154 NOT-VISIBLE Size-to-Fit
*/
156 FRAME F-Main
:SCROLLABLE = FALSE
157 FRAME F-Main
:HIDDEN = TRUE.
159 /* _RUN-TIME-ATTRIBUTES-END
*/
163 /* Setting information for Queries and Browse Widgets fields
*/
165 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
166 /* Query rebuild information for
FRAME F-Main
169 */ /* FRAME F-Main
*/
175 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
176 /* ************************* Included-Libraries
*********************** */
178 {src
/adm
/method
/viewer.i
}
179 {inc
/method
/m-mntvwr.i
}
181 /* _UIB-CODE-BLOCK-END
*/
187 /* ************************ Control Triggers
************************ */
189 &Scoped-define SELF-NAME btn_add
190 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_add V-table-Win
191 ON CHOOSE OF btn_add
IN FRAME F-Main
/* Add
*/
196 /* _UIB-CODE-BLOCK-END
*/
200 &Scoped-define SELF-NAME btn_rem
201 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_rem V-table-Win
202 ON CHOOSE OF btn_rem
IN FRAME F-Main
/* Remove
*/
207 /* _UIB-CODE-BLOCK-END
*/
211 &Scoped-define SELF-NAME sel_avail
212 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL sel_avail V-table-Win
213 ON MOUSE-SELECT-DBLCLICK
OF sel_avail
IN FRAME F-Main
215 APPLY '
CHOOSE'
:U
TO btn_add .
218 /* _UIB-CODE-BLOCK-END
*/
222 &Scoped-define SELF-NAME sel_curr
223 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL sel_curr V-table-Win
224 ON MOUSE-SELECT-DBLCLICK
OF sel_curr
IN FRAME F-Main
226 APPLY '
CHOOSE'
:U
TO btn_rem .
229 /* _UIB-CODE-BLOCK-END
*/
233 &Scoped-define SELF-NAME tgl_topmost
234 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tgl_topmost V-table-Win
235 ON VALUE-CHANGED
OF tgl_topmost
IN FRAME F-Main
/* On Top ?
*/
237 RUN top-most-changed.
240 /* _UIB-CODE-BLOCK-END
*/
246 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
249 /* *************************** Main Block
*************************** */
251 &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
252 RUN dispatch
IN THIS-PROCEDURE ('initialize'
:U
).
255 /************************ INTERNAL PROCEDURES
********************/
257 /* _UIB-CODE-BLOCK-END
*/
261 /* ********************** Internal Procedures
*********************** */
263 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE add-member V-table-Win
264 PROCEDURE add-member
:
265 /*------------------------------------------------------------------------------
269 ------------------------------------------------------------------------------*/
271 DO WITH FRAME {&FRAME-NAME}:
273 IF NOT AVAILABLE UsrGroup
THEN RETURN.
275 RUN notify
( 'set-busy
, CONTAINER-SOURCE'
:U
).
277 FIND FIRST Usr
WHERE Usr.UserName
= INPUT sel_avail.
278 CREATE UsrGroupMember.
280 UsrGroupMember.GroupName
= UsrGroup.GroupName
281 UsrGroupMember.UserName
= Usr.UserName .
283 sel_curr
:ADD-LAST( UsrGroupMember.UserName
) .
284 sel_curr
:SCREEN-VALUE = UsrGroupMember.UserName.
285 sel_avail
:DELETE( INPUT sel_avail
) .
289 RUN notify
( 'set-idle
, CONTAINER-SOURCE'
:U
).
295 /* _UIB-CODE-BLOCK-END
*/
299 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-find-using-key V-table-Win adm/support/_key-fnd.p
300 PROCEDURE adm-find-using-key
:
301 /*------------------------------------------------------------------------------
302 Purpose
: Finds the current record using the contents of
303 the 'Key-Name' and 'Key-Value' attributes.
305 ------------------------------------------------------------------------------*/
306 DEF VAR key-value
AS CHAR NO-UNDO.
307 DEF VAR row-avail-enabled
AS LOGICAL NO-UNDO.
309 /* LOCK status on the find depends on FIELDS-ENABLED.
*/
310 RUN get-attribute
('FIELDS-ENABLED'
:U
).
311 row-avail-enabled
= (RETURN-VALUE eq 'yes'
:U
).
312 /* Look up the current key-value.
*/
313 RUN get-attribute
('Key-Value'
:U
).
314 key-value
= RETURN-VALUE.
316 /* Find the current record using the current Key-Name.
*/
317 RUN get-attribute
('Key-Name'
:U
).
319 WHEN 'GroupName'
:U
THEN
320 {src
/adm
/template
/find-tbl.i
322 &WHERE = "WHERE UsrGroup.GroupName eq key-value"
328 /* _UIB-CODE-BLOCK-END
*/
332 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
333 PROCEDURE adm-row-available
:
334 /*------------------------------------------------------------------------------
335 Purpose
: Dispatched to this procedure when the Record-
336 Source has a new row available. This procedure
337 tries to get the new row
(or foriegn keys
) from
338 the Record-Source and process it.
340 ------------------------------------------------------------------------------*/
342 /* Define variables needed by this internal procedure.
*/
343 {src
/adm
/template
/row-head.i
}
345 /* Process the newly available records
(i.e. display fields
,
346 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
347 {src
/adm
/template
/row-end.i
}
351 /* _UIB-CODE-BLOCK-END
*/
355 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
356 PROCEDURE disable_UI
:
357 /*------------------------------------------------------------------------------
358 Purpose
: DISABLE the User Interface
360 Notes
: Here we clean-up the user-interface by deleting
361 dynamic widgets we have created and
/or hide
362 frames. This procedure is usually called when
363 we are ready to
"clean-up" after running.
364 ------------------------------------------------------------------------------*/
365 /* Hide all frames.
*/
367 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
370 /* _UIB-CODE-BLOCK-END
*/
374 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
375 PROCEDURE inst-initialize
:
376 /*------------------------------------------------------------------------------
378 ------------------------------------------------------------------------------*/
380 this-win
= {&WINDOW-NAME}:HANDLE .
381 RUN top-most-changed.
385 /* _UIB-CODE-BLOCK-END
*/
389 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-row-available V-table-Win
390 PROCEDURE inst-row-available
:
391 /*------------------------------------------------------------------------------
395 ------------------------------------------------------------------------------*/
397 RUN dispatch
( 'find-using-key'
:u
).
398 IF NOT AVAILABLE UsrGroup
THEN RETURN.
400 CURRENT-WINDOW:TITLE = "Members - " + UsrGroup.GroupName.
401 IF ROWID( UsrGroup
) <> last-id
THEN RUN refresh-members.
402 last-id
= ROWID( UsrGroup
).
406 /* _UIB-CODE-BLOCK-END
*/
410 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-row-available V-table-Win
411 PROCEDURE pre-row-available
:
412 /*------------------------------------------------------------------------------
413 Purpose
: Override toolkit behaviour
414 ------------------------------------------------------------------------------*/
420 /* _UIB-CODE-BLOCK-END
*/
424 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE refresh-members V-table-Win
425 PROCEDURE refresh-members
:
426 /*------------------------------------------------------------------------------
430 ------------------------------------------------------------------------------*/
432 DO WITH FRAME {&FRAME-NAME}:
434 sel_avail
:LIST-ITEMS = "".
435 sel_curr
:LIST-ITEMS = "".
437 IF NOT AVAILABLE UsrGroup
THEN RETURN.
439 RUN notify
( 'set-busy
, CONTAINER-SOURCE'
:U
).
441 FOR EACH Usr
NO-LOCK:
442 IF CAN-FIND( UsrGroupMember
WHERE UsrGroupMember.UserName
= Usr.UserName
443 AND UsrGroupMember.GroupName
= UsrGroup.GroupName
) THEN
444 sel_curr
:ADD-LAST( Usr.UserName
).
446 sel_avail
:ADD-LAST( Usr.UserName
).
451 RUN notify
( 'set-idle
, CONTAINER-SOURCE'
:U
).
457 /* _UIB-CODE-BLOCK-END
*/
461 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE remove-member V-table-Win
462 PROCEDURE remove-member
:
463 /*------------------------------------------------------------------------------
467 ------------------------------------------------------------------------------*/
469 DO WITH FRAME {&FRAME-NAME}:
471 IF NOT AVAILABLE UsrGroup
THEN RETURN.
473 RUN notify
( 'set-busy
, CONTAINER-SOURCE'
:U
).
475 FIND FIRST Usr
WHERE Usr.UserName
= INPUT sel_curr.
476 FIND UsrGroupMember
OF UsrGroup
WHERE UsrGroupMember.UserName
= Usr.UserName
EXCLUSIVE-LOCK.
477 DELETE UsrGroupMember.
479 sel_avail
:ADD-LAST( INPUT sel_curr
) .
480 sel_avail
:SCREEN-VALUE = INPUT sel_curr.
481 sel_curr
:DELETE( INPUT sel_curr
) .
484 RUN notify
( 'set-idle
, CONTAINER-SOURCE'
:U
).
490 /* _UIB-CODE-BLOCK-END
*/
494 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key V-table-Win adm/support/_key-snd.p
496 /*------------------------------------------------------------------------------
497 Purpose
: Sends a requested
KEY value back to the calling
499 Parameters
: <see adm
/template
/sndkytop.i
>
500 ------------------------------------------------------------------------------*/
502 /* Define variables needed by this internal procedure.
*/
503 {src
/adm
/template
/sndkytop.i
}
505 /* Return the key value associated with each key case.
*/
506 {src
/adm
/template
/sndkycas.i
"GroupName" "UsrGroup" "GroupName"}
508 /* Close the
CASE statement and end the procedure.
*/
509 {src
/adm
/template
/sndkyend.i
}
513 /* _UIB-CODE-BLOCK-END
*/
517 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
518 PROCEDURE send-records
:
519 /*------------------------------------------------------------------------------
520 Purpose
: Send record
ROWID's for all tables used by
522 Parameters
: see template
/snd-head.i
523 ------------------------------------------------------------------------------*/
525 /* SEND-RECORDS does nothing because there are no External
526 Tables specified for this SmartViewer
, and there are no
527 tables specified in any contained Browse
, Query
, or Frame.
*/
531 /* _UIB-CODE-BLOCK-END
*/
535 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
536 PROCEDURE state-changed
:
537 /* -----------------------------------------------------------
541 -------------------------------------------------------------*/
542 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
543 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
546 /* Object instance CASEs can go here to replace standard behavior
548 {src
/adm
/template
/vstates.i
}
552 /* _UIB-CODE-BLOCK-END
*/
556 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE top-most-changed V-table-Win
557 PROCEDURE top-most-changed
:
558 /*------------------------------------------------------------------------------
560 ------------------------------------------------------------------------------*/
562 IF INPUT FRAME {&FRAME-NAME} tgl_topmost THEN
563 RUN notify
( 'set-topmost
,container-source'
:U
).
565 RUN notify
( 'reset-topmost
,container-source'
:U
).
569 /* _UIB-CODE-BLOCK-END
*/
573 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-buttons V-table-Win
574 PROCEDURE update-buttons
:
575 /*------------------------------------------------------------------------------
579 ------------------------------------------------------------------------------*/
581 DO WITH FRAME {&FRAME-NAME}:
582 btn_add
:SENSITIVE = sel_avail
:SCREEN-VALUE <> "" AND sel_avail
:SCREEN-VALUE <> ?.
583 btn_rem
:SENSITIVE = sel_curr
:SCREEN-VALUE <> "" AND sel_curr
:SCREEN-VALUE <> ?.
588 /* _UIB-CODE-BLOCK-END
*/