Procedure

TfrmTemplateEditor.btnNewClick

Module

fTemplateEditor

Last Modified

7/15/2014 3:26:44 PM

Visibility

Public/Published

Owner

TfrmTemplateEditor

Declaration

procedure btnNewClick(Sender: TObject);

Calls Hierarchy


TfrmTemplateEditor.btnNewClick
 ├TfrmTemplateEditor.CanClone
 │ ├GetFirstPersonalNode
 │ │ └..(rec)..
 │ └TTemplate.CanModify
 │   ├TTemplate.ValidID
 │   └LockTemplate
 ├TfrmTemplateEditor.Clone
 │ ├TfrmTemplateEditor.CanClone...
 │ ├..(rec)..
 │ ├TTemplate.CanModify...
 │ ├TTemplate.Clone
 │ │ ├TTemplate.TrueClone
 │ │ │ ├TTemplate.GetChildren
 │ │ │ ├TTemplate.Create
 │ │ │ │ └TTemplate.ReminderDialogIEN
 │ │ │ ├TTemplate.SetBoilerplate
 │ │ │ │ ├TTemplate.CanModify...
 │ │ │ │ └TTemplate.ValidID
 │ │ │ ├TTemplate.GetBoilerplate
 │ │ │ │ └GetTemplateBoilerplate
 │ │ │ ├TTemplate.SetDescription
 │ │ │ │ ├TTemplate.CanModify...
 │ │ │ │ └TTemplate.ValidID
 │ │ │ └TTemplate.GetDescription
 │ │ │   └LoadTemplateDescription
 │ │ ├TTemplate.GetItems
 │ │ │ └ExpandTemplate
 │ │ │   ├TTemplate.GetChildren
 │ │ │   ├GetTemplateChildren
 │ │ │   ├AddTemplate
 │ │ │   │ ├TTemplate.Create...
 │ │ │   │ └TTemplate.AddChild
 │ │ │   │   └TTemplate.GetItems...
 │ │ │   └TTemplate.ItemIENs
 │ │ │     └TTemplate.GetItems...
 │ │ └TTemplate.BackupItems
 │ │   └TTemplate.ItemIENs...
 │ ├TTemplate.RemoveNode
 │ ├MarkDeleted
 │ │ ├TTemplate.ValidID
 │ │ ├TTemplate.SetFileLink
 │ │ │ └TTemplate.AssignFileLink
 │ │ │   ├TTemplate.CanModify...
 │ │ │   ├TTemplate.ValidID
 │ │ │   ├TTemplate.LinkType
 │ │ │   ├TTemplate.SetReminderDialog
 │ │ │   │ ├TTemplate.CanModify...
 │ │ │   │ ├TTemplate.ValidID
 │ │ │   │ ├TTemplate.ReminderDialogIEN
 │ │ │   │ ├TTemplate.LinkType
 │ │ │   │ └TTemplate.SetFileLink...
 │ │ │   ├TTemplate.GetItems...
 │ │ │   └..(rec)..
 │ │ ├TTemplate.GetItems...
 │ │ └..(rec)..
 │ ├TTemplate.AddNode
 │ ├TTemplate.GetItems...
 │ └TfrmTemplateEditor.ShowTemplateType
 ├TTemplate.CanModify...
 ├TTemplate.GetItems...
 ├TTemplate.CreateFromXML
 │ ├TTemplate.Create...
 │ ├TTemplate.SetBoilerplate...
 │ ├TTemplate.SetDescription...
 │ ├TTemplate.GetItems...
 │ ├..(rec)..
 │ └TTemplate.BackupItems...
 ├TTemplate.Create...
 ├TTemplate.BackupItems...
 └TfrmTemplateEditor.Resync
   ├TdmodShared.Resync
   │ ├InSyncNode
   │ ├GetID
   │ │ └..(rec)..
   │ ├TTemplate.RemoveNode
   │ ├BuildNodes
   │ │ ├TTemplate.AddNode
   │ │ ├TTemplate.GetItems...
   │ │ ├..(rec)..
   │ │ └TTemplate.GetChildren
   │ └GetNode
   │   └GetID...
   ├TfrmTemplateEditor.EnableNavControls
   │ └TfrmTemplateEditor.AllowMove
   │   ├TfrmTemplateEditor.IsTemplateLocked
   │   │ ├TTemplate.AutoLock
   │   │ │ └TTemplate.LinkType
   │   │ ├TTemplate.IsLocked
   │   │ │ └TTemplate.AutoLock...
   │   │ └..(rec)..
   │   └TTemplate.GetItems...
   └TfrmTemplateEditor.tvTreeChange
     ├TfrmTemplateEditor.ChangeTree
     ├TfrmTemplateEditor.IsTemplateLocked...
     ├TfrmTemplateEditor.EnableControls
     │ ├TfrmTemplateEditor.UpdateInsertsDialogs
     │ │ ├TfrmTemplateObjects.UpdateStatus
     │ │ └TfrmTemplateFields.UpdateStatus
     │ │   └TfrmTemplateFields.ValidInsert
     │ └TfrmTemplateEditor.EnableNavControls...
     └TfrmTemplateEditor.ShowInfo
       ├TfrmTemplateEditor.ShowTemplateType
       ├TfrmTemplateEditor.GetLinkType
       ├LoadServiceListWithSynonyms
       ├TTemplate.LinkName
       │ ├GetLinkName
       │ │ └ExternalName
       │ ├TTemplate.LinkIEN
       │ └TTemplate.LinkType
       ├TTemplate.LinkIEN
       ├TTemplate.GetDescription...
       ├TTemplate.IsLocked...
       ├TTemplate.AutoLock...
       ├TfrmTemplateEditor.IsTemplateLocked...
       ├TTemplate.GetChildren
       ├TTemplate.ReminderDialogIEN
       ├TdmodShared.InDialog
       │ └TTemplate.IsDialog
       ├TTemplate.GetBoilerplate...
       ├TfrmTemplateEditor.DisplayBoilerplate
       │ ├TfrmTemplateEditor.pnlBoilerplateResize
       │ ├TTemplate.GetBoilerplate...
       │ ├TTemplate.FullBoilerplate
       │ │ ├TTemplate.GetBoilerplate...
       │ │ ├TTemplate.ItemBoilerplate
       │ │ │ ├TTemplate.GetItems...
       │ │ │ ├TTemplate.GetTemplateType
       │ │ │ ├DlgText
       │ │ │ └TTemplate.DialogProperties
       │ │ │   ├TTemplate.GetBoilerplate...
       │ │ │   └TTemplate.DlgID
       │ │ ├DlgText
       │ │ └TTemplate.DialogProperties...
       │ ├TfrmTemplateEditor.UpdateInsertsDialogs...
       │ ├TfrmTemplateEditor.ShowBoilerPlate
       │ └TfrmTemplateEditor.ShowGroupBoilerplate
       ├TfrmTemplateEditor.ShowGroupBoilerplate
       └TfrmTemplateEditor.pnlBoilerplateResize

