Skip to content

Commit

Permalink
fix(developer): Project upgrade messages now show in Messages panel
Browse files Browse the repository at this point in the history
Relates to #9948.

Having the project upgrade messages in the Messages panel means that
users can refer to them as they clean up their projects to bring them
into the v17 format.
  • Loading branch information
mcdurdin committed Nov 8, 2023
1 parent 974bbd1 commit 3c0b7a9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
6 changes: 6 additions & 0 deletions developer/src/tike/main/UfrmMessages.pas
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ procedure TfrmMessages.memoMessageDblClick(Sender: TObject);
mi := FMessageItems[line] as TMessageItem;
FFilename := mi.FileName;

if FFileName = FGlobalProject.FileName then
begin
frmKeymanDeveloper.ShowProject;
Exit;
end;

frm := frmKeymanDeveloper.FindEditorByFileName(FFileName);
if not Assigned(frm) then
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,17 +984,6 @@ procedure TProject.PopulateFolder(const path: string);
end;
end;

{
function IsLMDLKeyboardFile(filename: string): Boolean;
if EndsText('.xml', filename) then
begin
Result := Pos('ldmlKeyboard3.dtd', ReadUtf8FileText(ff)) > 0;
end
else
Result := False;
end;
}

function TProject.CanUpgrade: Boolean;
var
i: Integer;
Expand All @@ -1015,12 +1004,12 @@ function TProject.CanUpgrade: Boolean;
if Options.BuildPath.Contains('$SOURCEPATH') then
begin
Result := False;
FUpgradeMessages.Add('The BuildPath option contains "$SOURCEPATH"');
FUpgradeMessages.Add('The BuildPath project setting contains the "$SOURCEPATH" tag, which is no longer supported');
end;
if Options.BuildPath.Contains('$VERSION') then
begin
Result := False;
FUpgradeMessages.Add('The BuildPath option contains "$VERSION"');
FUpgradeMessages.Add('The BuildPath project setting contains the "$VERSION" tag, which is no longer supported');
end;

for i := 0 to Files.Count - 1 do
Expand All @@ -1037,7 +1026,7 @@ function TProject.CanUpgrade: Boolean;
Continue;
end;

FUpgradeMessages.Add('File '+Files[i].FileName+' is outside the project folder');
FUpgradeMessages.Add('File '+Files[i].FileName+' is outside the project folder. All primary source files must be in the same folder as the project file, or in a subfolder.');
Result := False;
end;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ function TryUpgradeProject(Project: TProject): TUpgradeResult;
implementation

uses
System.Classes,
System.UITypes,
Vcl.Controls,
Vcl.Dialogs,

UfrmMessages,
Keyman.Developer.System.Project.ProjectLog,
KeymanDeveloperOptions;

function TryUpgradeProject(Project: TProject): TUpgradeResult;
var
msg: string;
begin
Result := urNoAction;

Expand All @@ -29,22 +34,32 @@ function TryUpgradeProject(Project: TProject): TUpgradeResult;
Exit;
end;

{ if not FKeymanDeveloperOptions.PromptForProjectUpgrade then
{ TODO:
if not FKeymanDeveloperOptions.PromptForProjectUpgrade then
begin
// User wishes to stick with v1.0 projects
Exit;
end;}
end;
}

frmMessages.Clear;

if not Project.CanUpgrade then
begin
// Project has restrictions, such as files in wrong folders, so
// we cannot upgrade. Show a message for the user
ShowMessage('The current project cannot be upgraded to v2.0. The following errors were encountered:'#13#10+
Project.UpgradeMessages.Text);
for msg in Project.UpgradeMessages do
begin
Project.Log(plsError, Project.FileName, msg, 0, 0);
end;
MessageDlg('Some issues must be addressed before the current project can '+
'be upgraded to Keyman Developer 17 format. '+
'Details of the issues are listed in the Messages panel.', mtError, [mbOk], 0);
Exit;
end;

case MessageDlg('The current project can be upgraded to Keyman Developer 17.0 format. Do you wish to upgrade it (recommended)?'#13#10#13#10+
case MessageDlg('The current project can be upgraded to Keyman Developer 17.0 format. '+
'Do you wish to upgrade it (recommended)?'#13#10#13#10+
'Note: upgraded projects will not be readable by older versions of Keyman Developer.',
mtConfirmation, mbYesNoCancel, 0) of
mrNo: Exit;
Expand Down

0 comments on commit 3c0b7a9

Please sign in to comment.