Skip to content

Commit

Permalink
Merge pull request #4 from JensBorrisholt/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
JensBorrisholt authored Jan 19, 2024
2 parents 4a2e233 + 599f864 commit af3ff6e
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 60 deletions.
19 changes: 10 additions & 9 deletions Components/uUpdate.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,30 @@ implementation
function CheckForUpdate(AOnFinish: TProc<TRelease, string>): ITaskEx;
var
Releases: TObjectList<TRelease>;
LResult: TRelease;
LErrorMessage: string;
Release: TRelease;
ErrorMessage: string;
begin
Result := TTaskEx.Run(
procedure
procedure
begin
try
Releases := TUGitHubSerializableObject.RestRequest<TReleasesDTO>(UpdateUrl).Releases;
if Releases.Count >= 0 then
LResult := Releases.Last;
Release := Releases.Last;

if JsonToFloat(LResult.Tag_Name) <= ProgramVersion then
FreeAndNil(LResult);
if JsonToFloat(Release.Tag_Name) <= ProgramVersion then
FreeAndNil(Release);

LErrorMessage := '';
ErrorMessage := '';
except
on e: Exception do
LErrorMessage := e.message;
ErrorMessage := e.message;
end;
end).ContinueWithInMainThread(
procedure(const aTask: ITaskEx)
begin
AOnFinish(LResult, LErrorMessage);
AOnFinish(Release, ErrorMessage);
FreeAndNil(Releases);
end, TTaskContinuationOptions.OnlyOnCompleted);
end;

Expand Down
2 changes: 1 addition & 1 deletion DTO/GitHUB/DTO.GitHUB.ReleaseDTO.pas
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ TAuthorDTO = class
property Url: string read FUrl write FUrl;
end;

TItemsDTO = class(TArrayMapper)
TItemsDTO = class(TJsonDTO)
private
[JSONName('assets')]
[JSONMarshalled(False)]
Expand Down
43 changes: 19 additions & 24 deletions Generator GUI/MainFormU.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ object MainForm: TMainForm
Top = 0
Caption = 'Form1'
ClientHeight = 480
ClientWidth = 613
ClientWidth = 612
StyleBook = StyleBook1
FormFactor.Width = 320
FormFactor.Height = 480
Expand All @@ -12,26 +12,24 @@ object MainForm: TMainForm
OnDestroy = FormDestroy
DesignerMasterStyle = 0
object MenuBar1: TMenuBar
Size.Width = 613.000000000000000000
Size.Width = 612.000000000000000000
Size.Height = 24.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
object MenuItem1: TMenuItem
Text = '&File'
object MenuItem2: TMenuItem
Action = actOpen
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem3: TMenuItem
Action = actSaveAs
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem4: TMenuItem
Action = actExit
Enabled = True
Locked = True
ImageIndex = -1
end
Expand All @@ -40,25 +38,21 @@ object MainForm: TMainForm
Text = '&View'
object MenuItem5: TMenuItem
Action = actOnlineValidation
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem6: TMenuItem
Action = actSettings
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem7: TMenuItem
Action = actDemoData
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem8: TMenuItem
Action = actClassVisualizer
Enabled = True
Locked = True
ImageIndex = -1
end
Expand All @@ -67,46 +61,44 @@ object MainForm: TMainForm
Text = 'Formats'
object MenuItem9: TMenuItem
Action = actBSON
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem10: TMenuItem
Action = actDelphiUnit
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem11: TMenuItem
Action = actMinifyJson
Enabled = True
Locked = True
ImageIndex = -1
end
object MenuItem12: TMenuItem
Action = actDemoProject
Enabled = True
Locked = True
ImageIndex = -1
end
end
end
object TabControl1: TTabControl
Align = Client
Size.Width = 613.000000000000000000
Size.Width = 612.000000000000000000
Size.Height = 434.000000000000000000
Size.PlatformDefault = False
TabIndex = 0
TabOrder = 1
TabPosition = PlatformDefault
Sizes = (
613s
612s
408s)
object TabItemJSON: TTabItem
CustomIcon = <
item
end>
TextSettings.Trimming = None
IsSelected = True
Size.Width = 44.000000000000000000
Size.Width = 43.000000000000000000
Size.Height = 26.000000000000000000
Size.PlatformDefault = False
StyleLookup = ''
Expand All @@ -126,13 +118,13 @@ object MainForm: TMainForm
OnChange = MemoJSONExit
OnChangeTracking = MemoJSONExit
Align = Client
Size.Width = 613.000000000000000000
Size.Width = 612.000000000000000000
Size.Height = 355.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
OnExit = MemoJSONExit
Viewport.Width = 613.000000000000000000
Viewport.Height = 355.000000000000000000
Viewport.Width = 608.000000000000000000
Viewport.Height = 351.000000000000000000
end
object ListView1: TListView
ItemAppearanceClassName = 'TListItemAppearance'
Expand Down Expand Up @@ -173,7 +165,7 @@ object MainForm: TMainForm
Padding.Right = 6.000000000000000000
Padding.Bottom = 6.000000000000000000
Position.Y = 355.000000000000000000
Size.Width = 613.000000000000000000
Size.Width = 612.000000000000000000
Size.Height = 53.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
Expand All @@ -193,6 +185,7 @@ object MainForm: TMainForm
Size.Width = 182.000000000000000000
Size.Height = 17.000000000000000000
Size.PlatformDefault = False
TextSettings.Trimming = None
Text = 'Destination Unit Name:'
end
object EditUnitName: TEdit
Expand All @@ -211,6 +204,7 @@ object MainForm: TMainForm
Size.Width = 182.000000000000000000
Size.Height = 17.000000000000000000
Size.PlatformDefault = False
TextSettings.Trimming = None
Text = 'Destination Class Name:'
TabOrder = 3
end
Expand All @@ -229,10 +223,10 @@ object MainForm: TMainForm
object Button1: TButton
Action = actConvert
Anchors = [akTop, akRight]
Enabled = True
ImageIndex = -1
Position.X = 528.000000000000000000
Position.X = 527.000000000000000000
Position.Y = 21.000000000000000000
TextSettings.Trimming = None
end
end
object Splitter2: TSplitter
Expand Down Expand Up @@ -1713,17 +1707,18 @@ object MainForm: TMainForm
Padding.Bottom = 2.000000000000000000
Position.Y = 458.000000000000000000
ShowSizeGrip = True
Size.Width = 613.000000000000000000
Size.Width = 612.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
object Label1: TLabel
Align = Client
HitTest = True
Size.Width = 607.000000000000000000
Size.Width = 606.000000000000000000
Size.Height = 18.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'LabelNormalStyle'
TextSettings.Trimming = None
Text = 'Idle'
OnClick = Label1Click
end
Expand Down
26 changes: 16 additions & 10 deletions Generator GUI/MainFormU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,20 @@ procedure TMainForm.actSaveAsExecute(Sender: TObject);
Buffer.Text := Output;
Buffer.SaveToFile(sd.FileName);

