ec_labelbase.pas 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. unit ec_labelbase;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Buttons,
  6. StdCtrls, ec_base;
  7. type
  8. { TECLabelBaseFrame }
  9. TECLabelBaseFrame = class(TECBaseFrame)
  10. LabelNameEdit: TEdit;
  11. LabelNameLabel: TLabel;
  12. procedure FormShow(Sender: TObject);
  13. public
  14. function GetCommandCode: Integer; virtual;
  15. procedure InitExisting; override;
  16. procedure MakeResultingCommand; override;
  17. end;
  18. var
  19. ECLabelBaseFrame: TECLabelBaseFrame;
  20. implementation
  21. uses
  22. fpjson;
  23. {$R *.lfm}
  24. { TECLabelBaseFrame }
  25. procedure TECLabelBaseFrame.FormShow(Sender: TObject);
  26. begin
  27. LabelNameEdit.SetFocus;
  28. end;
  29. function TECLabelBaseFrame.GetCommandCode: Integer;
  30. begin
  31. GetCommandCode := 0;
  32. raise ENotImplemented.Create('Called GetCommandCode of TECLabelBaseFrame');
  33. end;
  34. procedure TECLabelBaseFrame.InitExisting;
  35. var
  36. Params: TJSONArray = nil;
  37. LabelName: String = '';
  38. begin
  39. Params := GetFirstParams;
  40. if (Params <> nil) and (Params.Count >= 1) and (Params[0].JSONType = jtString)
  41. then
  42. LabelName := Params[0].AsString;
  43. LabelNameEdit.Text := LabelName;
  44. end;
  45. procedure TECLabelBaseFrame.MakeResultingCommand;
  46. begin
  47. ResultingCommand := SingleLineResultingCommand(
  48. GetCommandCode,
  49. TJSONArray.Create([
  50. LabelNameEdit.Text
  51. ])
  52. );
  53. end;
  54. end.