1 | unit UFormMenu;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
|
---|
9 | StdCtrls, Menus, ActnList, UTreeState;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormMenu }
|
---|
14 |
|
---|
15 | TFormMenu = class(TForm)
|
---|
16 | AObjectGroupShow: TAction;
|
---|
17 | AObjectGroupDelete: TAction;
|
---|
18 | AObjectGroupAddGroup: TAction;
|
---|
19 | AObjectGroupAddObject: TAction;
|
---|
20 | AObjectGroupEdit: TAction;
|
---|
21 | AObjectDelete: TAction;
|
---|
22 | AObjectEdit: TAction;
|
---|
23 | ActionList1: TActionList;
|
---|
24 | MenuItem1: TMenuItem;
|
---|
25 | MenuItem10: TMenuItem;
|
---|
26 | MenuItem5: TMenuItem;
|
---|
27 | MenuItem6: TMenuItem;
|
---|
28 | MenuItem7: TMenuItem;
|
---|
29 | MenuItem8: TMenuItem;
|
---|
30 | MenuItem9: TMenuItem;
|
---|
31 | PopupMenuObject: TPopupMenu;
|
---|
32 | PopupMenuObjectGroup: TPopupMenu;
|
---|
33 | TabControl1: TTabControl;
|
---|
34 | TreeViewMenu: TTreeView;
|
---|
35 | procedure AObjectEditExecute(Sender: TObject);
|
---|
36 | procedure AObjectGroupAddGroupExecute(Sender: TObject);
|
---|
37 | procedure AObjectGroupDeleteExecute(Sender: TObject);
|
---|
38 | procedure AObjectGroupEditExecute(Sender: TObject);
|
---|
39 | procedure AObjectGroupShowExecute(Sender: TObject);
|
---|
40 | procedure FormCreate(Sender: TObject);
|
---|
41 | procedure FormDestroy(Sender: TObject);
|
---|
42 | procedure TreeViewMenuChange(Sender: TObject; Node: TTreeNode);
|
---|
43 | private
|
---|
44 | TreeState: TTreeState;
|
---|
45 | public
|
---|
46 | procedure LoadTree;
|
---|
47 | end;
|
---|
48 |
|
---|
49 | var
|
---|
50 | FormMenu: TFormMenu;
|
---|
51 |
|
---|
52 | implementation
|
---|
53 |
|
---|
54 | {$R *.lfm}
|
---|
55 |
|
---|
56 | uses
|
---|
57 | UFormMain, USystem, UPDClient, UCore;
|
---|
58 |
|
---|
59 | procedure TFormMenu.TreeViewMenuChange(Sender: TObject; Node: TTreeNode);
|
---|
60 | begin
|
---|
61 | AObjectGroupDelete.Enabled := Assigned(TreeViewMenu.Selected);
|
---|
62 | AObjectGroupEdit.Enabled := Assigned(TreeViewMenu.Selected);
|
---|
63 | if Assigned(TreeViewMenu.Selected) then begin
|
---|
64 | if TreeViewMenu.Selected.ImageIndex = 0 then begin
|
---|
65 | TreeViewMenu.PopupMenu := PopupMenuObjectGroup;
|
---|
66 | MainForm.PanelData.Visible := False;
|
---|
67 | end;
|
---|
68 | if TreeViewMenu.Selected.ImageIndex = 1 then begin
|
---|
69 | TreeViewMenu.PopupMenu := PopupMenuObject;
|
---|
70 | //LoadItemList;
|
---|
71 | end;
|
---|
72 | end;
|
---|
73 | end;
|
---|
74 |
|
---|
75 | procedure TFormMenu.AObjectEditExecute(Sender: TObject);
|
---|
76 | begin
|
---|
77 | (* if Assigned(TreeView1.Selected) then begin
|
---|
78 | SelectedObjectId := 9;
|
---|
79 | SelectedItem := Integer(TreeView1.Selected.Data);
|
---|
80 | ItemEditForm.Show;
|
---|
81 | end;*)
|
---|
82 | end;
|
---|
83 |
|
---|
84 | procedure TFormMenu.AObjectGroupAddGroupExecute(Sender: TObject);
|
---|
85 | begin
|
---|
86 |
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TFormMenu.AObjectGroupDeleteExecute(Sender: TObject);
|
---|
90 | begin
|
---|
91 |
|
---|
92 | end;
|
---|
93 |
|
---|
94 | procedure TFormMenu.AObjectGroupEditExecute(Sender: TObject);
|
---|
95 | begin
|
---|
96 | (* if Assigned(TreeView1.Selected) then begin
|
---|
97 | SelectedObjectId := 8;
|
---|
98 | SelectedItem := Integer(TreeView1.Selected.Data);
|
---|
99 | ItemEditForm.Show;
|
---|
100 | end;*)
|
---|
101 | end;
|
---|
102 |
|
---|
103 | procedure TFormMenu.AObjectGroupShowExecute(Sender: TObject);
|
---|
104 | begin
|
---|
105 | if Assigned(TreeViewMenu.Selected) then begin
|
---|
106 | MainForm.MainPanelForm.SelectedObject.Load(Integer(TreeViewMenu.Selected.Data));
|
---|
107 | MainForm.MainPanelForm.Caption := MainForm.MainPanelForm.SelectedObject.Name;
|
---|
108 | MainForm.MainPanelForm.Show;
|
---|
109 | MainForm.MainPanelForm.Reload;
|
---|
110 | MainForm.UpdateInterface;
|
---|
111 | end;
|
---|
112 | end;
|
---|
113 |
|
---|
114 | procedure TFormMenu.FormCreate(Sender: TObject);
|
---|
115 | begin
|
---|
116 | TreeState := TTreeState.Create;
|
---|
117 | end;
|
---|
118 |
|
---|
119 | procedure TFormMenu.FormDestroy(Sender: TObject);
|
---|
120 | begin
|
---|
121 | FreeAndNil(TreeState);
|
---|
122 | end;
|
---|
123 |
|
---|
124 | procedure TFormMenu.LoadTree;
|
---|
125 | var
|
---|
126 | Groups: TListProxy;
|
---|
127 | Obj: TObjectProxy;
|
---|
128 | Objects: TListProxy;
|
---|
129 | Obj2: TObjectProxy;
|
---|
130 | I: Integer;
|
---|
131 | O: Integer;
|
---|
132 | NewNode: TTreeNode;
|
---|
133 | NewObjectNode: TTreeNode;
|
---|
134 | begin
|
---|
135 | with TreeViewMenu, Items do begin
|
---|
136 | TreeState.SaveTree(TreeViewMenu);
|
---|
137 | Clear;
|
---|
138 | AddChild(nil, SGroup);
|
---|
139 | TopItem.ImageIndex := 0;
|
---|
140 | TopItem.SelectedIndex := 0;
|
---|
141 | try
|
---|
142 | Groups := TListProxy.Create;
|
---|
143 | Groups.Client := Core.System.Client;
|
---|
144 | Groups.ObjectName := SystemMenuTable;
|
---|
145 | Groups.Path := Core.System.Client.Schema;
|
---|
146 | Groups.Load;
|
---|
147 | for I := 0 to Groups.Objects.Count - 1 do begin
|
---|
148 | Obj := TObjectProxy(Groups.Objects[I]);
|
---|
149 | NewNode := AddChild(TopItem, Obj.Properties.Values['Name']);
|
---|
150 | NewNode.ImageIndex := 0;
|
---|
151 | NewNode.SelectedIndex := 0;
|
---|
152 | NewNode.Data := Pointer(StrToInt(Obj.Properties.Values['Id']));
|
---|
153 | try
|
---|
154 | Objects := TListProxy.Create;
|
---|
155 | Objects.Client := Core.System.Client;
|
---|
156 | Objects.ObjectName := SystemObjectTable;
|
---|
157 | Objects.Path := Core.System.Client.Schema;
|
---|
158 | Objects.Condition := '`Group`="' + Obj.Properties.Values['Id'] + '"';
|
---|
159 | Objects.Load;
|
---|
160 | for O := 0 to Objects.Objects.Count - 1 do begin
|
---|
161 | Obj2 := TObjectProxy(Objects.Objects[O]);
|
---|
162 | NewObjectNode := AddChild(NewNode, Obj2.Properties.Values['Name']);
|
---|
163 | NewObjectNode.Data := Pointer(StrToInt(Obj2.Properties.Values['Id']));
|
---|
164 | NewObjectNode.ImageIndex := 1;
|
---|
165 | NewObjectNode.SelectedIndex := 1;
|
---|
166 | end;
|
---|
167 | finally
|
---|
168 | Objects.Free;
|
---|
169 | end;
|
---|
170 | end;
|
---|
171 | TopItem.Expand(True);
|
---|
172 | finally
|
---|
173 | Groups.Free;
|
---|
174 | end;
|
---|
175 | TreeState.LoadTree(TreeViewMenu);
|
---|
176 | end;
|
---|
177 | end;
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 | end.
|
---|
182 |
|
---|