1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
8 /*------------------------------------------------------------------------
11 ------------------------------------------------------------------------*/
15 /***************************** Definitions
****************************/
17 DEF VAR main-menu-node
AS INT NO-UNDO.
18 DEF VAR key-value
AS CHAR NO-UNDO.
20 FIND FIRST LinkNode
WHERE LinkNode.NodeType
= "MN"
21 AND LinkNode.Description
= "Main Menu" NO-LOCK NO-ERROR.
22 main-menu-node
= LinkNode.NodeCode.
23 key-value
= STRING(LinkNode.NodeCode
).
25 /* _UIB-CODE-BLOCK-END
*/
29 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
31 /* ******************** Preprocessor Definitions
******************** */
33 &Scoped-define PROCEDURE-TYPE SmartBrowser
35 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
37 /* Name of first Frame and
/or Browse and
/or first Query
*/
38 &Scoped-define FRAME-NAME F-Main
39 &Scoped-define BROWSE-NAME br_table
41 /* Internal Tables
(found by Frame
, Query
& Browse Queries) */
42 &Scoped-define INTERNAL-TABLES LinkNode UsrGroupMenu UsrGroupMenuItem ~
45 /* Define KEY-PHRASE in case it is used by any query.
*/
46 &Scoped-define KEY-PHRASE TRUE
48 /* Definitions for
BROWSE br_table
*/
49 &Scoped-define FIELDS-IN-QUERY-br_table UsrGroupMenuItem.SequenceCode ~
50 UsrGroupMenuItem.ButtonLabel UsrGroupMenuItem.GroupName
51 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table ~
52 UsrGroupMenuItem.SequenceCode
53 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table~
54 ~
{&FP1}SequenceCode ~{&FP2}SequenceCode ~{&FP3}
55 &Scoped-define ENABLED-TABLES-IN-QUERY-br_table UsrGroupMenuItem
56 &Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-br_table UsrGroupMenuItem
57 &Scoped-define OPEN-QUERY-br_table OPEN QUERY br_table FOR EACH LinkNode WHERE ~{&KEY-PHRASE} NO-LOCK, ~
58 EACH UsrGroupMenu
WHERE UsrGroupMenu.NodeCode
= LinkNode.NodeCode
NO-LOCK, ~
59 EACH UsrGroupMenuItem
WHERE UsrGroupMenuItem.GroupName
= UsrGroupMenu.GroupName ~
60 AND UsrGroupMenuItem.MenuName
= UsrGroupMenu.MenuName
NO-LOCK, ~
61 EACH ProgramLink
WHERE ProgramLink.LinkCode
= UsrGroupMenuItem.LinkCode ~
62 AND ProgramLink.Source
= (IF LinkNode.NodeType
= "MN" THEN main-menu-node
ELSE LinkNode.NodeCode
) NO-LOCK ~
64 &Scoped-define TABLES-IN-QUERY-br_table LinkNode UsrGroupMenu ~
65 UsrGroupMenuItem ProgramLink
66 &Scoped-define FIRST-TABLE-IN-QUERY-br_table LinkNode
69 /* Definitions for
FRAME F-Main
*/
71 /* Standard List Definitions
*/
72 &Scoped-Define ENABLED-OBJECTS br_table
74 /* Custom List Definitions
*/
75 /* List-1
,List-2
,List-3
,List-4
,List-5
,List-6
*/
77 /* _UIB-PREPROCESSOR-BLOCK-END
*/
81 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
82 /* Actions
: ? adm
/support
/keyedit.w ? ? ?
*/
88 LinkCode||y|TTPL.ProgramLink.Target
89 LinkCode|y||TTPL.LinkNode.NodeCode
92 **************************
93 * Set attributes related to FOREIGN
KEYS
95 RUN set-attribute-list
(
96 'Keys-Accepted
= "LinkCode",
97 Keys-Supplied
= "LinkCode"'
:U
).
99 /* Tell the ADM to use the OPEN-QUERY-CASES.
*/
100 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
101 /**************************
103 /* _UIB-CODE-BLOCK-END
*/
106 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
107 /* Actions
: ? adm
/support
/advqedit.w ? ? ?
*/
113 SequenceCode|y||TTPL.UsrGroupMenuItem.SequenceCode|yes
116 ************************
117 * Set attributes related to SORTBY-OPTIONS
*/
118 RUN set-attribute-list
(
119 'SortBy-Options
= "SequenceCode",
120 SortBy-Case
= SequenceCode'
:U
).
122 /* Tell the ADM to use the OPEN-QUERY-CASES.
*/
123 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
125 /************************
128 </FILTER-ATTRIBUTES
> */
130 /* _UIB-CODE-BLOCK-END
*/
134 /* *********************** Control Definitions
********************** */
137 /* Definitions of the field level widgets
*/
138 /* Query definitions
*/
140 DEFINE QUERY br_table
FOR
144 ProgramLink
SCROLLING.
147 /* Browse definitions
*/
148 DEFINE BROWSE br_table
149 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _STRUCTURED
150 QUERY br_table
NO-LOCK DISPLAY
151 UsrGroupMenuItem.SequenceCode
COLUMN-LABEL "Seq" FORMAT ">>9"
152 UsrGroupMenuItem.ButtonLabel
153 UsrGroupMenuItem.GroupName
155 UsrGroupMenuItem.SequenceCode
156 /* _UIB-CODE-BLOCK-END
*/
158 WITH NO-ASSIGN SEPARATORS SIZE 39.43 BY 20.8
162 /* ************************ Frame Definitions
*********************** */
165 br_table
AT ROW 1 COL 1
166 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
167 SIDE-LABELS NO-UNDERLINE THREE-D
168 AT COL 1 ROW 1 SCROLLABLE
169 BGCOLOR 16 FGCOLOR 0 FONT 10.
172 /* *********************** Procedure Settings
************************ */
174 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
175 /* Settings for
THIS-PROCEDURE
179 Add Fields to
: EXTERNAL-TABLES
180 Other Settings
: PERSISTENT-ONLY
COMPILE
183 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
184 /* then cleanup and return.
*/
185 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
186 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
187 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
191 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
193 /* ************************* Create Window
************************** */
195 &ANALYZE-SUSPEND _CREATE-WINDOW
196 /* DESIGN Window definition
(used by the UIB
)
197 CREATE WINDOW B-table-Win
ASSIGN
200 /* END WINDOW DEFINITION
*/
205 /* *************** Runtime Attributes and UIB Settings
************** */
207 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
208 /* SETTINGS
FOR WINDOW B-table-Win
209 NOT-VISIBLE
,,RUN-PERSISTENT
*/
210 /* SETTINGS
FOR FRAME F-Main
211 NOT-VISIBLE Size-to-Fit
*/
212 /* BROWSE-TAB br_table
1 F-Main
*/
214 FRAME F-Main
:SCROLLABLE = FALSE
215 FRAME F-Main
:HIDDEN = TRUE.
217 /* _RUN-TIME-ATTRIBUTES-END
*/
221 /* Setting information for Queries and Browse Widgets fields
*/
223 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
224 /* Query rebuild information for
BROWSE br_table
225 _TblList
= "TTPL.LinkNode,TTPL.UsrGroupMenu WHERE TTPL.LinkNode ...,TTPL.UsrGroupMenuItem WHERE TTPL.UsrGroupMenu ...,TTPL.ProgramLink WHERE TTPL.UsrGroupMenuItem ..."
226 _Options
= "NO-LOCK KEY-PHRASE SORTBY-PHRASE"
228 _JoinCode
[2] = "UsrGroupMenu.NodeCode = LinkNode.NodeCode"
229 _JoinCode
[3] = "UsrGroupMenuItem.GroupName = UsrGroupMenu.GroupName
230 AND UsrGroupMenuItem.MenuName = UsrGroupMenu.MenuName"
231 _JoinCode
[4] = "ProgramLink.LinkCode = UsrGroupMenuItem.LinkCode
232 AND ProgramLink.Source = (IF LinkNode.NodeType = ""MN"" THEN main-menu-node ELSE LinkNode.NodeCode)"
233 _FldNameList
[1] > TTPL.UsrGroupMenuItem.SequenceCode
234 "UsrGroupMenuItem.SequenceCode" "Seq" ">>9" "integer" ? ? ? ? ? ? yes ?
235 _FldNameList
[2] = TTPL.UsrGroupMenuItem.ButtonLabel
236 _FldNameList
[3] = TTPL.UsrGroupMenuItem.GroupName
238 */ /* BROWSE br_table
*/
241 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
242 /* Query rebuild information for
FRAME F-Main
245 */ /* FRAME F-Main
*/
251 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
252 /* ************************* Included-Libraries
*********************** */
254 {src
/adm
/method
/browser.i
}
255 {inc
/method
/m-drlvwr.i
}
257 /* _UIB-CODE-BLOCK-END
*/
263 /* ************************ Control Triggers
************************ */
265 &Scoped-define BROWSE-NAME br_table
266 &Scoped-define SELF-NAME br_table
267 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
268 ON ROW-ENTRY
OF br_table
IN FRAME F-Main
270 /* This code displays initial values for newly added or copied rows.
*/
271 {src
/adm
/template
/brsentry.i
}
272 RUN browse-row-changed.
275 /* _UIB-CODE-BLOCK-END
*/
279 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
280 ON ROW-LEAVE
OF br_table
IN FRAME F-Main
282 /* Do not disable this code or no updates will take place except
283 by pressing the Save button on an Update SmartPanel.
*/
284 {src
/adm
/template
/brsleave.i
}
287 /* _UIB-CODE-BLOCK-END
*/
291 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
292 ON VALUE-CHANGED
OF br_table
IN FRAME F-Main
294 /* This ADM trigger code must be preserved in order to notify other
295 objects when the browser's current row changes.
*/
296 {src
/adm
/template
/brschnge.i
}
299 /* _UIB-CODE-BLOCK-END
*/
305 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
308 /* *************************** Main Block
*************************** */
310 /* _UIB-CODE-BLOCK-END
*/
314 /* ********************** Internal Procedures
*********************** */
316 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-open-query-cases B-table-Win adm/support/_adm-opn.p
317 PROCEDURE adm-open-query-cases
:
318 /*------------------------------------------------------------------------------
319 Purpose
: Opens different cases of the query based on attributes
320 such as the 'Key-Name'
, or 'SortBy-Case'
322 ------------------------------------------------------------------------------*/
323 DEF VAR key-value
AS CHAR NO-UNDO.
325 /* Look up the current key-value.
*/
326 RUN get-attribute
('Key-Value'
:U
).
327 key-value
= RETURN-VALUE.
329 /* Find the current record using the current Key-Name.
*/
330 RUN get-attribute
('Key-Name'
:U
).
332 WHEN 'LinkCode'
:U
THEN DO:
333 &Scope KEY-PHRASE LinkNode.NodeCode eq INTEGER(key-value)
334 RUN get-attribute
('SortBy-Case'
:U
).
336 WHEN 'SequenceCode'
:U
THEN DO:
337 &Scope SORTBY-PHRASE BY UsrGroupMenuItem.SequenceCode
338 {&OPEN-QUERY-{&BROWSE-NAME}}
341 &Undefine SORTBY-PHRASE
342 {&OPEN-QUERY-{&BROWSE-NAME}}
343 END.
/* OTHERWISE...
*/
347 &Scope KEY-PHRASE TRUE
348 RUN get-attribute
('SortBy-Case'
:U
).
350 WHEN 'SequenceCode'
:U
THEN DO:
351 &Scope SORTBY-PHRASE BY UsrGroupMenuItem.SequenceCode
352 {&OPEN-QUERY-{&BROWSE-NAME}}
355 &Undefine SORTBY-PHRASE
356 {&OPEN-QUERY-{&BROWSE-NAME}}
357 END.
/* OTHERWISE...
*/
359 END.
/* OTHERWISE...
*/
364 /* _UIB-CODE-BLOCK-END
*/
368 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
369 PROCEDURE adm-row-available
:
370 /*------------------------------------------------------------------------------
371 Purpose
: Dispatched to this procedure when the Record-
372 Source has a new row available. This procedure
373 tries to get the new row
(or foriegn keys
) from
374 the Record-Source and process it.
376 ------------------------------------------------------------------------------*/
378 /* Define variables needed by this internal procedure.
*/
379 {src
/adm
/template
/row-head.i
}
381 /* Process the newly available records
(i.e. display fields
,
382 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
383 {src
/adm
/template
/row-end.i
}
387 /* _UIB-CODE-BLOCK-END
*/
391 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE browse-row-changed B-table-Win
392 PROCEDURE browse-row-changed
:
393 /*------------------------------------------------------------------------------
395 ------------------------------------------------------------------------------*/
397 RUN set-link-attributes
IN sys-mgr
(
398 THIS-PROCEDURE, "Menu Items",
399 "SENSITIVE = " + IF AVAILABLE ProgramLink
AND ProgramLink.LinkType
<> "MSG" THEN
404 /* _UIB-CODE-BLOCK-END
*/
408 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE current-row-changed B-table-Win
409 PROCEDURE current-row-changed
:
410 /*------------------------------------------------------------------------------
412 ------------------------------------------------------------------------------*/
416 /* _UIB-CODE-BLOCK-END
*/
420 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
421 PROCEDURE disable_UI
:
422 /*------------------------------------------------------------------------------
423 Purpose
: DISABLE the User Interface
425 Notes
: Here we clean-up the user-interface by deleting
426 dynamic widgets we have created and
/or hide
427 frames. This procedure is usually called when
428 we are ready to
"clean-up" after running.
429 ------------------------------------------------------------------------------*/
430 /* Hide all frames.
*/
432 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
435 /* _UIB-CODE-BLOCK-END
*/
439 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-open-query-cases B-table-Win
440 PROCEDURE local-open-query-cases
:
441 /*------------------------------------------------------------------------------
442 Purpose
: Override standard ADM method
444 ------------------------------------------------------------------------------*/
446 /* Code placed here will execute PRIOR to standard behavior.
*/
448 /* Dispatch standard ADM method.
*/
449 RUN dispatch
IN THIS-PROCEDURE ( INPUT 'open-query-cases'
:U
) .
451 /* Code placed here will execute AFTER standard behavior.
*/
452 IF AVAILABLE(UsrGroupMenu
) THEN
453 {&WINDOW-NAME}:TITLE = "Menu Options - " + UsrGroupMenu.MenuName.
457 /* _UIB-CODE-BLOCK-END
*/
461 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
463 /*------------------------------------------------------------------------------
464 Purpose
: Sends a requested
KEY value back to the calling
466 Parameters
: <see adm
/template
/sndkytop.i
>
467 ------------------------------------------------------------------------------*/
469 /* Define variables needed by this internal procedure.
*/
470 {src
/adm
/template
/sndkytop.i
}
472 /* Return the key value associated with each key case.
*/
473 {src
/adm
/template
/sndkycas.i
"LinkCode" "ProgramLink" "Target"}
475 /* Close the
CASE statement and end the procedure.
*/
476 {src
/adm
/template
/sndkyend.i
}
480 /* _UIB-CODE-BLOCK-END
*/
484 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
485 PROCEDURE send-records
:
486 /*------------------------------------------------------------------------------
487 Purpose
: Send record
ROWID's for all tables used by
489 Parameters
: see template
/snd-head.i
490 ------------------------------------------------------------------------------*/
492 /* Define variables needed by this internal procedure.
*/
493 {src
/adm
/template
/snd-head.i
}
495 /* For each requested table
, put it's
ROWID in the output list.
*/
496 {src
/adm
/template
/snd-list.i
"LinkNode"}
497 {src
/adm
/template
/snd-list.i
"UsrGroupMenu"}
498 {src
/adm
/template
/snd-list.i
"UsrGroupMenuItem"}
499 {src
/adm
/template
/snd-list.i
"ProgramLink"}
501 /* Deal with any unexpected table requests before closing.
*/
502 {src
/adm
/template
/snd-end.i
}
506 /* _UIB-CODE-BLOCK-END
*/
510 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
511 PROCEDURE state-changed
:
512 /* -----------------------------------------------------------
516 -------------------------------------------------------------*/
517 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
518 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
521 /* Object instance CASEs can go here to replace standard behavior
523 {src
/adm
/template
/bstates.i
}
527 /* _UIB-CODE-BLOCK-END
*/
531 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Key-Value B-table-Win
532 PROCEDURE use-Key-Value
:
533 /*------------------------------------------------------------------------------
535 ------------------------------------------------------------------------------*/
536 DEF INPUT PARAMETER new-key-value
AS CHAR NO-UNDO.
538 key-value
= new-key-value.
542 /* _UIB-CODE-BLOCK-END
*/