tvplanit: Report duplicate resource error in ResEditDlg before exiting dialog.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8355 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-07-20 09:12:16 +00:00
parent bca465e6dd
commit 30926a4826
6 changed files with 41 additions and 3 deletions

View File

@ -282,3 +282,4 @@ msgstr "Erledigte Aufgaben verbergen"
#: tmainform.titlelbl.caption
msgid "TitleLbl"
msgstr ""

View File

@ -279,3 +279,4 @@ msgstr "Hide completed tasks"
#: tmainform.titlelbl.caption
msgid "TitleLbl"
msgstr "TitleLbl"

View File

@ -237,7 +237,7 @@ resourcestring
RSPrintBtn = '&Print';
RSUntitled = 'Untitled';
{Sound Selection Dialog}
{ Sound Selection Dialog }
RSSelectASound = 'Select A Sound';
RSSoundFinder = 'Sound Finder';
RSDefaultSound = 'Use the default sound';

View File

@ -310,6 +310,7 @@ type
procedure UpdateGroupEvents; virtual;
procedure DeleteResource(Res: TVpResource);
function FindResource(const AResourceName: String): TVpResource;
property Connected : boolean read FConnected write SetConnected;
property Loading : Boolean read FLoading write FLoading;
@ -536,6 +537,11 @@ begin
PurgeResource(Res);
end;
function TVpCustomDataStore.FindResource(const AResourceName: String): TVpResource;
begin
Result := FResources.FindResourceByName(AResourceName);
end;
{=====}
procedure TVpCustomDataStore.DeregisterAllWatchers;

View File

@ -12,7 +12,7 @@ object ResEditForm: TResEditForm
Constraints.MinWidth = 400
OnCreate = FormCreate
OnShow = FormShow
LCLVersion = '1.6.4.0'
LCLVersion = '2.3.0.0'
object pnlBottom: TPanel
Left = 0
Height = 33
@ -79,6 +79,7 @@ object ResEditForm: TResEditForm
Width = 63
BorderSpacing.Left = 8
Caption = 'Description:'
Color = clDefault
ParentColor = False
end
object lblNotes: TLabel
@ -91,6 +92,7 @@ object ResEditForm: TResEditForm
Width = 34
BorderSpacing.Top = 8
Caption = 'Notes:'
Color = clDefault
ParentColor = False
end
object imgResources: TImage

View File

@ -41,7 +41,7 @@ uses
SysUtils,
{$IFDEF VERSION6} Variants, {$ENDIF}
Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
VpDlg, VpBase, VpData, VpConst;
VpDlg, VpBase, VpBaseDS, VpData, VpConst;
type
{ forward declarations }
@ -64,14 +64,17 @@ type
procedure FormShow(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
private
FDatastore: TVpCustomDatastore;
procedure PositionControls;
procedure SetControls;
function ValidData(out AControl: TWinControl; out AMsg: String): Boolean;
public
ReturnCode: TVpEditorReturnCode;
ResourceChanged: Boolean;
Resource: TVpResource;
procedure PopulateSelf;
procedure DePopulateSelf;
property Datastore: TVpCustomDatastore read FDatastore write FDatastore;
end;
TVpResourceEditDialog = class(TVpBaseDialog)
@ -158,6 +161,7 @@ begin
Application.CreateForm(TResEditForm, EditForm);
try
DoFormPlacement(EditForm);
EditForm.Datastore := Datastore;
EditForm.Resource := reResource;
EditForm.PopulateSelf;
EditForm.ShowModal;
@ -220,11 +224,35 @@ begin
end;
procedure TResEditForm.OKBtnClick(Sender: TObject);
var
C: TWinControl;
msg: String;
begin
if ResourceChanged and not ValidData(C, msg) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
exit;
end;
if ResourceChanged then
ReturnCode := rtCommit;
Close;
end;
function TResEditForm.ValidData(out AControl: TWinControl; out AMsg: String): Boolean;
begin
Result := false;
if FDatastore.FindResource(DescriptionEdit.Text) <> nil then
begin
AControl := DescriptionEdit;
AMsg := RSDuplicateResource;
exit;
end;
Result := true;
end;
{=====}
procedure TResEditForm.FormCreate(Sender: TObject);