ide, ideintf: prepare IDEOptionsIntf and IDE for common package options dialog:

- add GroupPackage and GroupPkgCompiler
  - split compiler options and project options into 2 independent options groups
  - register compiler frames for both GroupCompiler and GroupPkgCompiler
  - change DoOpenIDEOptions: replace filter argument from a class to array of classes to show [project options, compiler options] editor and [package options, compiler options] editors
  - inherit TLazPackageID from TAbstractIDEPackageOptions class
  - fix showing of required frame (like Object inspector or Editor) in the IDE options editor
  + other minor edits

git-svn-id: trunk@29481 -
This commit is contained in:
paul 2011-02-12 13:00:34 +00:00
parent 1efd38a79e
commit e9210bf352
18 changed files with 141 additions and 41 deletions

View File

@ -773,6 +773,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TBuildModesEditorFrame,
CompilerOptionsBuildModes);
RegisterIDEOptionsEditor(GroupPkgCompiler, TBuildModesEditorFrame,
CompilerOptionsBuildModes);
end.

View File

@ -1074,6 +1074,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompOptBuildMacrosFrame,
CompilerOptionsConditional);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompOptBuildMacrosFrame,
CompilerOptionsConditional);
end.

View File

@ -309,6 +309,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerCodegenOptionsFrame,
CompilerOptionsCodeGeneration);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerCodegenOptionsFrame,
CompilerOptionsCodeGeneration);
end.

View File

@ -257,6 +257,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerCompilationOptionsFrame,
CompilerOptionsCompilation);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerCompilationOptionsFrame,
CompilerOptionsCompilation);
end.

View File

@ -286,6 +286,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerInheritedOptionsFrame,
CompilerOptionsInherited);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerInheritedOptionsFrame,
CompilerOptionsInherited);
end.

View File

@ -131,6 +131,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerLinkingOptionsFrame,
CompilerOptionsLinking);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerLinkingOptionsFrame,
CompilerOptionsLinking);
end.

View File

@ -195,6 +195,7 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerMessagesOptionsFrame, CompilerOptionsMessages);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerMessagesOptionsFrame, CompilerOptionsMessages);
end.

View File

@ -132,6 +132,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerOtherOptionsFrame,
CompilerOptionsOther);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerOtherOptionsFrame,
CompilerOptionsOther);
end.

View File

@ -168,6 +168,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerParsingOptionsFrame,
CompilerOptionsParsing);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerParsingOptionsFrame,
CompilerOptionsParsing);
end.

View File

@ -831,6 +831,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerPathOptionsFrame,
CompilerOptionsSearchPaths);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerPathOptionsFrame,
CompilerOptionsSearchPaths);
end.

View File

@ -134,6 +134,8 @@ end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TCompilerVerbosityOptionsFrame,
CompilerOptionsVerbosity);
RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerVerbosityOptionsFrame,
CompilerOptionsVerbosity);
end.

View File

