Function

TfrmTemplateEditor.ScanNames

Module

fTemplateEditor

Last Modified

7/15/2014 3:26:44 PM

Visibility

Protected

Owner

TfrmTemplateEditor

Declaration

function ScanNames: boolean;

Calls Hierarchy


TfrmTemplateEditor.ScanNames
 └ScanTree
   └BadTemplateName

Called-By Hierarchy


          TfrmTemplateEditor.ScanNames
    TfrmTemplateEditor.btnApplyClick┤ 
TfrmTemplateEditor.mnuRefreshClick┘ │ 
       TfrmTemplateEditor.btnOKClick┤ 
   TfrmTemplateEditor.FormCloseQuery┘ 

Calls

Name Declaration Comments
ScanTree procedure ScanTree(Tree: TTreeView); -

Called-By

Name Declaration Comments
TfrmTemplateEditor.btnApplyClick procedure btnApplyClick(Sender: TObject); -
TfrmTemplateEditor.btnOKClick procedure btnOKClick(Sender: TObject); -
TfrmTemplateEditor.FormCloseQuery procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); -


Source

2636  function TfrmTemplateEditor.ScanNames: boolean;
2637  var
2638    Errors: TList;
2639    msg: string;
2640    i: integer;
2641    Node: TTreeNode;
2642  
2643    procedure ScanTree(Tree: TTreeView);
2644    begin
2645      Node := Tree.Items.GetFirstNode;
2646      while (assigned(Node)) do
2647      begin
2648        if (Node.Text <> EmptyNodeText) and (assigned(Node.Data)) then
2649        begin
2650          if (BadTemplateName(Node.Text)) then
2651            Errors.Add(Node);
2652        end;
2653        Node := Node.GetNext;
2654      end;
2655    end;
2656  
2657  begin
2658    Errors := TList.Create;
2659    try
2660      ScanTree(tvShared);
2661      ScanTree(tvPersonal);
2662      if (Errors.Count > 0) then
2663      begin
2664        if (Errors.Count > 1) then
2665          msg := IntToStr(Errors.Count) + ' Templates have invalid names'
2666        else
2667          msg := 'Template has an invalid name';
2668        msg := msg + ': ';
2669        for i := 0 to Errors.Count - 1 do
2670        begin
2671          if (i > 0) then msg := msg + ', ';
2672          Node := TTreeNode(Errors[i]);
2673          msg := msg + Node.Text;
2674          Node.MakeVisible;
2675        end;
2676        msg := msg + '.' + BadNameText;
2677        InfoBox(msg, 'Error', MB_OK or MB_ICONERROR);
2678        TTreeView(Node.TreeView).Selected := TTreeNode(Errors[0]);
2679      end;
2680    finally
2681      Result := (Errors.Count = 0);
2682      Errors.Free;
2683    end;
2684  end;