1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
5 &Scoped-define WINDOW-NAME CURRENT-WINDOW
6 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
7 /*------------------------------------------------------------------------
8 ------------------------------------------------------------------------*/
12 /* *************************** Definitions
************************** */
14 DEF VAR filter-type
AS CHAR INIT "All" NO-UNDO.
15 DEF VAR filter-case
AS CHAR INIT "" NO-UNDO.
16 DEF VAR node-mnt
AS HANDLE NO-UNDO.
18 /* _UIB-CODE-BLOCK-END
*/
22 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
24 /* ******************** Preprocessor Definitions
******************** */
26 &Scoped-define PROCEDURE-TYPE SmartBrowser
28 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
30 /* Name of first Frame and
/or Browse and
/or first Query
*/
31 &Scoped-define FRAME-NAME F-Main
32 &Scoped-define BROWSE-NAME br_table
34 /* Internal Tables
(found by Frame
, Query
& Browse Queries) */
35 &Scoped-define INTERNAL-TABLES LinkNode
37 /* Definitions for
BROWSE br_table
*/
38 &Scoped-define FIELDS-IN-QUERY-br_table LinkNode.Description
39 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table LinkNode.Description
40 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table~
41 ~
{&FP1}Description ~{&FP2}Description ~{&FP3}
42 &Scoped-define ENABLED-TABLES-IN-QUERY-br_table LinkNode
43 &Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-br_table LinkNode
44 &Scoped-define SELF-NAME br_table
45 &Scoped-define OPEN-QUERY-br_table OPEN QUERY br_table FOR EACH LinkNode NO-LOCK WHERE LinkNode.NodeType BEGINS filter-type AND LinkNode.Description BEGINS filter-case BY LinkNode.NodeType BY LinkNode.Description.
46 &Scoped-define TABLES-IN-QUERY-br_table LinkNode
47 &Scoped-define FIRST-TABLE-IN-QUERY-br_table LinkNode
50 /* Definitions for
FRAME F-Main
*/
52 /* Standard List Definitions
*/
53 &Scoped-Define ENABLED-OBJECTS br_table
55 /* Custom List Definitions
*/
56 /* List-1
,List-2
,List-3
,List-4
,List-5
,List-6
*/
58 /* _UIB-PREPROCESSOR-BLOCK-END
*/
63 /* *********************** Control Definitions
********************** */
66 /* Menu Definitions
*/
67 DEFINE MENU POPUP-MENU-br_table
TITLE "?"
68 MENU-ITEM m_Create_Node
LABEL "&Create Node"
69 MENU-ITEM m_Modify_Node
LABEL "&Modify Node"
70 MENU-ITEM m_Delete_Node
LABEL "&Delete Node"
71 MENU-ITEM m_Make_Copy
LABEL "Make Co&py" .
74 /* Definitions of the field level widgets
*/
75 /* Query definitions
*/
77 DEFINE QUERY br_table
FOR
81 /* Browse definitions
*/
82 DEFINE BROWSE br_table
83 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _FREEFORM
84 QUERY br_table
NO-LOCK DISPLAY
85 LinkNode.Description
FORMAT "X(57)"
88 /* _UIB-CODE-BLOCK-END
*/
90 WITH NO-LABELS NO-ASSIGN NO-ROW-MARKERS SIZE 44 BY 11.2
94 /* ************************ Frame Definitions
*********************** */
97 br_table
AT ROW 1 COL 1
98 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
99 SIDE-LABELS NO-UNDERLINE THREE-D
100 AT COL 1 ROW 1 SCROLLABLE
101 BGCOLOR 8 FGCOLOR 0 .
104 /* *********************** Procedure Settings
************************ */
106 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
107 /* Settings for
THIS-PROCEDURE
111 Add Fields to
: EXTERNAL-TABLES
112 Other Settings
: PERSISTENT-ONLY
COMPILE
115 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
116 /* then cleanup and return.
*/
117 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
118 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
119 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
123 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
125 /* ************************* Create Window
************************** */
127 &ANALYZE-SUSPEND _CREATE-WINDOW
128 /* DESIGN Window definition
(used by the UIB
)
129 CREATE WINDOW B-table-Win
ASSIGN
132 /* END WINDOW DEFINITION
*/
137 /* *************** Runtime Attributes and UIB Settings
************** */
139 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
140 /* SETTINGS
FOR WINDOW B-table-Win
141 NOT-VISIBLE
,,RUN-PERSISTENT
*/
142 /* SETTINGS
FOR FRAME F-Main
143 NOT-VISIBLE Size-to-Fit
*/
144 /* BROWSE-TAB br_table
1 F-Main
*/
146 FRAME F-Main
:SCROLLABLE = FALSE
147 FRAME F-Main
:HIDDEN = TRUE.
150 br_table
:POPUP-MENU IN FRAME F-Main
= MENU POPUP-MENU-br_table
:HANDLE
151 br_table
:MAX-DATA-GUESS IN FRAME F-Main
= 300.
153 /* _RUN-TIME-ATTRIBUTES-END
*/
157 /* Setting information for Queries and Browse Widgets fields
*/
159 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
160 /* Query rebuild information for
BROWSE br_table
162 OPEN QUERY br_table
FOR EACH LinkNode
NO-LOCK
163 WHERE LinkNode.NodeType
BEGINS filter-type
164 AND LinkNode.Description
BEGINS filter-case
165 BY LinkNode.NodeType
BY LinkNode.Description.
169 */ /* BROWSE br_table
*/
172 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
173 /* Query rebuild information for
FRAME F-Main
176 */ /* FRAME F-Main
*/
182 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
183 /* ************************* Included-Libraries
*********************** */
185 {src
/adm
/method
/browser.i
}
187 /* _UIB-CODE-BLOCK-END
*/
193 /* ************************ Control Triggers
************************ */
195 &Scoped-define BROWSE-NAME br_table
196 &Scoped-define SELF-NAME br_table
197 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
198 ON ROW-ENTRY
OF br_table
IN FRAME F-Main
200 /* This code displays initial values for newly added or copied rows.
*/
201 {src
/adm
/template
/brsentry.i
}
204 /* _UIB-CODE-BLOCK-END
*/
208 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
209 ON ROW-LEAVE
OF br_table
IN FRAME F-Main
211 /* Do not disable this code or no updates will take place except
212 by pressing the Save button on an Update SmartPanel.
*/
213 {src
/adm
/template
/brsleave.i
}
216 /* _UIB-CODE-BLOCK-END
*/
220 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
221 ON VALUE-CHANGED
OF br_table
IN FRAME F-Main
223 /* This ADM trigger code must be preserved in order to notify other
224 objects when the browser's current row changes.
*/
225 {src
/adm
/template
/brschnge.i
}
229 /* _UIB-CODE-BLOCK-END
*/
233 &Scoped-define SELF-NAME m_Create_Node
234 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Create_Node B-table-Win
235 ON CHOOSE OF MENU-ITEM m_Create_Node
/* Create Node
*/
240 /* _UIB-CODE-BLOCK-END
*/
244 &Scoped-define SELF-NAME m_Delete_Node
245 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Delete_Node B-table-Win
246 ON CHOOSE OF MENU-ITEM m_Delete_Node
/* Delete Node
*/
248 MESSAGE "Are you sure you want to delete this node ?"
249 VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE delete-it
AS LOGI.
250 IF delete-it
THEN RUN dispatch
( 'delete-record'
:U
).
253 /* _UIB-CODE-BLOCK-END
*/
257 &Scoped-define SELF-NAME m_Make_Copy
258 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Make_Copy B-table-Win
259 ON CHOOSE OF MENU-ITEM m_Make_Copy
/* Make Copy
*/
264 /* _UIB-CODE-BLOCK-END
*/
268 &Scoped-define SELF-NAME m_Modify_Node
269 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Modify_Node B-table-Win
270 ON CHOOSE OF MENU-ITEM m_Modify_Node
/* Modify Node
*/
275 /* _UIB-CODE-BLOCK-END
*/
281 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
284 /* *************************** Main Block
*************************** */
286 RUN set-attribute-list
( 'FilterBy-Case
= Drl
, FilterBy-Options
= Drl|Mnu|Sel|Mnt Vwr'
:U
).
287 RUN set-attribute-list
( 'Filter-Value
= '
:U
).
289 LinkNode.Description
:READ-ONLY IN BROWSE {&BROWSE-NAME} = Yes.
291 /* _UIB-CODE-BLOCK-END
*/
295 /* ********************** Internal Procedures
*********************** */
297 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE add-node B-table-Win
299 /*------------------------------------------------------------------------------
303 ------------------------------------------------------------------------------*/
306 RUN dispatch
IN node-mnt
( 'add-node'
:U
).
310 /* _UIB-CODE-BLOCK-END
*/
314 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
315 PROCEDURE adm-row-available
:
316 /*------------------------------------------------------------------------------
317 Purpose
: Dispatched to this procedure when the Record-
318 Source has a new row available. This procedure
319 tries to get the new row
(or foriegn keys
) from
320 the Record-Source and process it.
322 ------------------------------------------------------------------------------*/
324 /* Define variables needed by this internal procedure.
*/
325 {src
/adm
/template
/row-head.i
}
327 /* Process the newly available records
(i.e. display fields
,
328 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
329 {src
/adm
/template
/row-end.i
}
333 /* _UIB-CODE-BLOCK-END
*/
337 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE copy-node B-table-Win
338 PROCEDURE copy-node
:
339 /*------------------------------------------------------------------------------
343 ------------------------------------------------------------------------------*/
345 DEF BUFFER CopyNode
FOR LinkNode.
346 DEF BUFFER CopyLink
FOR ProgramLink.
347 DEF VAR file-suffix
AS INT INIT 2 NO-UNDO.
349 IF NOT AVAILABLE LinkNode
THEN RETURN.
351 DO WHILE CAN-FIND( FIRST CopyNode
WHERE
352 CopyNode.File
= LinkNode.File
+ STRING( file-suffix
) ):
353 file-suffix
= file-suffix
+ 1.
357 BUFFER-COPY LinkNode
EXCEPT NodeCode File
TO CopyNode
358 ASSIGN CopyNode.Description
= "Copy of " + LinkNode.Description
359 CopyNode.File
= LinkNode.File
+ STRING( file-suffix
).
361 FOR EACH ProgramLink
NO-LOCK
362 WHERE ProgramLink.Source
= LinkNode.NodeCode
:
364 BUFFER-COPY ProgramLink
EXCEPT LinkCode
TO CopyLink
365 ASSIGN CopyLink.Source
= CopyNode.NodeCode.
368 RUN dispatch
( 'open-query'
:U
).
369 REPOSITION {&BROWSE-NAME} TO ROWID ROWID( CopyNode ).
375 /* _UIB-CODE-BLOCK-END
*/
379 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
380 PROCEDURE disable_UI
:
381 /*------------------------------------------------------------------------------
382 Purpose
: DISABLE the User Interface
384 Notes
: Here we clean-up the user-interface by deleting
385 dynamic widgets we have created and
/or hide
386 frames. This procedure is usually called when
387 we are ready to
"clean-up" after running.
388 ------------------------------------------------------------------------------*/
389 /* Hide all frames.
*/
391 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
394 /* _UIB-CODE-BLOCK-END
*/
398 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-apply-entry B-table-Win
399 PROCEDURE local-apply-entry
:
400 /*------------------------------------------------------------------------------
401 Purpose
: Override standard ADM method
403 ------------------------------------------------------------------------------*/
405 /* Code placed here will execute PRIOR to standard behavior.
*/
406 IF filter-type
= "MN" THEN RETURN.
408 /* Dispatch standard ADM method.
*/
409 RUN dispatch
IN THIS-PROCEDURE ( INPUT 'apply-entry'
:U
) .
411 /* Code placed here will execute AFTER standard behavior.
*/
415 /* _UIB-CODE-BLOCK-END
*/
419 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-initialize B-table-Win
420 PROCEDURE local-initialize
:
421 /*------------------------------------------------------------------------------
422 Purpose
: Override standard ADM method
424 ------------------------------------------------------------------------------*/
426 /* Code placed here will execute PRIOR to standard behavior.
*/
428 /* Dispatch standard ADM method.
*/
429 RUN dispatch
IN THIS-PROCEDURE ( INPUT 'initialize'
:U
) .
431 /* Code placed here will execute AFTER standard behavior.
*/
432 APPLY 'VALUE-CHANGED'
:U
TO BROWSE {&BROWSE-NAME}.
436 /* _UIB-CODE-BLOCK-END
*/
440 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-open-query B-table-Win
441 PROCEDURE local-open-query
:
442 /*------------------------------------------------------------------------------
443 Purpose
: Override standard ADM method
445 ------------------------------------------------------------------------------*/
447 /* Code placed here will execute PRIOR to standard behavior.
*/
449 /* Dispatch standard ADM method.
*/
450 RUN dispatch
IN THIS-PROCEDURE ( INPUT 'open-query'
:U
) .
452 /* Code placed here will execute AFTER standard behavior.
*/
457 /* _UIB-CODE-BLOCK-END
*/
461 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-row-changed B-table-Win
462 PROCEDURE local-row-changed
:
463 /*------------------------------------------------------------------------------
464 Purpose
: Override standard ADM method
466 ------------------------------------------------------------------------------*/
468 /* Code placed here will execute PRIOR to standard behavior.
*/
470 /* Dispatch standard ADM method.
*/
471 RUN dispatch
IN THIS-PROCEDURE ( INPUT 'row-changed'
:U
) .
473 /* Code placed here will execute AFTER standard behavior.
*/
478 /* _UIB-CODE-BLOCK-END
*/
482 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE modify-node B-table-Win
483 PROCEDURE modify-node
:
484 /*------------------------------------------------------------------------------
488 ------------------------------------------------------------------------------*/
491 RUN dispatch
IN node-mnt
( 'modify-node'
:U
).
495 /* _UIB-CODE-BLOCK-END
*/
499 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
500 PROCEDURE send-records
:
501 /*------------------------------------------------------------------------------
502 Purpose
: Send record
ROWID's for all tables used by
504 Parameters
: see template
/snd-head.i
505 ------------------------------------------------------------------------------*/
507 /* Define variables needed by this internal procedure.
*/
508 {src
/adm
/template
/snd-head.i
}
510 /* For each requested table
, put it's
ROWID in the output list.
*/
511 {src
/adm
/template
/snd-list.i
"LinkNode"}
513 /* Deal with any unexpected table requests before closing.
*/
514 {src
/adm
/template
/snd-end.i
}
518 /* _UIB-CODE-BLOCK-END
*/
522 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE source-changed B-table-Win
523 PROCEDURE source-changed
:
524 /*------------------------------------------------------------------------------
526 ------------------------------------------------------------------------------*/
527 DEF VAR c-sctarget
AS CHAR NO-UNDO.
528 DEF VAR h-sctarget
AS HANDLE NO-UNDO.
529 DEF VAR c-ptarget
AS CHAR NO-UNDO.
530 DEF VAR h-ptarget
AS HANDLE NO-UNDO.
532 IF NOT VALID-HANDLE( adm-broker-hdl
) THEN RETURN.
534 RUN get-link-handle
IN adm-broker-hdl
(
535 THIS-PROCEDURE, 'PrgLnkSrc-Target'
:U
, OUTPUT c-sctarget
).
537 RUN get-link-handle
IN adm-broker-hdl
(
538 THIS-PROCEDURE, 'Partner-Target'
:U
, OUTPUT c-ptarget
).
540 h-sctarget
= WIDGET-HANDLE( ENTRY( 1, c-sctarget
) ).
541 h-ptarget
= WIDGET-HANDLE( ENTRY( 1, c-ptarget
) ).
543 IF VALID-HANDLE( h-sctarget
) AND AVAILABLE LinkNode
THEN
545 RUN set-attribute-list
IN h-sctarget
( 'LinkSource
= '
+ STRING( LinkNode.NodeCode
) ).
546 RUN dispatch
IN h-sctarget
( 'open-query'
:U
).
549 IF VALID-HANDLE( h-ptarget
) AND AVAILABLE LinkNode
THEN
551 RUN set-attribute-list
IN h-ptarget
( 'LinkSource
= '
+ STRING( LinkNode.NodeCode
) ).
552 RUN dispatch
IN h-ptarget
( 'open-query'
:U
).
557 /* _UIB-CODE-BLOCK-END
*/
561 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE start-node-mnt B-table-Win
562 PROCEDURE start-node-mnt
:
563 /*------------------------------------------------------------------------------
567 ------------------------------------------------------------------------------*/
569 RUN lnk
/w-lnknde.w
PERSISTENT SET node-mnt.
570 RUN add-link
IN adm-broker-hdl
(THIS-PROCEDURE, 'Record'
:U
, node-mnt
).
571 RUN dispatch
IN node-mnt
( 'initialize'
:U
).
575 /* _UIB-CODE-BLOCK-END
*/
579 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
580 PROCEDURE state-changed
:
581 /* -----------------------------------------------------------
585 -------------------------------------------------------------*/
586 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
587 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
590 /* Object instance CASEs can go here to replace standard behavior
592 {src
/adm
/template
/bstates.i
}
596 /* _UIB-CODE-BLOCK-END
*/
600 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Filter-Value B-table-Win
601 PROCEDURE use-Filter-Value
:
602 /*------------------------------------------------------------------------------
604 ------------------------------------------------------------------------------*/
605 DEF INPUT PARAMETER new-case
AS CHAR NO-UNDO.
607 IF filter-type
<> "MN" THEN filter-case
= new-case.
610 /* _UIB-CODE-BLOCK-END
*/
614 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-FilterBy-Case B-table-Win
615 PROCEDURE use-FilterBy-Case
:
616 /*------------------------------------------------------------------------------
618 ------------------------------------------------------------------------------*/
619 DEF INPUT PARAMETER new-case
AS CHAR NO-UNDO.
622 WHEN 'Drl'
:U
THEN filter-type
= 'DW'.
623 WHEN 'Sel'
:U
THEN filter-type
= 'SW'.
624 WHEN 'Mnu'
:U
THEN filter-type
= 'MN'.
625 WHEN 'Mnt Vwr'
:U
THEN filter-type
= 'MV'.
626 OTHERWISE filter-type
= ''.
629 IF filter-type
= "MN" THEN
630 filter-case
= "Main".
632 RUN get-attribute
( "Filter-Value":U
).
633 filter-case
= RETURN-VALUE.
637 /* _UIB-CODE-BLOCK-END
*/