@ -43,6 +43,8 @@ type
iodaRestore
);
TIDEOptionsEditorFilter = array of TAbstractIDEOptionsClass;
{ TIDEOptionsDialog }
TIDEOptionsDialog = class(TAbstractOptionsEditorDialog)
@ -61,7 +63,8 @@ type
private
FOnLoadOptions: TOnLoadIDEOptions;
FOnSaveOptions: TOnSaveIDEOptions;
FOptionsFilter: TAbstractIDEOptionsClass;
FOptionsFilter: TIDEOptionsEditorFilter;
FEditorToOpen: TAbstractIDEOptionsEditorClass;
PrevEditor: TAbstractIDEOptionsEditor;
FEditorsCreated: Boolean;
SelectNode: TTreeNode;
@ -89,7 +92,7 @@ type
procedure ReadAll;
procedure WriteAll(Restore: boolean);
property OptionsFilter: TAbstractIDEOptionsClass read FOptionsFilter write FOptionsFilter;
property OptionsFilter: TIDEOptionsEditorFilter read FOptionsFilter write FOptionsFilter;
property OnLoadIDEOptions: TOnLoadIDEOptions read FOnLoadOptions write FOnLoadOptions;
property OnSaveIDEOptions: TOnSaveIDEOptions read FOnSaveOptions write FOnSaveOptions;
end;
@ -108,6 +111,7 @@ begin
inherited Create(AOwner);
PrevEditor := nil;
FEditorsCreated := False;
FEditorToOpen := nil;
IDEDialogLayoutList.ApplyLayout(Self, Width, Height);
Caption := dlgIDEOptions;
@ -436,6 +440,7 @@ begin
for j := 0 to Rec^.Items.Count - 1 do
begin
Instance := Rec^.Items[j]^.EditorClass.Create(Self);
Instance.Name := ''; // allow multiply use of the same frame in different groups
Instance.OnLoadIDEOptions := @LoadIDEOptions;
Instance.OnSaveIDEOptions := @SaveIDEOptions;
Instance.Setup(Self);
@ -494,21 +499,28 @@ begin
end;
function TIDEOptionsDialog.PassesFilter(ARec: PIDEOptionsGroupRec): Boolean;
var
i: Integer;
begin
//DebugLn(['TIDEOptionsDialog.PassesFilter ',DbgSName(ARec^.GroupClass),' ',DbgSName(OptionsFilter)]);
if (ARec^.GroupClass = nil) and (OptionsFilter <> nil) then
Exit(False);
if (OptionsFilter<>nil) and (ARec^.GroupClass <> nil)
and (not ARec^.GroupClass.InheritsFrom(OptionsFilter)) then
Exit(False);
Result := True;
if (ARec^.GroupClass = nil) then
if Length(OptionsFilter) <> 0 then
Exit(False)
else
Exit(True);
for i := 0 to Length(OptionsFilter) - 1 do
if ARec^.GroupClass.InheritsFrom(OptionsFilter[i]) then
Exit(True);
Result := False;
end;
procedure TIDEOptionsDialog.DoOpenEditor(EditorToOpen: TAbstractIDEOptionsEditorClass);
var
Node: TTreeNode;
begin
if EditorToOpen = nil then begin
if EditorToOpen = nil then
begin
if SelectNode <> nil then
Node := SelectNode
else
@ -526,7 +538,7 @@ begin
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TIDEOptionsDialog.ShowModal'){$ENDIF};
try
CreateEditors;
DoOpenEditor(nil);
DoOpenEditor(FEditorToOpen);
finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TIDEOptionsDialog.ShowModal'){$ENDIF};
end;
@ -554,12 +566,17 @@ end;
procedure TIDEOptionsDialog.OpenEditor(AEditor: TAbstractIDEOptionsEditorClass);
begin
if IsVisible then
DoOpenEditor(AEditor);
DoOpenEditor(AEditor)
else
FEditorToOpen := AEditor;
end;
procedure TIDEOptionsDialog.OpenEditor(GroupIndex, AIndex: integer);
begin
DoOpenEditor(FindEditorClass(GroupIndex,AIndex));
if IsVisible then
DoOpenEditor(FindEditorClass(GroupIndex,AIndex))
else
FEditorToOpen := FindEditorClass(GroupIndex,AIndex);
end;
function TIDEOptionsDialog.FindEditor(AEditor: TAbstractIDEOptionsEditorClass): TAbstractIDEOptionsEditor;
@ -573,20 +590,18 @@ begin
Result := nil;
end;
function TIDEOptionsDialog.FindEditor(GroupIndex, AIndex: integer
): TAbstractIDEOptionsEditor;
function TIDEOptionsDialog.FindEditor(GroupIndex, AIndex: integer): TAbstractIDEOptionsEditor;
var
EditorClass: TAbstractIDEOptionsEditorClass;
begin
EditorClass:=FindEditorClass(GroupIndex,AIndex);
if EditorClass<>nil then
Result:=FindEditor(EditorClass)
EditorClass := FindEditorClass(GroupIndex, AIndex);
if EditorClass <> nil then
Result := FindEditor(EditorClass)
else
Result:=nil;
Result := nil;
end;
function TIDEOptionsDialog.FindEditorClass(GroupIndex, AIndex: integer
): TAbstractIDEOptionsEditorClass;
function TIDEOptionsDialog.FindEditorClass(GroupIndex, AIndex: integer): TAbstractIDEOptionsEditorClass;
var
Grp: PIDEOptionsGroupRec;
i: Integer;

View File

