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