1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
2 | unit fTemplateEditor;
|
---|
3 | {The OwnerScan conditional compile varaible was created because there were too
|
---|
4 | many things that needed to be done to incorporate the viewing of other user's
|
---|
5 | personal templates by clinical coordinators. These include:
|
---|
6 | Changing the Personal tree.
|
---|
7 | expanding entirely new personal list when personal list changes
|
---|
8 | when click on stop editing shared button, and personal is for someone else,
|
---|
9 | need to resync to personal list.
|
---|
10 |
|
---|
11 | HOT HEYS NOT YET ASSIGNED:
|
---|
12 | JFKQRUVZ
|
---|
13 | }
|
---|
14 | {$DEFINE OwnerScan}
|
---|
15 | {$UNDEF OwnerScan}
|
---|
16 | interface
|
---|
17 |
|
---|
18 | uses
|
---|
19 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
20 | ExtCtrls, StdCtrls, ComCtrls, ORCtrls, Buttons, Mask, ORFn, ORNet,
|
---|
21 | uTemplates, Menus, ImgList, Clipbrd, ToolWin, MenuBar, TypInfo, MSXML_TLB,
|
---|
22 | DKLang;
|
---|
23 |
|
---|
24 | type
|
---|
25 | TTemplateTreeControl = (tcDel, tcUp, tcDown, tcLbl, tcCopy);
|
---|
26 | TTemplateTreeType = (ttShared, ttPersonal);
|
---|
27 |
|
---|
28 | TfrmTemplateEditor = class(TForm)
|
---|
29 | splMain: TSplitter;
|
---|
30 | pnlBottom: TORAutoPanel;
|
---|
31 | btnApply: TButton;
|
---|
32 | btnCancel: TButton;
|
---|
33 | btnOK: TButton;
|
---|
34 | pnlBoilerplate: TPanel;
|
---|
35 | reBoil: TRichEdit;
|
---|
36 | pnlTop: TPanel;
|
---|
37 | pnlRightTop: TPanel;
|
---|
38 | splProperties: TSplitter;
|
---|
39 | pnlCopyBtns: TPanel;
|
---|
40 | sbCopyLeft: TBitBtn;
|
---|
41 | sbCopyRight: TBitBtn;
|
---|
42 | lblCopy: TLabel;
|
---|
43 | splMiddle: TSplitter;
|
---|
44 | pnlShared: TPanel;
|
---|
45 | lblShared: TLabel;
|
---|
46 | tvShared: TORTreeView;
|
---|
47 | pnlSharedBottom: TPanel;
|
---|
48 | sbShUp: TBitBtn;
|
---|
49 | sbShDown: TBitBtn;
|
---|
50 | sbShDelete: TBitBtn;
|
---|
51 | cbShHide: TCheckBox;
|
---|
52 | pnlSharedGap: TPanel;
|
---|
53 | pnlPersonal: TPanel;
|
---|
54 | lblPersonal: TLabel;
|
---|
55 | tvPersonal: TORTreeView;
|
---|
56 | pnlPersonalBottom: TPanel;
|
---|
57 | sbPerUp: TBitBtn;
|
---|
58 | sbPerDown: TBitBtn;
|
---|
59 | sbPerDelete: TBitBtn;
|
---|
60 | cbPerHide: TCheckBox;
|
---|
61 | pnlPersonalGap: TPanel;
|
---|
62 | popTemplates: TPopupMenu;
|
---|
63 | mnuCollapseTree: TMenuItem;
|
---|
64 | mnuFindTemplates: TMenuItem;
|
---|
65 | popBoilerplate: TPopupMenu;
|
---|
66 | mnuBPInsertObject: TMenuItem;
|
---|
67 | mnuBPErrorCheck: TMenuItem;
|
---|
68 | mnuBPSpellCheck: TMenuItem;
|
---|
69 | pnlGroupBP: TPanel;
|
---|
70 | reGroupBP: TRichEdit;
|
---|
71 | lblGroupBP: TLabel;
|
---|
72 | splBoil: TSplitter;
|
---|
73 | pnlGroupBPGap: TPanel;
|
---|
74 | tmrAutoScroll: TTimer;
|
---|
75 | popGroup: TPopupMenu;
|
---|
76 | mnuGroupBPCopy: TMenuItem;
|
---|
77 | mnuBPCut: TMenuItem;
|
---|
78 | N2: TMenuItem;
|
---|
79 | mnuBPCopy: TMenuItem;
|
---|
80 | mnuBPPaste: TMenuItem;
|
---|
81 | N4: TMenuItem;
|
---|
82 | mnuGroupBPSelectAll: TMenuItem;
|
---|
83 | mnuBPSelectAll: TMenuItem;
|
---|
84 | N6: TMenuItem;
|
---|
85 | mnuNodeCopy: TMenuItem;
|
---|
86 | mnuNodePaste: TMenuItem;
|
---|
87 | mnuNodeDelete: TMenuItem;
|
---|
88 | N8: TMenuItem;
|
---|
89 | mnuBPUndo: TMenuItem;
|
---|
90 | cbEditShared: TCheckBox;
|
---|
91 | pnlProperties: TPanel;
|
---|
92 | gbProperties: TGroupBox;
|
---|
93 | lblName: TLabel;
|
---|
94 | lblLines: TLabel;
|
---|
95 | cbExclude: TORCheckBox;
|
---|
96 | cbActive: TCheckBox;
|
---|
97 | edtGap: TCaptionEdit;
|
---|
98 | udGap: TUpDown;
|
---|
99 | edtName: TCaptionEdit;
|
---|
100 | mnuMain: TMainMenu;
|
---|
101 | mnuEdit: TMenuItem;
|
---|
102 | mnuUndo: TMenuItem;
|
---|
103 | N9: TMenuItem;
|
---|
104 | mnuCut: TMenuItem;
|
---|
105 | mnuCopy: TMenuItem;
|
---|
106 | mnuPaste: TMenuItem;
|
---|
107 | mnuSelectAll: TMenuItem;
|
---|
108 | N11: TMenuItem;
|
---|
109 | mnuInsertObject: TMenuItem;
|
---|
110 | mnuErrorCheck: TMenuItem;
|
---|
111 | mnuSpellCheck: TMenuItem;
|
---|
112 | N13: TMenuItem;
|
---|
113 | mnuGroupBoilerplate: TMenuItem;
|
---|
114 | mnuGroupCopy: TMenuItem;
|
---|
115 | mnuGroupSelectAll: TMenuItem;
|
---|
116 | mnuTemplate: TMenuItem;
|
---|
117 | mnuTCopy: TMenuItem;
|
---|
118 | mnuTPaste: TMenuItem;
|
---|
119 | mnuTDelete: TMenuItem;
|
---|
120 | N12: TMenuItem;
|
---|
121 | pnlShSearch: TPanel;
|
---|
122 | btnShFind: TORAlignButton;
|
---|
123 | edtShSearch: TCaptionEdit;
|
---|
124 | cbShMatchCase: TCheckBox;
|
---|
125 | cbShWholeWords: TCheckBox;
|
---|
126 | pnlPerSearch: TPanel;
|
---|
127 | btnPerFind: TORAlignButton;
|
---|
128 | edtPerSearch: TCaptionEdit;
|
---|
129 | cbPerMatchCase: TCheckBox;
|
---|
130 | cbPerWholeWords: TCheckBox;
|
---|
131 | mnuFindShared: TMenuItem;
|
---|
132 | mnuFindPersonal: TMenuItem;
|
---|
133 | N3: TMenuItem;
|
---|
134 | mnuShCollapse: TMenuItem;
|
---|
135 | mnuPerCollapse: TMenuItem;
|
---|
136 | pnlMenuBar: TPanel;
|
---|
137 | lblPerOwner: TLabel;
|
---|
138 | cboOwner: TORComboBox;
|
---|
139 | btnNew: TORAlignButton;
|
---|
140 | pnlMenu: TPanel;
|
---|
141 | mbMain: TMenuBar;
|
---|
142 | mnuNewTemplate: TMenuItem;
|
---|
143 | Bevel1: TBevel;
|
---|
144 | mnuNodeNew: TMenuItem;
|
---|
145 | mnuBPCheckGrammar: TMenuItem;
|
---|
146 | mnuCheckGrammar: TMenuItem;
|
---|
147 | N1: TMenuItem;
|
---|
148 | N7: TMenuItem;
|
---|
149 | N14: TMenuItem;
|
---|
150 | mnuSort: TMenuItem;
|
---|
151 | N15: TMenuItem;
|
---|
152 | mnuNodeSort: TMenuItem;
|
---|
153 | mnuTry: TMenuItem;
|
---|
154 | mnuBPTry: TMenuItem;
|
---|
155 | mnuAutoGen: TMenuItem;
|
---|
156 | mnuNodeAutoGen: TMenuItem;
|
---|
157 | pnlNotes: TPanel;
|
---|
158 | reNotes: TRichEdit;
|
---|
159 | splNotes: TSplitter;
|
---|
160 | lblNotes: TLabel;
|
---|
161 | popNotes: TPopupMenu;
|
---|
162 | mnuNotesUndo: TMenuItem;
|
---|
163 | MenuItem2: TMenuItem;
|
---|
164 | mnuNotesCut: TMenuItem;
|
---|
165 | mnuNotesCopy: TMenuItem;
|
---|
166 | mnuNotesPaste: TMenuItem;
|
---|
167 | MenuItem6: TMenuItem;
|
---|
168 | mnuNotesSelectAll: TMenuItem;
|
---|
169 | MenuItem8: TMenuItem;
|
---|
170 | mnuNotesGrammar: TMenuItem;
|
---|
171 | mnuNotesSpelling: TMenuItem;
|
---|
172 | cbNotes: TCheckBox;
|
---|
173 | gbDialogProps: TGroupBox;
|
---|
174 | cbDisplayOnly: TCheckBox;
|
---|
175 | cbOneItemOnly: TCheckBox;
|
---|
176 | cbHideItems: TORCheckBox;
|
---|
177 | cbFirstLine: TCheckBox;
|
---|
178 | cbHideDlgItems: TCheckBox;
|
---|
179 | cbIndent: TCheckBox;
|
---|
180 | mnuTools: TMenuItem;
|
---|
181 | mnuEditTemplateFields: TMenuItem;
|
---|
182 | N16: TMenuItem;
|
---|
183 | mnuImportTemplate: TMenuItem;
|
---|
184 | mnuExportTemplate: TMenuItem;
|
---|
185 | mnuBPInsertField: TMenuItem;
|
---|
186 | mnuInsertField: TMenuItem;
|
---|
187 | cbEditUser: TCheckBox;
|
---|
188 | dlgImport: TOpenDialog;
|
---|
189 | dlgExport: TSaveDialog;
|
---|
190 | cbxType: TCaptionComboBox;
|
---|
191 | lblType: TLabel;
|
---|
192 | cbxRemDlgs: TORComboBox;
|
---|
193 | lblRemDlg: TLabel;
|
---|
194 | N17: TMenuItem;
|
---|
195 | mnuTemplateIconLegend: TMenuItem;
|
---|
196 | pnlBP: TPanel;
|
---|
197 | lblBoilerplate: TLabel;
|
---|
198 | cbLongLines: TCheckBox;
|
---|
199 | cbLock: TORCheckBox;
|
---|
200 | mnuRefresh: TMenuItem;
|
---|
201 | lblBoilRow: TLabel;
|
---|
202 | lblGroupRow: TLabel;
|
---|
203 | lblBoilCol: TLabel;
|
---|
204 | lblGroupCol: TLabel;
|
---|
205 | pnlCOM: TPanel;
|
---|
206 | lblCOMParam: TLabel;
|
---|
207 | edtCOMParam: TCaptionEdit;
|
---|
208 | cbxCOMObj: TORComboBox;
|
---|
209 | lblCOMObj: TLabel;
|
---|
210 | pnlLink: TPanel;
|
---|
211 | cbxLink: TORComboBox;
|
---|
212 | lblLink: TLabel;
|
---|
213 | DKLanguageController1: TDKLanguageController;
|
---|
214 | procedure btnNewClick(Sender: TObject);
|
---|
215 | procedure btnApplyClick(Sender: TObject);
|
---|
216 | procedure FormCreate(Sender: TObject);
|
---|
217 | procedure cboOwnerNeedData(Sender: TObject; const StartFrom: String;
|
---|
218 | Direction, InsertAt: Integer);
|
---|
219 | procedure cboOwnerChange(Sender: TObject);
|
---|
220 | procedure tvPersonalExpanding(Sender: TObject; Node: TTreeNode;
|
---|
221 | var AllowExpansion: Boolean);
|
---|
222 | procedure tvSharedExpanding(Sender: TObject; Node: TTreeNode;
|
---|
223 | var AllowExpansion: Boolean);
|
---|
224 | procedure tvTreeGetImageIndex(Sender: TObject; Node: TTreeNode);
|
---|
225 | procedure tvTreeGetSelectedIndex(Sender: TObject; Node: TTreeNode);
|
---|
226 | procedure tvTreeChange(Sender: TObject; Node: TTreeNode);
|
---|
227 | procedure splMainMoved(Sender: TObject);
|
---|
228 | procedure pnlBoilerplateResize(Sender: TObject);
|
---|
229 | procedure edtNameOldChange(Sender: TObject);
|
---|
230 | procedure cbActiveClick(Sender: TObject);
|
---|
231 | procedure cbExcludeClick(Sender: TObject);
|
---|
232 | procedure edtGapChange(Sender: TObject);
|
---|
233 | procedure tvTreeEnter(Sender: TObject);
|
---|
234 | procedure tvTreeNodeEdited(Sender: TObject; Node: TTreeNode;
|
---|
235 | var S: String);
|
---|
236 | procedure cbShHideClick(Sender: TObject);
|
---|
237 | procedure cbPerHideClick(Sender: TObject);
|
---|
238 | procedure FormDestroy(Sender: TObject);
|
---|
239 | procedure sbMoveUpClick(Sender: TObject);
|
---|
240 | procedure sbMoveDownClick(Sender: TObject);
|
---|
241 | procedure sbDeleteClick(Sender: TObject);
|
---|
242 | procedure tvTreeDragging(Sender: TObject; Node: TTreeNode;
|
---|
243 | var CanDrag: Boolean);
|
---|
244 | procedure tvTreeDragOver(Sender, Source: TObject; X, Y: Integer;
|
---|
245 | State: TDragState; var Accept: Boolean);
|
---|
246 | procedure tvTreeDragDrop(Sender, Source: TObject; X, Y: Integer);
|
---|
247 | procedure sbCopyLeftClick(Sender: TObject);
|
---|
248 | procedure sbCopyRightClick(Sender: TObject);
|
---|
249 | procedure reBoilChange(Sender: TObject);
|
---|
250 | procedure cbEditSharedClick(Sender: TObject);
|
---|
251 | procedure popTemplatesPopup(Sender: TObject);
|
---|
252 | procedure mnuCollapseTreeClick(Sender: TObject);
|
---|
253 | procedure mnuFindTemplatesClick(Sender: TObject);
|
---|
254 | procedure btnFindClick(Sender: TObject);
|
---|
255 | procedure edtSearchChange(Sender: TObject);
|
---|
256 | procedure edtShSearchEnter(Sender: TObject);
|
---|
257 | procedure edtShSearchExit(Sender: TObject);
|
---|
258 | procedure edtPerSearchEnter(Sender: TObject);
|
---|
259 | procedure edtPerSearchExit(Sender: TObject);
|
---|
260 | procedure btnOKClick(Sender: TObject);
|
---|
261 | procedure FormShow(Sender: TObject);
|
---|
262 | procedure mnuBPInsertObjectClick(Sender: TObject);
|
---|
263 | procedure mnuBPErrorCheckClick(Sender: TObject);
|
---|
264 | procedure popBoilerplatePopup(Sender: TObject);
|
---|
265 | procedure btnCancelClick(Sender: TObject);
|
---|
266 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
---|
267 | procedure mnuBPSpellCheckClick(Sender: TObject);
|
---|
268 | procedure splBoilMoved(Sender: TObject);
|
---|
269 | procedure edtGapKeyPress(Sender: TObject; var Key: Char);
|
---|
270 | procedure edtNameExit(Sender: TObject);
|
---|
271 | procedure tmrAutoScrollTimer(Sender: TObject);
|
---|
272 | procedure tvTreeStartDrag(Sender: TObject;
|
---|
273 | var DragObject: TDragObject);
|
---|
274 | procedure tvTreeEndDrag(Sender, Target: TObject; X, Y: Integer);
|
---|
275 | procedure mnuGroupBPCopyClick(Sender: TObject);
|
---|
276 | procedure popGroupPopup(Sender: TObject);
|
---|
277 | procedure mnuBPCutClick(Sender: TObject);
|
---|
278 | procedure mnuBPCopyClick(Sender: TObject);
|
---|
279 | procedure mnuBPPasteClick(Sender: TObject);
|
---|
280 | procedure mnuGroupBPSelectAllClick(Sender: TObject);
|
---|
281 | procedure mnuBPSelectAllClick(Sender: TObject);
|
---|
282 | procedure mnuNodeDeleteClick(Sender: TObject);
|
---|
283 | procedure mnuNodeCopyClick(Sender: TObject);
|
---|
284 | procedure mnuNodePasteClick(Sender: TObject);
|
---|
285 | procedure mnuBPUndoClick(Sender: TObject);
|
---|
286 | procedure tvTreeKeyDown(Sender: TObject; var Key: Word;
|
---|
287 | Shift: TShiftState);
|
---|
288 | procedure mnuEditClick(Sender: TObject);
|
---|
289 | procedure mnuGroupBoilerplateClick(Sender: TObject);
|
---|
290 | procedure cbShFindOptionClick(Sender: TObject);
|
---|
291 | procedure cbPerFindOptionClick(Sender: TObject);
|
---|
292 | procedure mnuTemplateClick(Sender: TObject);
|
---|
293 | procedure mnuFindSharedClick(Sender: TObject);
|
---|
294 | procedure mnuFindPersonalClick(Sender: TObject);
|
---|
295 | procedure mnuShCollapseClick(Sender: TObject);
|
---|
296 | procedure mnuPerCollapseClick(Sender: TObject);
|
---|
297 | procedure pnlShSearchResize(Sender: TObject);
|
---|
298 | procedure pnlPerSearchResize(Sender: TObject);
|
---|
299 | procedure pnlPropertiesResize(Sender: TObject);
|
---|
300 | procedure mbMainResize(Sender: TObject);
|
---|
301 | procedure mnuBPCheckGrammarClick(Sender: TObject);
|
---|
302 | procedure mnuSortClick(Sender: TObject);
|
---|
303 | procedure pnlBoilerplateCanResize(Sender: TObject; var NewWidth,
|
---|
304 | NewHeight: Integer; var Resize: Boolean);
|
---|
305 | procedure mnuBPTryClick(Sender: TObject);
|
---|
306 | procedure mnuAutoGenClick(Sender: TObject);
|
---|
307 | procedure reNotesChange(Sender: TObject);
|
---|
308 | procedure mnuNotesUndoClick(Sender: TObject);
|
---|
309 | procedure mnuNotesCutClick(Sender: TObject);
|
---|
310 | procedure mnuNotesCopyClick(Sender: TObject);
|
---|
311 | procedure mnuNotesPasteClick(Sender: TObject);
|
---|
312 | procedure mnuNotesSelectAllClick(Sender: TObject);
|
---|
313 | procedure mnuNotesGrammarClick(Sender: TObject);
|
---|
314 | procedure mnuNotesSpellingClick(Sender: TObject);
|
---|
315 | procedure popNotesPopup(Sender: TObject);
|
---|
316 | procedure cbNotesClick(Sender: TObject);
|
---|
317 | procedure cbDisplayOnlyClick(Sender: TObject);
|
---|
318 | procedure cbFirstLineClick(Sender: TObject);
|
---|
319 | procedure cbOneItemOnlyClick(Sender: TObject);
|
---|
320 | procedure cbHideDlgItemsClick(Sender: TObject);
|
---|
321 | procedure cbHideItemsClick(Sender: TObject);
|
---|
322 | procedure cbIndentClick(Sender: TObject);
|
---|
323 | procedure mnuToolsClick(Sender: TObject);
|
---|
324 | procedure mnuEditTemplateFieldsClick(Sender: TObject);
|
---|
325 | procedure mnuBPInsertFieldClick(Sender: TObject);
|
---|
326 | procedure mnuExportTemplateClick(Sender: TObject);
|
---|
327 | procedure mnuImportTemplateClick(Sender: TObject);
|
---|
328 | procedure cbxTypeDrawItem(Control: TWinControl; Index: Integer;
|
---|
329 | Rect: TRect; State: TOwnerDrawState);
|
---|
330 | procedure cbxTypeChange(Sender: TObject);
|
---|
331 | procedure cbxRemDlgsChange(Sender: TObject);
|
---|
332 | procedure mnuTemplateIconLegendClick(Sender: TObject);
|
---|
333 | procedure cbLongLinesClick(Sender: TObject);
|
---|
334 | procedure cbLockClick(Sender: TObject);
|
---|
335 | procedure mnuRefreshClick(Sender: TObject);
|
---|
336 | procedure reResizeRequest(Sender: TObject; Rect: TRect);
|
---|
337 | procedure reBoilSelectionChange(Sender: TObject);
|
---|
338 | procedure reGroupBPSelectionChange(Sender: TObject);
|
---|
339 | procedure cbxCOMObjChange(Sender: TObject);
|
---|
340 | procedure edtCOMParamChange(Sender: TObject);
|
---|
341 | procedure cbxLinkNeedData(Sender: TObject; const StartFrom: String;
|
---|
342 | Direction, InsertAt: Integer);
|
---|
343 | procedure cbxLinkChange(Sender: TObject);
|
---|
344 | procedure cbxLinkSynonymCheck(Sender: TObject; const Text: String;
|
---|
345 | var IsSynonym: Boolean);
|
---|
346 | procedure reBoilKeyUp(Sender: TObject; var Key: Word;
|
---|
347 | Shift: TShiftState);
|
---|
348 | procedure reBoilKeyPress(Sender: TObject; var Key: Char);
|
---|
349 | procedure reBoilKeyDown(Sender: TObject; var Key: Word;
|
---|
350 | Shift: TShiftState);
|
---|
351 | private
|
---|
352 | FLastRect: TRect;
|
---|
353 | FForceContainer: boolean;
|
---|
354 | FSavePause: integer;
|
---|
355 | FCopyNode: TTreeNode;
|
---|
356 | FPasteNode: TTreeNode;
|
---|
357 | FCopying: boolean;
|
---|
358 | FDropNode: TTreeNode;
|
---|
359 | FDropInto: boolean;
|
---|
360 | FDragNode: TTreeNode;
|
---|
361 | FPersonalEmptyNodeCount: integer;
|
---|
362 | FSharedEmptyNodeCount: integer;
|
---|
363 | // FOldPersonalTemplate: TTemplate;
|
---|
364 | FCurrentPersonalUser: Int64;
|
---|
365 | FCanEditPersonal: boolean;
|
---|
366 | FCanEditShared: boolean;
|
---|
367 | FUpdating: boolean;
|
---|
368 | FCurTree: TTreeView;
|
---|
369 | FTreeControl: array[TTemplateTreeType, TTemplateTreeControl] of TControl;
|
---|
370 | FInternalHiddenExpand :boolean;
|
---|
371 | FFindShOn: boolean;
|
---|
372 | FFindShNext: boolean;
|
---|
373 | FLastFoundShNode: TTreeNode;
|
---|
374 | FFindPerOn: boolean;
|
---|
375 | FFindPerNext: boolean;
|
---|
376 | FLastFoundPerNode: TTreeNode;
|
---|
377 | FFirstShow: boolean;
|
---|
378 | FFocusName: boolean;
|
---|
379 | FOK2Close: boolean;
|
---|
380 | FBtnNewNode: TTreeNode;
|
---|
381 | FLastDropNode: TTreeNode;
|
---|
382 | FFromMainMenu: boolean;
|
---|
383 | FMainMenuTree: TTreeView;
|
---|
384 | FDragOverCount: integer;
|
---|
385 | FBPOK: boolean;
|
---|
386 | FImportingFromXML: boolean;
|
---|
387 | FXMLTemplateElement: IXMLDOMNode;
|
---|
388 | FXMLFieldElement: IXMLDOMNode;
|
---|
389 | FCanDoReminders: boolean;
|
---|
390 | FCanDoCOMObjects: boolean;
|
---|
391 | FPersonalObjects: TStringList;
|
---|
392 | FShowingTemplate: TTemplate;
|
---|
393 | FConsultServices: TStringList;
|
---|
394 | FNavigatingTab: boolean;
|
---|
395 | protected
|
---|
396 | procedure UpdateXY(re: TRichEdit; lblX, lblY: TLabel);
|
---|
397 | function IsTemplateLocked(Node: TTreeNode): boolean;
|
---|
398 | procedure RefreshData;
|
---|
399 | procedure ShowTemplateType(Template: TTemplate);
|
---|
400 | procedure DisplayBoilerplate(Node: TTreeNode);
|
---|
401 | procedure NewPersonalUser(UsrIEN: Int64);
|
---|
402 | procedure HideControls;
|
---|
403 | procedure EnableControls(ok, Root: boolean);
|
---|
404 | procedure EnableNavControls;
|
---|
405 | procedure MoveCopyButtons;
|
---|
406 | procedure ShowInfo(Node: TTreeNode);
|
---|
407 | function ChangeTree(NewTree: TTreeView): boolean;
|
---|
408 | procedure Resync(const Templates: array of TTemplate);
|
---|
409 | function AllowMove(ADropNode, ADragNode: TTreeNode): boolean;
|
---|
410 | function CanClone(const Node: TTreeNode): boolean;
|
---|
411 | function Clone(Node: TTreeNode): boolean;
|
---|
412 | procedure SharedEditing;
|
---|
413 | function GetTree: TTreeView;
|
---|
414 | procedure SetFindNext(const Tree: TTreeView; const Value: boolean);
|
---|
415 | function ScanNames: boolean;
|
---|
416 | function PasteOK: boolean;
|
---|
417 | function AutoDel(Template: TTemplate): boolean;
|
---|
418 | procedure cbClick(Sender: TCheckBox; Index: integer);
|
---|
419 | procedure UpdateInsertsDialogs;
|
---|
420 | procedure AutoLongLines(Sender: TObject);
|
---|
421 | procedure UpdatePersonalObjects;
|
---|
422 | procedure UpdateApply(Template: TTemplate);
|
---|
423 | procedure TemplateLocked(Sender: TObject);
|
---|
424 | procedure InitTrees;
|
---|
425 | function GetLinkType(const ANode: TTreeNode): TTemplateLinkType;
|
---|
426 | end;
|
---|
427 |
|
---|
428 | procedure EditTemplates(Form: TForm; NewTemplate: boolean = FALSE; CopiedText: string = ''; Shared: boolean = FALSE);
|
---|
429 |
|
---|
430 | implementation
|
---|
431 |
|
---|
432 | {$R *.DFM}
|
---|
433 |
|
---|
434 | uses dShared, uCore, rTemplates, fTemplateObjects, uSpell, fTemplateView,
|
---|
435 | fTemplateAutoGen, fDrawers, fTemplateFieldEditor, fTemplateFields, XMLUtils,
|
---|
436 | fIconLegend, uReminders, uConst, rCore, rEventHooks, rConsults;
|
---|
437 |
|
---|
438 | const
|
---|
439 | //PropText = ' Template Properties '; <-- original line. //kt 8/8/2007
|
---|
440 | // GroupTag = 5;
|
---|
441 | BPDisplayOnlyFld = 0;
|
---|
442 | BPFirstLineFld = 1;
|
---|
443 | BPOneItemOnlyFld = 2;
|
---|
444 | BPHideDlgItemsFld = 3;
|
---|
445 | BPHideItemsFld = 4;
|
---|
446 | BPIndentFld = 5;
|
---|
447 | BPLockFld = 6;
|
---|
448 | //NoIE5 = 'You must have Internet Explorer 5 or better installed to %s Templates'; <-- original line. //kt 8/8/2007
|
---|
449 | //NoIE5Header = 'Need Internet Explorer 5'; <-- original line. //kt 8/8/2007
|
---|
450 | VK_A = Ord('A');
|
---|
451 | VK_C = Ord('C');
|
---|
452 | VK_E = Ord('E');
|
---|
453 | VK_F = Ord('F');
|
---|
454 | VK_G = Ord('G');
|
---|
455 | VK_I = Ord('I');
|
---|
456 | VK_S = Ord('S');
|
---|
457 | VK_T = Ord('T');
|
---|
458 | VK_V = Ord('V');
|
---|
459 | VK_X = Ord('X');
|
---|
460 | VK_Z = Ord('Z');
|
---|
461 |
|
---|
462 | type
|
---|
463 | TTypeIndex = (tiTemplate, tiFolder, tiGroup, tiDialog, tiRemDlg, tiCOMObj);
|
---|
464 |
|
---|
465 | const
|
---|
466 | tiNone = TTypeIndex(-1);
|
---|
467 | // TypeTag: array[TTypeIndex] of integer = (7, 6, 8, -8, 7, 7);
|
---|
468 | ttDialog = TTemplateType(-ord(ttGroup));
|
---|
469 |
|
---|
470 | TypeTag: array[TTypeIndex] of TTemplateType = (ttDoc, ttClass, ttGroup, ttDialog, ttDoc, ttDoc);
|
---|
471 | ForcedIdx: array[boolean, TTypeIndex] of integer = ((0,1,2,3,4,5),(-1,0,1,2,-1,-1));
|
---|
472 | IdxForced: array[boolean, 0..5] of TTypeIndex = ((tiTemplate, tiFolder, tiGroup, tiDialog, tiRemDlg, tiCOMObj),
|
---|
473 | (tiFolder, tiGroup, tiDialog, tiNone, tiNone, tiNone));
|
---|
474 | //iMessage = 'This template has one or more new fields, and you are not authorized to create new fields. ' + <-- original line. //kt 8/8/2007
|
---|
475 | // 'If you continue, the program will import the new template without the new fields. Do you wish ' + <-- original line. //kt 8/8/2007
|
---|
476 | // 'to do this?'; <-- original line. //kt 8/8/2007
|
---|
477 | //iMessage2 = 'The imported template fields had XML errors. '; <-- original line. //kt 8/8/2007
|
---|
478 | //iMessage3 = 'No Fields were imported.'; <-- original line. //kt 8/8/2007
|
---|
479 |
|
---|
480 | var
|
---|
481 | PropText : string; //kt
|
---|
482 | NoIE5 : string; //kt
|
---|
483 | NoIE5Header : string; //kt
|
---|
484 | iMessage : string; //kt
|
---|
485 | iMessage2 : string; //kt
|
---|
486 | iMessage3 : string; //kt
|
---|
487 |
|
---|
488 | procedure SetupVars;
|
---|
489 | //kt Added entire function to replace constant declarations 8/8/2007
|
---|
490 | begin
|
---|
491 | PropText := DKLangConstW('fTemplateEditor_Template_Properties');
|
---|
492 | NoIE5 := DKLangConstW('fTemplateEditor_You_must_have_Internet_Explorer_5_or_better_installed_to_xs_Templates');
|
---|
493 | NoIE5Header := DKLangConstW('fTemplateEditor_Need_Internet_Explorer_5');
|
---|
494 | iMessage := DKLangConstW('fTemplateEditor_This_template_has_one_or_more_new_fieldsx_and_you_are_not_authorized_to_create_new_fieldsx') +
|
---|
495 | DKLangConstW('fTemplateEditor_If_you_continuex_the_program_will_import_the_new_template_without_the_new_fieldsx__Do_you_wish') +
|
---|
496 | DKLangConstW('fTemplateEditor_to_do_thisx');
|
---|
497 | iMessage2 := DKLangConstW('fTemplateEditor_The_imported_template_fields_had_XML_errorsx');
|
---|
498 | iMessage3 := DKLangConstW('fTemplateEditor_No_Fields_were_importedx');
|
---|
499 | end;
|
---|
500 |
|
---|
501 | var
|
---|
502 | frmTemplateObjects: TfrmTemplateObjects = nil;
|
---|
503 | frmTemplateFields: TfrmTemplateFields = nil;
|
---|
504 |
|
---|
505 | procedure EditTemplates(Form: TForm; NewTemplate: boolean = FALSE;
|
---|
506 | CopiedText: string = ''; Shared: boolean = FALSE);
|
---|
507 | var
|
---|
508 | frmTemplateEditor: TfrmTemplateEditor;
|
---|
509 | Drawers: TFrmDrawers;
|
---|
510 | ExpandStr, SelectStr: string;
|
---|
511 | SelNode: TTreeNode;
|
---|
512 | SelShared: boolean;
|
---|
513 |
|
---|
514 | begin
|
---|
515 | if(UserTemplateAccessLevel in [taReadOnly, taNone]) then exit;
|
---|
516 |
|
---|
517 | ExpandStr := '';
|
---|
518 | SelectStr := '';
|
---|
519 | Drawers := nil;
|
---|
520 | if(not NewTemplate) and (CopiedText = '') then
|
---|
521 | begin
|
---|
522 | if Form is TfrmDrawers then
|
---|
523 | Drawers := TFrmDrawers(Form)
|
---|
524 | else
|
---|
525 | // if IsPublishedProp(Form, 'Drawers') then <-- original line. //kt 8/8/2007
|
---|
526 | if IsPublishedProp(Form, DKLangConstW('fTemplateEditor_Drawers')) then //kt added 8/8/2007
|
---|
527 | // Drawers := TFrmDrawers(GetOrdProp(Form, 'Drawers')); <-- original line. //kt 8/8/2007
|
---|
528 | Drawers := TFrmDrawers(GetOrdProp(Form, DKLangConstW('fTemplateEditor_Drawers'))); //kt added 8/8/2007
|
---|
529 | end;
|
---|
530 |
|
---|
531 | if assigned(Drawers) then
|
---|
532 | begin
|
---|
533 | ExpandStr := Drawers.tvTemplates.GetExpandedIDStr(1, ';');
|
---|
534 | SelectStr := Drawers.tvTemplates.GetNodeID(TORTreeNode(Drawers.tvTemplates.Selected),1,';');
|
---|
535 | end;
|
---|
536 |
|
---|
537 | frmTemplateEditor := TfrmTemplateEditor.Create(Application);
|
---|
538 | try
|
---|
539 | with frmTemplateEditor do
|
---|
540 | begin
|
---|
541 | Font := Form.Font;
|
---|
542 | reBoil.Font.Size := Form.Font.Size;
|
---|
543 | reGroupBP.Font.Size := Form.Font.Size;
|
---|
544 | reNotes.Font.Size := Form.Font.Size;
|
---|
545 | dmodShared.ExpandTree(tvShared, ExpandStr, FSharedEmptyNodeCount);
|
---|
546 | SelNode := tvShared.FindPieceNode(SelectStr,1,';');
|
---|
547 | SelShared := assigned(SelNode);
|
---|
548 | dmodShared.ExpandTree(tvPersonal, ExpandStr, FPersonalEmptyNodeCount);
|
---|
549 | if not SelShared then
|
---|
550 | SelNode := tvPersonal.FindPieceNode(SelectStr,1,';');
|
---|
551 |
|
---|
552 | if(SelShared and (not Shared)) then
|
---|
553 | Shared := TRUE;
|
---|
554 |
|
---|
555 | if(Shared and (UserTemplateAccessLevel = taEditor)) then
|
---|
556 | begin
|
---|
557 | cbEditShared.Checked := TRUE;
|
---|
558 | ActiveControl := tvShared;
|
---|
559 | if SelShared then
|
---|
560 | tvShared.Selected := SelNode
|
---|
561 | else
|
---|
562 | tvShared.Selected := tvShared.Items.GetFirstNode;
|
---|
563 | end
|
---|
564 | else
|
---|
565 | if(not SelShared) and (assigned(SelNode)) then
|
---|
566 | tvPersonal.Selected := SelNode;
|
---|
567 | if(NewTemplate) then
|
---|
568 | begin
|
---|
569 | btnNewClick(frmTemplateEditor);
|
---|
570 | if(CopiedText <> '') then
|
---|
571 | begin
|
---|
572 | TTemplate(FBtnNewNode.Data).Boilerplate := CopiedText;
|
---|
573 | ShowInfo(FBtnNewNode);
|
---|
574 | end;
|
---|
575 | end;
|
---|
576 | ShowModal;
|
---|
577 | end;
|
---|
578 | finally
|
---|
579 | frmTemplateEditor.Free;
|
---|
580 | end;
|
---|
581 | end;
|
---|
582 |
|
---|
583 | procedure TfrmTemplateEditor.btnNewClick(Sender: TObject);
|
---|
584 | var
|
---|
585 | idx: integer;
|
---|
586 | Tmp, Owner: TTemplate;
|
---|
587 | Node, PNode: TTreeNode;
|
---|
588 | ownr: string;
|
---|
589 | ok: boolean;
|
---|
590 | ACheckBox: TCheckBox;
|
---|
591 |
|
---|
592 | begin
|
---|
593 | if((assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
594 | begin
|
---|
595 | if(FCurTree = tvShared) and (FCanEditShared) then
|
---|
596 | ok := TRUE
|
---|
597 | else
|
---|
598 | if(FCurTree = tvPersonal) and (FCanEditPersonal) then
|
---|
599 | ok := TRUE
|
---|
600 | else
|
---|
601 | ok := FALSE;
|
---|
602 | if(ok) then
|
---|
603 | begin
|
---|
604 | Node := FCurTree.Selected;
|
---|
605 | PNode := Node;
|
---|
606 | if(TTemplate(Node.Data).RealType = ttDoc) then
|
---|
607 | PNode := Node.Parent;
|
---|
608 | if CanClone(PNode) then
|
---|
609 | begin
|
---|
610 | Clone(PNode);
|
---|
611 | Owner := TTemplate(PNode.Data);
|
---|
612 | if assigned(Owner) and Owner.CanModify then
|
---|
613 | begin
|
---|
614 | if Node = PNode then
|
---|
615 | idx := 0
|
---|
616 | else
|
---|
617 | idx := Owner.Items.IndexOf(Node.Data) + 1;
|
---|
618 | if(FCurTree = tvShared) then
|
---|
619 | begin
|
---|
620 | ownr := '';
|
---|
621 | ACheckBox := cbShHide;
|
---|
622 | end
|
---|
623 | else
|
---|
624 | begin
|
---|
625 | ownr := IntToStr(User.DUZ);
|
---|
626 | ACheckBox := cbPerHide;
|
---|
627 | end;
|
---|
628 | if FImportingFromXML then
|
---|
629 | begin
|
---|
630 | Tmp := TTemplate.CreateFromXML(FXMLTemplateElement, ownr);
|
---|
631 | ACheckBox.Checked := ACheckBox.Checked and Tmp.Active;
|
---|
632 | end
|
---|
633 | else
|
---|
634 | begin
|
---|
635 | Tmp := TTemplate.Create('0^T^A^'+NewTemplateName+'^^^'+ownr);
|
---|
636 | Tmp.BackupItems;
|
---|
637 | Templates.AddObject(Tmp.ID, Tmp);
|
---|
638 | end;
|
---|
639 | btnApply.Enabled := TRUE;
|
---|
640 | if(idx >= Owner.Items.Count) then
|
---|
641 | Owner.Items.Add(Tmp)
|
---|
642 | else
|
---|
643 | Owner.Items.Insert(idx, Tmp);
|
---|
644 | Resync([Owner]);
|
---|
645 | Node := FCurTree.Selected;
|
---|
646 | if(Node.Data <> Tmp) then
|
---|
647 | begin
|
---|
648 | if(TTemplate(Node.Data).RealType = ttDoc) then
|
---|
649 | Node := Node.GetNextSibling
|
---|
650 | else
|
---|
651 | begin
|
---|
652 | Node.Expand(FALSE);
|
---|
653 | Node := Node.GetFirstChild;
|
---|
654 | end;
|
---|
655 | FCurTree.Selected := Node;
|
---|
656 | end;
|
---|
657 | FBtnNewNode := Node;
|
---|
658 | if(FFirstShow) then
|
---|
659 | FFocusName := TRUE
|
---|
660 | else
|
---|
661 | begin
|
---|
662 | edtName.SetFocus;
|
---|
663 | edtName.SelectAll;
|
---|
664 | end;
|
---|
665 | end;
|
---|
666 | end;
|
---|
667 | end;
|
---|
668 | end;
|
---|
669 | end;
|
---|
670 |
|
---|
671 | procedure TfrmTemplateEditor.btnApplyClick(Sender: TObject);
|
---|
672 | begin
|
---|
673 | if(ScanNames) then
|
---|
674 | begin
|
---|
675 | SaveAllTemplates;
|
---|
676 | BtnApply.Enabled := BackupDiffers;
|
---|
677 | if not BtnApply.Enabled then
|
---|
678 | UnlockAllTemplates;
|
---|
679 | end;
|
---|
680 | end;
|
---|
681 |
|
---|
682 | procedure TfrmTemplateEditor.FormCreate(Sender: TObject);
|
---|
683 | begin
|
---|
684 | ResizeAnchoredFormToFont(self);
|
---|
685 | //Now fix everything the resize messed up
|
---|
686 | lblLines.Width := cbLock.Left - lblLines.Left - 15;
|
---|
687 | sbPerDelete.Left := pnlPersonalBottom.ClientWidth - sbPerDelete.Width - 1;
|
---|
688 | sbPerDown.Left := sbPerDelete.Left - sbPerDown.Width - 2;
|
---|
689 | sbPerUp.Left := sbPerDown.Left - sbPerUp.Width - 2;
|
---|
690 | cbPerHide.Width := sbPerUp.Left - 3;
|
---|
691 | btnPerFind.Left := pnlPerSearch.ClientWidth - btnPerFind.Width;
|
---|
692 |
|
---|
693 | FSavePause := Application.HintHidePause;
|
---|
694 | Application.HintHidePause := FSavePause*2;
|
---|
695 | if InteractiveRemindersActive then
|
---|
696 | begin
|
---|
697 | QuickCopy(GetTemplateAllowedReminderDialogs, cbxRemDlgs.Items);
|
---|
698 | FCanDoReminders := (cbxRemDlgs.Items.Count > 0);
|
---|
699 | end
|
---|
700 | else
|
---|
701 | FCanDoReminders := FALSE;
|
---|
702 |
|
---|
703 | QuickCopy(GetAllActiveCOMObjects, cbxCOMObj.Items);
|
---|
704 | FCanDoCOMObjects := (cbxCOMObj.Items.Count > 0);
|
---|
705 |
|
---|
706 | FUpdating := TRUE;
|
---|
707 | FFirstShow := TRUE;
|
---|
708 |
|
---|
709 | FTreeControl[ttShared, tcDel] := sbShDelete;
|
---|
710 | FTreeControl[ttShared, tcUp] := sbShUp;
|
---|
711 | FTreeControl[ttShared, tcDown] := sbShDown;
|
---|
712 | FTreeControl[ttShared, tcLbl] := lblCopy;
|
---|
713 | FTreeControl[ttShared, tcCopy] := sbCopyRight;
|
---|
714 | FTreeControl[ttPersonal, tcDel] := sbPerDelete;
|
---|
715 | FTreeControl[ttPersonal, tcUp] := sbPerUp;
|
---|
716 | FTreeControl[ttPersonal, tcDown] := sbPerDown;
|
---|
717 | FTreeControl[ttPersonal, tcLbl] := lblCopy;
|
---|
718 | FTreeControl[ttPersonal, tcCopy] := sbCopyLeft;
|
---|
719 | dmodShared.InEditor := TRUE;
|
---|
720 | dmodShared.OnTemplateLock := TemplateLocked;
|
---|
721 |
|
---|
722 | gbProperties.Caption := PropText;
|
---|
723 | pnlShSearch.Visible := FALSE;
|
---|
724 | pnlPerSearch.Visible := FALSE;
|
---|
725 | FCanEditPersonal := TRUE;
|
---|
726 |
|
---|
727 | { Don't mess with the order of the following commands! }
|
---|
728 | InitTrees;
|
---|
729 |
|
---|
730 | tvPersonal.Selected := tvPersonal.Items.GetFirstNode;
|
---|
731 |
|
---|
732 | ClearBackup;
|
---|
733 |
|
---|
734 | cboOwner.SelText := MixedCase(User.Name);
|
---|
735 | NewPersonalUser(User.DUZ);
|
---|
736 |
|
---|
737 | cbEditShared.Visible := (UserTemplateAccessLevel = taEditor);
|
---|
738 | FCanEditShared := FALSE;
|
---|
739 | SharedEditing;
|
---|
740 |
|
---|
741 | HideControls;
|
---|
742 |
|
---|
743 | lblCopy.AutoSize := TRUE;
|
---|
744 | lblCopy.AutoSize := FALSE; // resets height based on font
|
---|
745 | lblCopy.Width := pnlCopyBtns.Width + splMiddle.Width;
|
---|
746 | MoveCopyButtons;
|
---|
747 |
|
---|
748 | cbShHide.Checked := TRUE;
|
---|
749 | cbPerHide.Checked := TRUE;
|
---|
750 |
|
---|
751 | BtnApply.Enabled := BackupDiffers;
|
---|
752 | end;
|
---|
753 |
|
---|
754 | procedure TfrmTemplateEditor.HideControls;
|
---|
755 | begin
|
---|
756 | sbCopyRight.Visible := FCanEditPersonal;
|
---|
757 | if(not FCanEditPersonal) then
|
---|
758 | cbPerHide.Checked := TRUE;
|
---|
759 | cbPerHide.Visible := FCanEditPersonal;
|
---|
760 | sbPerDelete.Visible := FCanEditPersonal;
|
---|
761 | sbPerUp.Visible := FCanEditPersonal;
|
---|
762 | sbPerDown.Visible := FCanEditPersonal;
|
---|
763 | tvPersonal.ReadOnly := not FCanEditPersonal;
|
---|
764 | MoveCopyButtons;
|
---|
765 | end;
|
---|
766 |
|
---|
767 | procedure TfrmTemplateEditor.cboOwnerNeedData(Sender: TObject;
|
---|
768 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
769 | begin
|
---|
770 | // cboOwner.ForDataUse(SubSetOfTemplateOwners(StartFrom, Direction));
|
---|
771 | end;
|
---|
772 |
|
---|
773 | procedure TfrmTemplateEditor.cboOwnerChange(Sender: TObject);
|
---|
774 | begin
|
---|
775 | NewPersonalUser(cboOwner.ItemIEN);
|
---|
776 | end;
|
---|
777 |
|
---|
778 | procedure TfrmTemplateEditor.NewPersonalUser(UsrIEN: Int64);
|
---|
779 | var
|
---|
780 | NewEdit: boolean;
|
---|
781 |
|
---|
782 | begin
|
---|
783 | FCurrentPersonalUser := UsrIEN;
|
---|
784 | NewEdit := (FCurrentPersonalUser = User.DUZ);
|
---|
785 | if(FCanEditPersonal <> NewEdit) then
|
---|
786 | begin
|
---|
787 | FCanEditPersonal := NewEdit;
|
---|
788 | HideControls;
|
---|
789 | end;
|
---|
790 | end;
|
---|
791 |
|
---|
792 | procedure TfrmTemplateEditor.tvPersonalExpanding(Sender: TObject;
|
---|
793 | Node: TTreeNode; var AllowExpansion: Boolean);
|
---|
794 | begin
|
---|
795 | AllowExpansion := dmodShared.ExpandNode(tvPersonal, Node,
|
---|
796 | FPersonalEmptyNodeCount, not cbPerHide.Checked);
|
---|
797 | if(AllowExpansion and FInternalHiddenExpand) then
|
---|
798 | AllowExpansion := FALSE;
|
---|
799 | end;
|
---|
800 |
|
---|
801 | procedure TfrmTemplateEditor.tvSharedExpanding(Sender: TObject;
|
---|
802 | Node: TTreeNode; var AllowExpansion: Boolean);
|
---|
803 | begin
|
---|
804 | AllowExpansion := dmodShared.ExpandNode(tvShared, Node,
|
---|
805 | FSharedEmptyNodeCount, not cbShHide.Checked);
|
---|
806 | if(AllowExpansion and FInternalHiddenExpand) then
|
---|
807 | AllowExpansion := FALSE;
|
---|
808 | end;
|
---|
809 |
|
---|
810 | procedure TfrmTemplateEditor.tvTreeGetImageIndex(Sender: TObject;
|
---|
811 | Node: TTreeNode);
|
---|
812 | begin
|
---|
813 | Node.ImageIndex := dmodShared.ImgIdx(Node);
|
---|
814 | end;
|
---|
815 |
|
---|
816 | procedure TfrmTemplateEditor.tvTreeGetSelectedIndex(Sender: TObject;
|
---|
817 | Node: TTreeNode);
|
---|
818 | begin
|
---|
819 | Node.SelectedIndex := dmodShared.ImgIdx(Node);
|
---|
820 | end;
|
---|
821 |
|
---|
822 | function TfrmTemplateEditor.IsTemplateLocked(Node: TTreeNode): boolean;
|
---|
823 | var
|
---|
824 | Template: TTemplate;
|
---|
825 |
|
---|
826 | begin
|
---|
827 | Result := FALSE;
|
---|
828 | if assigned(Node) then
|
---|
829 | begin
|
---|
830 | Template := TTemplate(Node.Data);
|
---|
831 | if Template.AutoLock then
|
---|
832 | Result := TRUE
|
---|
833 | else
|
---|
834 | if (Template.PersonalOwner = 0) then
|
---|
835 | begin
|
---|
836 | if RootTemplate.IsLocked then
|
---|
837 | Result := TRUE
|
---|
838 | else
|
---|
839 | begin
|
---|
840 | Result := TTemplate(Node.Data).IsLocked;
|
---|
841 | if (not Result) and assigned(Node.Parent) and
|
---|
842 | (TTemplate(Node.Parent).PersonalOwner = 0) then
|
---|
843 | Result := IsTemplateLocked(Node.Parent);
|
---|
844 | end;
|
---|
845 | end;
|
---|
846 | end;
|
---|
847 | end;
|
---|
848 |
|
---|
849 | procedure TfrmTemplateEditor.tvTreeChange(Sender: TObject;
|
---|
850 | Node: TTreeNode);
|
---|
851 | var
|
---|
852 | ok, Something: boolean;
|
---|
853 | Template: TTemplate;
|
---|
854 |
|
---|
855 | begin
|
---|
856 | ChangeTree(TTreeView(Sender));
|
---|
857 | Something := assigned(Node);
|
---|
858 | if Something then
|
---|
859 | begin
|
---|
860 | Template := TTemplate(Node.Data);
|
---|
861 | Something := assigned(Template);
|
---|
862 | if Something then
|
---|
863 | begin
|
---|
864 | if(Sender = tvPersonal) then
|
---|
865 | begin
|
---|
866 | ok := FCanEditPersonal;
|
---|
867 | if ok and (Template.PersonalOwner = 0) and IsTemplateLocked(Node) then
|
---|
868 | ok := FALSE;
|
---|
869 | end
|
---|
870 | else
|
---|
871 | ok := FCanEditShared;
|
---|
872 | EnableControls(ok, (Template.RealType in AllTemplateRootTypes));
|
---|
873 | ShowInfo(Node);
|
---|
874 | end;
|
---|
875 | end;
|
---|
876 | if not Something then
|
---|
877 | begin
|
---|
878 | gbProperties.Caption := PropText;
|
---|
879 | EnableControls(FALSE, FALSE);
|
---|
880 | ShowInfo(nil);
|
---|
881 | end;
|
---|
882 | end;
|
---|
883 |
|
---|
884 | procedure TfrmTemplateEditor.EnableControls(ok, Root: boolean);
|
---|
885 | begin
|
---|
886 | cbLock.Enabled := ok and (FCurTree = tvShared);
|
---|
887 | if(ok and Root) then
|
---|
888 | begin
|
---|
889 | ok := FALSE;
|
---|
890 | lblName.Enabled := TRUE;
|
---|
891 | edtName.Enabled := TRUE;
|
---|
892 | reNotes.ReadOnly := FALSE;
|
---|
893 | end
|
---|
894 | else
|
---|
895 | begin
|
---|
896 | lblName.Enabled := ok;
|
---|
897 | edtName.Enabled := ok;
|
---|
898 | reNotes.ReadOnly := not ok;
|
---|
899 | end;
|
---|
900 | lblNotes.Enabled := (not reNotes.ReadOnly);
|
---|
901 | if(reNotes.ReadOnly) then
|
---|
902 | reNotes.Color := ReadOnlyColor
|
---|
903 | else
|
---|
904 | reNotes.Color := clWindow;
|
---|
905 | cbxType.Enabled := ok;
|
---|
906 | lblType.Enabled := ok;
|
---|
907 | lblRemDlg.Enabled := ok;
|
---|
908 | cbxRemDlgs.Enabled := ok and FCanDoReminders;
|
---|
909 | cbActive.Enabled := ok;
|
---|
910 | cbExclude.Enabled := ok;
|
---|
911 | cbDisplayOnly.Enabled := ok;
|
---|
912 | cbFirstLine.Enabled := ok;
|
---|
913 | cbOneItemOnly.Enabled := ok;
|
---|
914 | cbHideDlgItems.Enabled := ok;
|
---|
915 | cbHideItems.Enabled := ok;
|
---|
916 | cbIndent.Enabled := ok;
|
---|
917 | edtGap.Enabled := ok;
|
---|
918 | udGap.Enabled := ok;
|
---|
919 | udGap.Invalidate;
|
---|
920 | lblLines.Enabled := ok;
|
---|
921 | reBoil.ReadOnly := not ok;
|
---|
922 | if(ok) then
|
---|
923 | reBoil.Color := clWindow
|
---|
924 | else
|
---|
925 | reBoil.Color := ReadOnlyColor;
|
---|
926 | lblLink.Enabled := ok;
|
---|
927 | cbxLink.Enabled := ok;
|
---|
928 | ok := ok and FCanDoCOMObjects;
|
---|
929 | cbxCOMObj.Enabled := ok;
|
---|
930 | lblCOMObj.Enabled := ok;
|
---|
931 | edtCOMParam.Enabled := ok;
|
---|
932 | lblCOMParam.Enabled := ok;
|
---|
933 | UpdateInsertsDialogs;
|
---|
934 | EnableNavControls;
|
---|
935 | end;
|
---|
936 |
|
---|
937 | procedure TfrmTemplateEditor.MoveCopyButtons;
|
---|
938 | var
|
---|
939 | tmpHeight: integer;
|
---|
940 |
|
---|
941 | begin
|
---|
942 | tmpHeight := tvShared.Height;
|
---|
943 | dec(tmpHeight,lblCopy.Height);
|
---|
944 | if(sbCopyLeft.Visible) then
|
---|
945 | dec(tmpHeight, sbCopyLeft.Height+5);
|
---|
946 | if(sbCopyRight.Visible) then
|
---|
947 | dec(tmpHeight, sbCopyRight.Height+5);
|
---|
948 | tmpHeight := (tmpHeight div 2) + tvShared.Top;
|
---|
949 | lblCopy.Top := tmpHeight;
|
---|
950 | inc(tmpHeight,lblCopy.height+5);
|
---|
951 | if(sbCopyLeft.Visible) then
|
---|
952 | begin
|
---|
953 | sbCopyLeft.Top := tmpHeight;
|
---|
954 | inc(tmpHeight, sbCopyLeft.Height+5);
|
---|
955 | end;
|
---|
956 | if(sbCopyRight.Visible) then
|
---|
957 | sbCopyRight.Top := tmpHeight;
|
---|
958 | end;
|
---|
959 |
|
---|
960 | procedure TfrmTemplateEditor.splMainMoved(Sender: TObject);
|
---|
961 | begin
|
---|
962 | MoveCopyButtons;
|
---|
963 | end;
|
---|
964 |
|
---|
965 | procedure TfrmTemplateEditor.ShowInfo(Node: TTreeNode);
|
---|
966 | var
|
---|
967 | OldUpdating, ClearName, ClearRB, ClearAll: boolean;
|
---|
968 | Idx: TTypeIndex;
|
---|
969 | CanDoCOM: boolean;
|
---|
970 | LinkTemplate: TTemplate;
|
---|
971 | lt: TTemplateLinkType;
|
---|
972 | lts: string;
|
---|
973 | i: integer;
|
---|
974 |
|
---|
975 | begin
|
---|
976 | OldUpdating := FUpdating;
|
---|
977 | FUpdating := TRUE;
|
---|
978 | try
|
---|
979 | if(assigned(Node)) then
|
---|
980 | begin
|
---|
981 | FShowingTemplate := TTemplate(Node.Data);
|
---|
982 | with FShowingTemplate do
|
---|
983 | begin
|
---|
984 | ClearName := FALSE;
|
---|
985 | ClearRB := FALSE;
|
---|
986 | ClearAll := FALSE;
|
---|
987 | ShowTemplateType(TTemplate(Node.Data));
|
---|
988 | lt := GetLinkType(Node);
|
---|
989 | if(lt = ltNone) or (IsReminderDialog and (not (lt in [ltNone, ltTitle]))) then
|
---|
990 | pnlLink.Visible := FALSE
|
---|
991 | else
|
---|
992 | begin
|
---|
993 | pnlLink.Visible := TRUE;
|
---|
994 | pnlLink.Tag := ord(lt);
|
---|
995 | case lt of
|
---|
996 | // ltTitle: lts := 'Title'; <-- original line. //kt 8/8/2007
|
---|
997 | ltTitle: lts := DKLangConstW('fTemplateEditor_Title'); //kt added 8/8/2007
|
---|
998 | // ltConsult: lts := 'Consult Service'; <-- original line. //kt 8/8/2007
|
---|
999 | ltConsult: lts := DKLangConstW('fTemplateEditor_Consult_Service'); //kt added 8/8/2007
|
---|
1000 | // ltProcedure: lts := 'Procedure'; <-- original line. //kt 8/8/2007
|
---|
1001 | ltProcedure: lts := DKLangConstW('fTemplateEditor_Procedure'); //kt added 8/8/2007
|
---|
1002 | else lts := '';
|
---|
1003 | end;
|
---|
1004 | cbxLink.Clear;
|
---|
1005 | if lt = ltConsult then
|
---|
1006 | begin
|
---|
1007 | cbxLink.LongList := FALSE;
|
---|
1008 | if not assigned(FConsultServices) then
|
---|
1009 | begin
|
---|
1010 | FConsultServices := TStringList.Create;
|
---|
1011 | FConsultServices.Assign(LoadServiceListWithSynonyms(1));
|
---|
1012 | SortByPiece(FConsultServices, U, 2);
|
---|
1013 | end;
|
---|
1014 | for i := 0 to FConsultServices.Count-1 do
|
---|
1015 | begin
|
---|
1016 | LinkTemplate := GetLinkedTemplate(piece(FConsultServices[i],U,1), ltConsult);
|
---|
1017 | if (not assigned(LinkTemplate)) or (LinkTemplate = FShowingTemplate) then
|
---|
1018 | cbxLink.Items.Add(FConsultServices[i]);
|
---|
1019 | end;
|
---|
1020 | end
|
---|
1021 | else
|
---|
1022 | begin
|
---|
1023 | cbxLink.LongList := TRUE;
|
---|
1024 | cbxLink.HideSynonyms := TRUE;
|
---|
1025 | cbxLink.InitLongList(LinkName);
|
---|
1026 | end;
|
---|
1027 | cbxLink.SelectByID(LinkIEN);
|
---|
1028 | // lblLink.Caption := ' Associated ' + lts + ': '; <-- original line. //kt 8/8/2007
|
---|
1029 | lblLink.Caption := DKLangConstW('fTemplateEditor_Associated') + lts + ': '; //kt added 8/8/2007
|
---|
1030 | cbxLink.Caption := lblLink.Caption;
|
---|
1031 | end;
|
---|
1032 |
|
---|
1033 | edtName.Text := PrintName;
|
---|
1034 | reNotes.Lines.Text := Description;
|
---|
1035 | if(PersonalOwner = 0) and (FCurTree = tvShared) and (cbEditShared.Checked) then
|
---|
1036 | begin
|
---|
1037 | cbLock.Checked := IsLocked;
|
---|
1038 | if AutoLock then
|
---|
1039 | cbLock.Enabled := FALSE;
|
---|
1040 | end
|
---|
1041 | else
|
---|
1042 | begin
|
---|
1043 | cbLock.Checked := IsTemplateLocked(Node);
|
---|
1044 | cbLock.Enabled := FALSE;
|
---|
1045 | end;
|
---|
1046 | CanDoCom := FCanDoCOMObjects and (PersonalOwner = 0);
|
---|
1047 | if(RealType in AllTemplateRootTypes) then
|
---|
1048 | begin
|
---|
1049 | ClearRB := TRUE;
|
---|
1050 | ClearAll := TRUE;
|
---|
1051 | end
|
---|
1052 | else
|
---|
1053 | begin
|
---|
1054 | case RealType of
|
---|
1055 | ttDoc: begin
|
---|
1056 | if IsReminderDialog then
|
---|
1057 | Idx := tiRemDlg
|
---|
1058 | else
|
---|
1059 | if IsCOMObject then
|
---|
1060 | Idx := tiCOMObj
|
---|
1061 | else
|
---|
1062 | Idx := tiTemplate;
|
---|
1063 | end;
|
---|
1064 | ttGroup: begin
|
---|
1065 | if(Dialog) then
|
---|
1066 | Idx := tiDialog
|
---|
1067 | else
|
---|
1068 | Idx := tiGroup;
|
---|
1069 | end;
|
---|
1070 | ttClass: Idx := tiFolder;
|
---|
1071 | else Idx := tiNone;
|
---|
1072 | end;
|
---|
1073 | FForceContainer := ((RealType in [ttGroup, ttClass]) and (Children <> tcNone));
|
---|
1074 | cbxType.Items.Clear;
|
---|
1075 | if not FForceContainer then
|
---|
1076 | // cbxType.Items.Add('Template'); <-- original line. //kt 8/8/2007
|
---|
1077 | cbxType.Items.Add(DKLangConstW('fTemplateEditor_Template')); //kt added 8/8/2007
|
---|
1078 | // cbxType.Items.Add('Folder'); <-- original line. //kt 8/8/2007
|
---|
1079 | cbxType.Items.Add(DKLangConstW('fTemplateEditor_Folder')); //kt added 8/8/2007
|
---|
1080 | // cbxType.Items.Add('Group Template'); <-- original line. //kt 8/8/2007
|
---|
1081 | cbxType.Items.Add(DKLangConstW('fTemplateEditor_Group_Template')); //kt added 8/8/2007
|
---|
1082 | // cbxType.Items.Add('Dialog'); <-- original line. //kt 8/8/2007
|
---|
1083 | cbxType.Items.Add(DKLangConstW('fTemplateEditor_Dialog')); //kt added 8/8/2007
|
---|
1084 | if (not FForceContainer) then
|
---|
1085 | begin
|
---|
1086 | if(FCanDoReminders or CanDoCOM) then
|
---|
1087 | // cbxType.Items.Add('Reminder Dialog'); <-- original line. //kt 8/8/2007
|
---|
1088 | cbxType.Items.Add(DKLangConstW('fTemplateEditor_Reminder_Dialog')); //kt added 8/8/2007
|
---|
1089 | if(CanDoCOM) then
|
---|
1090 | // cbxType.Items.Add('COM Object'); <-- original line. //kt 8/8/2007
|
---|
1091 | cbxType.Items.Add(DKLangConstW('fTemplateEditor_COM_Object')); //kt added 8/8/2007
|
---|
1092 | end;
|
---|
1093 | cbxType.ItemIndex := ForcedIdx[FForceContainer, Idx];
|
---|
1094 | if(Idx = tiRemDlg) and FCanDoReminders then
|
---|
1095 | cbxRemDlgs.SelectByID(ReminderDialogIEN)
|
---|
1096 | else
|
---|
1097 | begin
|
---|
1098 | lblRemDlg.Enabled := FALSE;
|
---|
1099 | cbxRemDlgs.Enabled := FALSE;
|
---|
1100 | cbxRemDlgs.ItemIndex := -1;
|
---|
1101 | end;
|
---|
1102 | if (Idx = tiCOMObj) and CanDoCOM then
|
---|
1103 | begin
|
---|
1104 | pnlCOM.Visible := TRUE;
|
---|
1105 | cbxCOMObj.SelectByIEN(COMObject);
|
---|
1106 | edtCOMParam.Text := COMParam;
|
---|
1107 | end
|
---|
1108 | else
|
---|
1109 | begin
|
---|
1110 | pnlCOM.Visible := FALSE;
|
---|
1111 | cbxCOMObj.ItemIndex := -1;
|
---|
1112 | edtCOMParam.Text := '';
|
---|
1113 | end;
|
---|
1114 | cbActive.Checked := Active;
|
---|
1115 | if(RealType in [ttClass, ttGroup]) then
|
---|
1116 | cbHideItems.Checked := HideItems
|
---|
1117 | else
|
---|
1118 | begin
|
---|
1119 | cbHideItems.Checked := FALSE;
|
---|
1120 | cbHideItems.Enabled := FALSE;
|
---|
1121 | end;
|
---|
1122 | if((RealType in [ttDoc, ttGroup]) and (assigned(Node.Parent)) and
|
---|
1123 | (TTemplate(Node.Parent.Data).RealType = ttGroup) and
|
---|
1124 | (not IsReminderDialog) and (not IsCOMObject)) then
|
---|
1125 | cbExclude.Checked := Exclude
|
---|
1126 | else
|
---|
1127 | begin
|
---|
1128 | cbExclude.Checked := FALSE;
|
---|
1129 | cbExclude.Enabled := FALSE;
|
---|
1130 | end;
|
---|
1131 | if dmodShared.InDialog(Node) and (not IsReminderDialog) and (not IsCOMObject) then
|
---|
1132 | begin
|
---|
1133 | cbDisplayOnly.Checked := DisplayOnly;
|
---|
1134 | cbFirstLine.Checked := FirstLine;
|
---|
1135 | end
|
---|
1136 | else
|
---|
1137 | begin
|
---|
1138 | cbDisplayOnly.Checked := FALSE;
|
---|
1139 | cbDisplayOnly.Enabled := FALSE;
|
---|
1140 | cbFirstLine.Checked := FALSE;
|
---|
1141 | cbFirstLine.Enabled := FALSE;
|
---|
1142 | end;
|
---|
1143 | if(RealType in [ttGroup, ttClass]) and (Children <> tcNone) and
|
---|
1144 | (dmodShared.InDialog(Node)) then
|
---|
1145 | begin
|
---|
1146 | cbOneItemOnly.Checked := OneItemOnly;
|
---|
1147 | cbIndent.Checked := IndentItems;
|
---|
1148 | if(RealType = ttGroup) and (Boilerplate <> '') then
|
---|
1149 | begin
|
---|
1150 | cbHideDlgItems.Checked := HideDlgItems;
|
---|
1151 | end
|
---|
1152 | else
|
---|
1153 | begin
|
---|
1154 | cbHideDlgItems.Checked := FALSE;
|
---|
1155 | cbHideDlgItems.Enabled := FALSE;
|
---|
1156 | end;
|
---|
1157 | end
|
---|
1158 | else
|
---|
1159 | begin
|
---|
1160 | cbOneItemOnly.Checked := FALSE;
|
---|
1161 | cbOneItemOnly.Enabled := FALSE;
|
---|
1162 | cbHideDlgItems.Checked := FALSE;
|
---|
1163 | cbHideDlgItems.Enabled := FALSE;
|
---|
1164 | cbIndent.Checked := FALSE;
|
---|
1165 | cbIndent.Enabled := FALSE;
|
---|
1166 | end;
|
---|
1167 | if(RealType = ttGroup) then
|
---|
1168 | edtGap.Text := IntToStr(Gap)
|
---|
1169 | else
|
---|
1170 | begin
|
---|
1171 | edtGap.Text := '0';
|
---|
1172 | edtGap.Enabled := FALSE;
|
---|
1173 | udGap.Enabled := FALSE;
|
---|
1174 | udGap.Invalidate;
|
---|
1175 | lblLines.Enabled := FALSE;
|
---|
1176 | end;
|
---|
1177 | DisplayBoilerPlate(Node);
|
---|
1178 | end;
|
---|
1179 | end;
|
---|
1180 | end
|
---|
1181 | else
|
---|
1182 | begin
|
---|
1183 | ClearAll := TRUE;
|
---|
1184 | ClearRB := TRUE;
|
---|
1185 | ClearName := TRUE;
|
---|
1186 | gbProperties.Caption := PropText;
|
---|
1187 | end;
|
---|
1188 | if(ClearName) then
|
---|
1189 | begin
|
---|
1190 | edtName.Text := '';
|
---|
1191 | reNotes.Clear;
|
---|
1192 | end;
|
---|
1193 | if(ClearRB) then
|
---|
1194 | begin
|
---|
1195 | cbxType.ItemIndex := Ord(tiNone);
|
---|
1196 | end;
|
---|
1197 | if(ClearAll) then
|
---|
1198 | begin
|
---|
1199 | cbActive.Checked := FALSE;
|
---|
1200 | cbExclude.Checked := FALSE;
|
---|
1201 | cbDisplayOnly.Checked := FALSE;
|
---|
1202 | cbFirstLine.Checked := FALSE;
|
---|
1203 | cbOneItemOnly.Checked := FALSE;
|
---|
1204 | cbHideDlgItems.Checked := FALSE;
|
---|
1205 | cbHideItems.Checked := FALSE;
|
---|
1206 | cbIndent.Checked := FALSE;
|
---|
1207 | edtGap.Text := '0';
|
---|
1208 | reBoil.Clear;
|
---|
1209 | pnlGroupBP.Visible := FALSE;
|
---|
1210 | splBoil.Visible := FALSE;
|
---|
1211 | pnlBoilerplateResize(Self);
|
---|
1212 | pnlCOM.Visible := FALSE;
|
---|
1213 | pnlLink.Visible := FALSE;
|
---|
1214 | end;
|
---|
1215 | if cbDisplayOnly.Enabled or
|
---|
1216 | cbFirstLine.Enabled or
|
---|
1217 | cbIndent.Enabled or
|
---|
1218 | cbOneItemOnly.Enabled or
|
---|
1219 | cbHideDlgItems.Enabled then
|
---|
1220 | gbDialogProps.Font.Color := clWindowText
|
---|
1221 | else
|
---|
1222 | gbDialogProps.Font.Color := clInactiveCaption;
|
---|
1223 | finally
|
---|
1224 | FUpdating := OldUpdating;
|
---|
1225 | end;
|
---|
1226 | end;
|
---|
1227 |
|
---|
1228 | procedure TfrmTemplateEditor.pnlBoilerplateResize(Sender: TObject);
|
---|
1229 | var
|
---|
1230 | Max: integer;
|
---|
1231 |
|
---|
1232 | begin
|
---|
1233 | if(pnlGroupBP.Visible) and (pnlGroupBP.Height > (pnlBoilerplate.Height-29)) then
|
---|
1234 | pnlGroupBP.Height := pnlBoilerplate.Height-29;
|
---|
1235 | if cbLongLines.checked then
|
---|
1236 | Max := 240
|
---|
1237 | else
|
---|
1238 | Max := MAX_ENTRY_WIDTH;
|
---|
1239 | LimitEditWidth(reBoil, Max);
|
---|
1240 | LimitEditWidth(reNotes, MAX_ENTRY_WIDTH);
|
---|
1241 | end;
|
---|
1242 |
|
---|
1243 | procedure TfrmTemplateEditor.edtNameOldChange(Sender: TObject);
|
---|
1244 | var
|
---|
1245 | i: integer;
|
---|
1246 | Template: TTemplate;
|
---|
1247 | DoRefresh: boolean;
|
---|
1248 |
|
---|
1249 | begin
|
---|
1250 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
1251 | begin
|
---|
1252 | if CanClone(FCurTree.Selected) then
|
---|
1253 | begin
|
---|
1254 | DoRefresh := Clone(FCurTree.Selected);
|
---|
1255 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
1256 | if assigned(Template) and Template.CanModify then
|
---|
1257 | begin
|
---|
1258 | Template.PrintName := edtName.Text;
|
---|
1259 | UpdateApply(Template);
|
---|
1260 | for i := 0 to Template.Nodes.Count-1 do
|
---|
1261 | TTreeNode(Template.Nodes.Objects[i]).Text := Template.PrintName;
|
---|
1262 | if(DoRefresh) then
|
---|
1263 | begin
|
---|
1264 | tvShared.Invalidate;
|
---|
1265 | tvPersonal.Invalidate;
|
---|
1266 | end;
|
---|
1267 | end;
|
---|
1268 | end;
|
---|
1269 | end;
|
---|
1270 | end;
|
---|
1271 |
|
---|
1272 | procedure TfrmTemplateEditor.cbActiveClick(Sender: TObject);
|
---|
1273 | var
|
---|
1274 | i: integer;
|
---|
1275 | Template: TTemplate;
|
---|
1276 | Node: TTreeNode;
|
---|
1277 |
|
---|
1278 | begin
|
---|
1279 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
1280 | begin
|
---|
1281 | if CanClone(FCurTree.Selected) then
|
---|
1282 | begin
|
---|
1283 | Clone(FCurTree.Selected);
|
---|
1284 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
1285 | if assigned(Template) and Template.CanModify then
|
---|
1286 | begin
|
---|
1287 | Template.Active := cbActive.Checked;
|
---|
1288 | UpdateApply(Template);
|
---|
1289 | for i := 0 to Template.Nodes.Count-1 do
|
---|
1290 | begin
|
---|
1291 | Node := TTreeNode(Template.Nodes.Objects[i]);
|
---|
1292 | Node.Cut := not Template.Active;
|
---|
1293 | end;
|
---|
1294 | if(FCurTree = tvShared) then
|
---|
1295 | begin
|
---|
1296 | cbPerHideClick(Sender);
|
---|
1297 | cbShHideClick(Sender);
|
---|
1298 | end
|
---|
1299 | else
|
---|
1300 | begin
|
---|
1301 | cbShHideClick(Sender);
|
---|
1302 | cbPerHideClick(Sender);
|
---|
1303 | end;
|
---|
1304 | tvTreeChange(FCurTree, FCurTree.Selected);
|
---|
1305 | EnableNavControls;
|
---|
1306 | if cbActive.CanFocus then
|
---|
1307 | cbActive.SetFocus;
|
---|
1308 | end;
|
---|
1309 | end;
|
---|
1310 | end;
|
---|
1311 | end;
|
---|
1312 |
|
---|
1313 | procedure TfrmTemplateEditor.cbExcludeClick(Sender: TObject);
|
---|
1314 | var
|
---|
1315 | i: integer;
|
---|
1316 | Template: TTemplate;
|
---|
1317 | Node: TTreeNode;
|
---|
1318 |
|
---|
1319 | begin
|
---|
1320 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
1321 | begin
|
---|
1322 | if CanClone(FCurTree.Selected) then
|
---|
1323 | begin
|
---|
1324 | Clone(FCurTree.Selected);
|
---|
1325 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
1326 | if assigned(Template) and Template.CanModify then
|
---|
1327 | begin
|
---|
1328 | Template.Exclude := cbExclude.Checked;
|
---|
1329 | UpdateApply(Template);
|
---|
1330 | for i := 0 to Template.Nodes.Count-1 do
|
---|
1331 | begin
|
---|
1332 | Node := TTreeNode(Template.Nodes.Objects[i]);
|
---|
1333 | Node.ImageIndex := dmodShared.ImgIdx(Node);
|
---|
1334 | Node.SelectedIndex := dmodShared.ImgIdx(Node);
|
---|
1335 | end;
|
---|
1336 | tvShared.Invalidate;
|
---|
1337 | tvPersonal.Invalidate;
|
---|
1338 | end;
|
---|
1339 | end;
|
---|
1340 | end;
|
---|
1341 | end;
|
---|
1342 |
|
---|
1343 | procedure TfrmTemplateEditor.edtGapChange(Sender: TObject);
|
---|
1344 | var
|
---|
1345 | DoRefresh: boolean;
|
---|
1346 | Template: TTemplate;
|
---|
1347 |
|
---|
1348 | begin
|
---|
1349 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
1350 | begin
|
---|
1351 | if CanClone(FCurTree.Selected) then
|
---|
1352 | begin
|
---|
1353 | DoRefresh := Clone(FCurTree.Selected);
|
---|
1354 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
1355 | if assigned(Template) and Template.CanModify then
|
---|
1356 | begin
|
---|
1357 | Template.Gap := StrToIntDef(edtGap.Text, 0);
|
---|
1358 | UpdateApply(Template);
|
---|
1359 | DisplayBoilerPlate(FCurTree.Selected);
|
---|
1360 | if(DoRefresh) then
|
---|
1361 | begin
|
---|
1362 | tvShared.Invalidate;
|
---|
1363 | tvPersonal.Invalidate;
|
---|
1364 | end;
|
---|
1365 | end;
|
---|
1366 | end;
|
---|
1367 | end;
|
---|
1368 | end;
|
---|
1369 |
|
---|
1370 | function TfrmTemplateEditor.ChangeTree(NewTree: TTreeView): boolean;
|
---|
1371 | var
|
---|
1372 | i: TTemplateTreeControl;
|
---|
1373 |
|
---|
1374 | begin
|
---|
1375 | Result := FALSE;
|
---|
1376 | tvShared.HideSelection := TRUE;
|
---|
1377 | tvPersonal.HideSelection := TRUE;
|
---|
1378 | if(NewTree <> FCurTree) then
|
---|
1379 | begin
|
---|
1380 | Result := TRUE;
|
---|
1381 | if(assigned(FCurTree)) then
|
---|
1382 | begin
|
---|
1383 | for i := low(TTemplateTreeControl) to high(TTemplateTreeControl) do
|
---|
1384 | FTreeControl[TTemplateTreeType(FCurTree.Tag), i].Enabled := FALSE;
|
---|
1385 | end;
|
---|
1386 | FCurTree := NewTree;
|
---|
1387 | end;
|
---|
1388 | if(assigned(FCurTree)) then
|
---|
1389 | begin
|
---|
1390 | FCurTree.HideSelection := FALSE;
|
---|
1391 | if(FCurTree = tvPersonal) and (Screen.ActiveControl = tvShared) then
|
---|
1392 | tvPersonal.SetFocus
|
---|
1393 | else
|
---|
1394 | if(FCurTree = tvShared) and (Screen.ActiveControl = tvPersonal) then
|
---|
1395 | tvShared.SetFocus;
|
---|
1396 | end;
|
---|
1397 | end;
|
---|
1398 |
|
---|
1399 | procedure TfrmTemplateEditor.tvTreeEnter(Sender: TObject);
|
---|
1400 | begin
|
---|
1401 | if((Sender is TTreeView) and (ChangeTree(TTreeView(Sender)))) then
|
---|
1402 | tvTreeChange(Sender, TTreeView(Sender).Selected);
|
---|
1403 | end;
|
---|
1404 |
|
---|
1405 | procedure TfrmTemplateEditor.tvTreeNodeEdited(Sender: TObject;
|
---|
1406 | Node: TTreeNode; var S: String);
|
---|
1407 | begin
|
---|
1408 | FUpdating := TRUE;
|
---|
1409 | try
|
---|
1410 | edtName.Text := S;
|
---|
1411 | finally
|
---|
1412 | FUpdating := FALSE;
|
---|
1413 | end;
|
---|
1414 | edtNameOldChange(edtName);
|
---|
1415 | end;
|
---|
1416 |
|
---|
1417 | procedure TfrmTemplateEditor.cbShHideClick(Sender: TObject);
|
---|
1418 | var
|
---|
1419 | Node: TTreeNode;
|
---|
1420 |
|
---|
1421 | begin
|
---|
1422 | Node := tvShared.Items.GetFirstNode;
|
---|
1423 | while assigned(Node) do
|
---|
1424 | begin
|
---|
1425 | dmodShared.Resync(Node, not cbShHide.Checked, FSharedEmptyNodeCount);
|
---|
1426 | Node := Node.getNextSibling;
|
---|
1427 | end;
|
---|
1428 | tvTreeChange(tvShared, tvShared.Selected);
|
---|
1429 | EnableNavControls;
|
---|
1430 | end;
|
---|
1431 |
|
---|
1432 | procedure TfrmTemplateEditor.cbPerHideClick(Sender: TObject);
|
---|
1433 | begin
|
---|
1434 | dmodShared.Resync(tvPersonal.Items.GetFirstNode, not cbPerHide.Checked,
|
---|
1435 | FPersonalEmptyNodeCount);
|
---|
1436 | tvTreeChange(tvPersonal, tvPersonal.Selected);
|
---|
1437 | EnableNavControls;
|
---|
1438 | end;
|
---|
1439 |
|
---|
1440 | procedure TfrmTemplateEditor.DisplayBoilerplate(Node: TTreeNode);
|
---|
1441 | var
|
---|
1442 | OldUpdating, ItemOK, BPOK, LongLines: boolean;
|
---|
1443 | i: integer;
|
---|
1444 | TmpSL: TStringList;
|
---|
1445 |
|
---|
1446 | begin
|
---|
1447 | OldUpdating := FUpdating;
|
---|
1448 | FUpdating := TRUE;
|
---|
1449 | try
|
---|
1450 | pnlBoilerplateResize(pnlBoilerplate);
|
---|
1451 | reBoil.Clear;
|
---|
1452 | ItemOK := FALSE;
|
---|
1453 | BPOK := TRUE;
|
---|
1454 | with Node, TTemplate(Node.Data) do
|
---|
1455 | begin
|
---|
1456 | if(RealType in [ttDoc, ttGroup]) then
|
---|
1457 | begin
|
---|
1458 | TmpSL := TStringList.Create;
|
---|
1459 | try
|
---|
1460 | if(RealType = ttGroup) and (not reBoil.ReadOnly) then
|
---|
1461 | begin
|
---|
1462 | ItemOK := TRUE;
|
---|
1463 | TmpSL.Text := Boilerplate;
|
---|
1464 | reGroupBP.Clear;
|
---|
1465 | reGroupBP.SelText := FullBoilerplate;
|
---|
1466 | end
|
---|
1467 | else
|
---|
1468 | TmpSL.Text := FullBoilerplate;
|
---|
1469 | LongLines := FALSE;
|
---|
1470 | for i := 0 to TmpSL.Count-1 do
|
---|
1471 | begin
|
---|
1472 | if length(TmpSL[i]) > MAX_ENTRY_WIDTH then
|
---|
1473 | begin
|
---|
1474 | LongLines := TRUE;
|
---|
1475 | break;
|
---|
1476 | end;
|
---|
1477 | end;
|
---|
1478 | cbLongLines.Checked := LongLines;
|
---|
1479 | reBoil.SelText := TmpSL.Text;
|
---|
1480 | finally
|
---|
1481 | TmpSL.Free;
|
---|
1482 | end;
|
---|
1483 | end
|
---|
1484 | else
|
---|
1485 | begin
|
---|
1486 | reBoil.ReadOnly := TRUE;
|
---|
1487 | reBoil.Color := ReadOnlyColor;
|
---|
1488 | UpdateInsertsDialogs;
|
---|
1489 | end;
|
---|
1490 | pnlGroupBP.Visible := ItemOK;
|
---|
1491 | splBoil.Visible := ItemOK;
|
---|
1492 | if(not ItemOK) and (IsReminderDialog or IsCOMObject) then
|
---|
1493 | BPOK := FALSE;
|
---|
1494 | if(ItemOK) then
|
---|
1495 | splBoil.Top := pnlGroupBP.Top - splBoil.Height;
|
---|
1496 | pnlBoilerplateResize(Self);
|
---|
1497 | pnlBoilerplate.Visible := BPOK;
|
---|
1498 | lblBoilerplate.Visible := BPOK;
|
---|
1499 | pnlCOM.Visible := (not BPOK) and IsCOMObject;
|
---|
1500 | end;
|
---|
1501 | finally
|
---|
1502 | FUpdating := OldUpdating;
|
---|
1503 | end;
|
---|
1504 | end;
|
---|
1505 |
|
---|
1506 | procedure TfrmTemplateEditor.FormDestroy(Sender: TObject);
|
---|
1507 | begin
|
---|
1508 | KillObj(@FConsultServices);
|
---|
1509 | Application.HintHidePause := FSavePause;
|
---|
1510 | if(assigned(frmTemplateObjects)) then
|
---|
1511 | begin
|
---|
1512 | frmTemplateObjects.Free;
|
---|
1513 | frmTemplateObjects := nil;
|
---|
1514 | end;
|
---|
1515 | if(assigned(frmTemplateFields)) then
|
---|
1516 | begin
|
---|
1517 | frmTemplateFields.Free;
|
---|
1518 | frmTemplateFields := nil;
|
---|
1519 | end;
|
---|
1520 | KillObj(@FPersonalObjects);
|
---|
1521 | dmodShared.OnTemplateLock := nil;
|
---|
1522 | dmodShared.InEditor := FALSE;
|
---|
1523 | RemoveAllNodes;
|
---|
1524 | ClearBackup;
|
---|
1525 | UnlockAllTemplates;
|
---|
1526 | dmodShared.Reload;
|
---|
1527 | end;
|
---|
1528 |
|
---|
1529 | procedure TfrmTemplateEditor.sbMoveUpClick(Sender: TObject);
|
---|
1530 | var
|
---|
1531 | idx: integer;
|
---|
1532 | ChangeLevel: boolean;
|
---|
1533 | ParentsParent, ParentNode, Node: TTreeNode;
|
---|
1534 | NodeTemplate, ParentTemplate, Template: TTemplate;
|
---|
1535 | Hide, First, ok: boolean;
|
---|
1536 |
|
---|
1537 | begin
|
---|
1538 | if((assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
|
---|
1539 | (assigned(FCurTree.Selected.Parent))) then
|
---|
1540 | begin
|
---|
1541 | Node := FCurTree.Selected;
|
---|
1542 | NodeTemplate := TTemplate(Node.Data);
|
---|
1543 | ParentNode := Node.Parent;
|
---|
1544 | Template := TTemplate(ParentNode.Data);
|
---|
1545 | idx := Template.Items.IndexOf(NodeTemplate);
|
---|
1546 | ChangeLevel := (idx < 1);
|
---|
1547 | if(not ChangeLevel) then
|
---|
1548 | begin
|
---|
1549 | if(TTemplateTreeType(TBitBtn(Sender).Tag) = ttShared) then
|
---|
1550 | Hide := cbShHide.Checked
|
---|
1551 | else
|
---|
1552 | Hide := cbPerHide.Checked;
|
---|
1553 | First := TRUE;
|
---|
1554 | while(idx > 0) do
|
---|
1555 | begin
|
---|
1556 | if First then
|
---|
1557 | begin
|
---|
1558 | ok := FALSE;
|
---|
1559 | First := FALSE;
|
---|
1560 | if CanClone(ParentNode) then
|
---|
1561 | begin
|
---|
1562 | if(Clone(ParentNode)) then
|
---|
1563 | Template := TTemplate(ParentNode.Data);
|
---|
1564 | if Template.CanModify then
|
---|
1565 | ok := TRUE;
|
---|
1566 | end;
|
---|
1567 | end
|
---|
1568 | else
|
---|
1569 | ok := TRUE;
|
---|
1570 | if ok then
|
---|
1571 | begin
|
---|
1572 | Template.Items.Exchange(idx-1, idx);
|
---|
1573 | if(Hide and (not TTemplate(Template.Items[idx]).Active)) then
|
---|
1574 | begin
|
---|
1575 | dec(idx);
|
---|
1576 | ChangeLevel := (idx < 1);
|
---|
1577 | end
|
---|
1578 | else
|
---|
1579 | idx := 0;
|
---|
1580 | end
|
---|
1581 | else
|
---|
1582 | idx := 0;
|
---|
1583 | end;
|
---|
1584 | end;
|
---|
1585 | if(ChangeLevel) then
|
---|
1586 | begin
|
---|
1587 | ParentsParent := ParentNode.Parent;
|
---|
1588 | if(assigned(ParentsParent)) then
|
---|
1589 | begin
|
---|
1590 | ParentTemplate := TTemplate(ParentsParent.Data);
|
---|
1591 | if(ParentTemplate.Items.IndexOf(NodeTemplate) >= 0) then
|
---|
1592 | // InfoBox(ParentsParent.Text + ' already contains the ' + <-- original line. //kt 8/8/2007
|
---|
1593 | InfoBox(ParentsParent.Text + DKLangConstW('fTemplateEditor_already_contains_the') + //kt added 8/8/2007
|
---|
1594 | // NodeTemplate.PrintName + ' template.', <-- original line. //kt 8/8/2007
|
---|
1595 | NodeTemplate.PrintName + DKLangConstW('fTemplateEditor_templatex'), //kt added 8/8/2007
|
---|
1596 | // 'Error', MB_OK or MB_ICONERROR) <-- original line. //kt 8/8/2007
|
---|
1597 | DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR) //kt added 8/8/2007
|
---|
1598 | else
|
---|
1599 | begin
|
---|
1600 | if CanClone(ParentNode) then
|
---|
1601 | begin
|
---|
1602 | if(Clone(ParentNode)) then
|
---|
1603 | Template := TTemplate(ParentNode.Data);
|
---|
1604 | if Template.CanModify and CanClone(ParentsParent) then
|
---|
1605 | begin
|
---|
1606 | if(Clone(ParentsParent)) then
|
---|
1607 | ParentTemplate := TTemplate(ParentsParent.Data);
|
---|
1608 | if ParentTemplate.CanModify then
|
---|
1609 | begin
|
---|
1610 | Template.Items.Delete(idx);
|
---|
1611 | idx := ParentTemplate.Items.IndexOf(Template);
|
---|
1612 | if(idx >= 0) then
|
---|
1613 | begin
|
---|
1614 | ParentTemplate.Items.Insert(idx, NodeTemplate);
|
---|
1615 | Resync([ParentTemplate, Template]);
|
---|
1616 | btnApply.Enabled := TRUE;
|
---|
1617 | end;
|
---|
1618 | end;
|
---|
1619 | end;
|
---|
1620 | end;
|
---|
1621 | end;
|
---|
1622 | end;
|
---|
1623 | end
|
---|
1624 | else
|
---|
1625 | begin
|
---|
1626 | Resync([Template]);
|
---|
1627 | btnApply.Enabled := TRUE;
|
---|
1628 | end;
|
---|
1629 | end;
|
---|
1630 | end;
|
---|
1631 |
|
---|
1632 | procedure TfrmTemplateEditor.sbMoveDownClick(Sender: TObject);
|
---|
1633 | var
|
---|
1634 | max, idx: integer;
|
---|
1635 | ChangeLevel: boolean;
|
---|
1636 | ParentsParent, ParentNode, Node: TTreeNode;
|
---|
1637 | NodeTemplate, ParentTemplate, Template: TTemplate;
|
---|
1638 | Hide, First, ok: boolean;
|
---|
1639 |
|
---|
1640 | begin
|
---|
1641 | if((assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
|
---|
1642 | (assigned(FCurTree.Selected.Parent))) then
|
---|
1643 | begin
|
---|
1644 | Node := FCurTree.Selected;
|
---|
1645 | NodeTemplate := TTemplate(Node.Data);
|
---|
1646 | ParentNode := Node.Parent;
|
---|
1647 | Template := TTemplate(ParentNode.Data);
|
---|
1648 | idx := Template.Items.IndexOf(NodeTemplate);
|
---|
1649 | max := Template.Items.Count-1;
|
---|
1650 | ChangeLevel := (idx >= max);
|
---|
1651 | if(not ChangeLevel) then
|
---|
1652 | begin
|
---|
1653 | if(TTemplateTreeType(TBitBtn(Sender).Tag) = ttShared) then
|
---|
1654 | Hide := cbShHide.Checked
|
---|
1655 | else
|
---|
1656 | Hide := cbPerHide.Checked;
|
---|
1657 | First := TRUE;
|
---|
1658 | while(idx < max) do
|
---|
1659 | begin
|
---|
1660 | if First then
|
---|
1661 | begin
|
---|
1662 | ok := FALSE;
|
---|
1663 | First := FALSE;
|
---|
1664 | if CanClone(ParentNode) then
|
---|
1665 | begin
|
---|
1666 | if(Clone(ParentNode)) then
|
---|
1667 | Template := TTemplate(ParentNode.Data);
|
---|
1668 | if Template.CanModify then
|
---|
1669 | ok := TRUE;
|
---|
1670 | end;
|
---|
1671 | end
|
---|
1672 | else
|
---|
1673 | ok := TRUE;
|
---|
1674 | if ok then
|
---|
1675 | begin
|
---|
1676 | Template.Items.Exchange(idx, idx+1);
|
---|
1677 | if(Hide and (not TTemplate(Template.Items[idx]).Active)) then
|
---|
1678 | begin
|
---|
1679 | inc(idx);
|
---|
1680 | ChangeLevel := (idx >= max);
|
---|
1681 | end
|
---|
1682 | else
|
---|
1683 | idx := max;
|
---|
1684 | end
|
---|
1685 | else
|
---|
1686 | idx := max;
|
---|
1687 | end;
|
---|
1688 | end;
|
---|
1689 | if(ChangeLevel) then
|
---|
1690 | begin
|
---|
1691 | ParentsParent := ParentNode.Parent;
|
---|
1692 | if(assigned(ParentsParent)) then
|
---|
1693 | begin
|
---|
1694 | ParentTemplate := TTemplate(ParentsParent.Data);
|
---|
1695 | if(ParentTemplate.Items.IndexOf(NodeTemplate) >= 0) then
|
---|
1696 | // InfoBox(ParentsParent.Text + ' already contains the ' + <-- original line. //kt 8/8/2007
|
---|
1697 | InfoBox(ParentsParent.Text + DKLangConstW('fTemplateEditor_already_contains_the') + //kt added 8/8/2007
|
---|
1698 | // NodeTemplate.PrintName + ' template.', <-- original line. //kt 8/8/2007
|
---|
1699 | NodeTemplate.PrintName + DKLangConstW('fTemplateEditor_templatex'), //kt added 8/8/2007
|
---|
1700 | // 'Error', MB_OK or MB_ICONERROR) <-- original line. //kt 8/8/2007
|
---|
1701 | DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR) //kt added 8/8/2007
|
---|
1702 | else
|
---|
1703 | begin
|
---|
1704 | if CanClone(ParentNode) then
|
---|
1705 | begin
|
---|
1706 | if(Clone(ParentNode)) then
|
---|
1707 | Template := TTemplate(ParentNode.Data);
|
---|
1708 | if Template.CanModify and CanClone(ParentsParent) then
|
---|
1709 | begin
|
---|
1710 | if(Clone(ParentsParent)) then
|
---|
1711 | ParentTemplate := TTemplate(ParentsParent.Data);
|
---|
1712 | if ParentTemplate.CanModify then
|
---|
1713 | begin
|
---|
1714 | Template.Items.Delete(idx);
|
---|
1715 | idx := ParentTemplate.Items.IndexOf(Template);
|
---|
1716 | if(idx >= 0) then
|
---|
1717 | begin
|
---|
1718 | if(idx = (ParentTemplate.Items.Count-1)) then
|
---|
1719 | ParentTemplate.Items.Add(NodeTemplate)
|
---|
1720 | else
|
---|
1721 | ParentTemplate.Items.Insert(idx+1, NodeTemplate);
|
---|
1722 | Resync([ParentTemplate, Template]);
|
---|
1723 | btnApply.Enabled := TRUE;
|
---|
1724 | end;
|
---|
1725 | end;
|
---|
1726 | end;
|
---|
1727 | end;
|
---|
1728 | end;
|
---|
1729 | end;
|
---|
1730 | end
|
---|
1731 | else
|
---|
1732 | begin
|
---|
1733 | Resync([Template]);
|
---|
1734 | btnApply.Enabled := TRUE;
|
---|
1735 | end;
|
---|
1736 | end;
|
---|
1737 | end;
|
---|
1738 |
|
---|
1739 | procedure TfrmTemplateEditor.sbDeleteClick(Sender: TObject);
|
---|
1740 | var
|
---|
1741 | PNode, Node: TTreeNode;
|
---|
1742 | Template, Parent: TTemplate;
|
---|
1743 | DoIt: boolean;
|
---|
1744 | Answer: Word;
|
---|
1745 |
|
---|
1746 | begin
|
---|
1747 | if((assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
|
---|
1748 | (assigned(FCurTree.Selected.Parent))) then
|
---|
1749 | begin
|
---|
1750 | Node := FCurTree.Selected;
|
---|
1751 | Template := TTemplate(Node.Data);
|
---|
1752 | PNode := Node.Parent;
|
---|
1753 | Parent := TTemplate(PNode.Data);
|
---|
1754 | if(AutoDel(Template)) then
|
---|
1755 | DoIt := TRUE
|
---|
1756 | else
|
---|
1757 | if(Template.Active) and (cbActive.Checked) then
|
---|
1758 | begin
|
---|
1759 | DoIt := FALSE;
|
---|
1760 | // Answer := MessageDlg('Once you delete a template you may not be able to retrieve it.' + CRLF + <-- original line. //kt 8/8/2007
|
---|
1761 | Answer := MessageDlg(DKLangConstW('fTemplateEditor_Once_you_delete_a_template_you_may_not_be_able_to_retrieve_itx') + CRLF + //kt added 8/8/2007
|
---|
1762 | // 'Rather than deleting, you may want to inactivate a template instead.' + CRLF + <-- original line. //kt 8/8/2007
|
---|
1763 | DKLangConstW('fTemplateEditor_Rather_than_deletingx_you_may_want_to_inactivate_a_template_insteadx') + CRLF + //kt added 8/8/2007
|
---|
1764 | // 'You may inactivate this template by pressing the Ignore button now.' + CRLF + <-- original line. //kt 8/8/2007
|
---|
1765 | DKLangConstW('fTemplateEditor_You_may_inactivate_this_template_by_pressing_the_Ignore_button_nowx') + CRLF + //kt added 8/8/2007
|
---|
1766 | // 'Are you sure you want to delete the "' + Node.Text + <-- original line. //kt 8/8/2007
|
---|
1767 | DKLangConstW('fTemplateEditor_Are_you_sure_you_want_to_delete_the_x') + Node.Text + //kt added 8/8/2007
|
---|
1768 | // '" Template?', mtConfirmation, [mbYes, mbNo, mbIgnore], 0); <-- original line. //kt 8/8/2007
|
---|
1769 | DKLangConstW('fTemplateEditor_x_Templatex'), mtConfirmation, [mbYes, mbNo, mbIgnore], 0); //kt added 8/8/2007
|
---|
1770 | if(Answer = mrYes) then
|
---|
1771 | DoIt := TRUE
|
---|
1772 | else
|
---|
1773 | if(Answer = mrIgnore) then
|
---|
1774 | cbActive.Checked := FALSE;
|
---|
1775 | end
|
---|
1776 | else
|
---|
1777 | // DoIt := InfoBox('Are you sure you want to delete the "' + Node.Text + <-- original line. //kt 8/8/2007
|
---|
1778 | DoIt := InfoBox(DKLangConstW('fTemplateEditor_Are_you_sure_you_want_to_delete_the_x') + Node.Text + //kt added 8/8/2007
|
---|
1779 | // '" Template?', 'Confirmation', MB_YESNO or MB_ICONQUESTION) = IDYES; <-- original line. //kt 8/8/2007
|
---|
1780 | DKLangConstW('fTemplateEditor_x_Templatex'), DKLangConstW('fTemplateEditor_Confirmation'), MB_YESNO or MB_ICONQUESTION) = IDYES; //kt added 8/8/2007
|
---|
1781 | if(DoIt and CanClone(PNode)) then
|
---|
1782 | begin
|
---|
1783 | if(Clone(PNode)) then
|
---|
1784 | Parent := TTemplate(PNode.Data);
|
---|
1785 | if assigned(Parent) and Parent.CanModify then
|
---|
1786 | begin
|
---|
1787 | btnApply.Enabled := TRUE;
|
---|
1788 | Parent.RemoveChild(Template);
|
---|
1789 | MarkDeleted(Template);
|
---|
1790 | Resync([Parent]);
|
---|
1791 | tvTreeChange(FCurTree, FCurTree.Selected);
|
---|
1792 | end;
|
---|
1793 | end;
|
---|
1794 | end;
|
---|
1795 | end;
|
---|
1796 |
|
---|
1797 | procedure TfrmTemplateEditor.EnableNavControls;
|
---|
1798 | var
|
---|
1799 | i: TTemplateTreeControl;
|
---|
1800 | AllowUp, AllowDown, AllowSet: boolean;
|
---|
1801 | Node: TTreeNode;
|
---|
1802 | Tree: TTemplateTreeType;
|
---|
1803 | Curok: boolean;
|
---|
1804 | OldActiveControl: TControl;
|
---|
1805 | begin
|
---|
1806 | if(Assigned(FCurTree)) then
|
---|
1807 | begin
|
---|
1808 | Tree := TTemplateTreeType(FCurTree.Tag);
|
---|
1809 | Node := FCurTree.Selected;
|
---|
1810 | if(Assigned(Node)) then
|
---|
1811 | Curok := (TTemplate(Node.Data).RealType in [ttDoc, ttGroup, ttClass])
|
---|
1812 | else
|
---|
1813 | Curok := FALSE;
|
---|
1814 | if(Curok) then
|
---|
1815 | begin
|
---|
1816 | OldActiveControl := ActiveControl;
|
---|
1817 | FTreeControl[Tree, tcDel].Enabled := TRUE;
|
---|
1818 | AllowSet := FALSE;
|
---|
1819 | if(Node.Index > 0) then
|
---|
1820 | AllowUp := TRUE
|
---|
1821 | else
|
---|
1822 | begin
|
---|
1823 | AllowUp := AllowMove(Node.Parent.Parent, Node);
|
---|
1824 | AllowSet := TRUE;
|
---|
1825 | end;
|
---|
1826 | FTreeControl[Tree, tcUp].Enabled := AllowUp;
|
---|
1827 | AllowDown := AllowUp;
|
---|
1828 | if(Node.Index < (Node.Parent.Count-1)) then
|
---|
1829 | AllowDown := TRUE
|
---|
1830 | else
|
---|
1831 | begin
|
---|
1832 | if(not AllowSet) then
|
---|
1833 | AllowDown := AllowMove(Node.Parent.Parent, Node);
|
---|
1834 | end;
|
---|
1835 | FTreeControl[Tree, tcDown].Enabled := AllowDown;
|
---|
1836 | if not AllowUp and (OldActiveControl = FTreeControl[Tree, tcUp]) then
|
---|
1837 | (FTreeControl[Tree, tcDown] as TWinControl).SetFocus;
|
---|
1838 | if not AllowDown and (OldActiveControl = FTreeControl[Tree, tcDown]) then
|
---|
1839 | (FTreeControl[Tree, tcUp] as TWinControl).SetFocus;
|
---|
1840 | FTreeControl[Tree, tcCopy].Enabled := FTreeControl[TTemplateTreeType(1-ord(Tree)), tcDel].Visible;
|
---|
1841 | if(FTreeControl[Tree, tcCopy].Enabled) then
|
---|
1842 | begin
|
---|
1843 | if(Tree = ttShared) then
|
---|
1844 | Node := tvPersonal.Selected
|
---|
1845 | else
|
---|
1846 | Node := tvShared.Selected;
|
---|
1847 | if(assigned(Node)) then
|
---|
1848 | begin
|
---|
1849 | if(TTemplate(Node.Data).RealType = ttDoc) then
|
---|
1850 | Node := Node.Parent;
|
---|
1851 | FTreeControl[Tree, tcCopy].Enabled := AllowMove(Node, FCurTree.Selected);
|
---|
1852 | end
|
---|
1853 | else
|
---|
1854 | FTreeControl[Tree, tcCopy].Enabled := FALSE;
|
---|
1855 | end;
|
---|
1856 | FTreeControl[Tree, tcLbl].Enabled := FTreeControl[Tree, tcCopy].Enabled;
|
---|
1857 | end
|
---|
1858 | else
|
---|
1859 | begin
|
---|
1860 | for i := low(TTemplateTreeControl) to high(TTemplateTreeControl) do
|
---|
1861 | FTreeControl[Tree, i].Enabled := FALSE;
|
---|
1862 | end;
|
---|
1863 | if(FCurTree = tvShared) and (FCanEditShared) then
|
---|
1864 | btnNew.Enabled := TRUE
|
---|
1865 | else
|
---|
1866 | if(FCurTree = tvPersonal) and (FCanEditPersonal) then
|
---|
1867 | btnNew.Enabled := TRUE
|
---|
1868 | else
|
---|
1869 | btnNew.Enabled := FALSE;
|
---|
1870 | end
|
---|
1871 | else
|
---|
1872 | btnNew.Enabled := FALSE;
|
---|
1873 | end;
|
---|
1874 |
|
---|
1875 | procedure TfrmTemplateEditor.tvTreeDragging(Sender: TObject;
|
---|
1876 | Node: TTreeNode; var CanDrag: Boolean);
|
---|
1877 |
|
---|
1878 | begin
|
---|
1879 | CanDrag := (TTemplate(Node.Data).RealType in [ttDoc, ttGroup, ttClass]);
|
---|
1880 | if(CanDrag) then
|
---|
1881 | FDragNode := Node
|
---|
1882 | else
|
---|
1883 | FDragNode := nil;
|
---|
1884 | end;
|
---|
1885 |
|
---|
1886 | procedure TfrmTemplateEditor.tvTreeDragOver(Sender, Source: TObject; X,
|
---|
1887 | Y: Integer; State: TDragState; var Accept: Boolean);
|
---|
1888 | var
|
---|
1889 | TmpNode: TTreeNode;
|
---|
1890 | Tree: TTreeView;
|
---|
1891 |
|
---|
1892 | begin
|
---|
1893 | FDropNode := nil;
|
---|
1894 | Accept := FALSE;
|
---|
1895 | if(Source is TTreeView) and (assigned(FDragNode)) then
|
---|
1896 | begin
|
---|
1897 | Tree := TTreeView(Sender);
|
---|
1898 | FDropNode := Tree.GetNodeAt(X,Y);
|
---|
1899 | if(((Tree = tvShared) and (FCanEditShared)) or
|
---|
1900 | ((Tree = tvPersonal) and (FCanEditPersonal))) then
|
---|
1901 | begin
|
---|
1902 | if(assigned(FDropNode)) then
|
---|
1903 | begin
|
---|
1904 | FDropInto := (TTemplate(FDropNode.Data).RealType in AllTemplateFolderTypes);
|
---|
1905 | if(FDropInto) then
|
---|
1906 | TmpNode := FDropNode
|
---|
1907 | else
|
---|
1908 | TmpNode := FDropNode.Parent;
|
---|
1909 | Accept := AllowMove(TmpNode, FDragNode);
|
---|
1910 | end;
|
---|
1911 | end;
|
---|
1912 | end;
|
---|
1913 | end;
|
---|
1914 |
|
---|
1915 | procedure TfrmTemplateEditor.tvTreeDragDrop(Sender, Source: TObject; X,
|
---|
1916 | Y: Integer);
|
---|
1917 | var
|
---|
1918 | Src, Template, Item: TTemplate;
|
---|
1919 | SIdx, idx: integer;
|
---|
1920 | TmpNode: TTreeNode;
|
---|
1921 |
|
---|
1922 | begin
|
---|
1923 | if(assigned(FDragNode)) and (assigned(FDropNode)) and (FDragNode <> FDropNode) then
|
---|
1924 | begin
|
---|
1925 | Item := TTemplate(FDragNode.Data);
|
---|
1926 | if(FDropInto) then
|
---|
1927 | begin
|
---|
1928 | TmpNode := FDropNode;
|
---|
1929 | idx := 0;
|
---|
1930 | end
|
---|
1931 | else
|
---|
1932 | begin
|
---|
1933 | TmpNode := FDropNode.Parent;
|
---|
1934 | idx := TTemplate(FDropNode.Parent.Data).Items.IndexOf(FDropNode.Data);
|
---|
1935 | end;
|
---|
1936 | if(AllowMove(TmpNode, FDragNode) and (idx >= 0)) then
|
---|
1937 | begin
|
---|
1938 | Template := TTemplate(TmpNode.Data);
|
---|
1939 | if(Template <> FDragNode.Parent.Data) and
|
---|
1940 | (Template.Items.IndexOf(Item) >= 0) then
|
---|
1941 | // InfoBox(Template.PrintName + ' already contains the ' + <-- original line. //kt 8/8/2007
|
---|
1942 | InfoBox(Template.PrintName + DKLangConstW('fTemplateEditor_already_contains_the') + //kt added 8/8/2007
|
---|
1943 | // Item.PrintName + ' template.', <-- original line. //kt 8/8/2007
|
---|
1944 | Item.PrintName + DKLangConstW('fTemplateEditor_templatex'), //kt added 8/8/2007
|
---|
1945 | // 'Error', MB_OK or MB_ICONERROR) <-- original line. //kt 8/8/2007
|
---|
1946 | DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR) //kt added 8/8/2007
|
---|
1947 | else
|
---|
1948 | begin
|
---|
1949 | Src := TTemplate(FDragNode.Parent.Data);
|
---|
1950 | Sidx := Src.Items.IndexOf(Item);
|
---|
1951 | if CanClone(TmpNode) then
|
---|
1952 | begin
|
---|
1953 | if(Clone(TmpNode)) then
|
---|
1954 | Template := TTemplate(TmpNode.Data);
|
---|
1955 | if assigned(Template) and Template.CanModify then
|
---|
1956 | begin
|
---|
1957 | if(Sidx >= 0) and (FDragNode.TreeView = FDropNode.TreeView) and
|
---|
1958 | (not FCopying) then // if same tree delete source
|
---|
1959 | begin
|
---|
1960 | if CanClone(FDragNode.Parent) then
|
---|
1961 | begin
|
---|
1962 | if(Clone(FDragNode.Parent)) then
|
---|
1963 | Src := TTemplate(FDragNode.Parent.Data);
|
---|
1964 | if assigned(Src) and Src.CanModify then
|
---|
1965 | begin
|
---|
1966 | Src.Items.Delete(Sidx);
|
---|
1967 | if(Template = Src) then
|
---|
1968 | Src := nil;
|
---|
1969 | end
|
---|
1970 | else
|
---|
1971 | Src := nil;
|
---|
1972 | end
|
---|
1973 | else
|
---|
1974 | Src := nil;
|
---|
1975 | end
|
---|
1976 | else
|
---|
1977 | Src := nil;
|
---|
1978 | if(idx > 0) then
|
---|
1979 | idx := TTemplate(FDropNode.Parent.Data).Items.IndexOf(FDropNode.Data);
|
---|
1980 | Template.Items.Insert(idx, Item);
|
---|
1981 | if(TTreeView(FDropNode.TreeView) = tvShared) then
|
---|
1982 | begin
|
---|
1983 | Item.PersonalOwner := 0;
|
---|
1984 | tvPersonal.Invalidate;
|
---|
1985 | end;
|
---|
1986 | TTreeView(FDragNode.TreeView).Selected := FDragNode;
|
---|
1987 | TTreeView(FDragNode.TreeView).SetFocus;
|
---|
1988 | Resync([Src, Template]);
|
---|
1989 | btnApply.Enabled := TRUE;
|
---|
1990 | end;
|
---|
1991 | end;
|
---|
1992 | end;
|
---|
1993 | end;
|
---|
1994 | end;
|
---|
1995 | end;
|
---|
1996 |
|
---|
1997 | procedure TfrmTemplateEditor.Resync(const Templates: array of TTemplate);
|
---|
1998 | var
|
---|
1999 | i, j: integer;
|
---|
2000 | NodeList: TStringList;
|
---|
2001 | TemplateList: TStringList;
|
---|
2002 | Node: TTreeNode;
|
---|
2003 | tmpl: TTemplate;
|
---|
2004 | NodeID: string;
|
---|
2005 |
|
---|
2006 | begin
|
---|
2007 | NodeList := TStringList.Create;
|
---|
2008 | try
|
---|
2009 | TemplateList := TStringList.Create;
|
---|
2010 | try
|
---|
2011 | for i := low(Templates) to high(Templates) do
|
---|
2012 | begin
|
---|
2013 | tmpl := Templates[i];
|
---|
2014 | if(assigned(tmpl)) then
|
---|
2015 | begin
|
---|
2016 | for j := 0 to tmpl.Nodes.Count-1 do
|
---|
2017 | begin
|
---|
2018 | Node := TTreeNode(tmpl.Nodes.Objects[j]);
|
---|
2019 | if(NodeList.IndexOfObject(Node) < 0) then
|
---|
2020 | begin
|
---|
2021 | NodeID := IntToStr(Node.Level);
|
---|
2022 | NodeID := copy('000',1,4-length(NodeID))+NodeID+U+tmpl.Nodes[j];
|
---|
2023 | TemplateList.AddObject(NodeID,tmpl);
|
---|
2024 | NodeList.AddObject(NodeId,Node);
|
---|
2025 | end;
|
---|
2026 | end;
|
---|
2027 | end;
|
---|
2028 | end;
|
---|
2029 |
|
---|
2030 | { By Sorting by Node Level, we prevent a Resync
|
---|
2031 | of nodes deeper within the heirchary }
|
---|
2032 |
|
---|
2033 | NodeList.Sort;
|
---|
2034 |
|
---|
2035 | for i := 0 to NodeList.Count-1 do
|
---|
2036 | begin
|
---|
2037 | NodeID := NodeList[i];
|
---|
2038 | Node := TTreeNode(NodeList.Objects[i]);
|
---|
2039 | j := TemplateList.IndexOf(NodeID);
|
---|
2040 | if(j >= 0) then
|
---|
2041 | begin
|
---|
2042 | tmpl := TTemplate(TemplateList.Objects[j]);
|
---|
2043 | NodeID := Piece(NodeID,U,2);
|
---|
2044 | if(tmpl.Nodes.IndexOf(NodeID) >= 0) then
|
---|
2045 | begin
|
---|
2046 | if(Node.TreeView = tvShared) then
|
---|
2047 | dmodShared.Resync(Node, not cbShHide.Checked, FSharedEmptyNodeCount)
|
---|
2048 | else
|
---|
2049 | if(Node.TreeView = tvPersonal) then
|
---|
2050 | dmodShared.Resync(Node, not cbPerHide.Checked, FPersonalEmptyNodeCount);
|
---|
2051 | end;
|
---|
2052 | end;
|
---|
2053 | end;
|
---|
2054 | finally
|
---|
2055 | TemplateList.Free;
|
---|
2056 | end;
|
---|
2057 | finally
|
---|
2058 | NodeList.Free;
|
---|
2059 | end;
|
---|
2060 | EnableNavControls;
|
---|
2061 | if((assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
2062 | tvTreeChange(FCurTree, FCurTree.Selected)
|
---|
2063 | else
|
---|
2064 | tvPersonal.Selected := tvPersonal.Items.GetFirstNode;
|
---|
2065 | FCopyNode := nil;
|
---|
2066 | end;
|
---|
2067 |
|
---|
2068 | procedure TfrmTemplateEditor.sbCopyLeftClick(Sender: TObject);
|
---|
2069 | begin
|
---|
2070 | if(assigned(tvPersonal.Selected)) then
|
---|
2071 | begin
|
---|
2072 | if(not assigned(tvShared.Selected)) then
|
---|
2073 | tvShared.Selected := tvShared.Items.GetFirstNode;
|
---|
2074 | FDragNode := tvPersonal.Selected;
|
---|
2075 | FDropNode := tvShared.Selected;
|
---|
2076 | FDropInto := (TTemplate(FDropNode.Data).RealType in AllTemplateFolderTypes);
|
---|
2077 | tvTreeDragDrop(tvPersonal, tvShared, 0,0);
|
---|
2078 | end;
|
---|
2079 | end;
|
---|
2080 |
|
---|
2081 | procedure TfrmTemplateEditor.sbCopyRightClick(Sender: TObject);
|
---|
2082 | begin
|
---|
2083 | if(assigned(tvShared.Selected)) then
|
---|
2084 | begin
|
---|
2085 | if(not assigned(tvPersonal.Selected)) then
|
---|
2086 | tvPersonal.Selected := tvPersonal.Items.GetFirstNode;
|
---|
2087 | FDragNode := tvShared.Selected;
|
---|
2088 | FDropNode := tvPersonal.Selected;
|
---|
2089 | FDropInto := (TTemplate(FDropNode.Data).RealType in AllTemplateFolderTypes);
|
---|
2090 | tvTreeDragDrop(tvShared, tvPersonal, 0,0);
|
---|
2091 | end;
|
---|
2092 | end;
|
---|
2093 |
|
---|
2094 | function TfrmTemplateEditor.AllowMove(ADropNode, ADragNode: TTreeNode): boolean;
|
---|
2095 | var
|
---|
2096 | i: integer;
|
---|
2097 | TmpNode: TTreeNode;
|
---|
2098 | DragTemplate, DropTemplate: TTemplate;
|
---|
2099 |
|
---|
2100 | begin
|
---|
2101 | if(assigned(ADropNode) and assigned(ADragNode)) then
|
---|
2102 | begin
|
---|
2103 | DropTemplate := TTemplate(ADropNode.Data);
|
---|
2104 | DragTemplate := TTemplate(ADragNode.Data);
|
---|
2105 | if IsTemplateLocked(ADropNode) then
|
---|
2106 | Result := FALSE
|
---|
2107 | else
|
---|
2108 | Result := (DragTemplate.RealType in [ttDoc, ttGroup, ttClass]);
|
---|
2109 | if(Result) then
|
---|
2110 | begin
|
---|
2111 | if(FCopying) then
|
---|
2112 | begin
|
---|
2113 | if(DropTemplate.Items.IndexOf(DragTemplate) >= 0) then
|
---|
2114 | Result := FALSE;
|
---|
2115 | end
|
---|
2116 | else
|
---|
2117 | if((assigned(ADragNode.Parent)) and (ADropNode <> ADragNode.Parent) and
|
---|
2118 | (DropTemplate.Items.IndexOf(DragTemplate) >= 0)) then
|
---|
2119 | Result := FALSE;
|
---|
2120 | end;
|
---|
2121 | if(Result) then
|
---|
2122 | begin
|
---|
2123 | for i := 0 to DropTemplate.Nodes.Count-1 do
|
---|
2124 | begin
|
---|
2125 | TmpNode := TTreeNode(DropTemplate.Nodes.Objects[i]);
|
---|
2126 | while (Result and (assigned(TmpNode.Parent))) do
|
---|
2127 | begin
|
---|
2128 | if(TmpNode.Data = DragTemplate) then
|
---|
2129 | Result := FALSE
|
---|
2130 | else
|
---|
2131 | TmpNode := TmpNode.Parent;
|
---|
2132 | end;
|
---|
2133 | if(not Result) then break;
|
---|
2134 | end;
|
---|
2135 | end;
|
---|
2136 | end
|
---|
2137 | else
|
---|
2138 | Result := FALSE;
|
---|
2139 | end;
|
---|
2140 |
|
---|
2141 | function TfrmTemplateEditor.Clone(Node: TTreeNode): boolean;
|
---|
2142 | var
|
---|
2143 | idx: integer;
|
---|
2144 | Prnt, OldT, NewT: TTemplate;
|
---|
2145 | PNode: TTreeNode;
|
---|
2146 | ok: boolean;
|
---|
2147 |
|
---|
2148 | begin
|
---|
2149 | Result := FALSE;
|
---|
2150 | if((assigned(Node)) and (TTreeView(Node.TreeView) = tvPersonal)) then
|
---|
2151 | begin
|
---|
2152 | OldT := TTemplate(Node.Data);
|
---|
2153 | if(OldT.PersonalOwner <> User.DUZ) then
|
---|
2154 | begin
|
---|
2155 | PNode := Node.Parent;
|
---|
2156 | Prnt := nil;
|
---|
2157 | if (assigned(PNode)) then
|
---|
2158 | begin
|
---|
2159 | ok := CanClone(PNode);
|
---|
2160 | if ok then
|
---|
2161 | begin
|
---|
2162 | Clone(PNode);
|
---|
2163 | Prnt := TTemplate(PNode.Data);
|
---|
2164 | ok := Prnt.CanModify;
|
---|
2165 | end;
|
---|
2166 | end
|
---|
2167 | else
|
---|
2168 | ok := TRUE;
|
---|
2169 | if ok then
|
---|
2170 | begin
|
---|
2171 | BtnApply.Enabled := TRUE;
|
---|
2172 | Result := TRUE;
|
---|
2173 | NewT := OldT.Clone(User.DUZ);
|
---|
2174 | OldT.RemoveNode(Node);
|
---|
2175 | MarkDeleted(OldT);
|
---|
2176 | Node.Data := NewT;
|
---|
2177 | NewT.AddNode(Node);
|
---|
2178 | if(assigned(Prnt)) then
|
---|
2179 | begin
|
---|
2180 | idx := Prnt.Items.IndexOf(OldT);
|
---|
2181 | if(idx >= 0) then
|
---|
2182 | Prnt.Items[idx] := NewT;
|
---|
2183 | end;
|
---|
2184 | tvPersonal.Invalidate;
|
---|
2185 | ShowTemplateType(NewT);
|
---|
2186 | end;
|
---|
2187 | end;
|
---|
2188 | end;
|
---|
2189 | end;
|
---|
2190 |
|
---|
2191 | procedure TfrmTemplateEditor.reBoilChange(Sender: TObject);
|
---|
2192 | var
|
---|
2193 | DoInfo, DoRefresh: boolean;
|
---|
2194 | TmpBPlate: string;
|
---|
2195 | Template: TTemplate;
|
---|
2196 | x: integer;
|
---|
2197 |
|
---|
2198 | begin
|
---|
2199 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
2200 | begin
|
---|
2201 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
2202 | TmpBPlate := reBoil.Lines.Text;
|
---|
2203 | if(Template.Boilerplate <> TmpBPlate) then
|
---|
2204 | begin
|
---|
2205 | if CanClone(FCurTree.Selected) then
|
---|
2206 | begin
|
---|
2207 | DoRefresh := Clone(FCurTree.Selected);
|
---|
2208 | if(DoRefresh) then
|
---|
2209 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
2210 | if assigned(Template) and Template.CanModify then
|
---|
2211 | begin
|
---|
2212 | DoInfo := FALSE;
|
---|
2213 | if(Template.Boilerplate = '') or (TmpBPlate = '') then
|
---|
2214 | DoInfo := TRUE;
|
---|
2215 | Template.Boilerplate := TmpBPlate;
|
---|
2216 | TTemplate(FCurTree.Selected.Data).Gap := StrToIntDef(edtGap.Text, 0);
|
---|
2217 | if(Template.RealType = ttGroup) then
|
---|
2218 | begin
|
---|
2219 | reGroupBP.Text := Template.FullBoilerplate;
|
---|
2220 | end;
|
---|
2221 | if(DoRefresh) then
|
---|
2222 | begin
|
---|
2223 | tvShared.Invalidate;
|
---|
2224 | tvPersonal.Invalidate;
|
---|
2225 | end;
|
---|
2226 | if(DoInfo) then
|
---|
2227 | begin
|
---|
2228 | x := reBoil.SelStart;
|
---|
2229 | ShowInfo(FCurTree.Selected);
|
---|
2230 | reBoil.SelStart := x;
|
---|
2231 | end;
|
---|
2232 | end;
|
---|
2233 | end;
|
---|
2234 | btnApply.Enabled := TRUE;
|
---|
2235 | // reBoil.Lines.Text := Template.Boilerplate;
|
---|
2236 | end;
|
---|
2237 | end;
|
---|
2238 | end;
|
---|
2239 |
|
---|
2240 | procedure TfrmTemplateEditor.SharedEditing;
|
---|
2241 | begin
|
---|
2242 | {$IFDEF OwnerScan}
|
---|
2243 | lblPerOwner.Visible := FCanEditShared;
|
---|
2244 | cboOwner.Visible := FCanEditShared;
|
---|
2245 | {$ELSE}
|
---|
2246 | lblPerOwner.Visible := FALSE;
|
---|
2247 | cboOwner.Visible := FALSE;
|
---|
2248 | {$ENDIF}
|
---|
2249 | sbCopyLeft.Visible := FCanEditShared;
|
---|
2250 | if(not FCanEditShared) then
|
---|
2251 | cbShHide.Checked := TRUE;
|
---|
2252 | cbShHide.Visible := FCanEditShared;
|
---|
2253 | sbShDelete.Visible := FCanEditShared;
|
---|
2254 | sbShUp.Visible := FCanEditShared;
|
---|
2255 | sbShDown.Visible := FCanEditShared;
|
---|
2256 | tvShared.ReadOnly := not FCanEditShared;
|
---|
2257 | MoveCopyButtons;
|
---|
2258 | tvTreeChange(FCurTree, FCurTree.Selected);
|
---|
2259 | end;
|
---|
2260 |
|
---|
2261 | procedure TfrmTemplateEditor.cbEditSharedClick(Sender: TObject);
|
---|
2262 | begin
|
---|
2263 | FCanEditShared := cbEditShared.Checked;
|
---|
2264 | SharedEditing;
|
---|
2265 | end;
|
---|
2266 |
|
---|
2267 | procedure TfrmTemplateEditor.popTemplatesPopup(Sender: TObject);
|
---|
2268 | var
|
---|
2269 | Tree: TTreeView;
|
---|
2270 | Node: TTreeNode;
|
---|
2271 | FindOn: boolean;
|
---|
2272 | Txt: string;
|
---|
2273 |
|
---|
2274 | begin
|
---|
2275 | FFromMainMenu := FALSE;
|
---|
2276 | Tree := GetTree;
|
---|
2277 | Node := Tree.Selected;
|
---|
2278 | Tree.Selected := Node; // This line prevents selected from changing after menu closes
|
---|
2279 | mnuCollapseTree.Enabled := dmodShared.NeedsCollapsing(Tree);
|
---|
2280 | if(Tree = tvShared) then
|
---|
2281 | begin
|
---|
2282 | // Txt := 'Shared'; <-- original line. //kt 8/8/2007
|
---|
2283 | Txt := DKLangConstW('fTemplateEditor_Shared'); //kt added 8/8/2007
|
---|
2284 | FindOn := FFindShOn;
|
---|
2285 | mnuNodeDelete.Enabled := ((sbShDelete.Visible) and (sbShDelete.Enabled));
|
---|
2286 | end
|
---|
2287 | else
|
---|
2288 | begin
|
---|
2289 | // Txt := 'Personal'; <-- original line. //kt 8/8/2007
|
---|
2290 | Txt := DKLangConstW('fTemplateEditor_Personal'); //kt added 8/8/2007
|
---|
2291 | FindOn := FFindPerOn;
|
---|
2292 | mnuNodeDelete.Enabled := ((sbPerDelete.Visible) and (sbPerDelete.Enabled));
|
---|
2293 | end;
|
---|
2294 | mnuFindTemplates.Checked := FindOn;
|
---|
2295 | //mnuCollapseTree.Caption := 'Collapse '+Txt+' &Tree'; <-- original line. //kt 8/8/2007
|
---|
2296 | mnuCollapseTree.Caption := DKLangConstW('fTemplateEditor_Collapse')+' '+Txt+DKLangConstW('fTemplateEditor_xTree'); //kt added 8/8/2007
|
---|
2297 | //mnuFindTemplates.Caption := '&Find '+Txt+' Templates'; <-- original line. //kt 8/8/2007
|
---|
2298 | mnuFindTemplates.Caption := DKLangConstW('fTemplateEditor_xFind')+' '+Txt+DKLangConstW('fTemplateEditor_Templates'); //kt added 8/8/2007
|
---|
2299 |
|
---|
2300 | if(assigned(Tree) and assigned(Tree.Selected) and assigned(Tree.Selected.Data)) then
|
---|
2301 | begin
|
---|
2302 | mnuNodeCopy.Enabled := (TTemplate(Tree.Selected.Data).RealType in [ttDoc, ttGroup, ttClass]);
|
---|
2303 | mnuNodeSort.Enabled := (TTemplate(Tree.Selected.Data).RealType in AllTemplateFolderTypes) and
|
---|
2304 | (Tree.Selected.HasChildren) and
|
---|
2305 | (Tree.Selected.GetFirstChild.GetNextSibling <> nil);
|
---|
2306 | end
|
---|
2307 | else
|
---|
2308 | begin
|
---|
2309 | mnuNodeCopy.Enabled := FALSE;
|
---|
2310 | mnuNodeSort.Enabled := FALSE;
|
---|
2311 | end;
|
---|
2312 | FPasteNode := Tree.Selected;
|
---|
2313 | mnuNodePaste.Enabled := PasteOK;
|
---|
2314 | mnuNodeNew.Enabled := btnNew.Enabled;
|
---|
2315 | mnuNodeAutoGen.Enabled := btnNew.Enabled;
|
---|
2316 | end;
|
---|
2317 |
|
---|
2318 | procedure TfrmTemplateEditor.mnuCollapseTreeClick(Sender: TObject);
|
---|
2319 | begin
|
---|
2320 | if(GetTree = tvShared) then
|
---|
2321 | begin
|
---|
2322 | tvShared.Selected := tvShared.Items.GetFirstNode;
|
---|
2323 | tvShared.FullCollapse;
|
---|
2324 | end
|
---|
2325 | else
|
---|
2326 | begin
|
---|
2327 | tvPersonal.Selected := tvShared.Items.GetFirstNode;
|
---|
2328 | tvPersonal.FullCollapse;
|
---|
2329 | end;
|
---|
2330 | end;
|
---|
2331 |
|
---|
2332 | procedure TfrmTemplateEditor.mnuFindTemplatesClick(Sender: TObject);
|
---|
2333 | var
|
---|
2334 | Tree: TTreeView;
|
---|
2335 |
|
---|
2336 | begin
|
---|
2337 | Tree := GetTree;
|
---|
2338 | if(Tree = tvShared) then
|
---|
2339 | begin
|
---|
2340 | FFindShOn := not FFindShOn;
|
---|
2341 | pnlShSearch.Visible := FFindShOn;
|
---|
2342 | if(FFindShOn) then
|
---|
2343 | begin
|
---|
2344 | edtShSearch.SetFocus;
|
---|
2345 | btnShFind.Enabled := (edtShSearch.Text <> '');
|
---|
2346 | end;
|
---|
2347 | end
|
---|
2348 | else
|
---|
2349 | begin
|
---|
2350 | FFindPerOn := not FFindPerOn;
|
---|
2351 | pnlPerSearch.Visible := FFindPerOn;
|
---|
2352 | if(FFindPerOn) then
|
---|
2353 | begin
|
---|
2354 | edtPerSearch.SetFocus;
|
---|
2355 | btnPerFind.Enabled := (edtPerSearch.Text <> '');
|
---|
2356 | end;
|
---|
2357 | end;
|
---|
2358 | SetFindNext(Tree, FALSE);
|
---|
2359 | end;
|
---|
2360 |
|
---|
2361 | procedure TfrmTemplateEditor.ShowTemplateType(Template: TTemplate);
|
---|
2362 | begin
|
---|
2363 | if(Template.PersonalOwner > 0) then
|
---|
2364 | // gbProperties.Caption := 'Personal' <-- original line. //kt 8/8/2007
|
---|
2365 | gbProperties.Caption := DKLangConstW('fTemplateEditor_Personal') //kt added 8/8/2007
|
---|
2366 | else
|
---|
2367 | // gbProperties.Caption := 'Shared'; <-- original line. //kt 8/8/2007
|
---|
2368 | gbProperties.Caption := DKLangConstW('fTemplateEditor_Shared'); //kt added 8/8/2007
|
---|
2369 | gbProperties.Caption := gbProperties.Caption + PropText;
|
---|
2370 | end;
|
---|
2371 |
|
---|
2372 | function TfrmTemplateEditor.GetTree: TTreeView;
|
---|
2373 | begin
|
---|
2374 | if(FFromMainMenu) then
|
---|
2375 | Result := FMainMenuTree
|
---|
2376 | else
|
---|
2377 | begin
|
---|
2378 | if(TTemplateTreeType(PopupComponent(popTemplates, popTemplates).Tag) = ttShared) then
|
---|
2379 | Result := tvShared
|
---|
2380 | else
|
---|
2381 | Result := tvPersonal;
|
---|
2382 | end;
|
---|
2383 | end;
|
---|
2384 |
|
---|
2385 | procedure TfrmTemplateEditor.btnFindClick(Sender: TObject);
|
---|
2386 | var
|
---|
2387 | Found: boolean;
|
---|
2388 | edtSearch: TEdit;
|
---|
2389 | FindNext: boolean;
|
---|
2390 | FindWholeWords: boolean;
|
---|
2391 | FindCase: boolean;
|
---|
2392 | Tree: TTreeView;
|
---|
2393 | LastFoundNode, TmpNode: TTreeNode;
|
---|
2394 | S1,S2: string;
|
---|
2395 |
|
---|
2396 | begin
|
---|
2397 | if(TTemplateTreeType(TButton(Sender).Tag) = ttShared) then
|
---|
2398 | begin
|
---|
2399 | Tree := tvShared;
|
---|
2400 | edtSearch := edtShSearch;
|
---|
2401 | FindNext := FFindShNext;
|
---|
2402 | FindWholeWords := cbShWholeWords.Checked;
|
---|
2403 | FindCase := cbShMatchCase.Checked;
|
---|
2404 | LastFoundNode := FLastFoundShNode;
|
---|
2405 | if(FSharedEmptyNodeCount > 0) then
|
---|
2406 | begin
|
---|
2407 | FInternalHiddenExpand := TRUE;
|
---|
2408 | try
|
---|
2409 | tvShared.Items.GetFirstNode.Expand(TRUE);
|
---|
2410 | finally
|
---|
2411 | FInternalHiddenExpand := FALSE;
|
---|
2412 | end;
|
---|
2413 | end;
|
---|
2414 | end
|
---|
2415 | else
|
---|
2416 | begin
|
---|
2417 | Tree := tvPersonal;
|
---|
2418 | edtSearch := edtPerSearch;
|
---|
2419 | FindNext := FFindPerNext;
|
---|
2420 | FindWholeWords := cbPerWholeWords.Checked;
|
---|
2421 | FindCase := cbPerMatchCase.Checked;
|
---|
2422 | LastFoundNode := FLastFoundPerNode;
|
---|
2423 | if(FPersonalEmptyNodeCount > 0) then
|
---|
2424 | begin
|
---|
2425 | FInternalHiddenExpand := TRUE;
|
---|
2426 | try
|
---|
2427 | tvPersonal.Items.GetFirstNode.Expand(TRUE);
|
---|
2428 | finally
|
---|
2429 | FInternalHiddenExpand := FALSE;
|
---|
2430 | end;
|
---|
2431 | end;
|
---|
2432 | end;
|
---|
2433 | if(edtSearch.text <> '') then
|
---|
2434 | begin
|
---|
2435 | if((FindNext) and assigned (LastFoundNode)) then
|
---|
2436 | TmpNode := LastFoundNode.GetNext
|
---|
2437 | else
|
---|
2438 | TmpNode := Tree.Items.GetFirstNode;
|
---|
2439 | Found := FALSE;
|
---|
2440 | if(assigned(TmpNode)) then
|
---|
2441 | begin
|
---|
2442 | S1 := edtSearch.Text;
|
---|
2443 | if(not FindCase) then
|
---|
2444 | S1 := UpperCase(S1);
|
---|
2445 | while (assigned(TmpNode) and (not Found)) do
|
---|
2446 | begin
|
---|
2447 | S2 := TmpNode.Text;
|
---|
2448 | if(not FindCase) then
|
---|
2449 | S2 := UpperCase(S2);
|
---|
2450 | Found := SearchMatch(S1, S2, FindWholeWords);
|
---|
2451 | if(not Found) then
|
---|
2452 | TmpNode := TmpNode.GetNext;
|
---|
2453 | end;
|
---|
2454 | end;
|
---|
2455 | if(Found) then
|
---|
2456 | begin
|
---|
2457 | if(Tree = tvShared) then
|
---|
2458 | FLastFoundShNode := TmpNode
|
---|
2459 | else
|
---|
2460 | FLastFoundPerNode := TmpNode;
|
---|
2461 | SetFindNext(Tree, TRUE);
|
---|
2462 | Tree.Selected := TmpNode;
|
---|
2463 | end
|
---|
2464 | else
|
---|
2465 | begin
|
---|
2466 | if(FindNext) then
|
---|
2467 | S1 := ''
|
---|
2468 | else
|
---|
2469 | // S1 := ' "' + edtSearch.Text + '" was not Found.'; <-- original line. //kt 8/8/2007
|
---|
2470 | S1 := ' "' + edtSearch.Text + DKLangConstW('fTemplateEditor_x_was_not_Foundx'); //kt added 8/8/2007
|
---|
2471 | SetFindNext(Tree, FALSE);
|
---|
2472 | // InfoBox('Search Complete.' + S1, 'Information', MB_OK or MB_ICONINFORMATION); <-- original line. //kt 8/8/2007
|
---|
2473 | InfoBox(DKLangConstW('fTemplateEditor_Search_Completex') + S1, DKLangConstW('fTemplateEditor_Information'), MB_OK or MB_ICONINFORMATION); //kt added 8/8/2007
|
---|
2474 | end;
|
---|
2475 | end;
|
---|
2476 | edtSearch.SetFocus;
|
---|
2477 | end;
|
---|
2478 |
|
---|
2479 | procedure TfrmTemplateEditor.edtSearchChange(Sender: TObject);
|
---|
2480 | begin
|
---|
2481 | if(TTemplateTreeType(TEdit(Sender).Tag) = ttShared) then
|
---|
2482 | begin
|
---|
2483 | btnShFind.Enabled := (edtShSearch.Text <> '');
|
---|
2484 | SetFindNext(tvShared, FALSE);
|
---|
2485 | end
|
---|
2486 | else
|
---|
2487 | begin
|
---|
2488 | btnPerFind.Enabled := (edtPerSearch.Text <> '');
|
---|
2489 | SetFindNext(tvPersonal, FALSE);
|
---|
2490 | end;
|
---|
2491 | end;
|
---|
2492 |
|
---|
2493 | procedure TfrmTemplateEditor.SetFindNext(const Tree: TTreeView; const Value: boolean);
|
---|
2494 | begin
|
---|
2495 | if(Tree = tvShared) then
|
---|
2496 | begin
|
---|
2497 | if(FFindShNext <> Value) then
|
---|
2498 | begin
|
---|
2499 | FFindShNext := Value;
|
---|
2500 | // if(FFindShNext) then btnShFind.Caption := 'Find Next' <-- original line. //kt 8/8/2007
|
---|
2501 | if(FFindShNext) then btnShFind.Caption := DKLangConstW('fTemplateEditor_Find_Next') //kt added 8/8/2007
|
---|
2502 | // else btnShFind.Caption := 'Find'; <-- original line. //kt 8/8/2007
|
---|
2503 | else btnShFind.Caption := DKLangConstW('fTemplateEditor_Find'); //kt added 8/8/2007
|
---|
2504 | end;
|
---|
2505 | end
|
---|
2506 | else
|
---|
2507 | begin
|
---|
2508 | if(FFindPerNext <> Value) then
|
---|
2509 | begin
|
---|
2510 | FFindPerNext := Value;
|
---|
2511 | // if(FFindPerNext) then btnPerFind.Caption := 'Find Next' <-- original line. //kt 8/8/2007
|
---|
2512 | if(FFindPerNext) then btnPerFind.Caption := DKLangConstW('fTemplateEditor_Find_Next') //kt added 8/8/2007
|
---|
2513 | // else btnPerFind.Caption := 'Find'; <-- original line. //kt 8/8/2007
|
---|
2514 | else btnPerFind.Caption := DKLangConstW('fTemplateEditor_Find'); //kt added 8/8/2007
|
---|
2515 | end;
|
---|
2516 | end;
|
---|
2517 | end;
|
---|
2518 |
|
---|
2519 | procedure TfrmTemplateEditor.edtShSearchEnter(Sender: TObject);
|
---|
2520 | begin
|
---|
2521 | btnShFind.Default := TRUE;
|
---|
2522 | end;
|
---|
2523 |
|
---|
2524 | procedure TfrmTemplateEditor.edtShSearchExit(Sender: TObject);
|
---|
2525 | begin
|
---|
2526 | btnShFind.Default := FALSE;
|
---|
2527 | end;
|
---|
2528 |
|
---|
2529 | procedure TfrmTemplateEditor.edtPerSearchEnter(Sender: TObject);
|
---|
2530 | begin
|
---|
2531 | btnPerFind.Default := TRUE;
|
---|
2532 | end;
|
---|
2533 |
|
---|
2534 | procedure TfrmTemplateEditor.edtPerSearchExit(Sender: TObject);
|
---|
2535 | begin
|
---|
2536 | btnPerFind.Default := FALSE;
|
---|
2537 | end;
|
---|
2538 |
|
---|
2539 | procedure TfrmTemplateEditor.btnOKClick(Sender: TObject);
|
---|
2540 | begin
|
---|
2541 | if(ScanNames) then
|
---|
2542 | begin
|
---|
2543 | if(SaveAllTemplates) then
|
---|
2544 | begin
|
---|
2545 | FOK2Close := TRUE;
|
---|
2546 | ModalResult := mrOK;
|
---|
2547 | end
|
---|
2548 | else
|
---|
2549 | BtnApply.Enabled := BackupDiffers;
|
---|
2550 | end;
|
---|
2551 | end;
|
---|
2552 |
|
---|
2553 | procedure TfrmTemplateEditor.FormShow(Sender: TObject);
|
---|
2554 | begin
|
---|
2555 | if(FFirstShow) then
|
---|
2556 | begin
|
---|
2557 | FUpdating := FALSE;
|
---|
2558 | FFirstShow := FALSE;
|
---|
2559 | if(FFocusName) then
|
---|
2560 | begin
|
---|
2561 | edtName.SetFocus;
|
---|
2562 | edtName.SelectAll;
|
---|
2563 | end;
|
---|
2564 | pnlBoilerplateResize(Self);
|
---|
2565 | end;
|
---|
2566 | end;
|
---|
2567 |
|
---|
2568 | procedure TfrmTemplateEditor.mnuBPInsertObjectClick(Sender: TObject);
|
---|
2569 | var
|
---|
2570 | i: integer;
|
---|
2571 | DoIt: boolean;
|
---|
2572 |
|
---|
2573 | begin
|
---|
2574 | if(not assigned(frmTemplateObjects)) then
|
---|
2575 | begin
|
---|
2576 | dmodShared.LoadTIUObjects;
|
---|
2577 | frmTemplateObjects := TfrmTemplateObjects.Create(Self);
|
---|
2578 | DoIt := TRUE;
|
---|
2579 | if (UserTemplateAccessLevel <> taEditor) then
|
---|
2580 | begin
|
---|
2581 | UpdatePersonalObjects;
|
---|
2582 | if FPersonalObjects.Count > 0 then
|
---|
2583 | begin
|
---|
2584 | DoIt := FALSE;
|
---|
2585 | for i := 0 to dmodShared.TIUObjects.Count-1 do
|
---|
2586 | if FPersonalObjects.IndexOf(Piece(dmodShared.TIUObjects[i],U,2)) >= 0 then
|
---|
2587 | frmTemplateObjects.cboObjects.Items.Add(dmodShared.TIUObjects[i]);
|
---|
2588 | end;
|
---|
2589 | end;
|
---|
2590 | if DoIt then
|
---|
2591 | frmTemplateObjects.cboObjects.Items.Assign(dmodShared.TIUObjects);
|
---|
2592 | frmTemplateObjects.Font := Font;
|
---|
2593 | frmTemplateObjects.re := reBoil;
|
---|
2594 | frmTemplateObjects.AutoLongLines := AutoLongLines;
|
---|
2595 | end;
|
---|
2596 | frmTemplateObjects.Show;
|
---|
2597 | end;
|
---|
2598 |
|
---|
2599 | procedure TfrmTemplateEditor.mnuBPErrorCheckClick(Sender: TObject);
|
---|
2600 | begin
|
---|
2601 | FBPOK := FALSE;
|
---|
2602 | if(reBoil.Lines.Count > 0) then
|
---|
2603 | begin
|
---|
2604 | if(dmodShared.TemplateOK(FCurTree.Selected.Data,'OK')) then
|
---|
2605 | begin
|
---|
2606 | TestBoilerplate(reBoil.Lines);
|
---|
2607 | if(RPCBrokerV.Results.Count > 0) then
|
---|
2608 | // InfoBox('Boilerplate Contains Errors:'+CRLF+CRLF+ <-- original line. //kt 8/8/2007
|
---|
2609 | InfoBox(DKLangConstW('fTemplateEditor_Boilerplate_Contains_Errorsx')+CRLF+CRLF+ //kt added 8/8/2007
|
---|
2610 | // RPCBrokerV.Results.Text, 'Error', MB_OK or MB_ICONERROR) <-- original line. //kt 8/8/2007
|
---|
2611 | RPCBrokerV.Results.Text, DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR) //kt added 8/8/2007
|
---|
2612 | else
|
---|
2613 | begin
|
---|
2614 | FBPOK := TRUE;
|
---|
2615 | if(assigned(Sender)) then
|
---|
2616 | // InfoBox('No Errors Found in Boilerplate.', 'Information', MB_OK or MB_ICONINFORMATION); <-- original line. //kt 8/8/2007
|
---|
2617 | InfoBox(DKLangConstW('fTemplateEditor_No_Errors_Found_in_Boilerplatex'), DKLangConstW('fTemplateEditor_Information'), MB_OK or MB_ICONINFORMATION); //kt added 8/8/2007
|
---|
2618 | end;
|
---|
2619 | end;
|
---|
2620 | end;
|
---|
2621 | end;
|
---|
2622 |
|
---|
2623 | procedure TfrmTemplateEditor.popBoilerplatePopup(Sender: TObject);
|
---|
2624 | var
|
---|
2625 | tryOK, ok: boolean;
|
---|
2626 |
|
---|
2627 | begin
|
---|
2628 | ok := not reBoil.ReadOnly;
|
---|
2629 | mnuBPInsertObject.Enabled := ok;
|
---|
2630 | mnuBPInsertField.Enabled := ok;
|
---|
2631 |
|
---|
2632 | mnuBPPaste.Enabled := (ok and Clipboard.HasFormat(CF_TEXT));
|
---|
2633 | if(ok) then
|
---|
2634 | ok := (reBoil.Lines.Count > 0);
|
---|
2635 | tryOK := (reBoil.Lines.Count > 0) or ((pnlGroupBP.Visible) and (reGroupBP.Lines.Count > 0));
|
---|
2636 | mnuBPErrorCheck.Enabled := tryOK;
|
---|
2637 | mnuBPTry.Enabled := tryOK;
|
---|
2638 | mnuBPSpellCheck.Enabled := ok and SpellCheckAvailable;
|
---|
2639 | mnuBPCheckGrammar.Enabled := ok and SpellCheckAvailable;
|
---|
2640 |
|
---|
2641 | mnuBPCopy.Enabled := (reBoil.SelLength > 0);
|
---|
2642 | mnuBPCut.Enabled := (ok and (reBoil.SelLength > 0));
|
---|
2643 | mnuBPSelectAll.Enabled := (reBoil.Lines.Count > 0);
|
---|
2644 | mnuBPUndo.Enabled := (reBoil.Perform(EM_CANUNDO, 0, 0) <> 0);
|
---|
2645 | end;
|
---|
2646 |
|
---|
2647 | function TfrmTemplateEditor.ScanNames: boolean;
|
---|
2648 | var
|
---|
2649 | Errors: TList;
|
---|
2650 | msg: string;
|
---|
2651 | i: integer;
|
---|
2652 | Node: TTreeNode;
|
---|
2653 |
|
---|
2654 | procedure ScanTree(Tree: TTreeView);
|
---|
2655 | begin
|
---|
2656 | Node := Tree.Items.GetFirstNode;
|
---|
2657 | while (assigned(Node)) do
|
---|
2658 | begin
|
---|
2659 | if(Node.Text <> EmptyNodeText) and (assigned(Node.Data)) then
|
---|
2660 | begin
|
---|
2661 | if(BadTemplateName(Node.Text)) then
|
---|
2662 | Errors.Add(Node);
|
---|
2663 | end;
|
---|
2664 | Node := Node.GetNext;
|
---|
2665 | end;
|
---|
2666 | end;
|
---|
2667 |
|
---|
2668 | begin
|
---|
2669 | Errors := TList.Create;
|
---|
2670 | try
|
---|
2671 | ScanTree(tvShared);
|
---|
2672 | ScanTree(tvPersonal);
|
---|
2673 | if(Errors.Count > 0) then
|
---|
2674 | begin
|
---|
2675 | if(Errors.Count > 1) then
|
---|
2676 | // msg := IntToStr(Errors.Count) + ' Templates have invalid names' <-- original line. //kt 8/8/2007
|
---|
2677 | msg := IntToStr(Errors.Count) + DKLangConstW('fTemplateEditor_Templates_have_invalid_names') //kt added 8/8/2007
|
---|
2678 | else
|
---|
2679 | // msg := 'Template has an invalid name'; <-- original line. //kt 8/8/2007
|
---|
2680 | msg := DKLangConstW('fTemplateEditor_Template_has_an_invalid_name'); //kt added 8/8/2007
|
---|
2681 | msg := msg + ': ';
|
---|
2682 | for i := 0 to Errors.Count-1 do
|
---|
2683 | begin
|
---|
2684 | if(i > 0) then msg := msg + ', ';
|
---|
2685 | Node := TTreeNode(Errors[i]);
|
---|
2686 | msg := msg + Node.Text;
|
---|
2687 | Node.MakeVisible;
|
---|
2688 | end;
|
---|
2689 | msg := msg + '.' + BadNameText;
|
---|
2690 | // InfoBox(msg, 'Error', MB_OK or MB_ICONERROR); <-- original line. //kt 8/8/2007
|
---|
2691 | InfoBox(msg, DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR); //kt added 8/8/2007
|
---|
2692 | TTreeView(Node.TreeView).Selected := TTreeNode(Errors[0]);
|
---|
2693 | end;
|
---|
2694 | finally
|
---|
2695 | Result := (Errors.Count = 0);
|
---|
2696 | Errors.Free;
|
---|
2697 | end;
|
---|
2698 | end;
|
---|
2699 |
|
---|
2700 | procedure TfrmTemplateEditor.btnCancelClick(Sender: TObject);
|
---|
2701 | begin
|
---|
2702 | FOK2Close := TRUE;
|
---|
2703 | end;
|
---|
2704 |
|
---|
2705 | procedure TfrmTemplateEditor.FormCloseQuery(Sender: TObject;
|
---|
2706 | var CanClose: Boolean);
|
---|
2707 | var
|
---|
2708 | ans: word;
|
---|
2709 |
|
---|
2710 | begin
|
---|
2711 | if(not FOK2Close) and (BackupDiffers) then
|
---|
2712 | begin
|
---|
2713 | // ans := InfoBox('Save Changes?', 'Confirmation', MB_YESNOCANCEL or MB_ICONQUESTION); <-- original line. //kt 8/8/2007
|
---|
2714 | ans := InfoBox(DKLangConstW('fTemplateEditor_Save_Changesx'), DKLangConstW('fTemplateEditor_Confirmation'), MB_YESNOCANCEL or MB_ICONQUESTION); //kt added 8/8/2007
|
---|
2715 | if(ans = IDCANCEL) then
|
---|
2716 | CanClose := FALSE
|
---|
2717 | else
|
---|
2718 | if(ans = IDYES) then
|
---|
2719 | begin
|
---|
2720 | CanClose := FALSE;
|
---|
2721 | if(ScanNames) then
|
---|
2722 | begin
|
---|
2723 | if(SaveAllTemplates) then
|
---|
2724 | CanClose := TRUE
|
---|
2725 | else
|
---|
2726 | BtnApply.Enabled := BackupDiffers;
|
---|
2727 | end;
|
---|
2728 | end;
|
---|
2729 | end;
|
---|
2730 | end;
|
---|
2731 |
|
---|
2732 | procedure TfrmTemplateEditor.mnuBPSpellCheckClick(Sender: TObject);
|
---|
2733 | begin
|
---|
2734 | SpellCheckForControl(reBoil);
|
---|
2735 | end;
|
---|
2736 |
|
---|
2737 | procedure TfrmTemplateEditor.splBoilMoved(Sender: TObject);
|
---|
2738 | begin
|
---|
2739 | pnlBoilerplateResize(Self);
|
---|
2740 | end;
|
---|
2741 |
|
---|
2742 | procedure TfrmTemplateEditor.edtGapKeyPress(Sender: TObject;
|
---|
2743 | var Key: Char);
|
---|
2744 | begin
|
---|
2745 | if(not (Key in ['0','1','2','3'])) then Key := #0;
|
---|
2746 | end;
|
---|
2747 |
|
---|
2748 | procedure TfrmTemplateEditor.edtNameExit(Sender: TObject);
|
---|
2749 | var
|
---|
2750 | Warn: boolean;
|
---|
2751 |
|
---|
2752 | begin
|
---|
2753 | Warn := (ActiveControl <> btnCancel) and (BadTemplateName(edtName.Text));
|
---|
2754 | if(Warn and ((ActiveControl = sbShDelete) or (ActiveControl = sbPerDelete))) then
|
---|
2755 | begin
|
---|
2756 | if((assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
2757 | Warn := not AutoDel(TTemplate(FCurTree.Selected.Data));
|
---|
2758 | end;
|
---|
2759 | if(Warn) then
|
---|
2760 | begin
|
---|
2761 | // InfoBox('Template has an invalid name: ' + edtName.Text + '.' + BadNameText, 'Error', MB_OK or MB_ICONERROR); <-- original line. //kt 8/8/2007
|
---|
2762 | InfoBox(DKLangConstW('fTemplateEditor_Template_has_an_invalid_namex')+' ' + edtName.Text + '.' + BadNameText, DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR); //kt added 8/8/2007
|
---|
2763 | edtName.SetFocus;
|
---|
2764 | end;
|
---|
2765 | end;
|
---|
2766 |
|
---|
2767 | procedure TfrmTemplateEditor.tmrAutoScrollTimer(Sender: TObject);
|
---|
2768 | const
|
---|
2769 | EdgeScroll = 16;
|
---|
2770 |
|
---|
2771 | var
|
---|
2772 | TopNode: TTreeNode;
|
---|
2773 | Redraw: boolean;
|
---|
2774 | TmpPt: TPoint;
|
---|
2775 | ht: THitTests;
|
---|
2776 | HPos, RMax: integer;
|
---|
2777 |
|
---|
2778 | begin
|
---|
2779 | if(assigned(FDropNode)) then
|
---|
2780 | begin
|
---|
2781 | TopNode := FDropNode.TreeView.TopItem;
|
---|
2782 | Redraw := FALSE;
|
---|
2783 | TmpPt := FDropNode.TreeView.ScreenToClient(Mouse.CursorPos);
|
---|
2784 | if(TopNode = FDropNode) and (TopNode <> TTreeView(FDropNode.TreeView).Items.GetFirstNode) then
|
---|
2785 | begin
|
---|
2786 | FDropNode.TreeView.TopItem := TopNode.GetPrevVisible;
|
---|
2787 | Redraw := TRUE;
|
---|
2788 | end
|
---|
2789 | else
|
---|
2790 | begin
|
---|
2791 | RMax := FDropNode.TreeView.ClientHeight - EdgeScroll;
|
---|
2792 | if((TmpPt.Y > RMax) and (FDropNode.GetNextVisible <> nil)) then
|
---|
2793 | begin
|
---|
2794 | TORTreeView(FDropNode.TreeView).VertScrollPos :=
|
---|
2795 | TORTreeView(FDropNode.TreeView).VertScrollPos + 1;
|
---|
2796 | Redraw := TRUE;
|
---|
2797 | end;
|
---|
2798 | end;
|
---|
2799 | if(FLastDropNode <> FDropNode) then
|
---|
2800 | begin
|
---|
2801 | if((assigned(FDropNode)) and (FDropNode.GetNext = nil)) then
|
---|
2802 | Redraw := TRUE
|
---|
2803 | else
|
---|
2804 | if((assigned(FLastDropNode)) and (FLastDropNode.GetNext = nil)) then
|
---|
2805 | Redraw := TRUE;
|
---|
2806 | FLastDropNode := FDropNode;
|
---|
2807 | FDragOverCount := 0;
|
---|
2808 | end
|
---|
2809 | else
|
---|
2810 | begin
|
---|
2811 | if(FDropNode.HasChildren) and (not FDropNode.Expanded) then
|
---|
2812 | begin
|
---|
2813 | ht := FDropNode.TreeView.GetHitTestInfoAt(TmpPt.X, TmpPt.Y);
|
---|
2814 | if(htOnButton in ht) then
|
---|
2815 | begin
|
---|
2816 | inc(FDragOverCount);
|
---|
2817 | if(FDragOverCount > 4) then
|
---|
2818 | begin
|
---|
2819 | TopNode := FDropNode.TreeView.TopItem;
|
---|
2820 | FDropNode.Expand(FALSE);
|
---|
2821 | FDropNode.TreeView.TopItem := TopNode;
|
---|
2822 | FDragOverCount := 0;
|
---|
2823 | Redraw := TRUE;
|
---|
2824 | end;
|
---|
2825 | end
|
---|
2826 | else
|
---|
2827 | FDragOverCount := 0;
|
---|
2828 | end;
|
---|
2829 | if(not Redraw) then
|
---|
2830 | begin
|
---|
2831 | HPos := TORTreeView(FDropNode.TreeView).HorzScrollPos;
|
---|
2832 | if(HPos > 0) and (TmpPt.X < EdgeScroll) then
|
---|
2833 | begin
|
---|
2834 | TORTreeView(FDropNode.TreeView).HorzScrollPos :=
|
---|
2835 | TORTreeView(FDropNode.TreeView).HorzScrollPos - EdgeScroll;
|
---|
2836 | Redraw := TRUE;
|
---|
2837 | end
|
---|
2838 | else
|
---|
2839 | begin
|
---|
2840 | RMax := FDropNode.TreeView.ClientWidth - EdgeScroll;
|
---|
2841 | if(TmpPt.X > RMax) then
|
---|
2842 | begin
|
---|
2843 | TORTreeView(FDropNode.TreeView).HorzScrollPos :=
|
---|
2844 | TORTreeView(FDropNode.TreeView).HorzScrollPos + EdgeScroll;
|
---|
2845 | Redraw := TRUE;
|
---|
2846 | end;
|
---|
2847 | end;
|
---|
2848 | end;
|
---|
2849 | end;
|
---|
2850 | if(Redraw) then
|
---|
2851 | begin
|
---|
2852 | TmpPt := Mouse.CursorPos; // Wiggling the mouse causes needed windows messages to fire
|
---|
2853 | inc(TmpPt.X);
|
---|
2854 | Mouse.CursorPos := TmpPt;
|
---|
2855 | dec(TmpPt.X);
|
---|
2856 | Mouse.CursorPos := TmpPt;
|
---|
2857 | FDropNode.TreeView.Invalidate;
|
---|
2858 | end;
|
---|
2859 | end;
|
---|
2860 | end;
|
---|
2861 |
|
---|
2862 | procedure TfrmTemplateEditor.tvTreeStartDrag(Sender: TObject;
|
---|
2863 | var DragObject: TDragObject);
|
---|
2864 | begin
|
---|
2865 | FDropNode := nil;
|
---|
2866 | FLastDropNode := nil;
|
---|
2867 | FDragOverCount := 0;
|
---|
2868 | tmrAutoScroll.Enabled := TRUE;
|
---|
2869 | end;
|
---|
2870 |
|
---|
2871 | procedure TfrmTemplateEditor.tvTreeEndDrag(Sender, Target: TObject; X,
|
---|
2872 | Y: Integer);
|
---|
2873 | begin
|
---|
2874 | tmrAutoScroll.Enabled := FALSE;
|
---|
2875 | end;
|
---|
2876 |
|
---|
2877 | procedure TfrmTemplateEditor.mnuGroupBPCopyClick(Sender: TObject);
|
---|
2878 | begin
|
---|
2879 | reGroupBP.CopyToClipboard;
|
---|
2880 | end;
|
---|
2881 |
|
---|
2882 | procedure TfrmTemplateEditor.popGroupPopup(Sender: TObject);
|
---|
2883 | begin
|
---|
2884 | mnuGroupBPCopy.Enabled := (pnlGroupBP.Visible and (reGroupBP.SelLength > 0));
|
---|
2885 | mnuGroupBPSelectAll.Enabled := (pnlGroupBP.Visible and (reGroupBP.Lines.Count > 0));
|
---|
2886 | end;
|
---|
2887 |
|
---|
2888 | procedure TfrmTemplateEditor.mnuBPCutClick(Sender: TObject);
|
---|
2889 | begin
|
---|
2890 | reBoil.CutToClipboard;
|
---|
2891 | end;
|
---|
2892 |
|
---|
2893 | procedure TfrmTemplateEditor.mnuBPCopyClick(Sender: TObject);
|
---|
2894 | begin
|
---|
2895 | reBoil.CopyToClipboard;
|
---|
2896 | end;
|
---|
2897 |
|
---|
2898 | procedure TfrmTemplateEditor.mnuBPPasteClick(Sender: TObject);
|
---|
2899 | begin
|
---|
2900 | reBoil.SelText := Clipboard.AsText;
|
---|
2901 | end;
|
---|
2902 |
|
---|
2903 | procedure TfrmTemplateEditor.mnuGroupBPSelectAllClick(Sender: TObject);
|
---|
2904 | begin
|
---|
2905 | reGroupBP.SelectAll;
|
---|
2906 | end;
|
---|
2907 |
|
---|
2908 | procedure TfrmTemplateEditor.mnuBPSelectAllClick(Sender: TObject);
|
---|
2909 | begin
|
---|
2910 | reBoil.SelectAll;
|
---|
2911 | end;
|
---|
2912 |
|
---|
2913 | procedure TfrmTemplateEditor.mnuNodeDeleteClick(Sender: TObject);
|
---|
2914 | begin
|
---|
2915 | if(FCurTree = tvShared) and (sbShDelete.Visible) and (sbShDelete.Enabled) then
|
---|
2916 | sbDeleteClick(sbShDelete)
|
---|
2917 | else
|
---|
2918 | if(FCurTree = tvPersonal) and (sbPerDelete.Visible) and (sbPerDelete.Enabled) then
|
---|
2919 | sbDeleteClick(sbPerDelete);
|
---|
2920 | end;
|
---|
2921 |
|
---|
2922 | procedure TfrmTemplateEditor.mnuNodeCopyClick(Sender: TObject);
|
---|
2923 | begin
|
---|
2924 | if(assigned(FCurTree)) then
|
---|
2925 | FCopyNode := FCurTree.Selected
|
---|
2926 | else
|
---|
2927 | FCopyNode := nil;
|
---|
2928 | end;
|
---|
2929 |
|
---|
2930 | procedure TfrmTemplateEditor.mnuNodePasteClick(Sender: TObject);
|
---|
2931 | begin
|
---|
2932 | if(PasteOK) then
|
---|
2933 | begin
|
---|
2934 | FDragNode := FCopyNode;
|
---|
2935 | FDropNode := FPasteNode;
|
---|
2936 | FDropInto := (TTemplate(FDropNode.Data).RealType in AllTemplateFolderTypes);
|
---|
2937 | FCopying := TRUE;
|
---|
2938 | try
|
---|
2939 | tvTreeDragDrop(tvShared, tvPersonal, 0, 0);
|
---|
2940 | finally
|
---|
2941 | FCopying := FALSE;
|
---|
2942 | end;
|
---|
2943 | end;
|
---|
2944 | FCopyNode := nil;
|
---|
2945 | end;
|
---|
2946 |
|
---|
2947 | function TfrmTemplateEditor.PasteOK: boolean;
|
---|
2948 | var
|
---|
2949 | OldCopying: boolean;
|
---|
2950 | Node: TTreeNode;
|
---|
2951 |
|
---|
2952 | begin
|
---|
2953 | Result := assigned(FCopyNode) and assigned(FPasteNode);
|
---|
2954 | if(Result) then
|
---|
2955 | Result := (FTreeControl[TTemplateTreeType(FPasteNode.TreeView.Tag), tcDel].Visible);
|
---|
2956 | if(Result) then
|
---|
2957 | begin
|
---|
2958 | OldCopying := FCopying;
|
---|
2959 | FCopying := TRUE;
|
---|
2960 | try
|
---|
2961 | Node := FPasteNode;
|
---|
2962 | if(TTemplate(Node.Data).RealType = ttDoc) then
|
---|
2963 | Node := Node.Parent;
|
---|
2964 | Result := AllowMove(Node, FCopyNode);
|
---|
2965 | finally
|
---|
2966 | FCopying := OldCopying;
|
---|
2967 | end;
|
---|
2968 | end;
|
---|
2969 | end;
|
---|
2970 |
|
---|
2971 | procedure TfrmTemplateEditor.mnuBPUndoClick(Sender: TObject);
|
---|
2972 | begin
|
---|
2973 | reBoil.Perform(EM_UNDO, 0, 0);
|
---|
2974 | end;
|
---|
2975 |
|
---|
2976 | procedure TfrmTemplateEditor.tvTreeKeyDown(Sender: TObject;
|
---|
2977 | var Key: Word; Shift: TShiftState);
|
---|
2978 | begin
|
---|
2979 |
|
---|
2980 | if(Key = VK_DELETE) then
|
---|
2981 | begin
|
---|
2982 | if(Sender = tvShared) then
|
---|
2983 | begin
|
---|
2984 | if(sbShDelete.Visible and sbShDelete.Enabled) then
|
---|
2985 | sbDeleteClick(sbShDelete);
|
---|
2986 | end
|
---|
2987 | else
|
---|
2988 | begin
|
---|
2989 | if(sbPerDelete.Visible and sbPerDelete.Enabled) then
|
---|
2990 | sbDeleteClick(sbPerDelete);
|
---|
2991 | end;
|
---|
2992 | end;
|
---|
2993 | //Code Added to provide CTRL Key access for 508 compliance GRE 3/03
|
---|
2994 | if (ssCtrl in Shift) and (Key = VK_A) then
|
---|
2995 | reBoil.SelectAll
|
---|
2996 | else
|
---|
2997 | if (ssCtrl in Shift) and (Key = VK_C) then
|
---|
2998 | reBoil.CopyToClipboard
|
---|
2999 | else
|
---|
3000 | if (ssCtrl in Shift) and (Key = VK_E) then
|
---|
3001 | mnuBPErrorCheckClick(Self)
|
---|
3002 | else
|
---|
3003 | if (ssCtrl in Shift) and (Key = VK_F) then
|
---|
3004 | mnuBPInsertFieldClick(Self)
|
---|
3005 | else
|
---|
3006 | if (ssCtrl in Shift) and (Key = VK_G) then
|
---|
3007 | GrammarCheckForControl(reBoil)
|
---|
3008 | else
|
---|
3009 | if (ssCtrl in Shift) and (Key = VK_I) then
|
---|
3010 | mnuBPInsertObjectClick(Self)
|
---|
3011 | else
|
---|
3012 | if (ssCtrl in Shift) and (Key = VK_S) then
|
---|
3013 | SpellCheckForControl(reBoil)
|
---|
3014 | else
|
---|
3015 | if (ssCtrl in Shift) and (Key = VK_T) then
|
---|
3016 | mnuBPTryClick(Self)
|
---|
3017 | else
|
---|
3018 | if (ssCtrl in Shift) and (Key = VK_V) then
|
---|
3019 | reBoil.SelText := Clipboard.AsText
|
---|
3020 | else
|
---|
3021 | if (ssCtrl in Shift) and (Key = VK_X) then
|
---|
3022 | reBoil.CutToClipboard
|
---|
3023 | else
|
---|
3024 | if (ssCtrl in Shift) and (Key = VK_Z) then
|
---|
3025 | reBoil.Perform(EM_UNDO, 0, 0);
|
---|
3026 | //End of ---- Code Added to provide CTRL Key access for 508 compliance GRE 3/03
|
---|
3027 | end;
|
---|
3028 |
|
---|
3029 | procedure TfrmTemplateEditor.mnuEditClick(Sender: TObject);
|
---|
3030 | var
|
---|
3031 | tryOK, ok: boolean;
|
---|
3032 |
|
---|
3033 | begin
|
---|
3034 | if pnlBoilerplate.Visible then
|
---|
3035 | begin
|
---|
3036 | ok := (not reBoil.ReadOnly);
|
---|
3037 | mnuInsertObject.Enabled := ok;
|
---|
3038 | mnuInsertField.Enabled := ok;
|
---|
3039 | mnuPaste.Enabled := (ok and Clipboard.HasFormat(CF_TEXT));
|
---|
3040 | if(ok) then
|
---|
3041 | ok := (reBoil.Lines.Count > 0);
|
---|
3042 | tryOK := (reBoil.Lines.Count > 0) or ((pnlGroupBP.Visible) and (reGroupBP.Lines.Count > 0));
|
---|
3043 | mnuErrorCheck.Enabled := tryOK;
|
---|
3044 | mnuTry.Enabled := tryOK;
|
---|
3045 | mnuSpellCheck.Enabled := ok and SpellCheckAvailable;
|
---|
3046 | mnuCheckGrammar.Enabled := ok and SpellCheckAvailable;
|
---|
3047 |
|
---|
3048 | mnuCopy.Enabled := (reBoil.SelLength > 0);
|
---|
3049 | mnuCut.Enabled := (ok and (reBoil.SelLength > 0));
|
---|
3050 | mnuSelectAll.Enabled := (reBoil.Lines.Count > 0);
|
---|
3051 | mnuUndo.Enabled := (reBoil.Perform(EM_CANUNDO, 0, 0) <> 0);
|
---|
3052 | mnuGroupBoilerplate.Enabled := pnlGroupBP.Visible;
|
---|
3053 | end
|
---|
3054 | else
|
---|
3055 | begin
|
---|
3056 | mnuInsertObject.Enabled := FALSE;
|
---|
3057 | mnuInsertField.Enabled := FALSE;
|
---|
3058 | mnuPaste.Enabled := FALSE;
|
---|
3059 | mnuErrorCheck.Enabled := FALSE;
|
---|
3060 | mnuTry.Enabled := FALSE;
|
---|
3061 | mnuSpellCheck.Enabled := FALSE;
|
---|
3062 | mnuCheckGrammar.Enabled := FALSE;
|
---|
3063 | mnuCopy.Enabled := FALSE;
|
---|
3064 | mnuCut.Enabled := FALSE;
|
---|
3065 | mnuSelectAll.Enabled := FALSE;
|
---|
3066 | mnuUndo.Enabled := FALSE;
|
---|
3067 | mnuGroupBoilerplate.Enabled := FALSE;
|
---|
3068 | end;
|
---|
3069 | end;
|
---|
3070 |
|
---|
3071 | procedure TfrmTemplateEditor.mnuGroupBoilerplateClick(Sender: TObject);
|
---|
3072 | begin
|
---|
3073 | mnuGroupCopy.Enabled := (pnlGroupBP.Visible and (reGroupBP.SelLength > 0));
|
---|
3074 | mnuGroupSelectAll.Enabled := (pnlGroupBP.Visible and (reGroupBP.Lines.Count > 0));
|
---|
3075 | end;
|
---|
3076 |
|
---|
3077 | procedure TfrmTemplateEditor.cbShFindOptionClick(Sender: TObject);
|
---|
3078 | begin
|
---|
3079 | SetFindNext(tvShared, FALSE);
|
---|
3080 | if(pnlShSearch.Visible) then edtShSearch.SetFocus;
|
---|
3081 | end;
|
---|
3082 |
|
---|
3083 | procedure TfrmTemplateEditor.cbPerFindOptionClick(Sender: TObject);
|
---|
3084 | begin
|
---|
3085 | SetFindNext(tvPersonal, FALSE);
|
---|
3086 | if(pnlPerSearch.Visible) then edtPerSearch.SetFocus;
|
---|
3087 | end;
|
---|
3088 |
|
---|
3089 | procedure TfrmTemplateEditor.mnuTemplateClick(Sender: TObject);
|
---|
3090 | var
|
---|
3091 | Tree: TTreeView;
|
---|
3092 |
|
---|
3093 | begin
|
---|
3094 | FFromMainMenu := TRUE;
|
---|
3095 | Tree := FCurTree;
|
---|
3096 | if(assigned(Tree) and assigned(Tree.Selected)) then
|
---|
3097 | begin
|
---|
3098 | if(Tree = tvShared) then
|
---|
3099 | mnuTDelete.Enabled := ((sbShDelete.Visible) and (sbShDelete.Enabled))
|
---|
3100 | else
|
---|
3101 | mnuTDelete.Enabled := ((sbPerDelete.Visible) and (sbPerDelete.Enabled));
|
---|
3102 | if(assigned(Tree) and assigned(Tree.Selected) and assigned(Tree.Selected.Data)) then
|
---|
3103 | begin
|
---|
3104 | mnuTCopy.Enabled := (TTemplate(Tree.Selected.Data).RealType in [ttDoc, ttGroup, ttClass]);
|
---|
3105 | mnuSort.Enabled := (TTemplate(Tree.Selected.Data).RealType in AllTemplateFolderTypes) and
|
---|
3106 | (Tree.Selected.HasChildren) and
|
---|
3107 | (Tree.Selected.GetFirstChild.GetNextSibling <> nil);
|
---|
3108 | end
|
---|
3109 | else
|
---|
3110 | begin
|
---|
3111 | mnuTCopy.Enabled := FALSE;
|
---|
3112 | mnuSort.Enabled := FALSE;
|
---|
3113 | end;
|
---|
3114 | FPasteNode := Tree.Selected;
|
---|
3115 | mnuTPaste.Enabled := PasteOK;
|
---|
3116 | end
|
---|
3117 | else
|
---|
3118 | begin
|
---|
3119 | mnuTCopy.Enabled := FALSE;
|
---|
3120 | mnuTPaste.Enabled := FALSE;
|
---|
3121 | mnuTDelete.Enabled := FALSE;
|
---|
3122 | mnuSort.Enabled := FALSE;
|
---|
3123 | end;
|
---|
3124 | mnuNewTemplate.Enabled := btnNew.Enabled;
|
---|
3125 | mnuAutoGen.Enabled := btnNew.Enabled;
|
---|
3126 | mnuFindShared.Checked := FFindShOn;
|
---|
3127 | mnuFindPersonal.Checked := FFindPerOn;
|
---|
3128 | mnuShCollapse.Enabled := dmodShared.NeedsCollapsing(tvShared);
|
---|
3129 | mnuPerCollapse.Enabled := dmodShared.NeedsCollapsing(tvPersonal);
|
---|
3130 | end;
|
---|
3131 |
|
---|
3132 | procedure TfrmTemplateEditor.mnuFindSharedClick(Sender: TObject);
|
---|
3133 | begin
|
---|
3134 | FMainMenuTree := tvShared;
|
---|
3135 | mnuFindTemplatesClick(tvShared);
|
---|
3136 | end;
|
---|
3137 |
|
---|
3138 | procedure TfrmTemplateEditor.mnuFindPersonalClick(Sender: TObject);
|
---|
3139 | begin
|
---|
3140 | FMainMenuTree := tvPersonal;
|
---|
3141 | mnuFindTemplatesClick(tvPersonal);
|
---|
3142 | end;
|
---|
3143 |
|
---|
3144 | procedure TfrmTemplateEditor.mnuShCollapseClick(Sender: TObject);
|
---|
3145 | begin
|
---|
3146 | FMainMenuTree := tvShared;
|
---|
3147 | mnuCollapseTreeClick(tvShared);
|
---|
3148 | end;
|
---|
3149 |
|
---|
3150 | procedure TfrmTemplateEditor.mnuPerCollapseClick(Sender: TObject);
|
---|
3151 | begin
|
---|
3152 | FMainMenuTree := tvPersonal;
|
---|
3153 | mnuCollapseTreeClick(tvPersonal);
|
---|
3154 | end;
|
---|
3155 |
|
---|
3156 | procedure TfrmTemplateEditor.pnlShSearchResize(Sender: TObject);
|
---|
3157 | begin
|
---|
3158 | if((cbShMatchCase.Width + cbShWholeWords.Width) > pnlShSearch.Width) then
|
---|
3159 | cbShWholeWords.Left := cbShMatchCase.Width
|
---|
3160 | else
|
---|
3161 | cbShWholeWords.Left := pnlShSearch.Width - cbShWholeWords.Width;
|
---|
3162 | end;
|
---|
3163 |
|
---|
3164 | procedure TfrmTemplateEditor.pnlPerSearchResize(Sender: TObject);
|
---|
3165 | begin
|
---|
3166 | if((cbPerMatchCase.Width + cbPerWholeWords.Width) > pnlPerSearch.Width) then
|
---|
3167 | cbPerWholeWords.Left := cbPerMatchCase.Width
|
---|
3168 | else
|
---|
3169 | cbPerWholeWords.Left := pnlPerSearch.Width - cbPerWholeWords.Width;
|
---|
3170 | end;
|
---|
3171 |
|
---|
3172 | procedure TfrmTemplateEditor.pnlPropertiesResize(Sender: TObject);
|
---|
3173 | begin
|
---|
3174 | btnNew.Width := pnlProperties.Width;
|
---|
3175 | end;
|
---|
3176 |
|
---|
3177 | procedure TfrmTemplateEditor.mbMainResize(Sender: TObject);
|
---|
3178 | begin
|
---|
3179 | pnlMenu.Width := mbMain.Width + 3;
|
---|
3180 | end;
|
---|
3181 |
|
---|
3182 | procedure TfrmTemplateEditor.mnuBPCheckGrammarClick(Sender: TObject);
|
---|
3183 | begin
|
---|
3184 | GrammarCheckForControl(reBoil);
|
---|
3185 | end;
|
---|
3186 |
|
---|
3187 | procedure TfrmTemplateEditor.mnuSortClick(Sender: TObject);
|
---|
3188 | var
|
---|
3189 | Tree: TTreeView;
|
---|
3190 |
|
---|
3191 | begin
|
---|
3192 | Tree := FCurTree;
|
---|
3193 | if(assigned(Tree) and assigned(Tree.Selected) and Tree.Selected.HasChildren) then
|
---|
3194 | begin
|
---|
3195 | TTemplate(Tree.Selected.Data).SortChildren;
|
---|
3196 | Resync([TTemplate(Tree.Selected.Data)]);
|
---|
3197 | btnApply.Enabled := TRUE;
|
---|
3198 | end;
|
---|
3199 | end;
|
---|
3200 |
|
---|
3201 | procedure TfrmTemplateEditor.pnlBoilerplateCanResize(Sender: TObject;
|
---|
3202 | var NewWidth, NewHeight: Integer; var Resize: Boolean);
|
---|
3203 | begin
|
---|
3204 | if(NewHeight < 40) then Resize := FALSE;
|
---|
3205 | end;
|
---|
3206 |
|
---|
3207 | function TfrmTemplateEditor.AutoDel(Template: TTemplate): boolean;
|
---|
3208 | begin
|
---|
3209 | if(assigned(Template)) then
|
---|
3210 | Result := (((Template.ID = '0') or (Template.ID = '')) and
|
---|
3211 | (Template.PrintName = NewTemplateName) and
|
---|
3212 | (Template.Boilerplate = ''))
|
---|
3213 | else
|
---|
3214 | Result := FALSE;
|
---|
3215 | end;
|
---|
3216 |
|
---|
3217 | procedure TfrmTemplateEditor.mnuBPTryClick(Sender: TObject);
|
---|
3218 | var
|
---|
3219 | R: TRect;
|
---|
3220 | Move: boolean;
|
---|
3221 | tmpl: TTemplate;
|
---|
3222 | txt: String;
|
---|
3223 |
|
---|
3224 | begin
|
---|
3225 | mnuBPErrorCheckClick(nil);
|
---|
3226 | if(FBPOK) or (reBoil.Lines.Count = 0) then
|
---|
3227 | begin
|
---|
3228 | Move := assigned(frmTemplateView);
|
---|
3229 | if(Move) then
|
---|
3230 | begin
|
---|
3231 | R := frmTemplateView.BoundsRect;
|
---|
3232 | frmTemplateView.Free;
|
---|
3233 | frmTemplateView := nil;
|
---|
3234 | end;
|
---|
3235 | tmpl := TTemplate(FCurTree.Selected.Data);
|
---|
3236 | tmpl.TemplatePreviewMode := TRUE; // Prevents "Are you sure?" dialog when canceling
|
---|
3237 | txt := tmpl.Text;
|
---|
3238 | if(not tmpl.DialogAborted) then
|
---|
3239 | ShowTemplateData(Self, tmpl.PrintName ,txt);
|
---|
3240 | if(Move) then
|
---|
3241 | frmTemplateView.BoundsRect := R;
|
---|
3242 | tmpl.TemplatePreviewMode := FALSE;
|
---|
3243 | end;
|
---|
3244 | end;
|
---|
3245 |
|
---|
3246 | procedure TfrmTemplateEditor.mnuAutoGenClick(Sender: TObject);
|
---|
3247 | var
|
---|
3248 | AName, AText: string;
|
---|
3249 |
|
---|
3250 | begin
|
---|
3251 | dmodShared.LoadTIUObjects;
|
---|
3252 | UpdatePersonalObjects;
|
---|
3253 | GetAutoGenText(AName, AText, FPersonalObjects);
|
---|
3254 | if(AName <> '') and (AText <> '') then
|
---|
3255 | begin
|
---|
3256 | btnNewClick(Self);
|
---|
3257 | TTemplate(FBtnNewNode.Data).PrintName := AName;
|
---|
3258 | TTemplate(FBtnNewNode.Data).Boilerplate := AText;
|
---|
3259 | ShowInfo(FBtnNewNode);
|
---|
3260 | edtNameOldChange(Self);
|
---|
3261 | end;
|
---|
3262 | end;
|
---|
3263 |
|
---|
3264 | procedure TfrmTemplateEditor.reNotesChange(Sender: TObject);
|
---|
3265 | var
|
---|
3266 | Template: TTemplate;
|
---|
3267 | DoRefresh: boolean;
|
---|
3268 |
|
---|
3269 | begin
|
---|
3270 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
3271 | begin
|
---|
3272 | if CanClone(FCurTree.Selected) then
|
---|
3273 | begin
|
---|
3274 | DoRefresh := Clone(FCurTree.Selected);
|
---|
3275 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
3276 | if assigned(Template) and Template.CanModify then
|
---|
3277 | begin
|
---|
3278 | Template.Description := reNotes.Lines.Text;
|
---|
3279 | UpdateApply(Template);
|
---|
3280 | if(DoRefresh) then
|
---|
3281 | begin
|
---|
3282 | tvShared.Invalidate;
|
---|
3283 | tvPersonal.Invalidate;
|
---|
3284 | end;
|
---|
3285 | end;
|
---|
3286 | end;
|
---|
3287 | btnApply.Enabled := TRUE;
|
---|
3288 | // reNotes.Lines.Text := Template.Description;
|
---|
3289 | end;
|
---|
3290 | end;
|
---|
3291 |
|
---|
3292 | procedure TfrmTemplateEditor.mnuNotesUndoClick(Sender: TObject);
|
---|
3293 | begin
|
---|
3294 | reNotes.Perform(EM_UNDO, 0, 0);
|
---|
3295 | end;
|
---|
3296 |
|
---|
3297 | procedure TfrmTemplateEditor.mnuNotesCutClick(Sender: TObject);
|
---|
3298 | begin
|
---|
3299 | reNotes.CutToClipboard;
|
---|
3300 | end;
|
---|
3301 |
|
---|
3302 | procedure TfrmTemplateEditor.mnuNotesCopyClick(Sender: TObject);
|
---|
3303 | begin
|
---|
3304 | reNotes.CopyToClipboard;
|
---|
3305 | end;
|
---|
3306 |
|
---|
3307 | procedure TfrmTemplateEditor.mnuNotesPasteClick(Sender: TObject);
|
---|
3308 | begin
|
---|
3309 | reNotes.SelText := Clipboard.AsText;
|
---|
3310 | end;
|
---|
3311 |
|
---|
3312 | procedure TfrmTemplateEditor.mnuNotesSelectAllClick(Sender: TObject);
|
---|
3313 | begin
|
---|
3314 | reNotes.SelectAll;
|
---|
3315 | end;
|
---|
3316 |
|
---|
3317 | procedure TfrmTemplateEditor.mnuNotesGrammarClick(Sender: TObject);
|
---|
3318 | begin
|
---|
3319 | GrammarCheckForControl(reNotes);
|
---|
3320 | end;
|
---|
3321 |
|
---|
3322 | procedure TfrmTemplateEditor.mnuNotesSpellingClick(Sender: TObject);
|
---|
3323 | begin
|
---|
3324 | SpellCheckForControl(reNotes);
|
---|
3325 | end;
|
---|
3326 |
|
---|
3327 | procedure TfrmTemplateEditor.popNotesPopup(Sender: TObject);
|
---|
3328 | var
|
---|
3329 | ok: boolean;
|
---|
3330 |
|
---|
3331 | begin
|
---|
3332 | ok := not reNotes.ReadOnly;
|
---|
3333 | mnuNotesPaste.Enabled := (ok and Clipboard.HasFormat(CF_TEXT));
|
---|
3334 | if(ok) then
|
---|
3335 | ok := (reNotes.Lines.Count > 0);
|
---|
3336 | mnuNotesSpelling.Enabled := ok and SpellCheckAvailable;
|
---|
3337 | mnuNotesGrammar.Enabled := ok and SpellCheckAvailable;
|
---|
3338 | mnuNotesCopy.Enabled := (reNotes.SelLength > 0);
|
---|
3339 | mnuNotesCut.Enabled := (ok and (reNotes.SelLength > 0));
|
---|
3340 | mnuNotesSelectAll.Enabled := (reNotes.Lines.Count > 0);
|
---|
3341 | mnuNotesUndo.Enabled := (reNotes.Perform(EM_CANUNDO, 0, 0) <> 0);
|
---|
3342 | end;
|
---|
3343 |
|
---|
3344 | procedure TfrmTemplateEditor.cbNotesClick(Sender: TObject);
|
---|
3345 | begin
|
---|
3346 | pnlNotes.Visible := cbNotes.Checked;
|
---|
3347 | splNotes.Visible := cbNotes.Checked;
|
---|
3348 | splNotes.Top := pnlNotes.Top-3;
|
---|
3349 | pnlBoilerplateResize(Self);
|
---|
3350 | end;
|
---|
3351 |
|
---|
3352 | procedure TfrmTemplateEditor.cbDisplayOnlyClick(Sender: TObject);
|
---|
3353 | begin
|
---|
3354 | cbClick(TCheckBox(Sender), BPDisplayOnlyFld);
|
---|
3355 | end;
|
---|
3356 |
|
---|
3357 | procedure TfrmTemplateEditor.cbFirstLineClick(Sender: TObject);
|
---|
3358 | begin
|
---|
3359 | cbClick(TCheckBox(Sender), BPFirstLineFld);
|
---|
3360 | end;
|
---|
3361 |
|
---|
3362 | procedure TfrmTemplateEditor.cbOneItemOnlyClick(Sender: TObject);
|
---|
3363 | begin
|
---|
3364 | cbClick(TCheckBox(Sender), BPOneItemOnlyFld);
|
---|
3365 | end;
|
---|
3366 |
|
---|
3367 | procedure TfrmTemplateEditor.cbHideDlgItemsClick(Sender: TObject);
|
---|
3368 | begin
|
---|
3369 | cbClick(TCheckBox(Sender), BPHideDlgItemsFld);
|
---|
3370 | end;
|
---|
3371 |
|
---|
3372 | procedure TfrmTemplateEditor.cbHideItemsClick(Sender: TObject);
|
---|
3373 | begin
|
---|
3374 | cbClick(TCheckBox(Sender), BPHideItemsFld);
|
---|
3375 | end;
|
---|
3376 |
|
---|
3377 | procedure TfrmTemplateEditor.cbClick(Sender: TCheckBox; Index: integer);
|
---|
3378 | var
|
---|
3379 | Template: TTemplate;
|
---|
3380 |
|
---|
3381 | begin
|
---|
3382 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
3383 | begin
|
---|
3384 | if CanClone(FCurTree.Selected) then
|
---|
3385 | begin
|
---|
3386 | Clone(FCurTree.Selected);
|
---|
3387 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
3388 | if assigned(Template) and Template.CanModify then
|
---|
3389 | begin
|
---|
3390 | case Index of
|
---|
3391 | BPDisplayOnlyFld: Template.DisplayOnly := Sender.Checked;
|
---|
3392 | BPFirstLineFld: Template.FirstLine := Sender.Checked;
|
---|
3393 | BPOneItemOnlyFld: Template.OneItemOnly := Sender.Checked;
|
---|
3394 | BPHideDlgItemsFld: Template.HideDlgItems := Sender.Checked;
|
---|
3395 | BPHideItemsFld: Template.HideItems := Sender.Checked;
|
---|
3396 | BPIndentFld: Template.IndentItems := Sender.Checked;
|
---|
3397 | BPLockFld: Template.Lock := Sender.Checked;
|
---|
3398 | end;
|
---|
3399 | UpdateApply(Template);
|
---|
3400 | end;
|
---|
3401 | end;
|
---|
3402 | end;
|
---|
3403 | end;
|
---|
3404 |
|
---|
3405 | procedure TfrmTemplateEditor.cbIndentClick(Sender: TObject);
|
---|
3406 | begin
|
---|
3407 | cbClick(TCheckBox(Sender), BPIndentFld);
|
---|
3408 | end;
|
---|
3409 |
|
---|
3410 | procedure TfrmTemplateEditor.mnuToolsClick(Sender: TObject);
|
---|
3411 | begin
|
---|
3412 | mnuEditTemplateFields.Enabled := CanEditTemplateFields;
|
---|
3413 | mnuImportTemplate.Enabled := btnNew.Enabled;
|
---|
3414 | mnuExportTemplate.Enabled := (assigned(FCurTree) and assigned(FCurTree.Selected) and
|
---|
3415 | assigned(FCurTree.Selected.Data));
|
---|
3416 | end;
|
---|
3417 |
|
---|
3418 | procedure TfrmTemplateEditor.mnuEditTemplateFieldsClick(Sender: TObject);
|
---|
3419 | begin
|
---|
3420 | if assigned(frmTemplateObjects) then
|
---|
3421 | frmTemplateObjects.Hide;
|
---|
3422 | if assigned(frmTemplateFields) then
|
---|
3423 | frmTemplateFields.Hide;
|
---|
3424 | if EditDialogFields and assigned(frmTemplateFields) then
|
---|
3425 | FreeAndNil(frmTemplateFields);
|
---|
3426 | end;
|
---|
3427 |
|
---|
3428 | procedure TfrmTemplateEditor.mnuBPInsertFieldClick(Sender: TObject);
|
---|
3429 | begin
|
---|
3430 | if(not assigned(frmTemplateFields)) then
|
---|
3431 | begin
|
---|
3432 | frmTemplateFields := TfrmTemplateFields.Create(Self);
|
---|
3433 | frmTemplateFields.Font := Font;
|
---|
3434 | frmTemplateFields.re := reBoil;
|
---|
3435 | frmTemplateFields.AutoLongLines := AutoLongLines;
|
---|
3436 | end;
|
---|
3437 | frmTemplateFields.Show;
|
---|
3438 | end;
|
---|
3439 |
|
---|
3440 | procedure TfrmTemplateEditor.UpdateInsertsDialogs;
|
---|
3441 | begin
|
---|
3442 | if assigned(frmTemplateObjects) then
|
---|
3443 | frmTemplateObjects.UpdateStatus;
|
---|
3444 | if assigned(frmTemplateFields) then
|
---|
3445 | frmTemplateFields.UpdateStatus;
|
---|
3446 | end;
|
---|
3447 |
|
---|
3448 | procedure TfrmTemplateEditor.mnuExportTemplateClick(Sender: TObject);
|
---|
3449 | var
|
---|
3450 | Tmpl, Flds: TStringList;
|
---|
3451 | i: integer;
|
---|
3452 | XMLDoc: IXMLDOMDocument;
|
---|
3453 | err: boolean;
|
---|
3454 |
|
---|
3455 | begin
|
---|
3456 | err := FALSE;
|
---|
3457 | if(assigned(FCurTree) and assigned(FCurTree.Selected) and assigned(FCurTree.Selected.Data)) then
|
---|
3458 | begin
|
---|
3459 | dlgExport.FileName := ValidFileName(TTemplate(FCurTree.Selected.Data).PrintName);
|
---|
3460 | if dlgExport.Execute then
|
---|
3461 | begin
|
---|
3462 | Tmpl := TStringList.Create;
|
---|
3463 | try
|
---|
3464 | Flds := TStringList.Create;
|
---|
3465 | try
|
---|
3466 | Tmpl.Add('<'+XMLHeader+'>');
|
---|
3467 | if TTemplate(FCurTree.Selected.Data).CanExportXML(Tmpl, Flds, 2) then
|
---|
3468 | begin
|
---|
3469 | if (Flds.Count > 0) then begin
|
---|
3470 | ExpandEmbeddedFields(Flds);
|
---|
3471 | Flds.Assign(ExportTemplateFields(Flds));
|
---|
3472 | for i := 0 to Flds.Count-1 do
|
---|
3473 | Flds[i] := ' ' + Flds[i];
|
---|
3474 | Tmpl.AddStrings(Flds);
|
---|
3475 | end; {if}
|
---|
3476 | Tmpl.Add('</'+XMLHeader+'>');
|
---|
3477 | try
|
---|
3478 | XMLDoc := CoDOMDocument.Create;
|
---|
3479 | try
|
---|
3480 | XMLDoc.preserveWhiteSpace := TRUE;
|
---|
3481 | XMLDoc.LoadXML(Tmpl.Text);
|
---|
3482 | XMLDoc.Save(dlgExport.FileName);
|
---|
3483 | finally
|
---|
3484 | XMLDoc := nil;
|
---|
3485 | end;
|
---|
3486 | except
|
---|
3487 | // InfoBox(Format(NoIE5, ['Export']), NoIE5Header, MB_OK); <-- original line. //kt 8/8/2007
|
---|
3488 | InfoBox(Format(NoIE5, [DKLangConstW('fTemplateEditor_Export')]), NoIE5Header, MB_OK); //kt added 8/8/2007
|
---|
3489 | err := TRUE;
|
---|
3490 | end;
|
---|
3491 | if not err then
|
---|
3492 | // InfoBox('Template ' + TTemplate(FCurTree.Selected.Data).PrintName + <-- original line. //kt 8/8/2007
|
---|
3493 | InfoBox(DKLangConstW('fTemplateEditor_Template') + TTemplate(FCurTree.Selected.Data).PrintName + //kt added 8/8/2007
|
---|
3494 | // ' Exported.', 'Template Exported', MB_OK); <-- original line. //kt 8/8/2007
|
---|
3495 | DKLangConstW('fTemplateEditor_Exportedx'), DKLangConstW('fTemplateEditor_Template_Exported'), MB_OK); //kt added 8/8/2007
|
---|
3496 | end;
|
---|
3497 | finally
|
---|
3498 | Flds.Free;
|
---|
3499 | end;
|
---|
3500 | finally
|
---|
3501 | Tmpl.Free;
|
---|
3502 | end;
|
---|
3503 | end;
|
---|
3504 | end;
|
---|
3505 | end;
|
---|
3506 |
|
---|
3507 | procedure TfrmTemplateEditor.mnuImportTemplateClick(Sender: TObject);
|
---|
3508 | //const
|
---|
3509 | //Filter1 = 'Template Files|*.txml'; <-- original line. //kt 8/8/2007
|
---|
3510 | //WordFilter = '|Word Documents|*.doc;*.dot'; <-- original line. //kt 8/8/2007
|
---|
3511 | //Filter2 = '|XML Files|*.xml|All Files|*.*'; <-- original line. //kt 8/8/2007
|
---|
3512 |
|
---|
3513 | var
|
---|
3514 | Filter1 : string; //kt
|
---|
3515 | WordFilter : string; //kt
|
---|
3516 | Filter2 : string; //kt
|
---|
3517 |
|
---|
3518 | XMLDoc: IXMLDOMDocument;
|
---|
3519 | RootElement: IXMLDOMElement;
|
---|
3520 | ImportedTemplate: TTemplate;
|
---|
3521 | AppData, Flds, ResultSet: TStringList;
|
---|
3522 | tmp,j,p3: string;
|
---|
3523 | err, ok, changes, xmlerr: boolean;
|
---|
3524 | i: integer;
|
---|
3525 | choice: word;
|
---|
3526 |
|
---|
3527 | procedure ClearFields;
|
---|
3528 | begin
|
---|
3529 | Flds.Text := '';
|
---|
3530 | ResultSet.Text := '';
|
---|
3531 | end;
|
---|
3532 |
|
---|
3533 | begin
|
---|
3534 | Filter1 := DKLangConstW('fTemplateEditor_Template_Filesxxxtxml'); //kt added 8/8/2007
|
---|
3535 | WordFilter := DKLangConstW('fTemplateEditor_xWord_Documentsxxxdocxxxdot'); //kt added 8/8/2007
|
---|
3536 | Filter2 := DKLangConstW('fTemplateEditor_xXML_FilesxxxxmlxAll_Filesxxxx'); //kt added 8/8/2007
|
---|
3537 | tmp := Filter1;
|
---|
3538 | err := FALSE;
|
---|
3539 | if WordImportActive then
|
---|
3540 | tmp := tmp + WordFilter;
|
---|
3541 | tmp := tmp + Filter2;
|
---|
3542 | dlgImport.Filter := tmp;
|
---|
3543 | if btnNew.Enabled and dlgImport.Execute then
|
---|
3544 | begin
|
---|
3545 | tmp := ExtractFileExt(dlgImport.FileName);
|
---|
3546 | // if(WordImportActive and ((CompareText(tmp,'.doc') = 0) or <-- original line. //kt 8/8/2007
|
---|
3547 | if(WordImportActive and ((CompareText(tmp,DKLangConstW('fTemplateEditor_xdoc')) = 0) or //kt added 8/8/2007
|
---|
3548 | // (CompareText(tmp,'.dot') = 0))) then <-- original line. //kt 8/8/2007
|
---|
3549 | (CompareText(tmp,DKLangConstW('fTemplateEditor_xdot')) = 0))) then //kt added 8/8/2007
|
---|
3550 | AppData := TStringList.Create
|
---|
3551 | else
|
---|
3552 | AppData := nil;
|
---|
3553 | try
|
---|
3554 | try
|
---|
3555 | XMLDoc := CoDOMDocument.Create;
|
---|
3556 | except
|
---|
3557 | // InfoBox(Format(NoIE5, ['Import']), NoIE5Header, MB_OK); <-- original line. //kt 8/8/2007
|
---|
3558 | InfoBox(Format(NoIE5, [DKLangConstW('fTemplateEditor_Import')]), NoIE5Header, MB_OK); //kt added 8/8/2007
|
---|
3559 | exit;
|
---|
3560 | end;
|
---|
3561 | try
|
---|
3562 | if assigned(AppData) then
|
---|
3563 | begin
|
---|
3564 | try
|
---|
3565 | ok := GetXMLFromWord(dlgImport.FileName, AppData);
|
---|
3566 | except
|
---|
3567 | ok := FALSE;
|
---|
3568 | err := TRUE;
|
---|
3569 | end;
|
---|
3570 | end
|
---|
3571 | else
|
---|
3572 | ok := TRUE;
|
---|
3573 | if ok and assigned(XMLDoc) then
|
---|
3574 | begin
|
---|
3575 | XMLDoc.preserveWhiteSpace := TRUE;
|
---|
3576 | if assigned(AppData) then
|
---|
3577 | XMLDoc.LoadXML(AppData.Text)
|
---|
3578 | else
|
---|
3579 | XMLDoc.Load(dlgImport.FileName);
|
---|
3580 | RootElement := XMLDoc.DocumentElement;
|
---|
3581 | if not assigned(RootElement) then
|
---|
3582 | XMLImportError(0);
|
---|
3583 | try
|
---|
3584 | if(RootElement.tagName <> XMLHeader)then
|
---|
3585 | XMLImportError(0)
|
---|
3586 | else
|
---|
3587 | begin
|
---|
3588 | ImportedTemplate := nil;
|
---|
3589 | FXMLTemplateElement := FindXMLElement(RootElement, XMLTemplateTag);
|
---|
3590 | if assigned(FXMLTemplateElement) then
|
---|
3591 | begin
|
---|
3592 | FXMLFieldElement := FindXMLElement(RootElement, XMLTemplateFieldsTag);
|
---|
3593 | if(assigned(FXMLFieldElement)) then
|
---|
3594 | begin
|
---|
3595 | Flds := TStringList.Create;
|
---|
3596 | ResultSet := TStringList.Create;
|
---|
3597 | try
|
---|
3598 | Flds.Text := FXMLFieldElement.Get_XML;
|
---|
3599 | choice := IDOK;
|
---|
3600 | changes := FALSE;
|
---|
3601 | Application.ProcessMessages;
|
---|
3602 | if not BuildTemplateFields(Flds) then //Calls RPC to transfer all field XML
|
---|
3603 | choice := IDCANCEL; //for processing
|
---|
3604 | Flds.Text := '';
|
---|
3605 | Application.ProcessMessages;
|
---|
3606 | if choice = IDOK then
|
---|
3607 | CheckTemplateFields(Flds);
|
---|
3608 | if Flds.Count > 0 then
|
---|
3609 | begin
|
---|
3610 | for i := 1 to Flds.Count do
|
---|
3611 | begin
|
---|
3612 | j := piece(Flds[i-1],U,2);
|
---|
3613 | if (j = '0') or (j = '2') then
|
---|
3614 | begin
|
---|
3615 | p3 := piece(Flds[i-1],U,3);
|
---|
3616 | if p3 = 'XML FORMAT ERROR' then
|
---|
3617 | choice := IDCANCEL;
|
---|
3618 | changes := TRUE;
|
---|
3619 | if j = '2' then begin
|
---|
3620 | j := Flds[i-1];
|
---|
3621 | SetPiece(j,U,2,'1');
|
---|
3622 | Flds[i-1] := j
|
---|
3623 | end;
|
---|
3624 | end;
|
---|
3625 | end;
|
---|
3626 | end
|
---|
3627 | else
|
---|
3628 | choice := IDCANCEL;
|
---|
3629 | if choice <> IDOK then
|
---|
3630 | // InfoBox(iMessage2+iMessage3, 'Error', MB_OK or MB_ICONERROR) <-- original line. //kt 8/8/2007
|
---|
3631 | InfoBox(iMessage2+iMessage3, DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR) //kt added 8/8/2007
|
---|
3632 | else
|
---|
3633 | if (not CanEditTemplateFields) AND
|
---|
3634 | changes {(there is at least one new field)} then
|
---|
3635 | begin
|
---|
3636 | // choice := InfoBox(iMessage, 'Warning', MB_OKCANCEL or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
3637 | choice := InfoBox(iMessage, DKLangConstW('fTemplateEditor_Warning'), MB_OKCANCEL or MB_ICONWARNING); //kt added 8/8/2007
|
---|
3638 | Flds.Text := '';
|
---|
3639 | end;
|
---|
3640 | if choice <> IDCANCEL then
|
---|
3641 | begin
|
---|
3642 | FImportingFromXML := TRUE;
|
---|
3643 | try
|
---|
3644 | btnNewClick(Self);
|
---|
3645 | ImportedTemplate := TTemplate(FBtnNewNode.Data);
|
---|
3646 | finally
|
---|
3647 | FImportingFromXML := FALSE;
|
---|
3648 | end; {try}
|
---|
3649 | Application.ProcessMessages;
|
---|
3650 | if assigned(ImportedTemplate) and (Flds.Count > 0) then
|
---|
3651 | if not ImportLoadedFields(ResultSet) then begin
|
---|
3652 | // InfoBox(iMessage2+iMessage3, 'Error', MB_OK or MB_ICONERROR); <-- original line. //kt 8/8/2007
|
---|
3653 | InfoBox(iMessage2+iMessage3, DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR); //kt added 8/8/2007
|
---|
3654 | ClearFields;
|
---|
3655 | choice := IDCANCEL;
|
---|
3656 | end;//if
|
---|
3657 | if Flds.Count = 0 then
|
---|
3658 | choice := IDCANCEL;
|
---|
3659 | end {if choice <> mrCancel}
|
---|
3660 | else
|
---|
3661 | ClearFields;
|
---|
3662 |
|
---|
3663 | xmlerr := FALSE;
|
---|
3664 | if (Flds.Count > 0) and
|
---|
3665 | (ResultSet.Count > 0) and
|
---|
3666 | (Flds.Count = ResultSet.Count) then
|
---|
3667 | for i := 0 to Flds.Count-1 do begin
|
---|
3668 | if piece(ResultSet[i],U,2) = '0' then begin
|
---|
3669 | j := piece(Flds[i],U,1) + U + '0' + U + piece(ResultSet[i],U,3);
|
---|
3670 | Flds[i] := j;
|
---|
3671 | end
|
---|
3672 | end
|
---|
3673 | else
|
---|
3674 | xmlerr := TRUE;
|
---|
3675 |
|
---|
3676 | if xmlerr and (choice <> IDCANCEL) then begin
|
---|
3677 | // InfoBox(iMessage2, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
|
---|
3678 | InfoBox(iMessage2, DKLangConstW('fTemplateEditor_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
|
---|
3679 | ClearFields;
|
---|
3680 | end;
|
---|
3681 |
|
---|
3682 | i := 0;
|
---|
3683 | while (i < Flds.Count) do begin
|
---|
3684 | if Piece(Flds[i], U, 2) <> '0' then
|
---|
3685 | Flds.Delete(i)
|
---|
3686 | else
|
---|
3687 | inc(i);
|
---|
3688 | end;//while
|
---|
3689 | if(Flds.Count > 0) then
|
---|
3690 | begin
|
---|
3691 | if assigned(frmTemplateFields) then
|
---|
3692 | FreeAndNil(frmTemplateFields);
|
---|
3693 | ImportedTemplate.UpdateImportedFieldNames(Flds);
|
---|
3694 | if not assigned(AppData) then
|
---|
3695 | begin
|
---|
3696 | for i := 0 to Flds.Count-1 do
|
---|
3697 | // Flds[i] := ' Field "' + Piece(Flds[i],U,1) + '" has been renamed to "'+ <-- original line. //kt 8/8/2007
|
---|
3698 | Flds[i] := DKLangConstW('fTemplateEditor_Field_x') + Piece(Flds[i],U,1) + DKLangConstW('fTemplateEditor_x_has_been_renamed_to_x')+ //kt added 8/8/2007
|
---|
3699 | Piece(Flds[i],U,3) + '"';
|
---|
3700 | if Flds.Count = 1 then
|
---|
3701 | // tmp := 'A template field has' <-- original line. //kt 8/8/2007
|
---|
3702 | tmp := DKLangConstW('fTemplateEditor_A_template_field_has') //kt added 8/8/2007
|
---|
3703 | else
|
---|
3704 | // tmp := IntToStr(Flds.Count) + ' template fields have'; <-- original line. //kt 8/8/2007
|
---|
3705 | tmp := IntToStr(Flds.Count) + DKLangConstW('fTemplateEditor_template_fields_have'); //kt added 8/8/2007
|
---|
3706 | // Flds.Insert(0,tmp + ' been imported with the same name as'); <-- original line. //kt 8/8/2007
|
---|
3707 | Flds.Insert(0,tmp + DKLangConstW('fTemplateEditor_been_imported_with_the_same_name_as')); //kt added 8/8/2007
|
---|
3708 | // Flds.Insert(1,'existing template fields, but with different field definitions.'); <-- original line. //kt 8/8/2007
|
---|
3709 | Flds.Insert(1,DKLangConstW('fTemplateEditor_existing_template_fieldsx_but_with_different_field_definitionsx')); //kt added 8/8/2007
|
---|
3710 | // Flds.Insert(2,'These imported template fields have been renamed as follows:'); <-- original line. //kt 8/8/2007
|
---|
3711 | Flds.Insert(2,DKLangConstW('fTemplateEditor_These_imported_template_fields_have_been_renamed_as_followsx')); //kt added 8/8/2007
|
---|
3712 | Flds.Insert(3,'');
|
---|
3713 | // InfoBox(Flds.Text, 'Information', MB_OK or MB_ICONINFORMATION); <-- original line. //kt 8/8/2007
|
---|
3714 | InfoBox(Flds.Text, DKLangConstW('fTemplateEditor_Information'), MB_OK or MB_ICONINFORMATION); //kt added 8/8/2007
|
---|
3715 | end;
|
---|
3716 | end;
|
---|
3717 | finally
|
---|
3718 | Flds.Free;
|
---|
3719 | ResultSet.Free;
|
---|
3720 | end;
|
---|
3721 | end
|
---|
3722 | else {There are no fields to consider...}
|
---|
3723 | begin
|
---|
3724 | FImportingFromXML := TRUE;
|
---|
3725 | try
|
---|
3726 | btnNewClick(Self);
|
---|
3727 | ImportedTemplate := TTemplate(FBtnNewNode.Data);
|
---|
3728 | finally
|
---|
3729 | FImportingFromXML := FALSE;
|
---|
3730 | end; {try}
|
---|
3731 | end;
|
---|
3732 | end;
|
---|
3733 | if assigned(ImportedTemplate) then
|
---|
3734 | ShowInfo(FBtnNewNode);
|
---|
3735 | end;
|
---|
3736 | finally
|
---|
3737 | RootElement := nil;
|
---|
3738 | end;
|
---|
3739 | end;
|
---|
3740 | finally
|
---|
3741 | XMLDoc := nil;
|
---|
3742 | end;
|
---|
3743 | finally
|
---|
3744 | if assigned(AppData) then
|
---|
3745 | begin
|
---|
3746 | AppData.Free;
|
---|
3747 | if err then
|
---|
3748 | // InfoBox('An error occured while Importing Word Document. Make sure Word is closed and try again.','Import Error', MB_OK); <-- original line. //kt 8/8/2007
|
---|
3749 | InfoBox(DKLangConstW('fTemplateEditor_An_error_occured_while_Importing_Word_Documentx__Make_sure_Word_is_closed_and_try_againx'),DKLangConstW('fTemplateEditor_Import_Error'), MB_OK); //kt added 8/8/2007
|
---|
3750 | end;
|
---|
3751 | end;
|
---|
3752 | end;
|
---|
3753 | end;
|
---|
3754 |
|
---|
3755 | procedure TfrmTemplateEditor.cbxTypeDrawItem(Control: TWinControl;
|
---|
3756 | Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
---|
3757 | var
|
---|
3758 | ImgIdx: integer;
|
---|
3759 |
|
---|
3760 | begin
|
---|
3761 | cbxType.Canvas.FillRect(Rect);
|
---|
3762 | case IdxForced[FForceContainer, Index] of
|
---|
3763 | tiTemplate: ImgIdx := 4;
|
---|
3764 | tiFolder: ImgIdx := 3;
|
---|
3765 | tiGroup: ImgIdx := 5;
|
---|
3766 | tiDialog: ImgIdx := 23;
|
---|
3767 | tiRemDlg: ImgIdx := 27;
|
---|
3768 | tiCOMObj: ImgIdx := 28;
|
---|
3769 | else
|
---|
3770 | ImgIdx := ord(tiNone);
|
---|
3771 | end;
|
---|
3772 | if ImgIdx >= 0 then
|
---|
3773 | dmodShared.imgTemplates.Draw(cbxType.Canvas, Rect.Left+1, Rect.Top+1, ImgIdx);
|
---|
3774 | if Index >= 0 then
|
---|
3775 | cbxType.Canvas.TextOut(Rect.Left+21, Rect.Top+2, cbxType.Items[Index]);
|
---|
3776 | end;
|
---|
3777 |
|
---|
3778 | procedure TfrmTemplateEditor.cbxTypeChange(Sender: TObject);
|
---|
3779 | var
|
---|
3780 | i,tg: integer;
|
---|
3781 | Template: TTemplate;
|
---|
3782 | ttyp: TTemplateType;
|
---|
3783 | Node: TTreeNode;
|
---|
3784 | idx: TTypeIndex;
|
---|
3785 |
|
---|
3786 | begin
|
---|
3787 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
|
---|
3788 | begin
|
---|
3789 | tg := cbxType.ItemIndex;
|
---|
3790 | if tg >= 0 then
|
---|
3791 | begin
|
---|
3792 | if CanClone(FCurTree.Selected) then
|
---|
3793 | begin
|
---|
3794 | idx := IdxForced[FForceContainer, tg];
|
---|
3795 | if(idx = tiRemDlg) and (not (GetLinkType(FCurTree.Selected) in [ltNone, ltTitle])) then
|
---|
3796 | begin
|
---|
3797 | FUpdating := TRUE;
|
---|
3798 | try
|
---|
3799 | cbxType.ItemIndex := ord(tiTemplate);
|
---|
3800 | finally
|
---|
3801 | FUpdating := FALSE;
|
---|
3802 | end;
|
---|
3803 | // ShowMessage('Can not assign a Reminder Dialog to a Reason for Request'); <-- original line. //kt 8/8/2007
|
---|
3804 | ShowMessage(DKLangConstW('fTemplateEditor_Can_not_assign_a_Reminder_Dialog_to_a_Reason_for_Request')); //kt added 8/8/2007
|
---|
3805 | end
|
---|
3806 | else
|
---|
3807 | begin
|
---|
3808 | Clone(FCurTree.Selected);
|
---|
3809 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
3810 | if assigned(Template) and Template.CanModify then
|
---|
3811 | begin
|
---|
3812 | ttyp := TypeTag[idx];
|
---|
3813 | if(not FForceContainer) or (not (idx in [tiTemplate, tiRemDlg])) then
|
---|
3814 | begin
|
---|
3815 | if(ttyp = ttDialog) then
|
---|
3816 | begin
|
---|
3817 | Template.Dialog := TRUE;
|
---|
3818 | ttyp := ttGroup;
|
---|
3819 | end
|
---|
3820 | else
|
---|
3821 | Template.Dialog := FALSE;
|
---|
3822 | Template.RealType := ttyp;
|
---|
3823 | if(Template.RealType = ttDoc) and (idx = tiRemDlg) then
|
---|
3824 | Template.IsReminderDialog := TRUE
|
---|
3825 | else
|
---|
3826 | Template.IsReminderDialog := FALSE;
|
---|
3827 | if(Template.RealType = ttDoc) and (idx = tiCOMObj) then
|
---|
3828 | Template.IsCOMObject := TRUE
|
---|
3829 | else
|
---|
3830 | Template.IsCOMObject := FALSE;
|
---|
3831 | UpdateApply(Template);
|
---|
3832 | end;
|
---|
3833 | for i := 0 to Template.Nodes.Count-1 do
|
---|
3834 | begin
|
---|
3835 | Node := TTreeNode(Template.Nodes.Objects[i]);
|
---|
3836 | Node.ImageIndex := dmodShared.ImgIdx(Node);
|
---|
3837 | Node.SelectedIndex := dmodShared.ImgIdx(Node);
|
---|
3838 | end;
|
---|
3839 | tvShared.Invalidate;
|
---|
3840 | tvPersonal.Invalidate;
|
---|
3841 | Node := FCurTree.Selected;
|
---|
3842 | tvTreeChange(TTreeView(Node.TreeView), Node);
|
---|
3843 | end;
|
---|
3844 | end;
|
---|
3845 | end;
|
---|
3846 | end;
|
---|
3847 | end;
|
---|
3848 | end;
|
---|
3849 |
|
---|
3850 | procedure TfrmTemplateEditor.cbxRemDlgsChange(Sender: TObject);
|
---|
3851 | var
|
---|
3852 | Template: TTemplate;
|
---|
3853 |
|
---|
3854 | begin
|
---|
3855 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
|
---|
3856 | FCanDoReminders) then
|
---|
3857 | begin
|
---|
3858 | if CanClone(FCurTree.Selected) then
|
---|
3859 | begin
|
---|
3860 | Clone(FCurTree.Selected);
|
---|
3861 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
3862 | if assigned(Template) and Template.CanModify then
|
---|
3863 | begin
|
---|
3864 | if cbxRemDlgs.ItemIndex < 0 then
|
---|
3865 | Template.ReminderDialog := ''
|
---|
3866 | else
|
---|
3867 | Template.ReminderDialog := cbxRemDlgs.Items[cbxRemDlgs.ItemIndex];
|
---|
3868 | UpdateApply(Template);
|
---|
3869 | end;
|
---|
3870 | end;
|
---|
3871 | end;
|
---|
3872 | end;
|
---|
3873 |
|
---|
3874 | procedure TfrmTemplateEditor.mnuTemplateIconLegendClick(Sender: TObject);
|
---|
3875 | begin
|
---|
3876 | ShowIconLegend(ilTemplates, TRUE);
|
---|
3877 | end;
|
---|
3878 |
|
---|
3879 | procedure TfrmTemplateEditor.cbLongLinesClick(Sender: TObject);
|
---|
3880 | begin
|
---|
3881 | pnlBoilerplateResize(Self);
|
---|
3882 | pnlBoilerplateResize(Self); // Second Call is Needed!
|
---|
3883 | end;
|
---|
3884 |
|
---|
3885 | procedure TfrmTemplateEditor.AutoLongLines(Sender: TObject);
|
---|
3886 | begin
|
---|
3887 | cbLongLines.Checked := TRUE;
|
---|
3888 | end;
|
---|
3889 |
|
---|
3890 | procedure TfrmTemplateEditor.UpdatePersonalObjects;
|
---|
3891 | var
|
---|
3892 | i: integer;
|
---|
3893 |
|
---|
3894 | begin
|
---|
3895 | if not assigned(FPersonalObjects) then
|
---|
3896 | begin
|
---|
3897 | FPersonalObjects := TStringList.Create;
|
---|
3898 | GetAllowedPersonalObjects;
|
---|
3899 | for i := 0 to RPCBrokerV.Results.Count-1 do
|
---|
3900 | FPersonalObjects.Add(Piece(RPCBrokerV.Results[i],U,1));
|
---|
3901 | FPersonalObjects.Sorted := TRUE;
|
---|
3902 | end;
|
---|
3903 | end;
|
---|
3904 |
|
---|
3905 | (*function TfrmTemplateEditor.ModifyAllowed(const Node: TTreeNode): boolean;
|
---|
3906 | var
|
---|
3907 | tmpl: TTemplate;
|
---|
3908 |
|
---|
3909 | function GetFirstPersonalNode(Node: TTreeNode): TTreeNode;
|
---|
3910 | begin
|
---|
3911 | Result := Node;
|
---|
3912 | if assigned(Node.Parent) and (TTemplate(Node.Data).PersonalOwner <> User.DUZ) then
|
---|
3913 | Result := GetFirstPersonalNode(Node.Parent);
|
---|
3914 | end;
|
---|
3915 |
|
---|
3916 | begin
|
---|
3917 | if(assigned(Node)) then
|
---|
3918 | begin
|
---|
3919 | if (TTreeView(Node.TreeView) = tvPersonal) then
|
---|
3920 | Result := TTemplate(GetFirstPersonalNode(Node).Data).CanModify
|
---|
3921 | else
|
---|
3922 | Result := TRUE;
|
---|
3923 | end
|
---|
3924 | else
|
---|
3925 | Result := FALSE;
|
---|
3926 | if Result then
|
---|
3927 | begin
|
---|
3928 | tmpl := TTemplate(Node.Data);
|
---|
3929 | if (tmpl.PersonalOwner = 0) or (tmpl.PersonalOwner = User.DUZ) then
|
---|
3930 | Result := tmpl.CanModify;
|
---|
3931 | end;
|
---|
3932 | end;
|
---|
3933 | *)
|
---|
3934 |
|
---|
3935 | { Returns TRUE if Cloning is not needed or if Cloning is needed and
|
---|
3936 | the top personal Node in the tree is locked. }
|
---|
3937 | function TfrmTemplateEditor.CanClone(const Node: TTreeNode): boolean;
|
---|
3938 | var
|
---|
3939 | Template: TTemplate;
|
---|
3940 |
|
---|
3941 | function GetFirstPersonalNode(Node: TTreeNode): TTreeNode;
|
---|
3942 | begin
|
---|
3943 | Result := Node;
|
---|
3944 | if assigned(Node.Parent) and (TTemplate(Node.Data).PersonalOwner <> User.DUZ) then
|
---|
3945 | Result := GetFirstPersonalNode(Node.Parent);
|
---|
3946 | end;
|
---|
3947 |
|
---|
3948 | begin
|
---|
3949 | if(assigned(Node)) and assigned(Node.Data) then
|
---|
3950 | begin
|
---|
3951 | if (TTreeView(Node.TreeView) = tvPersonal) then
|
---|
3952 | begin
|
---|
3953 | Template := TTemplate(Node.Data);
|
---|
3954 | if Template.IsCOMObject or (Template.FileLink <> '') then
|
---|
3955 | Result := FALSE
|
---|
3956 | else
|
---|
3957 | Result := TTemplate(GetFirstPersonalNode(Node).Data).CanModify
|
---|
3958 | end
|
---|
3959 | else
|
---|
3960 | Result := TRUE;
|
---|
3961 | end
|
---|
3962 | else
|
---|
3963 | Result := FALSE;
|
---|
3964 | end;
|
---|
3965 |
|
---|
3966 | procedure TfrmTemplateEditor.UpdateApply(Template: TTemplate);
|
---|
3967 | begin
|
---|
3968 | if(not btnApply.Enabled) then
|
---|
3969 | btnApply.Enabled := Template.Changed;
|
---|
3970 | end;
|
---|
3971 |
|
---|
3972 | procedure TfrmTemplateEditor.TemplateLocked(Sender: TObject);
|
---|
3973 | begin
|
---|
3974 | Resync([TTemplate(Sender)]);
|
---|
3975 | ShowMessage(Format(TemplateLockedText, [TTemplate(Sender).PrintName]));
|
---|
3976 | end;
|
---|
3977 |
|
---|
3978 | procedure TfrmTemplateEditor.cbLockClick(Sender: TObject);
|
---|
3979 | begin
|
---|
3980 | cbClick(TCheckBox(Sender), BPLockFLD);
|
---|
3981 | end;
|
---|
3982 |
|
---|
3983 | procedure TfrmTemplateEditor.mnuRefreshClick(Sender: TObject);
|
---|
3984 | begin
|
---|
3985 | if btnApply.Enabled then
|
---|
3986 | begin
|
---|
3987 | // if InfoBox('All changes must be saved before you can Refresh. Save Changes?', <-- original line. //kt 8/8/2007
|
---|
3988 | if InfoBox(DKLangConstW('fTemplateEditor_All_changes_must_be_saved_before_you_can_Refreshx__Save_Changesx'), //kt added 8/8/2007
|
---|
3989 | // 'Confirmation', MB_YESNO or MB_ICONQUESTION) <> IDYES then <-- original line. //kt 8/8/2007
|
---|
3990 | DKLangConstW('fTemplateEditor_Confirmation'), MB_YESNO or MB_ICONQUESTION) <> IDYES then //kt added 8/8/2007
|
---|
3991 | exit;
|
---|
3992 | end;
|
---|
3993 | btnApplyClick(Sender);
|
---|
3994 | if BtnApply.Enabled then
|
---|
3995 | // InfoBox('Save not completed - unable to refresh.', 'Error', MB_OK or MB_ICONERROR) <-- original line. //kt 8/8/2007
|
---|
3996 | InfoBox(DKLangConstW('fTemplateEditor_Save_not_completed_x_unable_to_refreshx'), DKLangConstW('fTemplateEditor_Error'), MB_OK or MB_ICONERROR) //kt added 8/8/2007
|
---|
3997 | else
|
---|
3998 | RefreshData;
|
---|
3999 | end;
|
---|
4000 |
|
---|
4001 | procedure TfrmTemplateEditor.RefreshData;
|
---|
4002 | var
|
---|
4003 | exp1, exp2, s1, s2, t1, t2: string;
|
---|
4004 | focus: TWinControl;
|
---|
4005 |
|
---|
4006 | begin
|
---|
4007 | focus := FCurTree;
|
---|
4008 | exp1 := tvShared.GetExpandedIDStr(1, ';');
|
---|
4009 | exp2 := tvPersonal.GetExpandedIDStr(1, ';');
|
---|
4010 | s1 := tvShared.GetNodeID(TORTreeNode(tvShared.Selected),1,';');
|
---|
4011 | s2 := tvPersonal.GetNodeID(TORTreeNode(tvPersonal.Selected),1,';');
|
---|
4012 | t1 := tvShared.GetNodeID(TORTreeNode(tvShared.TopItem),1,';');
|
---|
4013 | t2 := tvPersonal.GetNodeID(TORTreeNode(tvPersonal.TopItem),1,';');
|
---|
4014 | tvPersonal.Items.BeginUpdate;
|
---|
4015 | try
|
---|
4016 | tvShared.Items.BeginUpdate;
|
---|
4017 | try
|
---|
4018 | ReleaseTemplates;
|
---|
4019 | tvPersonal.Items.Clear;
|
---|
4020 | tvShared.Items.Clear;
|
---|
4021 | InitTrees;
|
---|
4022 | tvShared.SetExpandedIDStr(1, ';', exp1);
|
---|
4023 | tvShared.TopItem := tvShared.FindPieceNode(t1,1,';');
|
---|
4024 | tvShared.Selected := tvShared.FindPieceNode(s1,1,';');
|
---|
4025 | tvPersonal.SetExpandedIDStr(1, ';', exp2);
|
---|
4026 | tvPersonal.TopItem := tvPersonal.FindPieceNode(t2,1,';');
|
---|
4027 | tvPersonal.Selected := tvPersonal.FindPieceNode(s2,1,';');
|
---|
4028 | finally
|
---|
4029 | tvShared.Items.EndUpdate;
|
---|
4030 | end;
|
---|
4031 | finally
|
---|
4032 | tvPersonal.Items.EndUpdate;
|
---|
4033 | end;
|
---|
4034 | ActiveControl := focus;
|
---|
4035 | end;
|
---|
4036 |
|
---|
4037 | procedure TfrmTemplateEditor.InitTrees;
|
---|
4038 | begin
|
---|
4039 | LoadTemplateData;
|
---|
4040 | if(not assigned(RootTemplate)) then
|
---|
4041 | SaveTemplate(AddTemplate('0^R^A^Shared Templates'),-1);
|
---|
4042 | if(not assigned(MyTemplate)) then
|
---|
4043 | AddTemplate('0^P^A^My Templates^^^'+IntToStr(User.DUZ));
|
---|
4044 | dmodShared.AddTemplateNode(tvPersonal, FPersonalEmptyNodeCount, MyTemplate);
|
---|
4045 | dmodShared.AddTemplateNode(tvShared, FSharedEmptyNodeCount, RootTemplate);
|
---|
4046 | if (UserTemplateAccessLevel = taEditor) then
|
---|
4047 | begin
|
---|
4048 | if CanEditLinkType(ttTitles) then
|
---|
4049 | dmodShared.AddTemplateNode(tvShared, FSharedEmptyNodeCount, TitlesTemplate);
|
---|
4050 | if CanEditLinkType(ttConsults) then
|
---|
4051 | dmodShared.AddTemplateNode(tvShared, FSharedEmptyNodeCount, ConsultsTemplate);
|
---|
4052 | if CanEditLinkType(ttProcedures) then
|
---|
4053 | dmodShared.AddTemplateNode(tvShared, FSharedEmptyNodeCount, ProceduresTemplate);
|
---|
4054 | end;
|
---|
4055 | end;
|
---|
4056 |
|
---|
4057 | procedure TfrmTemplateEditor.reResizeRequest(Sender: TObject;
|
---|
4058 | Rect: TRect);
|
---|
4059 | var
|
---|
4060 | R: TRect;
|
---|
4061 |
|
---|
4062 | begin
|
---|
4063 | R := TRichEdit(Sender).ClientRect;
|
---|
4064 | if (FLastRect.Right <> R.Right) or
|
---|
4065 | (FLastRect.Bottom <> R.Bottom) or
|
---|
4066 | (FLastRect.Left <> R.Left) or
|
---|
4067 | (FLastRect.Top <> R.Top) then
|
---|
4068 | begin
|
---|
4069 | FLastRect := R;
|
---|
4070 | pnlBoilerplateResize(Self);
|
---|
4071 | end;
|
---|
4072 | end;
|
---|
4073 |
|
---|
4074 | procedure TfrmTemplateEditor.reBoilSelectionChange(Sender: TObject);
|
---|
4075 | begin
|
---|
4076 | UpdateXY(reBoil, lblBoilCol, lblBoilRow);
|
---|
4077 | end;
|
---|
4078 |
|
---|
4079 | procedure TfrmTemplateEditor.reGroupBPSelectionChange(Sender: TObject);
|
---|
4080 | begin
|
---|
4081 | UpdateXY(reGroupBP, lblGroupCol, lblGroupRow);
|
---|
4082 | end;
|
---|
4083 |
|
---|
4084 | procedure TfrmTemplateEditor.UpdateXY(re: TRichEdit; lblX, lblY: TLabel);
|
---|
4085 | var
|
---|
4086 | p: TPoint;
|
---|
4087 |
|
---|
4088 | begin
|
---|
4089 | p := re.CaretPos;
|
---|
4090 | //lblY.Caption := 'Line: ' + inttostr(p.y + 1); <-- original line. //kt 8/8/2007
|
---|
4091 | lblY.Caption := DKLangConstW('fTemplateEditor_Linex') + inttostr(p.y + 1); //kt added 8/8/2007
|
---|
4092 | //lblX.Caption := 'Column: ' + inttostr(p.x + 1); <-- original line. //kt 8/8/2007
|
---|
4093 | lblX.Caption := DKLangConstW('fTemplateEditor_Columnx') + inttostr(p.x + 1); //kt added 8/8/2007
|
---|
4094 | end;
|
---|
4095 |
|
---|
4096 | procedure TfrmTemplateEditor.cbxCOMObjChange(Sender: TObject);
|
---|
4097 | var
|
---|
4098 | Template: TTemplate;
|
---|
4099 |
|
---|
4100 | begin
|
---|
4101 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
|
---|
4102 | FCanDoCOMObjects and (FCurTree = tvShared)) then
|
---|
4103 | begin
|
---|
4104 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
4105 | if assigned(Template) and Template.CanModify then
|
---|
4106 | begin
|
---|
4107 | if cbxCOMObj.ItemIndex < 0 then
|
---|
4108 | Template.COMObject := 0
|
---|
4109 | else
|
---|
4110 | Template.COMObject := cbxCOMObj.ItemID;
|
---|
4111 | UpdateApply(Template);
|
---|
4112 | end;
|
---|
4113 | end;
|
---|
4114 | end;
|
---|
4115 |
|
---|
4116 | procedure TfrmTemplateEditor.edtCOMParamChange(Sender: TObject);
|
---|
4117 | var
|
---|
4118 | Template: TTemplate;
|
---|
4119 |
|
---|
4120 | begin
|
---|
4121 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
|
---|
4122 | FCanDoCOMObjects and (FCurTree = tvShared)) then
|
---|
4123 | begin
|
---|
4124 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
4125 | if assigned(Template) and Template.CanModify then
|
---|
4126 | begin
|
---|
4127 | Template.COMParam := edtCOMParam.Text;
|
---|
4128 | UpdateApply(Template);
|
---|
4129 | end;
|
---|
4130 | end;
|
---|
4131 | end;
|
---|
4132 |
|
---|
4133 | function TfrmTemplateEditor.GetLinkType(const ANode: TTreeNode): TTemplateLinkType;
|
---|
4134 | var
|
---|
4135 | Node: TTreeNode;
|
---|
4136 |
|
---|
4137 | begin
|
---|
4138 | Result := ltNone;
|
---|
4139 | if assigned(ANode) then
|
---|
4140 | begin
|
---|
4141 | if(not assigned(ANode.Data)) or (TTemplate(ANode.Data).RealType <> ttClass) then
|
---|
4142 | begin
|
---|
4143 | Node := ANode.Parent;
|
---|
4144 | repeat
|
---|
4145 | if assigned(Node) and assigned(Node.Data) then
|
---|
4146 | begin
|
---|
4147 | if (TTemplate(Node.Data).FileLink <> '') then
|
---|
4148 | Node := nil
|
---|
4149 | else
|
---|
4150 | if (TTemplate(Node.Data).RealType in AllTemplateLinkTypes) then
|
---|
4151 | begin
|
---|
4152 | case TTemplate(Node.Data).RealType of
|
---|
4153 | ttTitles: Result := ltTitle;
|
---|
4154 | ttConsults: Result := ltConsult;
|
---|
4155 | ttProcedures: Result := ltProcedure;
|
---|
4156 | end;
|
---|
4157 | end
|
---|
4158 | else
|
---|
4159 | Node := Node.Parent;
|
---|
4160 | end
|
---|
4161 | else
|
---|
4162 | Node := nil;
|
---|
4163 | until(Result <> ltNone) or (not assigned(Node));
|
---|
4164 | end;
|
---|
4165 | end;
|
---|
4166 | end;
|
---|
4167 |
|
---|
4168 | procedure TfrmTemplateEditor.cbxLinkNeedData(Sender: TObject;
|
---|
4169 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
4170 | var
|
---|
4171 | tmpSL: TStringList;
|
---|
4172 | i: integer;
|
---|
4173 | tmp: string;
|
---|
4174 |
|
---|
4175 | begin
|
---|
4176 | tmpSL := TStringList.Create;
|
---|
4177 | try
|
---|
4178 | case TTemplateLinkType(pnlLink.Tag) of
|
---|
4179 | ltTitle: tmpSL.Assign(SubSetOfAllTitles(StartFrom, Direction));
|
---|
4180 | // ltConsult:
|
---|
4181 | ltProcedure:
|
---|
4182 | begin
|
---|
4183 | tmpSL.Assign(SubSetOfProcedures(StartFrom, Direction));
|
---|
4184 | for i := 0 to tmpSL.Count-1 do
|
---|
4185 | begin
|
---|
4186 | tmp := tmpSL[i];
|
---|
4187 | setpiece(tmp,U,1,piece(piece(tmp,U,4),';',1));
|
---|
4188 | tmpSL[i] := tmp;
|
---|
4189 | end;
|
---|
4190 | end;
|
---|
4191 | end;
|
---|
4192 | cbxLink.ForDataUse(tmpSL);
|
---|
4193 | finally
|
---|
4194 | tmpSL.Free;
|
---|
4195 | end;
|
---|
4196 | end;
|
---|
4197 |
|
---|
4198 | procedure TfrmTemplateEditor.cbxLinkChange(Sender: TObject);
|
---|
4199 | var
|
---|
4200 | Template,LinkTemplate: TTemplate;
|
---|
4201 |
|
---|
4202 | begin
|
---|
4203 | if((not FUpdating) and (assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
|
---|
4204 | (FCurTree = tvShared)) then
|
---|
4205 | begin
|
---|
4206 | Template := TTemplate(FCurTree.Selected.Data);
|
---|
4207 | if assigned(Template) and Template.CanModify then
|
---|
4208 | begin
|
---|
4209 | if cbxLink.ItemIEN > 0 then
|
---|
4210 | begin
|
---|
4211 | LinkTemplate := GetLinkedTemplate(cbxLink.ItemID, TTemplateLinkType(pnlLink.tag));
|
---|
4212 | if (assigned(LinkTemplate) and (LinkTemplate <> Template)) then
|
---|
4213 | begin
|
---|
4214 | ShowMessage(GetLinkName(cbxLink.ItemID, TTemplateLinkType(pnlLink.tag)) +
|
---|
4215 | // ' is already assigned to another template.'); <-- original line. //kt 8/8/2007
|
---|
4216 | DKLangConstW('fTemplateEditor_is_already_assigned_to_another_templatex')); //kt added 8/8/2007
|
---|
4217 | cbxLink.ItemIndex := -1;
|
---|
4218 | end;
|
---|
4219 | Template.FileLink := ConvertFileLink(cbxLink.ItemID, TTemplateLinkType(pnlLink.tag));
|
---|
4220 | if Template.LinkName <> '' then
|
---|
4221 | edtName.Text := copy(Template.LinkName,1,edtName.MaxLength);
|
---|
4222 | end
|
---|
4223 | else
|
---|
4224 | Template.FileLink := '';
|
---|
4225 | UpdateApply(Template);
|
---|
4226 | end;
|
---|
4227 | end;
|
---|
4228 | end;
|
---|
4229 |
|
---|
4230 | procedure TfrmTemplateEditor.cbxLinkSynonymCheck(Sender: TObject;
|
---|
4231 | const Text: String; var IsSynonym: Boolean);
|
---|
4232 | var
|
---|
4233 | LinkTemplate: TTemplate;
|
---|
4234 | var IEN: string;
|
---|
4235 |
|
---|
4236 | begin
|
---|
4237 | IsSynonym := FALSE;
|
---|
4238 | if pnlLink.Visible and assigned(FShowingTemplate) then
|
---|
4239 | begin
|
---|
4240 | IEN := Piece(Text,#9,30);
|
---|
4241 | if IEN <> '' then
|
---|
4242 | begin
|
---|
4243 | LinkTemplate := GetLinkedTemplate(IEN, TTemplateLinkType(pnlLink.Tag));
|
---|
4244 | IsSynonym := (assigned(LinkTemplate) and (LinkTemplate <> FShowingTemplate));
|
---|
4245 | end
|
---|
4246 | else
|
---|
4247 | IsSynonym := FALSE;
|
---|
4248 | end;
|
---|
4249 | end;
|
---|
4250 |
|
---|
4251 | procedure TfrmTemplateEditor.reBoilKeyUp(Sender: TObject; var Key: Word;
|
---|
4252 | Shift: TShiftState);
|
---|
4253 | begin
|
---|
4254 | if FNavigatingTab then
|
---|
4255 | begin
|
---|
4256 | if ssShift in Shift then
|
---|
4257 | FindNextControl(Sender as TWinControl, False, True, False).SetFocus //previous control
|
---|
4258 | else if ssCtrl in Shift then
|
---|
4259 | FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
|
---|
4260 | FNavigatingTab := False;
|
---|
4261 | end;
|
---|
4262 | if (key = VK_ESCAPE) then begin
|
---|
4263 | FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
|
---|
4264 | key := 0;
|
---|
4265 | end;
|
---|
4266 | end;
|
---|
4267 |
|
---|
4268 | procedure TfrmTemplateEditor.reBoilKeyPress(Sender: TObject;
|
---|
4269 | var Key: Char);
|
---|
4270 | begin
|
---|
4271 | if FNavigatingTab then
|
---|
4272 | Key := #0; //Disable shift-tab processinend;
|
---|
4273 | end;
|
---|
4274 |
|
---|
4275 | procedure TfrmTemplateEditor.reBoilKeyDown(Sender: TObject; var Key: Word;
|
---|
4276 | Shift: TShiftState);
|
---|
4277 | begin
|
---|
4278 | //The navigating tab controls were inadvertantently adding tab characters
|
---|
4279 | //This should fix it
|
---|
4280 | FNavigatingTab := (Key = VK_TAB) and ([ssShift,ssCtrl] * Shift <> []);
|
---|
4281 | if FNavigatingTab then
|
---|
4282 | Key := 0;
|
---|
4283 | end;
|
---|
4284 |
|
---|
4285 | end.
|
---|
4286 |
|
---|