mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-18 09:29:35 +02:00
Converter: Support automatic removal of unknown properties.
git-svn-id: trunk@24355 -
This commit is contained in:
parent
b03f1d9fb6
commit
e4948d741a
@ -24,7 +24,7 @@ object ConvertSettingsForm: TConvertSettingsForm
|
||||
ClientHeight = 114
|
||||
ClientWidth = 607
|
||||
TabOrder = 0
|
||||
object MissingTypesCheckBox: TCheckBox
|
||||
object AutoConvertTypesCheckBox: TCheckBox
|
||||
Left = 382
|
||||
Height = 21
|
||||
Top = 4
|
||||
@ -34,15 +34,13 @@ object ConvertSettingsForm: TConvertSettingsForm
|
||||
TabOrder = 0
|
||||
Visible = False
|
||||
end
|
||||
object MissingPropertiesCheckBox: TCheckBox
|
||||
object AutoRemovePropertiesCheckBox: TCheckBox
|
||||
Left = 11
|
||||
Height = 21
|
||||
Top = 4
|
||||
Width = 294
|
||||
Caption = 'Automatic removal of missing properties (ToDo...)'
|
||||
Enabled = False
|
||||
Width = 250
|
||||
Caption = 'Automatic removal of unknown properties'
|
||||
TabOrder = 1
|
||||
Visible = False
|
||||
end
|
||||
object MissingStuffLabel: TLabel
|
||||
Left = 11
|
||||
|
@ -50,8 +50,8 @@ type
|
||||
fBackupFiles: boolean;
|
||||
fTarget: TConvertTarget;
|
||||
fSameDFMFile: boolean;
|
||||
fAutoMissingProperties: boolean;
|
||||
fAutoMissingTypes: boolean;
|
||||
fAutoRemoveProperties: boolean;
|
||||
fAutoConvertTypes: boolean;
|
||||
// Delphi units mapped to Lazarus units, will be replaced or removed.
|
||||
fReplaceUnits: TStringToStringTree;
|
||||
// Delphi types mapped to Lazarus types, will be replaced.
|
||||
@ -88,8 +88,8 @@ type
|
||||
property BackupFiles: boolean read fBackupFiles;
|
||||
property Target: TConvertTarget read fTarget;
|
||||
property SameDFMFile: boolean read fSameDFMFile;
|
||||
property AutoMissingProperties: boolean read fAutoMissingProperties;
|
||||
property AutoMissingTypes: boolean read fAutoMissingTypes;
|
||||
property AutoRemoveProperties: boolean read fAutoRemoveProperties;
|
||||
property AutoConvertTypes: boolean read fAutoConvertTypes;
|
||||
property ReplaceUnits: TStringToStringTree read fReplaceUnits;
|
||||
property ReplaceTypes: TStringToStringTree read fReplaceTypes;
|
||||
end;
|
||||
@ -111,8 +111,8 @@ type
|
||||
SettingsGroupBox: TGroupBox;
|
||||
MissingStuffGroupBox: TGroupBox;
|
||||
MissingStuffLabel: TLabel;
|
||||
MissingTypesCheckBox: TCheckBox;
|
||||
MissingPropertiesCheckBox: TCheckBox;
|
||||
AutoConvertTypesCheckBox: TCheckBox;
|
||||
AutoRemovePropertiesCheckBox: TCheckBox;
|
||||
procedure btnOKClick(Sender: TObject);
|
||||
procedure TypeReplacementsButtonClick(Sender: TObject);
|
||||
procedure UnitReplacementsButtonClick(Sender: TObject);
|
||||
@ -196,17 +196,17 @@ begin
|
||||
BackupCheckBox.Checked :=fBackupFiles;
|
||||
TargetRadioGroup.ItemIndex :=integer(fTarget);
|
||||
SameDFMCheckBox.Checked :=fSameDFMFile;
|
||||
MissingPropertiesCheckBox.Checked :=fAutoMissingProperties;
|
||||
MissingTypesCheckBox.Checked:=fAutoMissingTypes;
|
||||
AutoRemovePropertiesCheckBox.Checked :=fAutoRemoveProperties;
|
||||
AutoConvertTypesCheckBox.Checked:=fAutoConvertTypes;
|
||||
}
|
||||
Result:=ShowModal;
|
||||
if Result=mrOK then begin
|
||||
// UI --> Settings.
|
||||
fBackupFiles :=BackupCheckBox.Checked;
|
||||
fTarget :=TConvertTarget(TargetRadioGroup.ItemIndex);
|
||||
fSameDFMFile :=SameDFMCheckBox.Checked;
|
||||
fAutoMissingProperties:=MissingPropertiesCheckBox.Checked;
|
||||
fAutoMissingTypes :=MissingTypesCheckBox.Checked;
|
||||
fBackupFiles :=BackupCheckBox.Checked;
|
||||
fTarget :=TConvertTarget(TargetRadioGroup.ItemIndex);
|
||||
fSameDFMFile :=SameDFMCheckBox.Checked;
|
||||
fAutoRemoveProperties:=AutoRemovePropertiesCheckBox.Checked;
|
||||
fAutoConvertTypes :=AutoConvertTypesCheckBox.Checked;
|
||||
// ToDo: Save to XML.
|
||||
end;
|
||||
finally
|
||||
@ -329,6 +329,7 @@ begin
|
||||
TargetRadioGroup.ItemIndex:=0;
|
||||
SameDFMCheckBox.Caption:=lisUseSameDFMFile;
|
||||
MissingStuffGroupBox.Caption:= lisConvUnitsTypesProperties;
|
||||
AutoRemovePropertiesCheckBox.Caption:=lisConvAutoRemoveProperties;
|
||||
UnitReplacementsButton.Caption:=lisConvUnitReplacements;
|
||||
TypeReplacementsButton.Caption:=lisConvTypeReplacements;
|
||||
TargetRadioGroupClick(TargetRadioGroup);
|
||||
|
@ -677,10 +677,10 @@ object FixLFMDialog: TFixLFMDialog
|
||||
Left = 6
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 227
|
||||
Width = 230
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Replace and remove invalid properties'
|
||||
Caption = 'Replace unknown types and properties'
|
||||
NumGlyphs = 0
|
||||
OnClick = ReplaceAllButtonClick
|
||||
TabOrder = 1
|
||||
|
@ -66,6 +66,8 @@ type
|
||||
TLFMFixer = class(TLFMChecker)
|
||||
private
|
||||
fSettings: TConvertSettings;
|
||||
// There are also unknown object types, not just properties.
|
||||
fHasMissingObjectTypes: Boolean;
|
||||
// References to controls in UI:
|
||||
fPropReplaceGrid: TStringGrid;
|
||||
function ReplaceAndRemoveAll: TModalResult;
|
||||
@ -106,7 +108,6 @@ type
|
||||
procedure CheckLFMDialogCREATE(Sender: TObject);
|
||||
private
|
||||
fLfmFixer: TLFMFixer;
|
||||
procedure SetupComponents;
|
||||
public
|
||||
constructor Create(AOwner: TComponent; ALfmFixer: TLFMFixer); reintroduce;
|
||||
destructor Destroy; override;
|
||||
@ -214,6 +215,7 @@ constructor TLFMFixer.Create(APascalBuffer, ALFMBuffer: TCodeBuffer;
|
||||
const AOnOutput: TOnAddFilteredLine);
|
||||
begin
|
||||
inherited Create(APascalBuffer, ALFMBuffer, AOnOutput);
|
||||
fHasMissingObjectTypes:=false;
|
||||
end;
|
||||
|
||||
destructor TLFMFixer.Destroy;
|
||||
@ -295,13 +297,16 @@ var
|
||||
GridUpdater: TGridUpdater;
|
||||
OldIdent: string;
|
||||
begin
|
||||
fHasMissingObjectTypes:=false;
|
||||
GridUpdater:=TGridUpdater.Create(fPropReplaceGrid, fSettings.ReplaceTypes);
|
||||
try
|
||||
if fLFMTree<>nil then begin
|
||||
CurError:=fLFMTree.FirstError;
|
||||
while CurError<>nil do begin
|
||||
if CurError.IsMissingObjectType then
|
||||
OldIdent:=(CurError.Node as TLFMObjectNode).TypeName
|
||||
if CurError.IsMissingObjectType then begin
|
||||
OldIdent:=(CurError.Node as TLFMObjectNode).TypeName;
|
||||
fHasMissingObjectTypes:=true;
|
||||
end
|
||||
else
|
||||
OldIdent:=CurError.Node.GetIdentifier;
|
||||
// Add only one instance of each property name.
|
||||
@ -332,7 +337,10 @@ begin
|
||||
fErrorsListBox:=FixLFMDialog.ErrorsListBox;
|
||||
fPropReplaceGrid:=FixLFMDialog.PropertyReplaceGrid;
|
||||
LoadLFM;
|
||||
Result:=FixLFMDialog.ShowModal;
|
||||
if fSettings.AutoRemoveProperties and not fHasMissingObjectTypes then
|
||||
ReplaceAndRemoveAll
|
||||
else
|
||||
Result:=FixLFMDialog.ShowModal;
|
||||
finally
|
||||
FixLFMDialog.Free;
|
||||
end;
|
||||
@ -368,13 +376,22 @@ begin
|
||||
end;
|
||||
|
||||
procedure TFixLFMDialog.CheckLFMDialogCREATE(Sender: TObject);
|
||||
const // Will be moved to LazarusIDEStrConsts
|
||||
lisLFMFileContainsInvalidProperties = 'The LFM (Lazarus form) '
|
||||
+'file contains unknown properties/classes which do not exist in LCL. '
|
||||
+'They can be replaced or removed.';
|
||||
begin
|
||||
Caption:=lisFixLFMFile;
|
||||
PropertyReplaceGroupBox.Caption:=lisReplacementPropTypes;
|
||||
ReplaceAllButton.Caption:=lisReplaceRemoveInvalid;
|
||||
Position:=poScreenCenter;
|
||||
// IDEDialogLayoutList.ApplyLayout(Self,600,400);
|
||||
SetupComponents;
|
||||
// IDEDialogLayoutList.ApplyLayout(Self,600,400);
|
||||
NoteLabel.Caption:=lisLFMFileContainsInvalidProperties;
|
||||
ErrorsGroupBox.Caption:=lisErrors;
|
||||
LFMGroupBox.Caption:=lisLFMFile;
|
||||
PropertyReplaceGroupBox.Caption:=lisReplacementPropTypes;
|
||||
ReplaceAllButton.Caption:=lisReplaceRemoveUnknown;
|
||||
ReplaceAllButton.LoadGlyphFromLazarusResource('laz_refresh');
|
||||
EditorOpts.GetHighlighterSettings(SynLFMSyn1);
|
||||
EditorOpts.GetSynEditSettings(LFMSynEdit);
|
||||
end;
|
||||
|
||||
procedure TFixLFMDialog.ReplaceAllButtonClick(Sender: TObject);
|
||||
@ -398,22 +415,6 @@ begin
|
||||
EditorOpts.SetMarkupColor(SynLFMSyn1, ahaErrorLine, AMarkup);
|
||||
end;
|
||||
|
||||
procedure TFixLFMDialog.SetupComponents;
|
||||
const // Will be moved to LazarusIDEStrConsts
|
||||
lisLFMFileContainsInvalidProperties = 'The LFM (Lazarus form) '
|
||||
+'file contains invalid properties/classes which do not exist in LCL. '
|
||||
+'They can be replaced or removed.';
|
||||
lisReplaceAllProperties = 'Replace and remove invalid properties';
|
||||
begin
|
||||
NoteLabel.Caption:=lisLFMFileContainsInvalidProperties;
|
||||
ErrorsGroupBox.Caption:=lisErrors;
|
||||
LFMGroupBox.Caption:=lisLFMFile;
|
||||
ReplaceAllButton.Caption:=lisReplaceAllProperties;
|
||||
ReplaceAllButton.LoadGlyphFromLazarusResource('laz_refresh');
|
||||
EditorOpts.GetHighlighterSettings(SynLFMSyn1);
|
||||
EditorOpts.GetSynEditSettings(LFMSynEdit);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
@ -460,12 +460,13 @@ resourcestring
|
||||
lisConvertTarget2 = 'Lazarus/LCL for Windows only';
|
||||
lisConvertTarget3 = 'Both Lazarus/LCL and Delphi';
|
||||
lisConvUnitsTypesProperties = 'Units, Types and Properties';
|
||||
lisConvAutoRemoveProperties = 'Automatic removal of unknown properties';
|
||||
lisConvUnitsToReplace = 'Units to replace';
|
||||
lisConvTypesToReplace = 'Types to replace';
|
||||
lisConvUnitReplacements = 'Unit Replacements';
|
||||
lisConvTypeReplacements = 'Type Replacements';
|
||||
lisReplacementPropTypes = 'Replacement Properties and Types';
|
||||
lisReplaceRemoveInvalid = 'Replace and remove invalid properties / types';
|
||||
lisReplaceRemoveUnknown = 'Replace unknown types and properties';
|
||||
|
||||
lisUnableToLoadOldResourceFileTheResourceFileIs = 'Unable to load old '
|
||||
+'resource file.%sThe resource file is the first include file in the%'
|
||||
|
Loading…
Reference in New Issue
Block a user