if not SameText(FileExtention, 'pas') then
exit;

ResourceStream := TResourceStream.Create(HInstance, 'JsonDTO', 'PAS');
try
ResourceStream.Position := 0;
Buffer.LoadFromStream(ResourceStream);
Buffer.SaveToFile(ExtractFilePath(sd.FileName) + 'Pkg.Json.DTO.pas');
if not SameText(FileExtention, 'pas') then
exit;

ResourceStream := TResourceStream.Create(HInstance, 'JsonDTO', 'PAS');
try
ResourceStream.Position := 0;
Buffer.LoadFromStream(ResourceStream);
Buffer.SaveToFile(ExtractFilePath(sd.FileName) + 'Pkg.Json.DTO.pas');
finally
ResourceStream.Free;
end;

finally
ResourceStream.Free;
Buffer.Free;
end;
end;
Expand Down Expand Up @@ -337,7 +341,10 @@ procedure TMainForm.FormCreate(Sender: TObject);
CheckForUpdate(
procedure(aRelease: TRelease; aErrorMessage: string)
begin
FCheckVersionResponse := aRelease;
if aRelease <> nil then
FCheckVersionResponse := aRelease.Clone<TRelease>
else
FCheckVersionResponse := nil;

if (aRelease = nil) and (aErrorMessage = '') then
begin
Expand Down Expand Up @@ -405,4 +412,3 @@ procedure TMainForm.ListView1Change(Sender: TObject);
end;

end.

7 changes: 7 additions & 0 deletions Lib/Pkg.Json.DTO.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TJsonDTO = class(TArrayMapper)
constructor Create; override;
class function PrettyPrintJSON(aJson: string): string; overload;
function ToString: string; override;
function Clone<T: TJsonDTO, constructor>: T;
property AsJson: string read GetAsJson write SetAsJson;
end;

Expand All @@ -46,6 +47,12 @@ implementation

{ TJsonDTO }

function TJsonDTO.Clone<T>: T;
begin
Result := T.Create;
Result.AsJson := AsJson;
end;

constructor TJsonDTO.Create;
begin
inherited;
Expand Down
4 changes: 4 additions & 0 deletions Lib/Pkg.Json.ReservedWords.pas
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ initialization
ReservedWords.Add('while');
ReservedWords.Add('with');
ReservedWords.Add('xor');
ReservedWords.Add('threadvar');
ReservedWords.Add('raise');
ReservedWords.Add('interface');

ReservedWords.Sorted := True;

finalization
Expand Down
8 changes: 4 additions & 4 deletions Lib/Pkg.Json.Settings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

interface

uses Pkg.Json.DTO;
uses
Pkg.Json.DTO;

Type
TSettings = class(TJsonDTO)
Expand All @@ -29,7 +30,8 @@ TSettings = class(TJsonDTO)

implementation

uses System.SysUtils, System.Strutils;
uses
System.SysUtils, System.Strutils;

{ TSettings }

Expand Down Expand Up @@ -67,5 +69,3 @@ finalization
TSettings.Instance.Free;

end.


Loading

0 comments on commit af3ff6e

Please sign in to comment.