-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProjectViewForm.pas
More file actions
178 lines (162 loc) · 4.52 KB
/
ProjectViewForm.pas
File metadata and controls
178 lines (162 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
unit ProjectViewForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IDEView, VirtualTrees, ProjectTreeController, Events, IDEModule,
Menus, IDEActionModule, ActnList;
type
TProjectView = class(TIDEView)
ProjectTree: TVirtualStringTree;
ProjectPopup: TPopupMenu;
NewUnit2: TMenuItem;
AddUnit2: TMenuItem;
Options3: TMenuItem;
UnitPopup: TPopupMenu;
NewUnit1: TMenuItem;
AddUnit1: TMenuItem;
RemoveUnit1: TMenuItem;
Options2: TMenuItem;
ActionList: TActionList;
actRemoveSelectedUnit: TAction;
procedure FormCreate(Sender: TObject);
procedure ProjectTreeContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
procedure ProjectTreeDblClick(Sender: TObject);
procedure actRemoveSelectedUnitExecute(Sender: TObject);
private
{ Private declarations }
FTreeController: TProjectTreeController;
FIDEData: TIDEData;
FIDEActions: TIDEActions;
procedure SetIDEData(const Value: TIDEData);
procedure SetIDEActions(const Value: TIDEActions);
public
{ Public declarations }
procedure Event(AEventData: TEventData); override;
property IDEData: TIDEData read FIDEData write SetIDEData;
property IDEActions: TIDEActions read FIDEActions write SetIDEActions;
end;
var
ProjectView: TProjectView;
implementation
uses
ProjectEvents, IDEUnit, Project;
{$R *.dfm}
procedure TProjectView.actRemoveSelectedUnitExecute(Sender: TObject);
var
LItem: TObject;
LIndex: Integer;
begin
LItem := FTreeController.GetSelectedItem();
if LItem is TIDEUnit then
begin
LIndex := Controller.GetPageIndexForIdeUnit(TIDEUnit(LItem));
if (LIndex = -1) or Controller.ClosePage(LIndex) then
begin
FTreeController.Project.Units.Remove(TIDEUnit(LItem));
end;
end;
end;
procedure TProjectView.Event(AEventData: TEventData);
begin
inherited;
if AEventData.EventID = evProjectChanged then
begin
FTreeController.Project := TProjectEvenetData(AEventData).Project;
end;
end;
procedure TProjectView.FormCreate(Sender: TObject);
begin
ProjectTree.NodeDataSize := SizeOf(Cardinal);
FTreeController := TProjectTreeController.Create(ProjectTree);
end;
procedure TProjectView.ProjectTreeContextPopup(Sender: TObject;
MousePos: TPoint; var Handled: Boolean);
var
LNode: PVirtualNode;
begin
LNode := ProjectTree.GetNodeAt(MousePos.X, MousePos.Y);
if LNode = ProjectTree.GetFirst() then
begin
ProjectTree.PopupMenu := ProjectPopup;
end
else
begin
if Assigned(LNode) then
begin
ProjectTree.PopupMenu := UnitPopup;
end
else
begin
ProjectTree.PopupMenu := nil;
end;
end;
end;
procedure TProjectView.ProjectTreeDblClick(Sender: TObject);
var
LPos: TPoint;
LNode: PVirtualNode;
LData: PProjectNodeData;
LUnit: TIDEUnit;
begin
LUnit := nil;
GetCursorPos(LPos);
LPos := ProjectTree.ScreenToClient(LPos);
LNode := ProjectTree.GetNodeAt(LPos.X, LPos.Y);
if Assigned(LNode) then
begin
if LNode = ProjectTree.GetFirst() then
begin
LData := ProjectTree.GetNodeData(LNode);
if Assigned(LData) then
begin
LUnit := TProject(LData.Item).ProjectUnit;
end;
end
else
begin
LData := ProjectTree.GetNodeData(LNode);
if Assigned(LData) then
begin
LUnit := TIDEUnit(LData.Item);
end;
end;
if Assigned(LUnit) then
begin
if not Controller.IDEUnitIsOpen(LUnit) then
begin
Controller.AddPage(LUnit.Caption, '', LUnit);
end;
Controller.FokusIDEPageByUnit(LUnit);
end;
end;
end;
procedure TProjectView.SetIDEActions(const Value: TIDEActions);
begin
FIDEActions := Value;
if Assigned(FIDEActions) then
begin
//UnitPopup
NewUnit1.Action := FIDEActions.actNewUnit;
AddUnit1.Action := FIDEActions.actAddExistingUnit;
RemoveUnit1.Action := actRemoveSelectedUnit;
Options2.Action := FIDEActions.actProjectOptions;
//Projectpopup
NewUnit2.Action := FIDEActions.actNewUnit;
AddUnit2.Action := FIDEActions.actAddExistingUnit;
Options3.Action := FIDEActions.actProjectOptions;
end;
end;
procedure TProjectView.SetIDEData(const Value: TIDEData);
begin
FIDEData := Value;
if Assigned(FIDEData) then
begin
FTreeController.Images := FIDEData.TreeImages;
end
else
begin
FTreeController.Images := nil;
end;
end;
end.