source: branches/test1/Client/Forms/UFormMenu.pas

Last change on this file was 54, checked in by chronos, 12 years ago
  • Added: ChronisAppServer base project.
  • Modified: Changes in client virtual database layer handling.
File size: 5.0 KB
Line 
1unit UFormMenu;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
9 StdCtrls, Menus, ActnList, UTreeState;
10
11type
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
49var
50 FormMenu: TFormMenu;
51
52implementation
53
54{$R *.lfm}
55
56uses
57 UFormMain, USystem, UPDClient, UCore;
58
59procedure TFormMenu.TreeViewMenuChange(Sender: TObject; Node: TTreeNode);
60begin
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;
73end;
74
75procedure TFormMenu.AObjectEditExecute(Sender: TObject);
76begin
77(* if Assigned(TreeView1.Selected) then begin
78 SelectedObjectId := 9;
79 SelectedItem := Integer(TreeView1.Selected.Data);
80 ItemEditForm.Show;
81 end;*)
82end;
83
84procedure TFormMenu.AObjectGroupAddGroupExecute(Sender: TObject);
85begin
86
87end;
88
89procedure TFormMenu.AObjectGroupDeleteExecute(Sender: TObject);
90begin
91
92end;
93
94procedure TFormMenu.AObjectGroupEditExecute(Sender: TObject);
95begin
96(* if Assigned(TreeView1.Selected) then begin
97 SelectedObjectId := 8;
98 SelectedItem := Integer(TreeView1.Selected.Data);
99 ItemEditForm.Show;
100 end;*)
101end;
102
103procedure TFormMenu.AObjectGroupShowExecute(Sender: TObject);
104begin
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;
112end;
113
114procedure TFormMenu.FormCreate(Sender: TObject);
115begin
116 TreeState := TTreeState.Create;
117end;
118
119procedure TFormMenu.FormDestroy(Sender: TObject);
120begin
121 FreeAndNil(TreeState);
122end;
123
124procedure TFormMenu.LoadTree;
125var
126 Groups: TListProxy;
127 Obj: TObjectProxy;
128 Objects: TListProxy;
129 Obj2: TObjectProxy;
130 I: Integer;
131 O: Integer;
132 NewNode: TTreeNode;
133 NewObjectNode: TTreeNode;
134begin
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;
177end;
178
179
180
181end.
182
Note: See TracBrowser for help on using the repository browser.