@ -373,9 +373,9 @@ type
// Environment options dialog events
procedure OnLoadIDEOptions(Sender: TObject; AOptions: TAbstractIDEOptions);
procedure OnSaveIDEOptions(Sender: TObject; AOptions: TAbstractIDEOptions);
procedure DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass = nil;
ACaption: String = '';
AOptionsFilter: TAbstractIDEOptionsClass = nil); override;
procedure DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass;
ACaption: String;
AOptionsFilter: array of TAbstractIDEOptionsClass); override;
procedure DoEnvironmentOptionsBeforeRead(Sender: TObject);
procedure DoEnvironmentOptionsBeforeWrite(Sender: TObject; Restore: boolean);
@ -3458,7 +3458,7 @@ end;
procedure TMainIDE.mnuChgBuildModeClicked(Sender: TObject);
begin
DoOpenIDEOptions(TBuildModesEditorFrame, '', TAbstractIDEProjectOptions);
DoOpenIDEOptions(TBuildModesEditorFrame, '', [TProjectCompilerOptions]);
end;
procedure TMainIDE.mnuSetBuildModeClick(Sender: TObject);
@ -4002,7 +4002,7 @@ begin
NewCaption := Project1.Title;
if NewCaption = '' then
NewCaption := ExtractFilenameOnly(Project1.ProjectInfoFile);
DoOpenIDEOptions(nil, Format(dlgProjectOptionsFor, [NewCaption]), TAbstractIDEProjectOptions);
DoOpenIDEOptions(nil, Format(dlgProjectOptionsFor, [NewCaption]), [TProject, TProjectCompilerOptions]);
end;
function TMainIDE.UpdateProjectPOFile(AProject: TProject): TModalResult;
@ -4520,23 +4520,33 @@ begin
SaveDesktopSettings(AOptions as TEnvironmentOptions);
end;
procedure TMainIDE.DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass = nil;
ACaption: String = ''; AOptionsFilter: TAbstractIDEOptionsClass = nil);
procedure TMainIDE.DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass;
ACaption: String; AOptionsFilter: array of TAbstractIDEOptionsClass);
var
IDEOptionsDialog: TIDEOptionsDialog;
OptionsFilter: TIDEOptionsEditorFilter;
i: Integer;
begin
IDEOptionsDialog := TIDEOptionsDialog.Create(nil);
try
if ACaption <> '' then
IDEOptionsDialog.Caption := ACaption;
if AOptionsFilter = nil then
if Length(AOptionsFilter) = 0 then
begin
SetLength(OptionsFilter, 1);
if AEditor <> nil then
AOptionsFilter := AEditor.SupportedOptionsClass
OptionsFilter[0] := AEditor.SupportedOptionsClass
else
AOptionsFilter := TAbstractIDEEnvironmentOptions;
IDEOptionsDialog.OptionsFilter := AOptionsFilter;
//DebugLn(['TMainIDE.DoOpenIDEOptions ',DbgSName(IDEOptionsDialog.OptionsFilter)]);
OptionsFilter[0] := TAbstractIDEEnvironmentOptions;
end
else
begin
SetLength(OptionsFilter, Length(AOptionsFilter));
for i := 0 to Length(AOptionsFilter) - 1 do
OptionsFilter[i] := AOptionsFilter[i];
end;
IDEOptionsDialog.OptionsFilter := OptionsFilter;
IDEOptionsDialog.OpenEditor(AEditor);
with IDEOptionsDialog do

View File

@ -84,9 +84,12 @@ type
TAbstractIDEOptionsClass = class of TAbstractIDEOptions;
TAbstractIDEEnvironmentOptions = class(TAbstractIDEOptions);
TAbstractIDEProjectOptions = class(TAbstractIDEOptions);
TAbstractIDEHelpOptions = class(TAbstractIDEEnvironmentOptions);
TAbstractIDEProjectOptions = class(TAbstractIDEOptions);
TAbstractIDEPackageOptions = class(TAbstractIDEOptions);
TAbstractIDECompilerOptions = class(TAbstractIDEOptions);
TOnLoadIDEOptions = procedure(Sender: TObject; AOptions: TAbstractIDEOptions) of object;
TOnSaveIDEOptions = procedure(Sender: TObject; AOptions: TAbstractIDEOptions) of object;
@ -267,6 +270,9 @@ const
CompilerOptionsInherited = 1000;
CompilerOptionsCompilation = 1100;
GroupPackage = 200100;
GroupPkgCompiler = 200200;
implementation
var

View File

@ -246,8 +246,10 @@ type
class function GetSecondaryConfigPath: String; virtual; abstract;
procedure CopySecondaryConfigFile(const AFilename: String); virtual; abstract;
procedure DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass = nil;
ACaption: String = '';
AOptionsFilter: TAbstractIDEOptionsClass = nil); virtual; abstract;
ACaption: String = ''); overload;
procedure DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass;
ACaption: String;
AOptionsFilter: array of TAbstractIDEOptionsClass); overload; virtual; abstract;
// filenames, paths
function CreateNewUniqueFilename(const Prefix, Ext: string;
@ -439,6 +441,11 @@ begin
Result:=DoNewFile(NewFileDescriptor,NewFilename,NewSource,NewFlags,nil);
end;
procedure TLazIDEInterface.DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass; ACaption: String);
begin
DoOpenIDEOptions(AEditor, ACaption, []);
end;
procedure TLazIDEInterface.RemoveAllHandlersOfObject(AnObject: TObject);
var
HandlerType: TLazarusIDEHandlerType;

