-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDFRefactor.src
More file actions
1501 lines (1245 loc) · 60.6 KB
/
DFRefactor.src
File metadata and controls
1501 lines (1245 loc) · 60.6 KB
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
//****************************************************************************
// $Module type: Program
// $Module name: DFRefactor
// $Author : Nils Svedmyr, RDC Tools International, <mailto:support@rdctools.com>
// Web-site : http://www.rdctools.com
// Created : 2018-08-05 @ 09:50 (Military date format: YY-MM-DD)
//
// Description : Code Refactor functions for DataFlex.
//
// The code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// This is free software; you can redistribute it and/or modify it under the terms of the
// GNU Lesser General Public License - see the "GNU Lesser General Public License.txt"
// in the help folder for more details.
//
//****************************************************************************
Use DFAllEnt.pkg
Use cRDCCJCommandBarSystem.pkg
Use File_dlg.pkg
Use gFormatNumbers.pkg
Use vWin32fh.pkg
Use RefactorConstants.h.pkg
Use cWorkspaceMenuItem.pkg
// Uncomment this define statement to show a "Theme selector" combo-button and
// a "Snap Shot" camera iton in the toolbar.
//Define Is$BlingStuff
// Not sure why we need this, but it somehow is linked to the "OnIdle events"
Procedure Exit_Application for cDesktop
Send SuspendGUI of Desktop True
If (Exit_System_Confirmation(Self)) ;
Abort
End_Procedure
Object oHtmlHelp is a cHtmlHelp
Set pbAlwaysOnTop to False
End_Object
// Dummy messages that are called from the toolbars; in case they
// doesn't exist in a view. This avoids runtime errors.
Function Can_UndoAction Desktop Returns Boolean
Function_Return False
End_Function
Function Can_RedoAction Desktop Returns Boolean
Function_Return False
End_Function
Function pbShouldSave Desktop Returns Boolean
Function_Return False
End_Function
Function BackupFile Desktop Returns String
Function_Return ""
End_Function
Procedure OpenSourceFile Desktop
End_Procedure
Procedure Compare Desktop String sCompareApp
End_Procedure
Procedure OnWorkspaceLoaded Desktop
End_Procedure
Procedure LoadFile Desktop String sFileName
End_Procedure
External_Function GetACP "GetACP" kernel32.dll Returns Integer
Register_Procedure DoChangeFontSize
Enum_List
Define CI_CleanupSource
Define CI_CodeIndenter
End_Enum_List
// Needs to be _before_ the cApplication object as we refer to it there.
// However, the package itself must be Used _after_ the ghoApplication object,
// as it contains references to the phoWorkspace property. (Kind of catch 22).
Global_Variable Integer ghoEditorProperties
Move 0 to ghoEditorProperties
Declare_Datafile FolderSelHea
Use cFunctionsDataDictionary.dd
Use cRefactorApplication.pkg
Object oApplication is a cRefactorApplication
Set psProduct to "DFRefactor"
Set psCompany to "RDC Tools International"
Set peHelpType to htHtmlHelp
Set psHelpFile to "DFRefactor.chm"
Property String[] pasCmdLineSetSelectedFolders
Property Boolean pbBatchMode False
Property String psCmdLineIniFile ""
Procedure OnWorkspaceOpened
String sProduct
Integer iRetval
Forward Send OnWorkspaceOpened
/* Check that the 'correct' collating.cfg is used when the program is
started. The data in the database was entered with an english (standard)
collating sequence. If another df_collate.cfg is encountered at runtime,
all data tables will automatically be reindexed, prior to running the program.
Note: We cannot use the event OnCreate for this, because the psDataPath
et. al. is set after that event.
*/
Open Functions
Send CheckCollatingSequence of ghoDatabaseFunctions File_Field Functions.Function_Name
End_Procedure
Procedure Set psSWSFile String sSWSFile
Handle hoCombo
Integer iItem iCount
String sListItem
Forward Set psSWSFile to sSWSFile
If (ghoCommandBars > 0) Begin
Send DisplayWorkspaceItem of (oWorkspaceSelector_Menuitem(ghoCommandBars)) sSWSFile
If (hoCombo > 0) Begin
Get ComListCount of hoCombo to iCount
For iItem from 0 to iCount
Get ComList of hoCombo iItem to sListItem
If (sListItem = "Select Workspace:") Begin
Set ComListIndex of hoCombo to iItem
End
Loop
Send Destroy of hoCombo
End
End
End_Procedure
Procedure OnFileNameUpdate String sFileName
String sText sFileBrowseText sFileNameOnly
If (sFileName <> "") Begin
Move sFileName to sText
Get ParseFileName sFileName to sFileNameOnly
Move CS_CurrentSourceFileTxt to sFileBrowseText
End
Else Begin
Move CS_BrowseSourceFileTxt to sFileBrowseText
Move CS_NoActiveSourceFileText to sText
End
Set psCurrentSourceFileName to sFileName
If (phoMainPanel(Self) <> 0) Begin
Set psCaption of (oOpenFolderMenuItem(ghoCommandBars)) to sFileBrowseText
Set psCaption of (oSourceFileText_MenuItem(ghoCommandBars)) to sFileNameOnly
Set psToolTip of (oSourceFileText_MenuItem(ghoCommandBars)) to sText
Set pbChecked of (oSourceFileText_MenuItem(ghoCommandBars)) to (sText <> "")
End
End_Procedure
Procedure ToggleWorkspaceMode
Boolean bState
Get pbWorkspaceMode to bState
If (oWorkspaceRadio_MenuItem(ghoCommandBars) <> 0) Begin
Set pbChecked of (oWorkspaceRadio_MenuItem(ghoCommandBars)) to bState
End
If (oFileRadioMenuItem(ghoCommandBars) <> 0) Begin
Set pbChecked of (oFileRadioMenuItem(ghoCommandBars)) to (not(bState))
End
End_Procedure
Procedure SelectSourceFile
Boolean bOpen bReadOnly bExists
String sFileName sHomePath sAppSrcPath sInitialFolder
Handle ho
Move (phoOpenSourceFileDialog(Self)) to ho
Get Initial_Folder of ho to sInitialFolder
If (sInitialFolder = "") Begin
Get psHomePath to sHomePath
// If an "AppSrc" folder exists we want to display those source files.
Get vFolderFormat sHomePath to sAppSrcPath
Move (sAppSrcPath + "AppSrc") to sAppSrcPath
Get vFolderExists sAppSrcPath to bExists
If (bExists = True) Begin
Move sAppSrcPath to sHomePath
End
Set Initial_Folder of ho to sHomePath
End
Get Show_Dialog of ho to bOpen
If (bOpen = True) Begin
Get File_Name of ho to sFileName
// Check if user is opening file as read_only
Get TickReadOnly_State of ho to bReadOnly
If (bReadOnly = True) Begin
Send Info_Box ("Files should not be opened as ReadOnly.") "Warning!"
End
Else Begin
Set pbWorkspaceMode to False
Send OnFileNameUpdate sFileName
Send LoadFile of (phoEditor(Self)) sFileName
Send Activate_oEditorView_vw of (Client_Id(phoMainPanel(Self)))
End
End
End_Procedure
/* Command Line Interface:
"/h" "/help" or "/?" - Show command line parameters help
Enables the ability to pass, on the command line;
- The path and name of a *.sws file
- And path to a source -folder or -filename
Command line samples:
/sws "C:\DataFlex 24.0 Examples\Order Entry\Order Entry.sws" /d AppSrc;AppHtml;DDSrc
/c "C:\DataFlex 24.0 Examples\DFRefactorCmdLineOE.ini"
This command line sample would tell the DFRefactor program to run automatically,
applying all previously selected refactoring functions and apply them to all source
files for the AppSrc, AppHtml and DDSrc folders, that matches the file extensions previously
setup in the DFRefactor program. Then exit the program when done.
Note: The program's UI will be visible while the program runs. However, no UI
interaction is needed while it is run. All actions as well as possible errors,
will be automatically registered, but not shown on screen.
*/
Procedure OnWorkspaceOpened
Handle hoCmdLine
String sSourceFile sSWSFile sChar sArgument sParamText sFolders sPath sCmdLineIniFile
Integer iWin10BetaSetting iNumArgs iCount
Boolean bShowParamHelp bDebugMode bBatch bConfigFile
String[] asFolders
// Test for serious Windows 10 "bug": "https://support.dataaccess.com/Forums/showthread.php?64797-Recent-Microsoft-Changes-to-Windows-10-May-Impact-Functionality-and-or-Data-Integrity"
Move (GetACP()) to iWin10BetaSetting
If (iWin10BetaSetting = 65001) Begin
Send Info_Box ("Windows 10 ouch! This workstation has its BETA option set to TRUE. This means that the normal codepage that DataFlex relies on does not work. This also means that some refactoring functions will fail. Program will now exit!")
Send vShellExecute "Open" "https://support.dataaccess.com/Forums/showthread.php?64797-Recent-Microsoft-Changes-to-Windows-10-May-Impact-Functionality-and-or-Data-Integrity" "" ""
Send Exit_Application
End
Set psStartupProgramPath to (psProgramPath(phoWorkspace(Self)))
Set psStartupBitmapPath to (psBitmapPath(phoWorkspace(Self)))
Get phoCommandLine to hoCmdLine
Get CountOfArgs of hoCmdLine to iNumArgs
For iCount from 1 to iNumArgs
Get Argument of hoCmdLine iCount to sArgument
Move (Left(sArgument, 1)) to sChar
If (sChar = "-") Begin
Move (Replace("-", sArgument, "/")) to sArgument
End
Move (Lowercase(sArgument)) to sArgument
Case Begin
Case (sArgument = CS_CmdLineDebug)
Move True to bDebugMode
Case Break
Case (sArgument = CS_CmdLineHelp1 or sArgument = CS_CmdLineHelp2 or sArgument = CS_CmdLineHelp3 or sArgument = CS_CmdLineHelp4)
Move True to bShowParamHelp
Case Break
Case (sArgument = CS_CmdLineSWSFile)
Get Argument of hoCmdLine (iCount + 1) to sSWSFile
Move (Trim(sSWSFile)) to sSWSFile
Case Break
Case (sArgument = CS_CmdLineFileName1 or sArgument = CS_CmdLineFileName2)
Get Argument of hoCmdLine (iCount + 1) to sSourceFile
Case Break
Case (sArgument = CS_CmdLineFolders1 or sArgument = CS_CmdLineFolders2 or sArgument = CS_CmdLineFolders3)
Get Argument of hoCmdLine (iCount + 1) to sFolders
Case Break
Case (sArgument = CS_CmdLineBatch1 or sArgument = CS_CmdLineBatch2)
Move True to bBatch
Case Break
Case (sArgument = CS_CmdConfigFile1 or sArgument = CS_CmdConfigFile2)
Get Argument of hoCmdLine (iCount +1) to sCmdLineIniFile
Get ParseFolderName sCmdLineIniFile to sPath
If (sPath = "") Begin
Get psHome of (phoWorkspace(ghoApplication)) to sPath
Get vFolderFormat sPath to sPath
Move (sPath + sCmdLineIniFile) to sCmdLineIniFile
End
Set psCmdLineIniFile to sCmdLineIniFile
Move True to bConfigFile
Move True to bBatch
Case Break
Case End
Loop
If (bShowParamHelp = True) Begin
Move "" to sParamText
Append sParamText "PARAMETER SYNTAX:"
Append sParamText "\n=============="
Append sParamText "\n\n/h or /help or /? - Displays *this* help text. Then exits the program."
Append sParamText "\n\n/debug - displays all passed parameters. Then exits the program."
Append sParamText " The /h takes precedence over the /debug flag."
Append sParamText "\nIf the /batch flag is omitted, the program will wait for the user to start the process."
Append sParamText "\n\nNote: Parameters and its value(s) must all be passed as a pair separated by a SPACE, when applicable."
Append sParamText "\nParameters can be passed in any order."
Append sParamText "\n\nPaths should be surrounded by single- or double-quotes('""')"
Append sParamText "\nOnly parameters that are necessary needs to be passed."
Append sParamText "\nUppercase/Lowercase doesn't matter when spelling flags."
Append sParamText "\nEach flag must be preceeded by a '/' (forward slash) or a '-' (dash) character."
Append sParamText "\n\nFLAGS AND SAMPLE USAGE:"
Append sParamText "\n========================"
Append sParamText "\n *.sws workspace file:"
Append sParamText '\n/sws "C:\Projects\DF20\My_Folder\MySWSFile.sws"'
Append sParamText "\nMandatory, if not the /c flag is used."
Append sParamText "\n\nSingle Source File:"
Append sParamText "\n/f or /file - A single file name with full path."
Append sParamText '\n/f "C:\Projects\DF20\My_Folder\AppSrc\MySourceFile.vw"'
Append sParamText "A Single Source File takes precedence over a *.sws workspace file."
Append sParamText "\n\nFolder Names Selections:"
Append sParamText "\n/d or /dirs or /folders - followed by a semi-comma separated list with folder names to be selected."
Append sParamText "\nThe semi-comma separated list with folders will be added to those previously saved for the workspace."
Append sParamText "\n/d AppSrc;DDSrc;AppHtml;Libraries (only together with the /sws param)"
Append sParamText "\n\nBatch mode - Automatically start and run a refactoring silently:"
Append sParamText "\nThe running program's UI will be shown on screen, but there will be no user interaction."
Append sParamText "\n/batch"
Append sParamText "\nIf omitted, program will start, display the passed parameters, but *will not* start automatically."
Append sParamText '\n\n/c or /config - Use an ini-file:'
Append sParamText "\n/c " CS_CmdIniFileName
Append sParamText "\nThat is the default ini-file name."
Append sParamText "\nThe default location is the Home folder. Else the full path and name must be specified."
Append sParamText "\nNote: If the /c or /config flag is used, it overrules the /batch flag, to always be true."
Append sParamText "\nTop Tip: On the 'Program Settings' dialog, there is an 'Export to ini-file' button, that exports current"
Append sParamText "\nworkpace settings to an ini-file of choice, so there is no need to create one from scratch."
Send Info_Box sParamText
Abort
End
If (bDebugMode = True) Begin
Move "Parameters passed on the command line:" to sParamText
Append sParamText "\n\nDebug mode:"
Append sParamText "\n/debug = TRUE"
Append sParamText "\n\n *.sws param and file:"
If (sSWSFile <> "") Begin
Append sParamText "\n/sws " sSWSFile
End
Else Begin
Append sParamText "\n/sws " "None specified"
End
Append sParamText "\n\nSingle Source File:"
If (sSourceFile <> "") Begin
Append sParamText "\n/f " sSourceFile
End
Else Begin
Append sParamText "\n/f " "None specified"
End
Append sParamText "\n\n Folder Names:"
If (sFolders <> "") Begin
Append sParamText "\n/f " sFolders
End
Else Begin
Append sParamText "\n/f " "None specified"
End
Append sParamText "\n\nBatch mode:"
Append sParamText "\n/batch = " (If(bBatch = True, "TRUE", "FALSE"))
Append sParamText "\nIf omitted, program will start, display the passed parameters, but *will not* start automatically."
Append sParamText "\n\nIni-file:"
If (sCmdLineIniFile <> "") Begin
Append sParamText "\n" sCmdLineIniFile
Append sParamText "\n/batch = TRUE"
End
Else Begin
Append sParamText "\n" "None specified"
End
Send Info_Box sParamText
Abort
End
// We need to send messages in this order:
If (sSWSFile <> "") Begin
If (bConfigFile = False) Begin
Set pbWorkspaceMode to True
Send UpdateWorkspaceSelectorDisplay sSWSFile
End
Else Begin
Send Stop_Box "You need to specify an .sws file on the command line! Program will now stop."
Abort
End
End
Else If (sSourceFile <> "") Begin
Set pbWorkspaceMode to False
Send OnFileNameUpdate sSourceFile
End
If (sFolders <> "") Begin
Move (StrSplitToArray(sFolders, ";")) to asFolders
Set pasCmdLineSetSelectedFolders to asFolders
End
If (bBatch = True) Begin
Set pbBatchMode to True
End
If (bConfigFile = True) Begin
Set pbBatchMode to True
Send ReadCmdLineIniFile sCmdLineIniFile
End
End_Procedure
// Helper message for: Command Line Interface:
Procedure ReadCmdLineIniFile String sCmdLineIniFile
Handle hoIni hoDD
String sSWSFile sUserName sFolder sFilters sFunction sFileName sText
String[] asFolders asFunctions
Boolean bFolders bExists
Integer iCount iSize
File_Exist sCmdLineIniFile bExists
If (bExists = False) Begin
Send Stop_Box ("The CmdLineIniFile can't be found:" * String(sCmdLineIniFile) + "\nThe program will now close.")
Abort
End
Get Create (RefClass(cIniFile)) to hoIni
Set psFileName of hoIni to sCmdLineIniFile
// SWS-File:
Get ReadString of hoIni CS_CmdIniSWSFileSection CS_CmdIniSWSFile (psSWSFile(Self)) to sSWSFile
If (sSWSFile <> "") Begin
Set pbWorkspaceMode to True
Send UpdateWorkspaceSelectorDisplay sSWSFile
End
Else Begin
Get psSWSFile to sFileName
If (sFileName = "") Begin
If (sCmdLineIniFile <> "")
Send Stop_Box ("The .sws file is missing from the ini-file and has not been specified on the command line. Cannot continue. Program will now close.")
Abort
End
End
// User Name:
Get ReadString of hoIni CS_CmdIniUserSection CS_CmdIniUserName "" to sUserName
If (sUserName <> "") Begin
Set psUsername to sUserName
End
// Folders:
Move 1000 to iSize // Just an arbitrarly large integer.
For iCount from 1 to iSize
Get ReadString of hoIni CS_CmdIniFoldersSection (CS_CmdIniFolderName + String(iCount)) "" to sFolder
If (sFolder = "") Begin
Move iSize to iCount
End
Else Begin
Move sFolder to asFolders[-1]
End
Loop
// Update Folders table selections
Set pasCmdLineSetSelectedFolders to asFolders
// Filters:
Get ReadString of hoIni CS_CmdIniFileFilterSection CS_CmdIniFileFilters "" to sFilters
If (sFilters <> "") Begin
Open SysFile
Move sFilters to SysFile.FileExtensionFilter
SaveRecord SysFile
End
// Functions:
For iCount from 1 to iSize
Get ReadString of hoIni CS_CmdIniFunctionSection (CS_CmdInitFunction + String(iCount)) "" to sFunction
If (sFunction = "") Begin
Move iSize to iCount
End
Else Begin
Move sFunction to asFunctions[-1]
End
Loop
// Update Functions table selections
Get Create (RefClass(cFunctionsDataDictionary)) to hoDD
Send UnSelectAllRecords of hoDD
Send SelectRecordsFromStringArray of hoDD asFunctions
Send Destroy of hoDD
Send Destroy of hoIni
End_Procedure
End_Object
// *** Include Main Refactoring Functions ***
// Object is of the cRefactorFuncLib class.
Use oRefactorFuncLib.pkg
// *** Create the Refactor Engine ***
Use cRefactorEngine.pkg
Get Create (RefClass(cRefactorEngine)) to ghoRefactorEngine
Set Name of ghoRefactorEngine to "oRefactorEngine"
Set pbBatchMode of ghoRefactorEngine to (pbBatchMode(ghoApplication))
Use cDbUpdateHandler.pkg
Object oDbUpdateHandler is a cDbUpdateHandler
Set piDbVersionFileNumber to 363 // DbVersion table
Set piDbVersionFieldNumber to 1
Set pbAutoCreateDbVersionTable to True
Set pbUseIntFilesBackup to True
Set piIntFilesFileNumber to 364
Set pbContinueOnError to True
Set pbEnableCancelButton to True
// Use DUF_MultipleTables1_0.pkg
// Use DUF_MultipleTables1_1.pkg
// Use DUF_MultipleTables1_2.pkg
// Use DUF_MultipleTables1_3.pkg
Use DUF_MultipleTables1_4.pkg
End_Object
Use SelectWorkspace.dg
If (pbBatchMode(ghoApplication) = False) Begin
Send Popup of oSelectWorkspace_dg
End
Use cRDCTooltipController.pkg
Object oToolTipController is a cRDCTooltipController
End_Object
Open SysFile
Open StatLog
Register_Object oSysfile_DD
Use cRDCCJSelectionGrid.pkg // Needed for Struct tFolderData
Use cSciLexer.h
Use oEditorProperties.pkg
Use oEditContextMenu.pkg
Use oDEOEditContextMenu.pkg
Object oMain is a Panel
Set Label to (psProduct(ghoApplication) * "- Refactor DataFlex Legacy Source Code")
Set Size to 310 550
Set piMinSize to 294 550
Set Icon to "DFRefactor.ico"
Object oCJCommandBarSystem is a cRDCCJCommandBarSystem
Object oWorkspace_Toolbar is a cCJToolbar
Set pbDockNextTo to False
Set peStretched to stStretchShared
Set pbCloseable to False
Set pbCustomizable to False
Object oWorkspaceSelectorText_Menuitem is a cCJMenuItem
Set psCaption to CS_SelectWorkspaceText
Set psToolTip to "Select Workspace"
Set psDescription to (CS_SelectWorkspaceFile * String("Alt+W"))
Set psImage to "ActionOpenWorkspace.ico"
Set peControlType to xtpControlCustom
Set peControlStyle to xtpButtonIconAndCaption
Procedure OnExecute Variant vCommandBarControl
Send Execute of (oWorkspaceOpen_Menuitem(ghoCommandBars))
End_Procedure
Procedure OnCreateControl Handle hoObj
Set ComDefaultItem of hoObj to True
End_Procedure
End_Object
Object oWorkspaceSelector_Menuitem is a cCJWorkspaceComboMenuItem
Set psToolTip to "Recent Workspaces"
Set psImage to "ActionOpenWorkspace.ico"
Set peControlType to xtpControlComboBox
Set phoWorkspaceSelector_Menuitem of ghoApplication to Self
Set phoWorkspaceSelectorText_MenuItem to (oWorkspaceSelectorText_Menuitem(ghoCommandBars))
Set phoClear_MenuItem to (oClear_MenuItem(ghoCommandBars))
End_Object
Object oWorkspaceOpen_Menuitem is a cCJMenuItem
Set psToolTip to "Open Workspace File"
Set psDescription to (CS_SelectWorkspaceFile * String("(Alt+W)"))
Set psShortcut to "Alt+W"
Set pbControlCloseSubMenu to False
Set pbControlFlagNoMovable to True
Set psImage to "ActionOpen.ico"
Set peControlStyle to xtpButtonIcon
Procedure OnExecute Variant vCommandBarControl
String sFileName
Get SelectWorkspaceFile of ghoApplication to sFileName
If (sFileName <> "") Begin
Send UpdateWorkspaceSelectorDisplay of ghoApplication sFileName
Send DisplayWorkspaceItem of (oWorkspaceSelector_Menuitem(ghoCommandBars)) sFileName
End
End_Procedure
End_Object
Object oRadioSelectorText_Menuitem is a cCJMenuItem
Set psCaption to "Mode:"
Set psToolTip to "Refactoring Mode"
Set psDescription to "Select if the refactoring should run on all source files that matches the 'File extensions' combo for selected workspace, or only on one selected file. (Toggle with Alt+F)"
Set pbControlBeginGroup to True
Set pbActiveUpdate to True
Set peControlStyle to xtpButtonIconAndCaption
Procedure OnExecute Variant vCommandBarControl
Forward Send OnExecute vCommandBarControl
Send Execute of oWorkspaceRadio_MenuItem
End_Procedure
Function IsEnabled Returns Boolean
String sSWSFile
Get psSWSFile of ghoApplication to sSWSFile
Function_Return (sSWSFile <> "")
End_Function
End_Object
Object oWorkspaceRadio_MenuItem is a cCJMenuItem
Set peControlType to xtpControlRadioButton
Set psCaption to "All Files"
Set psToolTip to "All files mode"
Set psDescription to "Select if the refactoring should run on all source files that matches the 'File Filter' combo for selected workspace. Toggles with (Alt+F)"
Set pbChecked to True
Set pbActiveUpdate to True
Procedure OnExecute Variant vCommandBarControl
Boolean bState
Get pbChecked to bState
Set pbChecked to (not(bState))
Set pbWorkspaceMode of ghoApplication to (not(bState))
End_Procedure
Function IsEnabled Returns Boolean
String sSWSFile
Get psSWSFile of ghoApplication to sSWSFile
Function_Return (sSWSFile <> "")
End_Function
Procedure OnCreateControl Handle hoObj
String sSWSFile
Get psSWSFile of ghoApplication to sSWSFile
Set pbChecked to (sSWSFile <> "")
Set ComDefaultItem of hoObj to True
End_Procedure
End_Object
Object oFileRadioMenuItem is a cCJMenuItem
Set peControlType to xtpControlRadioButton
Set psCaption to "Single &File"
Set psToolTip to "Mode"
Set psDescription to "Select if the refactoring should be run on one selected source file only (use the 'Open Source File:' to select) Toggles with (Alt+F)"
Set psShortcut to "Alt+F"
Set pbActiveUpdate to True
Procedure OnExecute Variant vCommandBarControl
Boolean bState
Get pbChecked to bState
Set pbChecked to (not(bState))
Set pbWorkspaceMode of ghoApplication to bState
End_Procedure
Function IsEnabled Returns Boolean
String sSWSFile
Get psSWSFile of ghoApplication to sSWSFile
Function_Return (sSWSFile <> "")
End_Function
Procedure OnCreateControl Handle hoObj
String sSWSFile sSourceFile
Forward Send OnCreateControl hoObj
Get psSWSFile of ghoApplication to sSWSFile
Get psCurrentSourceFileName of ghoApplication to sSourceFile
Set pbChecked to (sSWSFile <> "")
Set pbWorkspaceMode of ghoApplication to (sSourceFile = "")
Set ComDefaultItem of hoObj to True
End_Procedure
End_Object
End_Object
Object oSourceFile_Toolbar is a cCJToolbar
Set pbEnableDocking to False
Set pbCloseable to False
Set pbCustomizable to False
Set pbShowExpandButton to False
Set peStretched to stStretchShared
Object oOpenFolderMenuItem is a cCJMenuItem
Set psCaption to CS_BrowseSourceFileTxt
Set psToolTip to "Select source file"
Set psDescription to "Displays an Open File dialog to select a SINGLE source file from (Ctrl+O). This will automatically set the 'Refactoring Mode' to 'Single File'"
Set psImage to "ActionOpen.ico"
Set peControlStyle to xtpButtonIconAndCaption
Set pbActiveUpdate to True
Procedure OnExecute Variant vCommandBarControl
Forward Send OnExecute vCommandBarControl
Send SelectSourceFile of ghoApplication
End_Procedure
Function IsEnabled Returns Boolean
Boolean bState
Move False to bState
Get pbWorkspaceMode of ghoApplication to bState
Function_Return (bState = False)
End_Function
End_Object
Object oSourceFileText_MenuItem is a cCJMenuItem
Set peControlType to xtpControlCustom
Procedure OnExecute Variant vCommandBarControl
Forward Send OnExecute vCommandBarControl
Send Execute of oOpenFolderMenuItem
End_Procedure
End_Object
End_Object
Object oEditToolBar is a cCJToolbar
Set psTitle to "Edit Toolbar"
Set peStretched to stStretchShared
Set pbCloseable to False
Set pbCustomizable to False
Object oClear_MenuItem is a cCJMenuItem
Set pbControlBeginGroup to True
Set pbActiveUpdate to True
Set psCaption to "Clear"
Set psToolTip to "Clear Workspace/File"
Set psDescription to "Clears the currently selected workspace/or File depending on the selected mode"
Set psImage to "ActionClear.ico"
Set peControlStyle to xtpButtonIconAndCaption
Procedure OnExecute Variant vCommandBarControl
Boolean bChanged bMode
Integer iRetval
Handle hoEditor
Broadcast Recursive Get pbShouldSave of (Client_Id(phoMainPanel(ghoApplication))) to bChanged
If (bChanged = True) Begin
Get YesNo_Box ("Changes exists! If you answer 'Yes' your changes will be lost. Are you sure?") "" MB_DEFBUTTON2 to iRetval
If (iRetval <> MBR_Yes) Begin
Procedure_Return
End
End
Send UpdateWorkspaceSelectorDisplay of ghoApplication ""
Get phoEditor of ghoApplication to hoEditor
Send Request_Clear of hoEditor
Set pbWorkspaceMode of ghoApplication to True
Send Activate_oRefactorView of (Client_Id(ghoCommandBars))
Broadcast Recursive Send Request_Clear of (oRefactorView(Client_Id(ghoCommandBars)))
Send Request_Switch_To_Tab of (oMain_TabDialog(phoRefactorView(ghoApplication))) 0 1
End_Procedure
Function IsEnabled Returns Boolean
String sSWSFile
Get psSWSFile of ghoApplication to sSWSFile
Function_Return (sSWSFile <> "")
End_Function
End_Object
Object oSave_ToolItem is a cCJSaveMenuItem
Set peControlStyle to xtpButtonIcon
Set psCaption to "&Save"
Set psToolTip to "Save"
Set psDescription to "Save editor changes (Alt+S)"
Set psShortcut to "Alt+S"
Function IsEnabled Returns Boolean
Boolean bChanged
Move False to bChanged
If (oSysfile_DD(phoRefactorView(ghoApplication))) Begin
Get Should_Save of (oSysfile_DD(phoRefactorView(ghoApplication))) to bChanged
End
If (bChanged = False) Begin
Get pbShouldSave of (phoEditorView(ghoApplication)) to bChanged
End
If (bChanged = False) Begin
Get pbShouldSave of (phoRefactorView(ghoApplication)) to bChanged
End
Function_Return bChanged
End_Function
Procedure OnExecute Variant vCommandBarControl
Send Request_Save of (Focus(Self))
End_Procedure
End_Object
Object oDeleteEditToolbarItem is a cCJDeleteEditMenuItem
End_Object
Object oUndo_MenuItem is a cCJMenuItem
Set psToolTip to "Undo"
Set psDescription to "Undo last editor action (Ctrl+Z)"
Set psImage to "ActionUndo.ico"
Set pbActiveUpdate to True
Set pbControlBeginGroup to True
Procedure OnExecute Variant vCommandBarControl
Send CME_UndoAction of (Focus(Desktop))
End_Procedure
Function IsEnabled Returns Boolean
Boolean bCanUndo
Get Can_UndoAction of (Focus(Desktop)) to bCanUndo
Function_Return bCanUndo
End_Function
End_Object
Object oRedo_MenuItem is a cCJMenuItem
Set psToolTip to "Redo"
Set psDescription to "Redo last editor action (Ctrl+Z)"
Set psImage to "ActionRedo.ico"
Set pbActiveUpdate to True
Procedure OnExecute Variant vCommandBarControl
Send CME_RedoAction of (Focus(Desktop))
End_Procedure
Function IsEnabled Returns Boolean
Boolean bCanRedo
Get Can_RedoAction of (Focus(Desktop)) to bCanRedo
Function_Return bCanRedo
End_Function
End_Object
Object oCutToolbarItem is a cCJCutMenuItem
Set pbControlBeginGroup to True
End_Object
Object oCopyToolbarItem is a cCJCopyMenuItem
End_Object
Object oPasteToolbarItem is a cCJPasteMenuItem
End_Object
End_Object
Object oActions_Toolbar is a cCJToolbar
Set psTitle to "Action Toolbar"
Set peStretched to stStretchShared
Set pbCloseable to False
Set pbCustomizable to False
Set pbDockNextTo to False
Object oRefactor_ToolItem is a cCJMenuItem
Set pbControlBeginGroup to True
Set pbActiveUpdate to True
Set peControlStyle to xtpButtonIconAndCaption
Set psCaption to "Start &Refactoring"
Set psToolTip to "Refactor code with the selected functions and Mode: All Files/One File (Ctrl+F5)"
Set psDescription to "Refactor Code (Ctrl+F5)"
Set psImage to "Start.ico"
Set psShortcut to "Ctrl+F5"
Set pbActiveUpdate to True
Procedure OnExecute Variant vCommandBarControl
Send RefactoreCode of (phoRefactorView(ghoApplication))
End_Procedure
Function IsEnabled Returns Boolean
Boolean bEnabled bWorkspaceMode
String sFileName sSWSFile sHomePath
Integer iSelectedFunctions iFolders
Handle hoFolderSelHeaDD
Boolean bExists bUseDDO
tFolderData[] asSavedFolders
Get pbWorkspaceMode of ghoApplication to bWorkspaceMode
Get psSWSFile of ghoApplication to sSWSFile
Get psCurrentSourceFileName of ghoApplication to sFileName
If (bWorkspaceMode = True) Begin
Move (sSWSFile <> "") to bEnabled
End
Else Begin
Move (sFileName <> "") to bEnabled
End
If (bEnabled = True) Begin
Move (SysFile.SelectedFunctionTotal > 0) to bEnabled
End
If (bEnabled = True and bWorkspaceMode = True) Begin
Get TotalSelectedFolders of (phoFolderSelHeaDD(ghoApplication)) to iFolders
Move (iFolders <> 0) to bEnabled
End
If (bEnabled = False) Begin
Move SysFile.bCountSourceLines to bEnabled
End
Function_Return bEnabled
End_Function
Procedure OnCreateControl Handle hoObj
Set ComDefaultItem of hoObj to True
End_Procedure
End_Object
Object oCompare_MenuItem is a cCJMenuItem
Set psCaption to "Co&mpare"
Set psToolTip to "Compare"
Set psDescription to "Compare file changes after running refactoring function(s) (Alt+M)"
Set psImage to "Compare.ico"
Set peControlStyle to xtpButtonIconAndCaption
Set pbActiveUpdate to True
Set pbControlBeginGroup to True
Procedure OnExecute Variant vCommandBarControl
String sCompareApp
Boolean bWorkspaceMode
Forward Send OnExecute vCommandBarControl
Get psFileCompareApp of ghoApplication to sCompareApp
Get pbWorkspaceMode of ghoApplication to bWorkspaceMode
If (bWorkspaceMode = True) Begin
Send ComparePaths of ghoApplication sCompareApp
End
Else Begin
Send CompareFiles of ghoApplication sCompareApp
End
End_Procedure
Function IsEnabled Returns Boolean
Boolean bOK
tsSearchResult[] BackpupFileArray
Move False to bOK
Get AllBackupFolderFiles of ghoApplication to BackpupFileArray
Move (SizeOfArray(BackpupFileArray) <> 0) to bOK
Function_Return bOK
End_Function
End_Object
Object oOpenLogFile_MenuItem is a cCJMenuItem
Set psToolTip to "View log file"
Set psDescription to "View the logfile that is added to for each run (Alt+L)"
Set psImage to "OpenLogFile.ico"
Set peControlStyle to xtpButtonIcon
Set pbControlBeginGroup to True
Set pbActiveUpdate to True
Procedure OnExecute Variant vCommandBarControl
Send ShowLogFile of ghoApplication
End_Procedure
Function IsEnabled Returns Boolean
String sPath sLogFile
Boolean bLogFileExists
Get psHomePath of ghoApplication to sPath
Get vFolderFormat sPath to sPath
Move (sPath + CS_BackupFolder + CS_DirSeparator + CS_SummaryLogfileName) to sLogFile
Get vFilePathExists sLogFile to bLogFileExists
Function_Return (bLogFileExists = True)
End_Function
End_Object
Object oOpenOtherLogFile_MenuItem is a cCJMenuItem
Set psToolTip to "Other log files"
Set psDescription to "View a list of log files created by functions of type: 'eOther_Function"
Set psImage to "OtherLogFiles.ico"
Set peControlStyle to xtpButtonIcon
Set pbActiveUpdate to True
Procedure OnExecute Variant vCommandBarControl
Send ShowOtherLogFiles of ghoApplication
End_Procedure
Function IsEnabled Returns Boolean
String[] asOtherLogFiles
// Get pasOtherLogFiles of ghoRefactorFuncLib to asOtherLogFiles
Get OtherLogFiles of ghoApplication to asOtherLogFiles
Function_Return (SizeOfArray(asOtherLogFiles) > 0)
End_Function
End_Object