1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
2 | unit fTemplateAutoGen;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
8 | StdCtrls, ORCtrls, ExtCtrls, ORFn, DKLang;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TfrmTemplateAutoGen = class(TForm)
|
---|
12 | rgSource: TKeyClickRadioGroup;
|
---|
13 | cbxObjects: TORComboBox;
|
---|
14 | btnOK: TButton;
|
---|
15 | btnCancel: TButton;
|
---|
16 | lblTop: TMemo;
|
---|
17 | cbxTitles: TORComboBox;
|
---|
18 | lblSelect: TStaticText;
|
---|
19 | DKLanguageController1: TDKLanguageController;
|
---|
20 | procedure rgSourceClick(Sender: TObject);
|
---|
21 | procedure cbxTitlesNeedData(Sender: TObject; const StartFrom: String;
|
---|
22 | Direction, InsertAt: Integer);
|
---|
23 | procedure cbxTitlesDblClick(Sender: TObject);
|
---|
24 | procedure cbxObjectsDblClick(Sender: TObject);
|
---|
25 | procedure FormShow(Sender: TObject);
|
---|
26 | private
|
---|
27 | FTitlesDone: boolean;
|
---|
28 | FObjectsDone: boolean;
|
---|
29 | public
|
---|
30 | { Public declarations }
|
---|
31 | end;
|
---|
32 |
|
---|
33 | procedure GetAutoGenText(var AName, AText: string; InList: TStringList);
|
---|
34 |
|
---|
35 | implementation
|
---|
36 |
|
---|
37 | uses dShared, rTemplates, uTemplates;
|
---|
38 |
|
---|
39 | {$R *.DFM}
|
---|
40 |
|
---|
41 | var
|
---|
42 | PersObjects: TStringList;
|
---|
43 |
|
---|
44 | const
|
---|
45 | idxTitle = 0;
|
---|
46 | idxObject = 1;
|
---|
47 |
|
---|
48 | procedure GetAutoGenText(var AName, AText: string; InList: TStringList);
|
---|
49 | var
|
---|
50 | frmTemplateAutoGen: TfrmTemplateAutoGen;
|
---|
51 |
|
---|
52 | begin
|
---|
53 | AName := '';
|
---|
54 | AText := '';
|
---|
55 | PersObjects := InList;
|
---|
56 | frmTemplateAutoGen := TfrmTemplateAutoGen.Create(Application);
|
---|
57 | try
|
---|
58 | ResizeAnchoredFormToFont(frmTemplateAutoGen);
|
---|
59 | with frmTemplateAutoGen do
|
---|
60 | begin
|
---|
61 | ShowModal;
|
---|
62 | if(ModalResult = mrOK) then
|
---|
63 | begin
|
---|
64 | if(rgSource.ItemIndex = idxTitle) then
|
---|
65 | begin
|
---|
66 | if(cbxTitles.ItemID <> '') then
|
---|
67 | begin
|
---|
68 | AName := MixedCase(cbxTitles.DisplayText[cbxTitles.ItemIndex]);
|
---|
69 | AText := GetTitleBoilerplate(cbxTitles.ItemID);
|
---|
70 | end;
|
---|
71 | end
|
---|
72 | else
|
---|
73 | if(rgSource.ItemIndex = idxObject) then
|
---|
74 | begin
|
---|
75 | if(cbxObjects.Text <> '') then
|
---|
76 | begin
|
---|
77 | AName := cbxObjects.Text;
|
---|
78 | AText := '|'+Piece(cbxObjects.Items[cbxObjects.ItemIndex],U,3)+'|'
|
---|
79 | end;
|
---|
80 | end;
|
---|
81 | end;
|
---|
82 | end;
|
---|
83 | finally
|
---|
84 | frmTemplateAutoGen.Free;
|
---|
85 | end;
|
---|
86 | end;
|
---|
87 |
|
---|
88 | procedure TfrmTemplateAutoGen.rgSourceClick(Sender: TObject);
|
---|
89 | var
|
---|
90 | idx,i: integer;
|
---|
91 | DoIt: boolean;
|
---|
92 |
|
---|
93 | begin
|
---|
94 | idx := rgSource.ItemIndex;
|
---|
95 | rgSource.TabStop := (idx < 0);
|
---|
96 | if(idx < 0) then exit;
|
---|
97 | if(idx = idxTitle) then
|
---|
98 | begin
|
---|
99 | cbxTitles.Visible := TRUE;
|
---|
100 | cbxObjects.Visible := FALSE;
|
---|
101 | if(not FTitlesDone) then
|
---|
102 | begin
|
---|
103 | cbxTitles.InitLongList('');
|
---|
104 | FTitlesDone := TRUE
|
---|
105 | end;
|
---|
106 | cbxTitles.SetFocus;
|
---|
107 | end
|
---|
108 | else
|
---|
109 | if(idx = idxObject) then
|
---|
110 | begin
|
---|
111 | cbxObjects.Visible := TRUE;
|
---|
112 | cbxTitles.Visible := FALSE;
|
---|
113 | if(not FObjectsDone) then
|
---|
114 | begin
|
---|
115 | DoIt := TRUE; //10/31/01 S Monson-- Added
|
---|
116 | if (UserTemplateAccessLevel <> taEditor) then //UserTemplateAccessLevel check and
|
---|
117 | if PersObjects.Count > 0 then //PersObjects modification of the list
|
---|
118 | begin //in response to NOIS HUN-0701-22052
|
---|
119 | DoIt := FALSE;
|
---|
120 | for i := 0 to dmodShared.TIUObjects.Count-1 do
|
---|
121 | if PersObjects.IndexOf(Piece(dmodShared.TIUObjects[i],U,2)) >= 0 then
|
---|
122 | cbxObjects.Items.Add(dmodShared.TIUObjects[i]);
|
---|
123 | end;
|
---|
124 | if DoIt then
|
---|
125 | cbxObjects.Items.Assign(dmodShared.TIUObjects);
|
---|
126 | FObjectsDone := TRUE;
|
---|
127 | end;
|
---|
128 | cbxObjects.SetFocus;
|
---|
129 | end;
|
---|
130 | end;
|
---|
131 |
|
---|
132 | procedure TfrmTemplateAutoGen.cbxTitlesNeedData(Sender: TObject;
|
---|
133 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
134 | begin
|
---|
135 | cbxTitles.ForDataUse(SubSetOfBoilerplatedTitles(StartFrom, Direction));
|
---|
136 | end;
|
---|
137 |
|
---|
138 | procedure TfrmTemplateAutoGen.cbxTitlesDblClick(Sender: TObject);
|
---|
139 | begin
|
---|
140 | if(cbxTitles.ItemIndex >= 0) then
|
---|
141 | ModalResult := mrOK;
|
---|
142 | end;
|
---|
143 |
|
---|
144 | procedure TfrmTemplateAutoGen.cbxObjectsDblClick(Sender: TObject);
|
---|
145 | begin
|
---|
146 | if(cbxObjects.ItemIndex >= 0) then
|
---|
147 | ModalResult := mrOK;
|
---|
148 | end;
|
---|
149 |
|
---|
150 | procedure TfrmTemplateAutoGen.FormShow(Sender: TObject);
|
---|
151 | begin
|
---|
152 | //pre-select the first radio item
|
---|
153 | rgSource.ItemIndex := 0;
|
---|
154 | end;
|
---|
155 |
|
---|
156 | end.
|
---|