Procedure

TfrmTemplateEditor.sbMoveDownClick

Module

fTemplateEditor

Last Modified

7/15/2014 3:26:44 PM

Visibility

Public/Published

Owner

TfrmTemplateEditor

Declaration

procedure sbMoveDownClick(Sender: TObject);

Calls Hierarchy


TfrmTemplateEditor.sbMoveDownClick
 ├TTemplate.GetItems
 │ └ExpandTemplate
 │   ├TTemplate.GetChildren
 │   ├GetTemplateChildren
 │   ├AddTemplate
 │   │ ├TTemplate.Create
 │   │ │ └TTemplate.ReminderDialogIEN
 │   │ └TTemplate.AddChild
 │   │   └TTemplate.GetItems...
 │   └TTemplate.ItemIENs
 │     └TTemplate.GetItems...
 ├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.SetBoilerplate
 │ │ │ │ ├TTemplate.CanModify...
 │ │ │ │ └TTemplate.ValidID
 │ │ │ ├TTemplate.GetBoilerplate
 │ │ │ │ └GetTemplateBoilerplate
 │ │ │ ├TTemplate.SetDescription
 │ │ │ │ ├TTemplate.CanModify...
 │ │ │ │ └TTemplate.ValidID
 │ │ │ └TTemplate.GetDescription
 │ │ │   └LoadTemplateDescription
 │ │ ├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...
 └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

Calls

Name Declaration Comments
TfrmTemplateEditor.CanClone function CanClone(const Node: TTreeNode): boolean; -
TTemplate.CanModify function CanModify: boolean; -
TfrmTemplateEditor.Clone function Clone(Node: TTreeNode): boolean; -
TTemplate.GetItems function GetItems: TList; -
TfrmTemplateEditor.Resync procedure Resync(const Templates: array of TTemplate); -


Source

1650  procedure TfrmTemplateEditor.sbMoveDownClick(Sender: TObject);
1651  var
1652    max, idx: integer;
1653    ChangeLevel: boolean;
1654    ParentsParent, ParentNode, Node: TTreeNode;
1655    NodeTemplate, ParentTemplate, Template: TTemplate;
1656    Hide, First, ok: boolean;
1657  
1658  begin
1659    if ((assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
1660      (assigned(FCurTree.Selected.Parent))) then
1661    begin
1662      Node := FCurTree.Selected;
1663      NodeTemplate := TTemplate(Node.Data);
1664      ParentNode := Node.Parent;
1665      Template := TTemplate(ParentNode.Data);
1666      idx := Template.Items.IndexOf(NodeTemplate);
1667      max := Template.Items.Count - 1;
1668      ChangeLevel := (idx >= max);
1669      if (not ChangeLevel) then
1670      begin
1671        if (TTemplateTreeType(TBitBtn(Sender).Tag) = ttShared) then
1672          Hide := cbShHide.Checked
1673        else
1674          Hide := cbPerHide.Checked;
1675        First := TRUE;
1676        while (idx < max) do
1677        begin
1678          if First then
1679          begin
1680            ok := FALSE;
1681            First := FALSE;
1682            if CanClone(ParentNode) then
1683            begin
1684              if (Clone(ParentNode)) then
1685                Template := TTemplate(ParentNode.Data);
1686              if Template.CanModify then
1687                ok := TRUE;
1688            end;
1689          end
1690          else
1691            ok := TRUE;
1692          if ok then
1693          begin
1694            Template.Items.Exchange(idx, idx + 1);
1695            if (Hide and (not TTemplate(Template.Items[idx]).Active)) then
1696            begin
1697              inc(idx);
1698              ChangeLevel := (idx >= max);
1699            end
1700            else
1701              idx := max;
1702          end
1703          else
1704            idx := max;
1705        end;
1706      end;
1707      if (ChangeLevel) then
1708      begin
1709        ParentsParent := ParentNode.Parent;
1710        if (assigned(ParentsParent)) then
1711        begin
1712          ParentTemplate := TTemplate(ParentsParent.Data);
1713          if (ParentTemplate.Items.IndexOf(NodeTemplate) >= 0) then
1714            InfoBox(ParentsParent.Text + ' already contains the ' +
1715              NodeTemplate.PrintName + ' template.',
1716              'Error', MB_OK or MB_ICONERROR)
1717          else
1718          begin
1719            if CanClone(ParentNode) then
1720            begin
1721              if (Clone(ParentNode)) then
1722                Template := TTemplate(ParentNode.Data);
1723              if Template.CanModify and CanClone(ParentsParent) then
1724              begin
1725                if (Clone(ParentsParent)) then
1726                  ParentTemplate := TTemplate(ParentsParent.Data);
1727                if ParentTemplate.CanModify then
1728                begin
1729                  Template.Items.Delete(idx);
1730                  idx := ParentTemplate.Items.IndexOf(Template);
1731                  if (idx >= 0) then
1732                  begin
1733                    if (idx = (ParentTemplate.Items.Count - 1)) then
1734                      ParentTemplate.Items.Add(NodeTemplate)
1735                    else
1736                      ParentTemplate.Items.Insert(idx + 1, NodeTemplate);
1737                    Resync([ParentTemplate, Template]);
1738                    btnApply.Enabled := TRUE;
1739                  end;
1740                end;
1741              end;
1742            end;
1743          end;
1744        end;
1745      end
1746      else
1747      begin
1748        Resync([Template]);
1749        btnApply.Enabled := TRUE;
1750      end;
1751    end;
1752  end;