-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkflowButtonDialogUnit.pas
More file actions
105 lines (91 loc) · 2.6 KB
/
Copy pathWorkflowButtonDialogUnit.pas
File metadata and controls
105 lines (91 loc) · 2.6 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
unit WorkflowButtonDialogUnit;
{$mode objfpc}{$H+}
{$codepage utf8}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls, Dialogs, ExtCtrls, AppSettings;
type
TWorkflowButtonDialogForm = class(TForm)
CancelButton: TButton;
CopyModeCombo: TComboBox;
CopyModeLabel: TLabel;
HintEdit: TEdit;
HintLabel: TLabel;
MainPanel: TPanel;
NameEdit: TEdit;
NameLabel: TLabel;
OkButton: TButton;
PrefixLabel: TLabel;
PrefixMemo: TMemo;
SuffixLabel: TLabel;
SuffixMemo: TMemo;
TargetEdit: TEdit;
TargetLabel: TLabel;
private
function ValidateInput: Boolean;
public
function Execute(AConfig: TWorkflowButtonConfig): Boolean;
end;
function EditWorkflowButton(AConfig: TWorkflowButtonConfig): Boolean;
implementation
{$R *.lfm}
function CopyModeCaption(AMode: TWorkflowCopyMode): string;
begin
case AMode of
wcmTitleAndChapterText: Result := 'Kapiteltitel + Kapiteltext';
wcmPromptPlusChapter: Result := 'Prefix/Suffix + Kapiteltext';
else
Result := 'Nur Kapiteltext';
end;
end;
function TWorkflowButtonDialogForm.ValidateInput: Boolean;
begin
Result := False;
if Trim(NameEdit.Text) = '' then
begin
MessageDlg('Bitte einen Button-Namen eingeben.', mtWarning, [mbOK], 0);
Exit;
end;
if Trim(TargetEdit.Text) = '' then
begin
MessageDlg('Bitte ein Ziel als URL oder Programmpfad eingeben.', mtWarning, [mbOK], 0);
Exit;
end;
Result := True;
end;
function TWorkflowButtonDialogForm.Execute(AConfig: TWorkflowButtonConfig): Boolean;
begin
NameEdit.Text := AConfig.Name;
TargetEdit.Text := AConfig.Target;
HintEdit.Text := AConfig.Hint;
PrefixMemo.Text := AConfig.Prefix;
SuffixMemo.Text := AConfig.Suffix;
CopyModeCombo.Items.Clear;
CopyModeCombo.Items.Add(CopyModeCaption(wcmChapterText));
CopyModeCombo.Items.Add(CopyModeCaption(wcmTitleAndChapterText));
CopyModeCombo.Items.Add(CopyModeCaption(wcmPromptPlusChapter));
CopyModeCombo.ItemIndex := Ord(AConfig.CopyMode);
Result := ShowModal = mrOk;
if not Result then
Exit(False);
if not ValidateInput then
Exit(Execute(AConfig));
AConfig.Name := Trim(NameEdit.Text);
AConfig.Target := Trim(TargetEdit.Text);
AConfig.Hint := Trim(HintEdit.Text);
AConfig.Prefix := PrefixMemo.Text;
AConfig.Suffix := SuffixMemo.Text;
AConfig.CopyMode := TWorkflowCopyMode(CopyModeCombo.ItemIndex);
end;
function EditWorkflowButton(AConfig: TWorkflowButtonConfig): Boolean;
var
Dialog: TWorkflowButtonDialogForm;
begin
Dialog := TWorkflowButtonDialogForm.Create(nil);
try
Result := Dialog.Execute(AConfig);
finally
Dialog.Free;
end;
end;
end.