Called-By Hierarchy


              TfrmTemplateEditor.btnNewClick
                             EditTemplates┤ 
     TfrmDCSumm.popSummMemoTemplateClick┤ │ 
          TfrmDCSumm.mnuNewTemplateClick┤ │ 
        TfrmDCSumm.mnuEditTemplatesClick┤ │ 
  TfrmDCSumm.mnuEditSharedTemplatesClick┤ │ 
    TfrmDCSumm.mnuNewSharedTemplateClick┤ │ 
   TfrmConsults.popNoteMemoTemplateClick┤ │ 
      TfrmConsults.mnuEditTemplatesClick┤ │ 
        TfrmConsults.mnuNewTemplateClick┤ │ 
TfrmConsults.mnuEditSharedTemplatesClick┤ │ 
  TfrmConsults.mnuNewSharedTemplateClick┤ │ 
       TfrmDrawers.mnuEditTemplatesClick┤ │ 
         TfrmDrawers.mnuNewTemplateClick┤ │ 
    TfrmSurgery.popNoteMemoTemplateClick┤ │ 
       TfrmSurgery.mnuEditTemplatesClick┤ │ 
         TfrmSurgery.mnuNewTemplateClick┤ │ 
 TfrmSurgery.mnuEditSharedTemplatesClick┤ │ 
   TfrmSurgery.mnuNewSharedTemplateClick┤ │ 
      TfrmNotes.popNoteMemoTemplateClick┤ │ 
         TfrmNotes.mnuEditTemplatesClick┤ │ 
           TfrmNotes.mnuNewTemplateClick┤ │ 
   TfrmNotes.mnuEditSharedTemplatesClick┤ │ 
     TfrmNotes.mnuNewSharedTemplateClick┘ │ 
        TfrmTemplateEditor.mnuAutoGenClick┤ 
 TfrmTemplateEditor.mnuImportTemplateClick┘ 

