-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathProjectEditorRelease.pas
More file actions
158 lines (136 loc) · 4.51 KB
/
ProjectEditorRelease.pas
File metadata and controls
158 lines (136 loc) · 4.51 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
/// Documentation editor Version number wizard form
// - this unit is part of SynProject, under GPL 3.0 license; version 1.7
unit ProjectEditorRelease;
(*
This file is part of SynProject.
Synopse SynProject. Copyright (C) 2008-2023 Arnaud Bouchez
Synopse Informatique - https://synopse.info
SynProject is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.
SynProject is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with SynProject. If not, see <http://www.gnu.org/licenses/>.
*)
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons,
ProjectSections;
type
TProjectEditorReleaseForm = class(TForm)
Description: TLabeledEdit;
BtnCurrent: TBitBtn;
BtnCancel: TBitBtn;
Version: TLabeledEdit;
Date: TLabeledEdit;
BtnToday: TButton;
BtnNew: TBitBtn;
procedure BtnCurrentClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BtnTodayClick(Sender: TObject);
private
Doc: TSection;
public
procedure Init(aDoc: TSection);
end;
resourcestring
sNewReleaseForDocumentN = 'New Release for the "%s" document';
sDocumentVersionNumberN = '"%s" document version number (1.01 e.g.):';
sErrorRevisionNotInUserN = 'The revision %s is not in use - please enter an existing one';
sErrorRevisionUsedN = 'The revision %s is already used - please enter a new value';
implementation
uses
ProjectCommons,
ProjectFormDocWizard,
ProjectVersionSCR;
{
Revision=0.1
RevisionDescription=Initial Version
RevisionDate=October 1, 2008
}
{$R *.dfm}
procedure TProjectEditorReleaseForm.Init(aDoc: TSection);
var Title: string;
begin
if self=nil then exit;
Doc := aDoc;
Title := Doc.DisplayName(nil);
Caption := ' '+format(sNewReleaseForDocumentN,[Title]);
Version.EditLabel.Caption := format(sDocumentVersionNumberN,[Title]);
Version.Text := aDoc['Revision'];
Description.Text := aDoc['RevisionDescription'];
Date.Text := aDoc['RevisionDate'];
end;
procedure TProjectEditorReleaseForm.BtnCurrentClick(Sender: TObject);
var i, num, first: integer;
s,up: string;
oldDate: boolean;
begin
ModalResult := mrNone;
if not notVoid(Version) or not notVoid(Description) then exit;
up := uppercase(trim(Version.Text));
if Sender=BtnCurrent then begin
if not SameText(Doc['Revision'],up) then begin // check is current
MessageErrFmt(sErrorRevisionNotInUserN,up);
Version.SetFocus;
exit;
end;
Doc['RevisionDescription'] := Description.Text;
Doc['RevisionDate'] := Date.Text;
end else
if Sender=BtnNew then begin
first := -1;
num := -1;
for i := 0 to Doc.Lines.Count-1 do begin
s := Doc.Lines[i];
if (s='') or (s[1]=':') then break;
if IdemPChar(pointer(s),'REVISION=') then begin
if first<0 then
first := i;
if IdemPChar(@s[length('REVISION=')+1],pointer(up)) then begin
num := i;
break;
end;
end;
end;
if num>=0 then begin // check if unique
MessageErrFmt(sErrorRevisionUsedN,up);
Version.SetFocus;
exit;
end;
if Doc['RevisionDate']='' then begin
Doc['RevisionDate'] := trim(Date.Text); // update old version date
oldDate := true;
end else
oldDate := false;
if first<0 then begin // no Revision= yet -> just add new
Doc['Revision'] := up;
Doc['RevisionDescription'] := trim(Description.Text);
// RevisionDate was '' -> already set
end else begin // add before any existing Revision=
if oldDate then
Doc.Lines.Insert(first,'RevisionDate=') else
Doc.Lines.Insert(first,'RevisionDate='+trim(Date.Text));
Doc.Lines.Insert(first,'RevisionDescription='+trim(Description.Text));
Doc.Lines.Insert(first,'Revision='+up);
end;
end;
ModalResult := mrOk;
end;
procedure TProjectEditorReleaseForm.FormShow(Sender: TObject);
begin
if Version.Text='' then
Version.SetFocus;
end;
procedure TProjectEditorReleaseForm.BtnTodayClick(Sender: TObject);
var s: string;
begin
DateTimeToString(s,'mmmm d, yyyy',now);
Date.Text := s;
end;
end.