You've already forked lazarus-ccr
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:
@ -282,3 +282,4 @@ msgstr "Erledigte Aufgaben verbergen"
|
|||||||
#: tmainform.titlelbl.caption
|
#: tmainform.titlelbl.caption
|
||||||
msgid "TitleLbl"
|
msgid "TitleLbl"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -279,3 +279,4 @@ msgstr "Hide completed tasks"
|
|||||||
#: tmainform.titlelbl.caption
|
#: tmainform.titlelbl.caption
|
||||||
msgid "TitleLbl"
|
msgid "TitleLbl"
|
||||||
msgstr "TitleLbl"
|
msgstr "TitleLbl"
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ resourcestring
|
|||||||
RSPrintBtn = '&Print';
|
RSPrintBtn = '&Print';
|
||||||
RSUntitled = 'Untitled';
|
RSUntitled = 'Untitled';
|
||||||
|
|
||||||
{Sound Selection Dialog}
|
{ Sound Selection Dialog }
|
||||||
RSSelectASound = 'Select A Sound';
|
RSSelectASound = 'Select A Sound';
|
||||||
RSSoundFinder = 'Sound Finder';
|
RSSoundFinder = 'Sound Finder';
|
||||||
RSDefaultSound = 'Use the default sound';
|
RSDefaultSound = 'Use the default sound';
|
||||||
|
@ -310,6 +310,7 @@ type
|
|||||||
procedure UpdateGroupEvents; virtual;
|
procedure UpdateGroupEvents; virtual;
|
||||||
|
|
||||||
procedure DeleteResource(Res: TVpResource);
|
procedure DeleteResource(Res: TVpResource);
|
||||||
|
function FindResource(const AResourceName: String): TVpResource;
|
||||||
|
|
||||||
property Connected : boolean read FConnected write SetConnected;
|
property Connected : boolean read FConnected write SetConnected;
|
||||||
property Loading : Boolean read FLoading write FLoading;
|
property Loading : Boolean read FLoading write FLoading;
|
||||||
@ -536,6 +537,11 @@ begin
|
|||||||
PurgeResource(Res);
|
PurgeResource(Res);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TVpCustomDataStore.FindResource(const AResourceName: String): TVpResource;
|
||||||
|
begin
|
||||||
|
Result := FResources.FindResourceByName(AResourceName);
|
||||||
|
end;
|
||||||
|
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
procedure TVpCustomDataStore.DeregisterAllWatchers;
|
procedure TVpCustomDataStore.DeregisterAllWatchers;
|
||||||
|
@ -12,7 +12,7 @@ object ResEditForm: TResEditForm
|
|||||||
Constraints.MinWidth = 400
|
Constraints.MinWidth = 400
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
LCLVersion = '1.6.4.0'
|
LCLVersion = '2.3.0.0'
|
||||||
object pnlBottom: TPanel
|
object pnlBottom: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 33
|
Height = 33
|
||||||
@ -79,6 +79,7 @@ object ResEditForm: TResEditForm
|
|||||||
Width = 63
|
Width = 63
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
Caption = 'Description:'
|
Caption = 'Description:'
|
||||||
|
Color = clDefault
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object lblNotes: TLabel
|
object lblNotes: TLabel
|
||||||
@ -91,6 +92,7 @@ object ResEditForm: TResEditForm
|
|||||||
Width = 34
|
Width = 34
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
Caption = 'Notes:'
|
Caption = 'Notes:'
|
||||||
|
Color = clDefault
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object imgResources: TImage
|
object imgResources: TImage
|
||||||
|
@ -41,7 +41,7 @@ uses
|
|||||||
SysUtils,
|
SysUtils,
|
||||||
{$IFDEF VERSION6} Variants, {$ENDIF}
|
{$IFDEF VERSION6} Variants, {$ENDIF}
|
||||||
Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
||||||
VpDlg, VpBase, VpData, VpConst;
|
VpDlg, VpBase, VpBaseDS, VpData, VpConst;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ forward declarations }
|
{ forward declarations }
|
||||||
@ -64,14 +64,17 @@ type
|
|||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure OKBtnClick(Sender: TObject);
|
procedure OKBtnClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
|
FDatastore: TVpCustomDatastore;
|
||||||
procedure PositionControls;
|
procedure PositionControls;
|
||||||
procedure SetControls;
|
procedure SetControls;
|
||||||
|
function ValidData(out AControl: TWinControl; out AMsg: String): Boolean;
|
||||||
public
|
public
|
||||||
ReturnCode: TVpEditorReturnCode;
|
ReturnCode: TVpEditorReturnCode;
|
||||||
ResourceChanged: Boolean;
|
ResourceChanged: Boolean;
|
||||||
Resource: TVpResource;
|
Resource: TVpResource;
|
||||||
procedure PopulateSelf;
|
procedure PopulateSelf;
|
||||||
procedure DePopulateSelf;
|
procedure DePopulateSelf;
|
||||||
|
property Datastore: TVpCustomDatastore read FDatastore write FDatastore;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TVpResourceEditDialog = class(TVpBaseDialog)
|
TVpResourceEditDialog = class(TVpBaseDialog)
|
||||||
@ -158,6 +161,7 @@ begin
|
|||||||
Application.CreateForm(TResEditForm, EditForm);
|
Application.CreateForm(TResEditForm, EditForm);
|
||||||
try
|
try
|
||||||
DoFormPlacement(EditForm);
|
DoFormPlacement(EditForm);
|
||||||
|
EditForm.Datastore := Datastore;
|
||||||
EditForm.Resource := reResource;
|
EditForm.Resource := reResource;
|
||||||
EditForm.PopulateSelf;
|
EditForm.PopulateSelf;
|
||||||
EditForm.ShowModal;
|
EditForm.ShowModal;
|
||||||
@ -220,11 +224,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TResEditForm.OKBtnClick(Sender: TObject);
|
procedure TResEditForm.OKBtnClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
C: TWinControl;
|
||||||
|
msg: String;
|
||||||
begin
|
begin
|
||||||
|
if ResourceChanged and not ValidData(C, msg) then
|
||||||
|
begin
|
||||||
|
C.SetFocus;
|
||||||
|
MessageDlg(msg, mtError, [mbOK], 0);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if ResourceChanged then
|
if ResourceChanged then
|
||||||
ReturnCode := rtCommit;
|
ReturnCode := rtCommit;
|
||||||
Close;
|
Close;
|
||||||
end;
|
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);
|
procedure TResEditForm.FormCreate(Sender: TObject);
|
||||||
|
Reference in New Issue
Block a user