1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
8 /*------------------------------------------------------------------------
12 Description
: from VIEWER.W
- Template for SmartViewer Objects
20 ------------------------------------------------------------------------*/
21 /* This .W file was created with the Progress UIB.
*/
22 /*----------------------------------------------------------------------*/
24 /* Create an unnamed pool to store all the widgets created
25 by this procedure. This is a good default which assures
26 that this procedure's triggers and internal procedures
27 will execute in this procedure's storage
, and that proper
28 cleanup will occur on deletion of the procedure.
*/
32 /* *************************** Definitions
************************** */
34 /* Parameters Definitions
--- */
36 /* Local Variable Definitions
--- */
38 DEF VAR mode
AS CHAR NO-UNDO.
40 /* _UIB-CODE-BLOCK-END
*/
44 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
46 /* ******************** Preprocessor Definitions
******************** */
48 &Scoped-define PROCEDURE-TYPE SmartViewer
50 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
52 /* Name of first Frame and
/or Browse and
/or first Query
*/
53 &Scoped-define FRAME-NAME F-Main
56 &Scoped-define EXTERNAL-TABLES FrequencyType
57 &Scoped-define FIRST-EXTERNAL-TABLE FrequencyType
60 /* Need to scope the external tables to this procedure
*/
61 DEFINE QUERY external_tables
FOR FrequencyType.
62 /* Standard List Definitions
*/
63 &Scoped-Define ENABLED-FIELDS FrequencyType.FrequencyCode ~
64 FrequencyType.Description FrequencyType.UnitCount FrequencyType.RepeatUnits
65 &Scoped-define FIELD-PAIRS~
66 ~
{&FP1}FrequencyCode ~{&FP2}FrequencyCode ~{&FP3}~
67 ~
{&FP1}Description ~{&FP2}Description ~{&FP3}~
68 ~
{&FP1}UnitCount ~{&FP2}UnitCount ~{&FP3}
69 &Scoped-define ENABLED-TABLES FrequencyType
70 &Scoped-define FIRST-ENABLED-TABLE FrequencyType
71 &Scoped-Define ENABLED-OBJECTS RECT-11
72 &Scoped-Define DISPLAYED-FIELDS FrequencyType.FrequencyCode ~
73 FrequencyType.Description FrequencyType.UnitCount FrequencyType.RepeatUnits
75 /* Custom List Definitions
*/
76 /* ADM-CREATE-FIELDS
,ADM-ASSIGN-FIELDS
,List-3
,List-4
,List-5
,List-6
*/
78 /* _UIB-PREPROCESSOR-BLOCK-END
*/
83 /* *********************** Control Definitions
********************** */
86 /* Definitions of the field level widgets
*/
87 DEFINE RECTANGLE RECT-11
88 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
92 /* ************************ Frame Definitions
*********************** */
95 FrequencyType.FrequencyCode
AT ROW 1.2 COL 8.14 COLON-ALIGNED
99 FrequencyType.Description
AT ROW 2.4 COL 8.14 COLON-ALIGNED
102 FrequencyType.UnitCount
AT ROW 3.4 COL 8.14 COLON-ALIGNED
105 FrequencyType.RepeatUnits
AT ROW 3.4 COL 31.29 HELP
106 "Units for the repeat frequency (Day, Month, Year...)" NO-LABEL
107 VIEW-AS RADIO-SET HORIZONTAL
112 RECT-11
AT ROW 1 COL 1
113 "Units are:" VIEW-AS TEXT
114 SIZE 6.86 BY 1 AT ROW 3.4 COL 23.29
115 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
116 SIDE-LABELS NO-UNDERLINE THREE-D
117 AT COL 1 ROW 1 SCROLLABLE
121 /* *********************** Procedure Settings
************************ */
123 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
124 /* Settings for
THIS-PROCEDURE
126 External Tables
: TTPL.FrequencyType
127 Allow
: Basic
,DB-Fields
129 Add Fields to
: EXTERNAL-TABLES
130 Other Settings
: PERSISTENT-ONLY
COMPILE
133 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
134 /* then cleanup and return.
*/
135 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
136 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
137 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
141 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
143 /* ************************* Create Window
************************** */
145 &ANALYZE-SUSPEND _CREATE-WINDOW
146 /* DESIGN Window definition
(used by the UIB
)
147 CREATE WINDOW V-table-Win
ASSIGN
150 /* END WINDOW DEFINITION
*/
155 /* *************** Runtime Attributes and UIB Settings
************** */
157 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
158 /* SETTINGS
FOR WINDOW V-table-Win
159 VISIBLE,,RUN-PERSISTENT
*/
160 /* SETTINGS
FOR FRAME F-Main
161 NOT-VISIBLE Size-to-Fit
*/
163 FRAME F-Main
:SCROLLABLE = FALSE
164 FRAME F-Main
:HIDDEN = TRUE.
166 /* SETTINGS
FOR FILL-IN FrequencyType.FrequencyCode
IN FRAME F-Main
168 /* SETTINGS
FOR RADIO-SET FrequencyType.RepeatUnits
IN FRAME F-Main
170 /* _RUN-TIME-ATTRIBUTES-END
*/
174 /* Setting information for Queries and Browse Widgets fields
*/
176 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
177 /* Query rebuild information for
FRAME F-Main
180 */ /* FRAME F-Main
*/
186 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
187 /* ************************* Included-Libraries
*********************** */
189 {src
/adm
/method
/viewer.i
}
190 {inc
/method
/m-mntvwr.i
}
192 /* _UIB-CODE-BLOCK-END
*/
197 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
200 /* *************************** Main Block
*************************** */
202 &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
203 RUN dispatch
IN THIS-PROCEDURE ('initialize'
:U
).
206 /************************ INTERNAL PROCEDURES
********************/
208 /* _UIB-CODE-BLOCK-END
*/
212 /* ********************** Internal Procedures
*********************** */
214 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
215 PROCEDURE adm-row-available
:
216 /*------------------------------------------------------------------------------
217 Purpose
: Dispatched to this procedure when the Record-
218 Source has a new row available. This procedure
219 tries to get the new row
(or foriegn keys
) from
220 the Record-Source and process it.
222 ------------------------------------------------------------------------------*/
224 /* Define variables needed by this internal procedure.
*/
225 {src
/adm
/template
/row-head.i
}
227 /* Create a list of all the tables that we need to get.
*/
228 {src
/adm
/template
/row-list.i
"FrequencyType"}
230 /* Get the record
ROWID's from the RECORD-SOURCE.
*/
231 {src
/adm
/template
/row-get.i
}
233 /* FIND each record specified by the RECORD-SOURCE.
*/
234 {src
/adm
/template
/row-find.i
"FrequencyType"}
236 /* Process the newly available records
(i.e. display fields
,
237 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
238 {src
/adm
/template
/row-end.i
}
242 /* _UIB-CODE-BLOCK-END
*/
246 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cancel-changes V-table-Win
247 PROCEDURE cancel-changes
:
248 /*------------------------------------------------------------------------------
252 ------------------------------------------------------------------------------*/
254 RUN notify
( 'hide
, CONTAINER-SOURCE'
:U
).
255 IF mode
= "Add" THEN RUN delete-frequency.
ELSE RUN check-modified
( "CLEAR" ).
256 RUN dispatch
( 'exit'
:U
).
260 /* _UIB-CODE-BLOCK-END
*/
264 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE confirm-changes V-table-Win
265 PROCEDURE confirm-changes
:
266 /*------------------------------------------------------------------------------
270 ------------------------------------------------------------------------------*/
272 RUN verify-frequency.
273 IF RETURN-VALUE = "FAIL" THEN RETURN.
275 RUN dispatch
( 'update-record'
:U
).
276 RUN notify
( 'open-query
,record-source'
:U
).
277 RUN dispatch
( 'exit'
:U
).
281 /* _UIB-CODE-BLOCK-END
*/
285 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE delete-frequency V-table-Win
286 PROCEDURE delete-frequency
:
287 /*------------------------------------------------------------------------------
291 ------------------------------------------------------------------------------*/
293 FIND CURRENT FrequencyType
EXCLUSIVE-LOCK NO-ERROR.
294 IF AVAILABLE FrequencyType
THEN DELETE FrequencyType.
298 /* _UIB-CODE-BLOCK-END
*/
302 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
303 PROCEDURE disable_UI
:
304 /*------------------------------------------------------------------------------
305 Purpose
: DISABLE the User Interface
307 Notes
: Here we clean-up the user-interface by deleting
308 dynamic widgets we have created and
/or hide
309 frames. This procedure is usually called when
310 we are ready to
"clean-up" after running.
311 ------------------------------------------------------------------------------*/
312 /* Hide all frames.
*/
314 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
317 /* _UIB-CODE-BLOCK-END
*/
321 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
322 PROCEDURE inst-initialize
:
323 /*------------------------------------------------------------------------------
327 ------------------------------------------------------------------------------*/
329 RUN get-attribute
( 'mode'
).
335 RUN dispatch
( 'add-record'
:U
).
337 ELSE RUN dispatch
( 'enable-fields'
).
341 /* _UIB-CODE-BLOCK-END
*/
345 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE override-add-record V-table-Win
346 PROCEDURE override-add-record
:
347 /*------------------------------------------------------------------------------
351 ------------------------------------------------------------------------------*/
353 CREATE FrequencyType.
354 ASSIGN FrequencyType.RepeatUnits
= "DAYS".
356 RUN dispatch
( 'display-fields'
:U
).
357 RUN dispatch
( 'enable-fields'
:U
).
359 CURRENT-WINDOW:TITLE = "Adding a new Frequency Type".
363 /* _UIB-CODE-BLOCK-END
*/
367 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
368 PROCEDURE pre-destroy
:
369 /*------------------------------------------------------------------------------
373 ------------------------------------------------------------------------------*/
375 IF LAST-EVENT:FUNCTION = "WINDOW-CLOSE" THEN RUN cancel-changes.
379 /* _UIB-CODE-BLOCK-END
*/
383 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
384 PROCEDURE send-records
:
385 /*------------------------------------------------------------------------------
386 Purpose
: Send record
ROWID's for all tables used by
388 Parameters
: see template
/snd-head.i
389 ------------------------------------------------------------------------------*/
391 /* Define variables needed by this internal procedure.
*/
392 {src
/adm
/template
/snd-head.i
}
394 /* For each requested table
, put it's
ROWID in the output list.
*/
395 {src
/adm
/template
/snd-list.i
"FrequencyType"}
397 /* Deal with any unexpected table requests before closing.
*/
398 {src
/adm
/template
/snd-end.i
}
402 /* _UIB-CODE-BLOCK-END
*/
406 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
407 PROCEDURE state-changed
:
408 /* -----------------------------------------------------------
412 -------------------------------------------------------------*/
413 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
414 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
417 /* Object instance CASEs can go here to replace standard behavior
419 {src
/adm
/template
/vstates.i
}
423 /* _UIB-CODE-BLOCK-END
*/
427 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-frequency V-table-Win
428 PROCEDURE verify-frequency
:
429 /*------------------------------------------------------------------------------
433 ------------------------------------------------------------------------------*/
435 DO WITH FRAME {&FRAME-NAME}:
437 IF TRIM( INPUT FrequencyType.FrequencyCode
) = ""
438 OR TRIM( INPUT FrequencyType.Description
) = "" THEN DO:
439 MESSAGE "You must enter a code and a description" SKIP
440 "for this frequency type."
441 VIEW-AS ALERT-BOX ERROR TITLE "No code or description entered".
443 IF INPUT FrequencyType.Description
= "" THEN
444 APPLY '
ENTRY'
TO FrequencyType.Description.
446 APPLY '
ENTRY'
TO FrequencyType.FrequencyCode.
451 IF INPUT FrequencyType.FrequencyCode
<> FrequencyType.FrequencyCode
452 AND CAN-FIND( FrequencyType
WHERE FrequencyType.FrequencyCode
453 = INPUT FrequencyType.FrequencyCode
) THEN DO:
454 MESSAGE "A frequency already exists with code" INPUT FrequencyType.FrequencyCode
+ "."
455 VIEW-AS ALERT-BOX ERROR TITLE "Duplicate Frequency".
456 APPLY '
ENTRY'
TO FrequencyType.FrequencyCode.
460 IF NOT INPUT FrequencyType.UnitCount
> 0 THEN DO:
461 MESSAGE "The repeat units must be greater than zero!" VIEW-AS ALERT-BOX ERROR
462 TITLE "Invalid repeat units".
463 APPLY '
ENTRY'
TO FrequencyType.UnitCount.
471 /* _UIB-CODE-BLOCK-END
*/