Procedure

TfrmTemplateEditor.sbMoveUpClick

Module

fTemplateEditor

Last Modified

7/15/2014 3:26:44 PM

Visibility

Public/Published

Owner

TfrmTemplateEditor

Declaration

procedure sbMoveUpClick(Sender: TObject);

Calls Hierarchy


TfrmTemplateEditor.sbMoveUpClick
 ├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

1550  procedure TfrmTemplateEditor.sbMoveUpClick(Sender: TObject);
1551  var
1552    idx: integer;
1553    ChangeLevel: boolean;
1554    ParentsParent, ParentNode, Node: TTreeNode;
1555    NodeTemplate, ParentTemplate, Template: TTemplate;
1556    Hide, First, ok: boolean;
1557  
1558  begin
1559    if ((assigned(FCurTree)) and (assigned(FCurTree.Selected)) and
1560      (assigned(FCurTree.Selected.Parent))) then
1561    begin
1562      Node := FCurTree.Selected;
1563      NodeTemplate := TTemplate(Node.Data);
1564      ParentNode := Node.Parent;
1565      Template := TTemplate(ParentNode.Data);
1566      idx := Template.Items.IndexOf(NodeTemplate);
1567      ChangeLevel := (idx < 1);
1568      if (not ChangeLevel) then
1569      begin
1570        if (TTemplateTreeType(TBitBtn(Sender).Tag) = ttShared) then
1571          Hide := cbShHide.Checked
1572        else
1573          Hide := cbPerHide.Checked;
1574        First := TRUE;
1575        while (idx > 0) do
1576        begin
1577          if First then
1578          begin
1579            ok := FALSE;
1580            First := FALSE;
1581            if CanClone(ParentNode) then
1582            begin
1583              if (Clone(ParentNode)) then
1584                Template := TTemplate(ParentNode.Data);
1585              if Template.CanModify then
1586                ok := TRUE;
1587            end;
1588          end
1589          else
1590            ok := TRUE;
1591          if ok then
1592          begin
1593            Template.Items.Exchange(idx - 1, idx);
1594            if (Hide and (not TTemplate(Template.Items[idx]).Active)) then
1595            begin
1596              dec(idx);
1597              ChangeLevel := (idx < 1);
1598            end
1599            else
1600              idx := 0;
1601          end
1602          else
1603            idx := 0;
1604        end;
1605      end;
1606      if (ChangeLevel) then
1607      begin
1608        ParentsParent := ParentNode.Parent;
1609        if (assigned(ParentsParent)) then
1610        begin
1611          ParentTemplate := TTemplate(ParentsParent.Data);
1612          if (ParentTemplate.Items.IndexOf(NodeTemplate) >= 0) then
1613            InfoBox(ParentsParent.Text + ' already contains the ' +
1614              NodeTemplate.PrintName + ' template.',
1615              'Error', MB_OK or MB_ICONERROR)
1616          else
1617          begin
1618            if CanClone(ParentNode) then
1619            begin
1620              if (Clone(ParentNode)) then
1621                Template := TTemplate(ParentNode.Data);
1622              if Template.CanModify and CanClone(ParentsParent) then
1623              begin
1624                if (Clone(ParentsParent)) then
1625                  ParentTemplate := TTemplate(ParentsParent.Data);
1626                if ParentTemplate.CanModify then
1627                begin
1628                  Template.Items.Delete(idx);
1629                  idx := ParentTemplate.Items.IndexOf(Template);
1630                  if (idx >= 0) then
1631                  begin
1632                    ParentTemplate.Items.Insert(idx, NodeTemplate);
1633                    Resync([ParentTemplate, Template]);
1634                    btnApply.Enabled := TRUE;
1635                  end;
1636                end;
1637              end;
1638            end;
1639          end;
1640        end;
1641      end
1642      else
1643      begin
1644        Resync([Template]);
1645        btnApply.Enabled := TRUE;
1646      end;
1647    end;
1648  end;