1 | unit UInstanceOptions;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | ComCtrls, ExtCtrls, DOM, XMLWrite, XMLRead, USource, UInstance,
|
---|
10 | USourceSelection;
|
---|
11 |
|
---|
12 | type
|
---|
13 |
|
---|
14 | { TInstanceOptionsForm }
|
---|
15 |
|
---|
16 | TInstanceOptionsForm = class(TForm)
|
---|
17 | Button1: TButton;
|
---|
18 | Button2: TButton;
|
---|
19 | ButtonCancel: TButton;
|
---|
20 | ButtonOk: TButton;
|
---|
21 | Edit1: TEdit;
|
---|
22 | Edit2: TEdit;
|
---|
23 | Edit3: TEdit;
|
---|
24 | Label1: TLabel;
|
---|
25 | Label2: TLabel;
|
---|
26 | Label3: TLabel;
|
---|
27 | procedure Button1Click(Sender: TObject);
|
---|
28 | procedure Button2Click(Sender: TObject);
|
---|
29 | procedure ButtonCancelClick(Sender: TObject);
|
---|
30 | procedure ButtonOkClick(Sender: TObject);
|
---|
31 | procedure FormCreate(Sender: TObject);
|
---|
32 | procedure FormDestroy(Sender: TObject);
|
---|
33 | procedure FormShow(Sender: TObject);
|
---|
34 | private
|
---|
35 | IsNew: Boolean;
|
---|
36 | public
|
---|
37 | Instance: TInstance;
|
---|
38 | FPCSource: TSource;
|
---|
39 | IDESource: TSource;
|
---|
40 | end;
|
---|
41 |
|
---|
42 | var
|
---|
43 | InstanceOptionsForm: TInstanceOptionsForm;
|
---|
44 |
|
---|
45 | implementation
|
---|
46 |
|
---|
47 | {$R *.lfm}
|
---|
48 |
|
---|
49 | uses
|
---|
50 | UMainForm;
|
---|
51 |
|
---|
52 | { TInstanceOptionsForm }
|
---|
53 |
|
---|
54 | procedure TInstanceOptionsForm.ButtonOkClick(Sender: TObject);
|
---|
55 | begin
|
---|
56 | Instance.Name := Edit1.Text;
|
---|
57 | Instance.FPCSource := FPCSource;
|
---|
58 | Instance.IDESource := IDESource;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TInstanceOptionsForm.ButtonCancelClick(Sender: TObject);
|
---|
62 | begin
|
---|
63 | if IsNew then Instance.Free;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TInstanceOptionsForm.Button1Click(Sender: TObject);
|
---|
67 | begin
|
---|
68 | SourceSelectionForm.ProjectType := 'Compiler';
|
---|
69 | if SourceSelectionForm.ShowModal = mrOk then begin
|
---|
70 | if Assigned(SourceSelectionForm.ListView1.Selected) then
|
---|
71 | FPCSource := TSource(SourceSelectionForm.ListView1.Selected.Data)
|
---|
72 | else FPCSource := nil;
|
---|
73 | if Assigned(FPCSource) then
|
---|
74 | Edit2.Text := FPCSource.GetName
|
---|
75 | else Edit2.Text := '';
|
---|
76 | end;
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TInstanceOptionsForm.Button2Click(Sender: TObject);
|
---|
80 | begin
|
---|
81 | SourceSelectionForm.ProjectType := 'IDE';
|
---|
82 | if SourceSelectionForm.ShowModal = mrOk then begin
|
---|
83 | if Assigned(SourceSelectionForm.ListView1.Selected) then
|
---|
84 | IDESource := TSource(SourceSelectionForm.ListView1.Selected.Data)
|
---|
85 | else IDESource := nil;
|
---|
86 | if Assigned(IDESource) then
|
---|
87 | Edit3.Text := IDESource.GetName
|
---|
88 | else Edit3.Text := '';
|
---|
89 | end;
|
---|
90 | end;
|
---|
91 |
|
---|
92 | procedure TInstanceOptionsForm.FormCreate(Sender: TObject);
|
---|
93 | begin
|
---|
94 | end;
|
---|
95 |
|
---|
96 | procedure TInstanceOptionsForm.FormDestroy(Sender: TObject);
|
---|
97 | begin
|
---|
98 | end;
|
---|
99 |
|
---|
100 | procedure TInstanceOptionsForm.FormShow(Sender: TObject);
|
---|
101 | begin
|
---|
102 | if not Assigned(Instance) then begin
|
---|
103 | Instance := TInstance.Create;
|
---|
104 | Instance.Id := MainForm.Instances.GetNewId;
|
---|
105 | Instance.Name := 'Instance ' + IntToStr(Instance.Id);
|
---|
106 | IsNew := True;
|
---|
107 | end else IsNew := False;
|
---|
108 |
|
---|
109 | Edit1.Text := Instance.Name;
|
---|
110 | FPCSource := Instance.FPCSource;
|
---|
111 | IDESource := Instance.IDESource;
|
---|
112 | if Assigned(FPCSource) then
|
---|
113 | Edit2.Text := FPCSource.GetName
|
---|
114 | else Edit2.Text := '';
|
---|
115 | if Assigned(IDESource) then
|
---|
116 | Edit3.Text := IDESource.GetName
|
---|
117 | else Edit3.Text := '';
|
---|
118 | end;
|
---|
119 |
|
---|
120 | end.
|
---|
121 |
|
---|