-
Notifications
You must be signed in to change notification settings - Fork 23
/
wEdit.w
1797 lines (1411 loc) · 58.5 KB
/
wEdit.w
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI
&ANALYZE-RESUME
/* Connected Databases
*/
&Scoped-define WINDOW-NAME wEdit
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS wEdit
/*------------------------------------------------------------------------
Name : wEdit.w
Desc : Edit one or more records
----------------------------------------------------------------------*/
/* This .W file was created with the Progress AppBuilder. */
/*----------------------------------------------------------------------*/
CREATE WIDGET-POOL.
{ DataDigger.i }
/* Parameters Definitions --- */
DEFINE {&invar} plReadOnlyDigger AS LOGICAL NO-UNDO.
DEFINE {&invar} picMode AS CHARACTER NO-UNDO.
DEFINE {&invar} pihBrowse AS HANDLE NO-UNDO.
DEFINE {&invar} picDatabase AS CHARACTER NO-UNDO.
DEFINE {&invar} picTableName AS CHARACTER NO-UNDO.
&IF DEFINED(UIB_is_Running) = 0 &THEN
DEFINE {&invar} TABLE FOR ttField.
DEFINE {&invar} TABLE FOR ttColumn.
&ENDIF
DEFINE {&outvar} polSuccess AS LOGICAL NO-UNDO INITIAL ?.
DEFINE {&outvar} porRepositionId AS ROWID NO-UNDO.
/* Local Variable Definitions --- */
DEFINE VARIABLE gcUniqueFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE ghBackupTable AS HANDLE NO-UNDO.
DEFINE VARIABLE gcLargeFields AS CHARACTER NO-UNDO.
/* This table holds the actual values of the selected records */
DEFINE TEMP-TABLE ttData NO-UNDO
FIELD cFieldName AS CHARACTER
FIELD cValue AS CHARACTER FORMAT 'x(80)'
INDEX iPrim IS PRIMARY cFieldName /* cValue */.
&GLOBAL-DEFINE field-lShow 1
&GLOBAL-DEFINE field-iOrder 2
&GLOBAL-DEFINE field-cFullName 3
&GLOBAL-DEFINE field-cLabel 4
&GLOBAL-DEFINE field-cNewValue 5
/* TT to keep track of records we are editing */
DEFINE TEMP-TABLE ttRecordMapping NO-UNDO
FIELD ttRowid AS ROWID
FIELD dbRowid AS ROWID.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE Window
&Scoped-define DB-AWARE no
/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME frMain
&Scoped-define BROWSE-NAME brRecord
/* Internal Tables (found by Frame, Query & Browse Queries) */
&Scoped-define INTERNAL-TABLES ttColumn
/* Definitions for BROWSE brRecord */
&Scoped-define FIELDS-IN-QUERY-brRecord ttColumn.lShow ttColumn.iOrder ttColumn.cFullName ttColumn.cLabel ttColumn.cNewValue
&Scoped-define ENABLED-FIELDS-IN-QUERY-brRecord ttColumn.lShow ttColumn.cNewValue
&Scoped-define ENABLED-TABLES-IN-QUERY-brRecord ttColumn
&Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-brRecord ttColumn
&Scoped-define SELF-NAME brRecord
&Scoped-define QUERY-STRING-brRecord FOR EACH ttColumn
&Scoped-define OPEN-QUERY-brRecord OPEN QUERY {&SELF-NAME} FOR EACH ttColumn.
&Scoped-define TABLES-IN-QUERY-brRecord ttColumn
&Scoped-define FIRST-TABLE-IN-QUERY-brRecord ttColumn
/* Definitions for FRAME frMain */
/* Standard List Definitions */
&Scoped-Define ENABLED-OBJECTS brRecord tgSelAll fiNumRecords btnDecrease ~
btnOk btnClose tgWriteTrigger btnIncrease btnDatePicker btnEditor btnEncode ~
btnListEdit btnLowerCase btnUpperCase btnWordCase
&Scoped-Define DISPLAYED-OBJECTS tgSelAll fiNumRecords tgWriteTrigger
/* Custom List Definitions */
/* List-1,List-2,List-3,List-4,List-5,List-6 */
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* ************************ Function Prototypes ********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD increaseCharValue wEdit
FUNCTION increaseCharValue RETURNS CHARACTER
( pcCharValue AS CHARACTER
, piDelta AS INTEGER) FORWARD.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Control Definitions ********************** */
/* Define the widget handle for the window */
DEFINE VAR wEdit AS WIDGET-HANDLE NO-UNDO.
/* Definitions of the field level widgets */
DEFINE BUTTON btnClose AUTO-END-KEY
LABEL "&Close"
SIZE-PIXELS 74 BY 24.
DEFINE BUTTON btnDatePicker NO-FOCUS FLAT-BUTTON
LABEL "Date"
SIZE-PIXELS 30 BY 23 TOOLTIP "pick a date".
DEFINE BUTTON btnDecrease NO-FOCUS FLAT-BUTTON
LABEL "--"
SIZE-PIXELS 30 BY 23 TOOLTIP "decrease value (CTRL-CURSOR-DOWN)".
DEFINE BUTTON btnEditor NO-FOCUS FLAT-BUTTON
LABEL "Edit"
SIZE-PIXELS 30 BY 23 TOOLTIP "view-as editor (F3)".
DEFINE BUTTON btnEncode NO-FOCUS FLAT-BUTTON
LABEL "Enc"
SIZE-PIXELS 30 BY 23 TOOLTIP "encode the current value (F11)".
DEFINE BUTTON btnIncrease NO-FOCUS FLAT-BUTTON
LABEL "++"
SIZE-PIXELS 30 BY 23 TOOLTIP "increase value (CTRL-CURSOR-UP)".
DEFINE BUTTON btnListEdit NO-FOCUS FLAT-BUTTON
LABEL "List"
SIZE-PIXELS 30 BY 23 TOOLTIP "edit as list (F12)".
DEFINE BUTTON btnLowerCase NO-FOCUS FLAT-BUTTON
LABEL "abc"
SIZE-PIXELS 30 BY 23 TOOLTIP "convert to all lower case (SHIFT-DOWN)".
DEFINE BUTTON btnOk
LABEL "&Ok"
SIZE-PIXELS 74 BY 24 TOOLTIP "confirm changes".
DEFINE BUTTON btnUpperCase NO-FOCUS FLAT-BUTTON
LABEL "ABC"
SIZE-PIXELS 30 BY 23 TOOLTIP "convert to all upper case (SHIFT-UP)".
DEFINE BUTTON btnWordCase NO-FOCUS FLAT-BUTTON
LABEL "Abc"
SIZE-PIXELS 30 BY 23 TOOLTIP "each word begins with a capital".
DEFINE VARIABLE fiNumRecords AS CHARACTER FORMAT "X(256)":U
LABEL "Records"
VIEW-AS FILL-IN NATIVE
SIZE-PIXELS 50 BY 21 NO-UNDO.
DEFINE VARIABLE tgSelAll AS LOGICAL INITIAL yes
LABEL ""
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 15 BY 15 TOOLTIP "toggle selection for all records" NO-UNDO.
DEFINE VARIABLE tgWriteTrigger AS LOGICAL INITIAL yes
LABEL "Use &write trigger"
VIEW-AS TOGGLE-BOX
SIZE-PIXELS 136 BY 17 TOOLTIP "Enable write triggers or not" NO-UNDO.
/* Query definitions */
&ANALYZE-SUSPEND
DEFINE QUERY brRecord FOR
ttColumn SCROLLING.
&ANALYZE-RESUME
/* Browse definitions */
DEFINE BROWSE brRecord
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS brRecord wEdit _FREEFORM
QUERY brRecord DISPLAY
ttColumn.lShow COLUMN-LABEL '' VIEW-AS TOGGLE-BOX
ttColumn.iOrder
ttColumn.cFullName
ttColumn.cLabel
ttColumn.cNewValue
enable
ttColumn.lShow
ttColumn.cNewValue
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
WITH NO-ROW-MARKERS SEPARATORS
&IF '{&WINDOW-SYSTEM}' = 'TTY':U &THEN SIZE 132 BY 19
&ELSE SIZE-PIXELS 660 BY 390 &ENDIF FIT-LAST-COLUMN TOOLTIP "fields to edit".
/* ************************ Frame Definitions *********************** */
DEFINE FRAME frMain
brRecord AT Y 25 X 0
tgSelAll AT Y 27 X 5
fiNumRecords AT Y 425 X 78 COLON-ALIGNED
btnDecrease AT Y 0 X 210
btnOk AT Y 425 X 505
btnClose AT Y 425 X 585
tgWriteTrigger AT Y 427 X 145
btnIncrease AT Y 0 X 180
btnDatePicker AT Y 0 X 240
btnEditor AT Y 0 X 0
btnEncode AT Y 0 X 60
btnListEdit AT Y 0 X 30
btnLowerCase AT Y 0 X 120
btnUpperCase AT Y 0 X 90
btnWordCase AT Y 0 X 150
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1 SCROLLABLE
CANCEL-BUTTON btnClose.
/* *********************** Procedure Settings ************************ */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: Window
Allow: Basic,Browse,DB-Fields,Window,Query
Other Settings: COMPILE
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ************************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW wEdit ASSIGN
HIDDEN = YES
TITLE = "Edit records"
HEIGHT-P = 454
WIDTH-P = 664
MAX-HEIGHT-P = 2079
MAX-WIDTH-P = 1600
VIRTUAL-HEIGHT-P = 2079
VIRTUAL-WIDTH-P = 1600
RESIZE = yes
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
KEEP-FRAME-Z-ORDER = yes
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION */
&ANALYZE-RESUME
/* *********** Runtime Attributes and AppBuilder Settings *********** */
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW wEdit
NOT-VISIBLE,,RUN-PERSISTENT */
/* SETTINGS FOR FRAME frMain
NOT-VISIBLE FRAME-NAME Size-to-Fit */
/* BROWSE-TAB brRecord 1 frMain */
ASSIGN
FRAME frMain:SCROLLABLE = FALSE
FRAME frMain:RESIZABLE = TRUE.
ASSIGN
brRecord:COLUMN-RESIZABLE IN FRAME frMain = TRUE.
ASSIGN
btnEditor:HIDDEN IN FRAME frMain = TRUE.
ASSIGN
btnEncode:HIDDEN IN FRAME frMain = TRUE.
ASSIGN
btnListEdit:HIDDEN IN FRAME frMain = TRUE.
ASSIGN
fiNumRecords:READ-ONLY IN FRAME frMain = TRUE.
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wEdit)
THEN wEdit:HIDDEN = yes.
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME
/* Setting information for Queries and Browse Widgets fields */
&ANALYZE-SUSPEND _QUERY-BLOCK BROWSE brRecord
/* Query rebuild information for BROWSE brRecord
_START_FREEFORM
OPEN QUERY {&SELF-NAME} FOR EACH ttColumn.
_END_FREEFORM
_Query is NOT OPENED
*/ /* BROWSE brRecord */
&ANALYZE-RESUME
/* ************************ Control Triggers ************************ */
&Scoped-define SELF-NAME wEdit
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wEdit wEdit
ON END-ERROR OF wEdit /* Edit records */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
/* This case occurs when the user presses the "Esc" key.
In a persistently run window, just ignore this. If we did not, the
application would exit. */
IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wEdit wEdit
ON WINDOW-CLOSE OF wEdit /* Edit records */
DO:
/* This event will close the window and terminate the procedure. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wEdit wEdit
ON WINDOW-RESIZED OF wEdit /* Edit records */
DO:
IF FOCUS:NAME = 'cNewValue' THEN APPLY 'leave' TO FOCUS.
RUN LockWindow (INPUT wEdit:HANDLE, INPUT YES).
DO WITH FRAME frMain:
/* Make 'em small so we don't get errors on resizing the window */
btnOk:X = 1.
btnOk:Y = 1.
btnClose:X = 1.
btnClose:Y = 1.
/* Set frame width */
FRAME frMain:WIDTH-PIXELS = wEdit:WIDTH-PIXELS NO-ERROR.
FRAME frMain:HEIGHT-PIXELS = wEdit:HEIGHT-PIXELS NO-ERROR.
/* Adjust the browse */
brRecord:WIDTH-PIXELS = FRAME frMain:WIDTH-PIXELS - 3.
brRecord:HEIGHT-PIXELS = FRAME frMain:HEIGHT-PIXELS - brRecord:Y - 35.
btnClose:X = brRecord:X + brRecord:WIDTH-PIXELS - btnClose:WIDTH-PIXELS.
btnClose:Y = FRAME frMain:HEIGHT-PIXELS - 27.
btnOk:X = btnClose:X - btnOk:WIDTH-PIXELS - 10.
btnOk:Y = btnClose:Y.
fiNumRecords:Y = btnClose:Y.
fiNumRecords:SIDE-LABEL-HANDLE:Y = fiNumRecords:y.
tgWriteTrigger:y = fiNumRecords:Y + 2.
tgWriteTrigger:X = fiNumRecords:X + fiNumRecords:WIDTH-PIXELS + 10.
/* Save settings */
setRegistry("DataDigger:Edit", "Window:x", STRING(wEdit:X) ).
setRegistry("DataDigger:Edit", "Window:y", STRING(wEdit:Y) ).
setRegistry("DataDigger:Edit", "Window:height", STRING(wEdit:HEIGHT-PIXELS) ).
setRegistry("DataDigger:Edit", "Window:width", STRING(wEdit:WIDTH-PIXELS) ).
END.
RUN showScrollBars(FRAME frMain:HANDLE, NO, NO).
RUN LockWindow (INPUT wEdit:HANDLE, INPUT NO).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME frMain
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL frMain wEdit
ON GO OF FRAME frMain
DO:
RUN btnGoChoose(OUTPUT polSuccess).
IF NOT polSuccess THEN RETURN NO-APPLY.
ELSE APPLY 'close' TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define BROWSE-NAME brRecord
&Scoped-define SELF-NAME brRecord
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL brRecord wEdit
ON RETURN OF brRecord IN FRAME frMain
DO:
APPLY 'entry' TO ttColumn.cNewValue IN BROWSE brRecord.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL brRecord wEdit
ON ROW-DISPLAY OF brRecord IN FRAME frMain
DO:
/* Get field definition */
FIND ttField WHERE ttField.cFieldName = ttColumn.cFieldName NO-ERROR.
IF NOT AVAILABLE ttField THEN RETURN.
/* Change color when it has been changed */
IF ttColumn.cNewValue <> ttColumn.cOldValue THEN
ttColumn.cNewValue:FGCOLOR IN BROWSE brRecord = 12. /* red */
ELSE
ttColumn.cNewValue:FGCOLOR IN BROWSE brRecord = 9. /* blue */
/* Set bgcolor of the new value field if it is mandatory */
IF ttField.lMandatory = TRUE THEN
ASSIGN
ttColumn.lShow :BGCOLOR IN BROWSE brRecord = 8 /* gray */
ttColumn.iOrder :BGCOLOR IN BROWSE brRecord = 8
ttColumn.cFullName:BGCOLOR IN BROWSE brRecord = 8
ttColumn.cLabel :BGCOLOR IN BROWSE brRecord = 8.
ELSE
ASSIGN
ttColumn.lShow :BGCOLOR IN BROWSE brRecord = ?
ttColumn.iOrder :BGCOLOR IN BROWSE brRecord = ?
ttColumn.cFullName:BGCOLOR IN BROWSE brRecord = ?
ttColumn.cLabel :BGCOLOR IN BROWSE brRecord = ?.
/* Set fgcolor for fields that are too large */
IF ttField.cDatatype = 'character'
AND LOOKUP(ttColumn.cFullName, gcLargeFields) > 0 THEN
ASSIGN
ttColumn.cFullName:FGCOLOR IN BROWSE brRecord = 12
ttColumn.cLabel :FGCOLOR IN BROWSE brRecord = 12.
ELSE
ASSIGN
ttColumn.cFullName:FGCOLOR IN BROWSE brRecord = ?
ttColumn.cLabel :FGCOLOR IN BROWSE brRecord = ?.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL brRecord wEdit
ON SCROLL-NOTIFY OF brRecord IN FRAME frMain
DO:
IF FOCUS:NAME = 'cNewValue' THEN APPLY 'leave' TO FOCUS.
RUN enableToolbar("").
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL brRecord wEdit
ON START-SEARCH OF brRecord IN FRAME frMain
DO:
APPLY 'leave' TO ttColumn.cNewValue IN BROWSE brRecord.
RUN reopenFieldBrowse(brRecord:current-column:name,?).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnClose
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnClose wEdit
ON CHOOSE OF btnClose IN FRAME frMain /* Close */
DO:
DEFINE VARIABLE hToggle AS HANDLE NO-UNDO.
DEFINE BUFFER ttColumn FOR ttColumn.
DEFINE BUFFER ttData FOR ttData.
/* If we are updating and we press ESC we don't want to close the
* window, but we want to escape out of the update mode
*/
IF FOCUS:NAME = 'cNewValue' THEN
DO WITH FRAME {&frame-name}:
FIND ttColumn WHERE ttColumn.cFullName = brRecord:get-browse-column( {&field-cFullName} ):SCREEN-VALUE NO-ERROR.
IF NOT AVAILABLE ttColumn THEN RETURN.
/* See if there is only ONE ttData for this field.
* The find will only succeed if there is exactly ONE record
*/
FIND ttData WHERE ttData.cFieldName = ttColumn.cFullName NO-ERROR.
IF NOT AVAILABLE ttData THEN ttColumn.lShow = NO.
brRecord:get-browse-column( {&field-cNewValue} ):screen-value IN FRAME {&frame-name} = ttColumn.cOldValue.
brRecord:get-browse-column( {&field-lShow} ):screen-value IN FRAME {&frame-name} = string(ttColumn.lShow).
hToggle = brRecord:get-browse-column( {&field-lShow} ) IN FRAME {&frame-name}.
APPLY 'entry' TO hToggle.
RETURN NO-APPLY.
END.
APPLY 'close' TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnDatePicker
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnDatePicker wEdit
ON CHOOSE OF btnDatePicker IN FRAME frMain /* Date */
OR "F10" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
DEFINE VARIABLE dDate AS DATE NO-UNDO.
/* Check if allowed to run */
IF NOT btnDatePicker:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
DO WITH FRAME frMain:
dDate = DATE(FOCUS:SCREEN-VALUE).
RUN VALUE(getProgramDir() + 'datepicker.w') (INPUT-OUTPUT dDate).
IF dDate <> ? THEN FOCUS:SCREEN-VALUE = STRING(dDate).
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnDecrease
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnDecrease wEdit
ON CHOOSE OF btnDecrease IN FRAME frMain /* -- */
OR "CTRL-CURSOR-DOWN" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* Check if allowed to run */
IF NOT btnDecrease:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
RUN increaseValue(-1).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnEditor
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnEditor wEdit
ON CHOOSE OF btnEditor IN FRAME frMain /* Edit */
OR "F3" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* View-as editor */
DEFINE VARIABLE cValue AS LONGCHAR NO-UNDO.
/* Check if allowed to run */
IF NOT btnEditor:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
DO WITH FRAME frMain:
/* Make sure we are looking at the right field. */
FIND ttColumn WHERE ttColumn.cFullName = brRecord:GET-BROWSE-COLUMN( {&field-cFullName} ):SCREEN-VALUE NO-ERROR.
IF NOT AVAILABLE ttColumn THEN RETURN.
cValue = ttColumn.cNewValue:SCREEN-VALUE IN BROWSE brRecord.
RUN VALUE(getProgramDir() + 'wViewAsEditor.w')(INPUT-OUTPUT cValue).
ttColumn.cNewValue:SCREEN-VALUE IN BROWSE brRecord = SUBSTRING(cValue,1,20000).
APPLY 'value-changed' TO ttColumn.cNewValue IN BROWSE brRecord.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnEncode
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnEncode wEdit
ON CHOOSE OF btnEncode IN FRAME frMain /* Enc */
OR "F11" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* Check if allowed to run */
IF NOT btnEncode:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
DO WITH FRAME frMain:
brRecord:GET-BROWSE-COLUMN( {&field-cNewValue} ):SCREEN-VALUE = ENCODE(brRecord:GET-BROWSE-COLUMN( {&field-cNewValue} ):SCREEN-VALUE).
APPLY 'value-changed' TO ttColumn.cNewValue IN BROWSE brRecord.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnIncrease
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnIncrease wEdit
ON CHOOSE OF btnIncrease IN FRAME frMain /* ++ */
OR "CTRL-CURSOR-UP" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* Check if allowed to run */
IF NOT btnIncrease:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
RUN increaseValue(+1).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnListEdit
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnListEdit wEdit
ON CHOOSE OF btnListEdit IN FRAME frMain /* List */
OR "F12" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* List editor */
DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
/* Check if allowed to run */
IF NOT btnListEdit:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
DO WITH FRAME frMain:
/* Make sure we are looking at the right field. */
FIND ttColumn WHERE ttColumn.cFullName = brRecord:GET-BROWSE-COLUMN( {&field-cFullName} ):SCREEN-VALUE NO-ERROR.
IF NOT AVAILABLE ttColumn THEN RETURN.
cValue = ttColumn.cNewValue:SCREEN-VALUE IN BROWSE brRecord.
RUN VALUE( getProgramDir() + 'wLister.w')
( INPUT picDatabase
, INPUT SUBSTITUTE("&1.&2", picTableName, ttColumn.cFullName)
, INPUT-OUTPUT cValue
).
ttColumn.cNewValue:SCREEN-VALUE IN BROWSE brRecord = cValue.
APPLY 'value-changed' TO ttColumn.cNewValue IN BROWSE brRecord.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnLowerCase
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnLowerCase wEdit
ON CHOOSE OF btnLowerCase IN FRAME frMain /* abc */
OR "SHIFT-CURSOR-DOWN" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* Check if allowed to run */
IF NOT btnLowerCase:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
/* Make the string LOWER case */
DO WITH FRAME frMain:
brRecord:GET-BROWSE-COLUMN({&field-cNewValue}):SCREEN-VALUE = LOWER(brRecord:GET-BROWSE-COLUMN({&field-cNewValue}):SCREEN-VALUE).
APPLY 'value-changed' TO ttColumn.cNewValue IN BROWSE brRecord.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnOk
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnOk wEdit
ON CHOOSE OF btnOk IN FRAME frMain /* Ok */
DO:
RUN btnGoChoose(OUTPUT polSuccess).
IF NOT polSuccess THEN RETURN NO-APPLY.
ELSE APPLY 'close' TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnUpperCase
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnUpperCase wEdit
ON CHOOSE OF btnUpperCase IN FRAME frMain /* ABC */
OR "SHIFT-CURSOR-UP" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* Check if allowed to run */
IF NOT btnUpperCase:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
RUN btnUpperCaseChoose.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnWordCase
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnWordCase wEdit
ON CHOOSE OF btnWordCase IN FRAME frMain /* Abc */
OR "ALT-SHIFT-CURSOR-DOWN" OF ttColumn.cNewValue IN BROWSE brRecord
OR "ALT-SHIFT-CURSOR-UP" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
/* Let each word begin with a capital and let it continue in lower */
DEFINE VARIABLE iWord AS INTEGER NO-UNDO.
DEFINE VARIABLE cText AS CHARACTER NO-UNDO.
DEFINE VARIABLE cWord AS CHARACTER NO-UNDO.
/* Check if allowed to run */
IF NOT btnWordCase:SENSITIVE
OR FOCUS:NAME <> 'cNewValue' THEN RETURN.
DO WITH FRAME frMain:
cText = brRecord:GET-BROWSE-COLUMN({&field-cNewValue}):SCREEN-VALUE.
DO iWord = 1 TO NUM-ENTRIES(cText," "):
cWord = ENTRY(iWord,cText," ").
cWord = CAPS(SUBSTRING(cWord,1,1)) + LOWER(SUBSTRING(cWord,2)).
ENTRY(iWord,cText," ") = cWord.
END.
brRecord:GET-BROWSE-COLUMN({&field-cNewValue}):SCREEN-VALUE = cText.
APPLY 'value-changed' TO ttColumn.cNewValue IN BROWSE brRecord.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME tgSelAll
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tgSelAll wEdit
ON VALUE-CHANGED OF tgSelAll IN FRAME frMain
DO:
FOR EACH ttColumn:
ttColumn.lShow = SELF:CHECKED.
END.
RUN reopenFieldBrowse(?,?).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME tgWriteTrigger
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL tgWriteTrigger wEdit
ON VALUE-CHANGED OF tgWriteTrigger IN FRAME frMain /* Use write trigger */
DO:
setRegistry("DataDigger","EnableWriteTriggers", STRING(SELF:CHECKED) ).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&UNDEFINE SELF-NAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK wEdit
/* *************************** Main Block *************************** */
/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames. */
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.
/* The CLOSE event can be used from inside or outside the procedure to */
/* terminate it. */
ON CLOSE OF THIS-PROCEDURE
DO:
/* Save settings */
setRegistry("DataDigger:Edit", "Window:x", STRING(wEdit:X) ).
setRegistry("DataDigger:Edit", "Window:y", STRING(wEdit:Y) ).
setRegistry("DataDigger:Edit", "Window:height", STRING(wEdit:HEIGHT-PIXELS) ).
setRegistry("DataDigger:Edit", "Window:width", STRING(wEdit:WIDTH-PIXELS) ).
RUN disable_UI.
END.
ON "RETURN" OF ttColumn.lShow IN BROWSE brRecord
OR 'default-action' OF brRecord
DO:
DEFINE VARIABLE hDataField AS HANDLE NO-UNDO.
hDataField = brRecord:GET-BROWSE-COLUMN( {&field-cNewValue} ) IN FRAME {&FRAME-NAME}.
APPLY "ENTRY" TO hDataField.
RETURN NO-APPLY.
END. /* RETURN lShow */
ON " " OF ttColumn.lShow IN BROWSE brRecord
DO:
DO WITH FRAME {&FRAME-NAME}:
ttColumn.lShow = NOT ttColumn.lShow.
brRecord:GET-BROWSE-COLUMN( {&field-lShow} ):CHECKED = ttColumn.lShow.
APPLY "value-changed" TO ttColumn.lShow IN BROWSE brRecord.
brRecord:SELECT-NEXT-ROW().
END.
END. /* space lShow */
ON VALUE-CHANGED OF ttColumn.lShow IN BROWSE brRecord
DO:
/* If you toggle the field off, set the value to blank */
DO WITH FRAME {&FRAME-NAME}:
IF brRecord:GET-BROWSE-COLUMN( {&field-lShow} ):SCREEN-VALUE = "no" THEN
DO:
ttColumn.cNewValue = "".
ttColumn.lShow = NO.
brRecord:GET-BROWSE-COLUMN( {&field-cNewValue} ):SCREEN-VALUE = "".
END.
END.
END. /* value-changed lShow */
ON "PAGE-DOWN" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
DEFINE BUFFER bData FOR ttData.
DO WITH FRAME frMain:
findNext:
FOR EACH bData
WHERE bData.cFieldName = brRecord:GET-BROWSE-COLUMN( {&field-cFullName} ):SCREEN-VALUE
AND SUBSTRING(bData.cValue,1,100) > SELF:SCREEN-VALUE
BY SUBSTRING(bData.cValue,1,100):
SELF:SCREEN-VALUE = bData.cValue.
APPLY "value-changed" TO SELF.
LEAVE findNext.
END.
END.
RETURN NO-APPLY.
END. /* page-down cNewValue */
ON "PAGE-UP" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
DEFINE BUFFER bData FOR ttData.
DO WITH FRAME frMain:
findPrev:
FOR EACH bData
WHERE bData.cFieldName = brRecord:GET-BROWSE-COLUMN( {&field-cFullName} ):SCREEN-VALUE
AND bData.cValue < SELF:SCREEN-VALUE
BY SUBSTRING(bData.cValue,1,100) DESCENDING:
SELF:SCREEN-VALUE = bData.cValue.
APPLY "value-changed" TO SELF.
LEAVE findPrev.
END.
END.
RETURN NO-APPLY.
END. /* page-up cNewValue */
ON VALUE-CHANGED OF ttColumn.cNewValue IN BROWSE brRecord
DO:
ttColumn.lShow = TRUE.
ttColumn.cNewValue = SELF:INPUT-VALUE.
DO WITH FRAME {&FRAME-NAME}:
brRecord:GET-BROWSE-COLUMN( {&field-lShow} ):SCREEN-VALUE = "YES".
END.
END. /* value-changed cNewValue */
ON "entry" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
DO WITH FRAME {&FRAME-NAME}:
brRecord:TOOLTIP = "use CTRL-PGUP / CTRL-PGDN to~nbrowse through existing values".
/* Make sure we are looking at the right field. It might have changed due to a sort */
FIND ttColumn WHERE ttColumn.cFullName = brRecord:GET-BROWSE-COLUMN( {&field-cFullName} ):SCREEN-VALUE NO-ERROR.
IF NOT AVAILABLE ttColumn THEN RETURN NO-APPLY.
FIND ttField WHERE ttField.cFieldname = ttColumn.cFieldName NO-ERROR.
IF NOT AVAILABLE ttField THEN RETURN NO-APPLY.
IF ttField.cDataType = "character" THEN
DO:
SELF:FORMAT = ttField.cFormat.
SELF:SCREEN-VALUE = ttColumn.cNewValue.
END.
RUN enableToolbar(ttField.cDataType).
END.
END. /* entry cNewValue */
ON "leave" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
DO WITH FRAME {&FRAME-NAME}:
brRecord:TOOLTIP = "fields to edit".
RUN enableToolbar("").
END.
END. /* leave cNewValue */
/* Clean field */
ON "SHIFT-DEL" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
DO WITH FRAME {&FRAME-NAME}:
/* Make sure we are looking at the right field. */
FIND ttColumn WHERE ttColumn.cFullName = brRecord:GET-BROWSE-COLUMN( {&field-cFullName} ):SCREEN-VALUE NO-ERROR.
IF NOT AVAILABLE ttColumn THEN RETURN NO-APPLY.
FIND ttField WHERE ttField.cFieldname = ttColumn.cFieldName NO-ERROR.
IF NOT AVAILABLE ttField THEN RETURN NO-APPLY.
CASE ttField.cDataType:
WHEN "date" THEN SELF:SCREEN-VALUE = ?.
WHEN "integer" THEN SELF:SCREEN-VALUE = "0".
WHEN "decimal" THEN SELF:SCREEN-VALUE = "0".
WHEN "character" THEN SELF:SCREEN-VALUE = "".
WHEN "logical" THEN SELF:SCREEN-VALUE = ?.
END CASE.
END.
END. /* shift-del cNewValue */
/* Set date to today */
ON "HOME" OF ttColumn.cNewValue IN BROWSE brRecord
DO:
DEFINE VARIABLE dValue AS DATE NO-UNDO.
DO WITH FRAME {&FRAME-NAME}:
/* Make sure we are looking at the right field. */
FIND ttColumn WHERE ttColumn.cFullName = brRecord:GET-BROWSE-COLUMN( {&field-cFullName} ):SCREEN-VALUE NO-ERROR.
IF NOT AVAILABLE ttColumn THEN RETURN NO-APPLY.
FIND ttField WHERE ttField.cFieldname = ttColumn.cFieldName NO-ERROR.
IF NOT AVAILABLE ttField THEN RETURN NO-APPLY.
/* If it is a date or looks like a date, treat it like a date */
dValue = DATE(SELF:SCREEN-VALUE) NO-ERROR.
IF dValue <> ? OR ttField.cDataType = "date"
THEN SELF:SCREEN-VALUE = STRING(TODAY) NO-ERROR.
END.
END. /* home cNewValue */
/* Best default for GUI applications is... */
PAUSE 0 BEFORE-HIDE.
/* Now enable the interface and wait for the exit condition. */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire. */
MAIN-BLOCK:
DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
RUN enable_UI.
RUN initializeObject.
VIEW wEdit.
IF NOT THIS-PROCEDURE:PERSISTENT THEN
WAIT-FOR CLOSE OF THIS-PROCEDURE FOCUS brRecord.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE btnGoChoose wEdit
PROCEDURE btnGoChoose :
/*
* Apply changes to all selected records
*/
DEFINE OUTPUT PARAMETER plSuccess AS LOGICAL NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hBufferDB AS HANDLE NO-UNDO.
DEFINE VARIABLE hBufferOrg AS HANDLE NO-UNDO.
DEFINE VARIABLE hSourceBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE iNumRecs AS INTEGER NO-UNDO.
DEFINE VARIABLE iRow AS INTEGER NO-UNDO.
DEFINE VARIABLE iStartTime AS INT64 NO-UNDO.
DEFINE VARIABLE lDisableTrigger AS LOGICAL NO-UNDO.
DEFINE VARIABLE lCommit AS LOGICAL NO-UNDO.
DEFINE BUFFER bColumn FOR ttColumn.
DEFINE BUFFER bField FOR ttField.
/* In read-only mode, return */
IF plReadOnlyDigger THEN
DO:
plSuccess = TRUE.
RETURN.
END.
lDisableTrigger = (tgWriteTrigger:SCREEN-VALUE IN FRAME {&FRAME-NAME} = "no").