Calls

Name Declaration Comments
TTemplate.BackupItems procedure BackupItems; -
TfrmTemplateEditor.CanClone function CanClone(const Node: TTreeNode): boolean; -
TTemplate.CanModify function CanModify: boolean; -
TfrmTemplateEditor.Clone function Clone(Node: TTreeNode): boolean; -
TTemplate.Create constructor Create(DataString: string); -
TTemplate.CreateFromXML class function CreateFromXML(Element: IXMLDOMNode; Owner: string): TTemplate; -
TTemplate.GetItems function GetItems: TList; -
TfrmTemplateEditor.Resync procedure Resync(const Templates: array of TTemplate); -

Called-By

Name Declaration Comments
EditTemplates procedure EditTemplates(Form: TForm; NewTemplate: boolean = FALSE; CopiedText: string = ''; Shared: boolean = FALSE); -
TfrmTemplateEditor.mnuAutoGenClick procedure mnuAutoGenClick(Sender: TObject); -
TfrmTemplateEditor.mnuImportTemplateClick procedure mnuImportTemplateClick(Sender: TObject); -


Source

576   procedure TfrmTemplateEditor.btnNewClick(Sender: TObject);
577   var
578     idx: integer;
579     Tmp, Owner: TTemplate;
580     Node, PNode: TTreeNode;
581     ownr: string;
582     ok: boolean;
583     ACheckBox: TCheckBox;
584   
585   begin
586     if ((assigned(FCurTree)) and (assigned(FCurTree.Selected))) then
587     begin
588       if (FCurTree = tvShared) and (FCanEditShared) then
589         ok := TRUE
590       else
591         if (FCurTree = tvPersonal) and (FCanEditPersonal) then
592           ok := TRUE
593         else
594           ok := FALSE;
595       if (ok) then
596       begin
597         Node := FCurTree.Selected;
598         PNode := Node;
599         if (TTemplate(Node.Data).RealType = ttDoc) then
600           PNode := Node.Parent;
601         if CanClone(PNode) then
602         begin
603           Clone(PNode);
604           Owner := TTemplate(PNode.Data);
605           if assigned(Owner) and Owner.CanModify then
606           begin
607             if Node = PNode then
608               idx := 0
609             else
610               idx := Owner.Items.IndexOf(Node.Data) + 1;
611             if (FCurTree = tvShared) then
612             begin
613               ownr := '';
614               ACheckBox := cbShHide;
615             end
616             else
617             begin
618               ownr := IntToStr(User.DUZ);
619               ACheckBox := cbPerHide;
620             end;
621             if FImportingFromXML then
622             begin
623               Tmp := TTemplate.CreateFromXML(FXMLTemplateElement, ownr);
624               ACheckBox.Checked := ACheckBox.Checked and Tmp.Active;
625             end
626             else
627             begin
628               Tmp := TTemplate.Create('0^T^A^' + NewTemplateName + '^^^' + ownr);
629               Tmp.BackupItems;
630               Templates.AddObject(Tmp.ID, Tmp);
631             end;
632             btnApply.Enabled := TRUE;
633             if (idx >= Owner.Items.Count) then
634               Owner.Items.Add(Tmp)
635             else
636               Owner.Items.Insert(idx, Tmp);
637             Resync([Owner]);
638             Node := FCurTree.Selected;
639             if (Node.Data <> Tmp) then
640             begin
641               if (TTemplate(Node.Data).RealType = ttDoc) then
642                 Node := Node.GetNextSibling
643               else
644               begin
645                 Node.Expand(FALSE);
646                 Node := Node.GetFirstChild;
647               end;
648               FCurTree.Selected := Node;
649             end;
650             FBtnNewNode := Node;
651             if (FFirstShow) then
652               FFocusName := TRUE
653             else
654             begin
655               edtName.SetFocus;
656               edtName.SelectAll;
657             end;
658           end;
659         end;
660       end;
661     end;
662   end;