View File

@ -23,7 +23,7 @@ unit PackageIntf;
interface
uses
Classes, SysUtils, LCLProc, Forms, LazConfigStorage, NewItemIntf, AvgLvlTree;
Classes, SysUtils, LCLProc, Forms, LazConfigStorage, NewItemIntf, IDEOptionsIntf, AvgLvlTree;
const
PkgDescGroupName = 'Package';
@ -83,7 +83,7 @@ type
{ TLazPackageID }
TLazPackageID = class
TLazPackageID = class(TAbstractIDEPackageOptions)
private
FIDAsWord: string;
protected
@ -100,6 +100,9 @@ type
function Compare(PackageID2: TLazPackageID): integer;
function CompareMask(ExactPackageID: TLazPackageID): integer;
procedure AssignID(Source: TLazPackageID); virtual;
// IDE options
class function GetGroupCaption: string; override;
class function GetInstance: TAbstractIDEOptions; override;
public
property Name: string read FName write SetName;
property Version: TPkgVersion read FVersion;
@ -605,6 +608,16 @@ begin
Version.Assign(Source.Version);
end;
class function TLazPackageID.GetGroupCaption: string;
begin
Result := '';
end;
class function TLazPackageID.GetInstance: TAbstractIDEOptions;
begin
Result := nil;
end;
{ TIDEPackage }
constructor TIDEPackage.Create;

View File

@ -119,7 +119,7 @@ const
type
{ TLazCompilerOptions }
TLazCompilerOptions = class(TAbstractIDEProjectOptions)
TLazCompilerOptions = class(TAbstractIDECompilerOptions)
private
FOnModified: TNotifyEvent;
fOwner: TObject;

View File

@ -48,8 +48,8 @@ uses
Classes, SysUtils, LCLProc, LResources, Graphics, Forms, FileProcs, FileUtil,
AVL_Tree, LazConfigStorage,
CodeToolsCfgScript, DefineTemplates, CodeToolManager, Laz_XMLCfg, CodeCache,
PropEdits, LazIDEIntf, MacroIntf, PackageIntf,
EditDefineTree, CompilerOptions, CompOptsModes, IDEOptionDefs,
PropEdits, LazIDEIntf, MacroIntf, PackageIntf, IDEOptionsIntf,
EditDefineTree, CompilerOptions, CompOptsModes, IDEOptionDefs,
LazarusIDEStrConsts, IDEProcs, ComponentReg,
TransferMacros, FileReferenceList, PublishModule;
@ -371,6 +371,9 @@ type
procedure SetConditionals(const AValue: string); override;
public
constructor Create(const AOwner: TObject); override;
// IDE options
class function GetGroupCaption: string; override;
class function GetInstance: TAbstractIDEOptions; override;
function IsActive: boolean; override;
procedure Clear; override;
procedure GetInheritedCompilerOptions(var OptionsList: TFPList); override;
@ -651,6 +654,9 @@ type
public
constructor Create;
destructor Destroy; override;
// IDE options
class function GetGroupCaption: string; override;
class function GetInstance: TAbstractIDEOptions; override;
// modified
procedure BeginUpdate;
procedure EndUpdate;
@ -2494,6 +2500,16 @@ begin
inherited Destroy;
end;
class function TLazPackage.GetGroupCaption: string;
begin
Result := lisPckOptsPackageOptions;
end;
class function TLazPackage.GetInstance: TAbstractIDEOptions;
begin
Result := nil;
end;
procedure TLazPackage.BeginUpdate;
begin
inc(FUpdateLock);
@ -3800,6 +3816,16 @@ begin
FLazPackage := AOwner as TLazPackage;
end;
class function TPkgCompilerOptions.GetGroupCaption: string;
begin
Result := dlgCompilerOptions;
end;
class function TPkgCompilerOptions.GetInstance: TAbstractIDEOptions;
begin
Result := nil;
end;
function TPkgCompilerOptions.IsActive: boolean;
begin
Result:=(LazPackage<>nil) and (LazPackage.CompilerOptions=Self);
@ -4409,6 +4435,8 @@ begin
end;
initialization
RegisterIDEOptionsGroup(GroupPackage, TLazPackage);
RegisterIDEOptionsGroup(GroupPkgCompiler, TPkgCompilerOptions);
PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames);
finalization