mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 13:39:11 +02:00
Replacement property and type editor.
git-svn-id: trunk@24237 -
This commit is contained in:
parent
6bcc6465df
commit
878b9cd77a
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2230,6 +2230,8 @@ converter/missingpropertiesdlg.lfm svneol=native#text/plain
|
|||||||
converter/missingpropertiesdlg.pas svneol=native#text/plain
|
converter/missingpropertiesdlg.pas svneol=native#text/plain
|
||||||
converter/missingunits.lfm svneol=native#text/plain
|
converter/missingunits.lfm svneol=native#text/plain
|
||||||
converter/missingunits.pas svneol=native#text/plain
|
converter/missingunits.pas svneol=native#text/plain
|
||||||
|
converter/replacenamesunit.lfm svneol=native#text/plain
|
||||||
|
converter/replacenamesunit.pas svneol=native#text/plain
|
||||||
debian/README.Debian svneol=native#text/plain
|
debian/README.Debian svneol=native#text/plain
|
||||||
debian/README.source svneol=native#text/plain
|
debian/README.source svneol=native#text/plain
|
||||||
debian/changelog svneol=native#text/plain
|
debian/changelog svneol=native#text/plain
|
||||||
|
101
converter/replacenamesunit.lfm
Normal file
101
converter/replacenamesunit.lfm
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
object ReplaceNamesForm: TReplaceNamesForm
|
||||||
|
Left = 314
|
||||||
|
Height = 472
|
||||||
|
Top = 438
|
||||||
|
Width = 343
|
||||||
|
ActiveControl = NamePairGrid
|
||||||
|
Caption = 'Properties and Types to replace'
|
||||||
|
ClientHeight = 472
|
||||||
|
ClientWidth = 343
|
||||||
|
OnCreate = FormCreate
|
||||||
|
LCLVersion = '0.9.29'
|
||||||
|
object NamePairGrid: TStringGrid
|
||||||
|
Left = 0
|
||||||
|
Height = 434
|
||||||
|
Top = 0
|
||||||
|
Width = 343
|
||||||
|
Align = alClient
|
||||||
|
AutoFillColumns = True
|
||||||
|
ColCount = 2
|
||||||
|
Columns = <
|
||||||
|
item
|
||||||
|
Title.Caption = 'Delphi name'
|
||||||
|
Width = 169
|
||||||
|
end
|
||||||
|
item
|
||||||
|
Title.Caption = 'New name'
|
||||||
|
Width = 170
|
||||||
|
end>
|
||||||
|
FixedCols = 0
|
||||||
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
||||||
|
RowCount = 2
|
||||||
|
TabOrder = 0
|
||||||
|
ColWidths = (
|
||||||
|
169
|
||||||
|
170
|
||||||
|
)
|
||||||
|
end
|
||||||
|
object BtnPanel: TPanel
|
||||||
|
Left = 0
|
||||||
|
Height = 38
|
||||||
|
Top = 434
|
||||||
|
Width = 343
|
||||||
|
Align = alBottom
|
||||||
|
AutoSize = True
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 38
|
||||||
|
ClientWidth = 343
|
||||||
|
TabOrder = 1
|
||||||
|
object HelpButton: TBitBtn
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
|
Left = 6
|
||||||
|
Height = 26
|
||||||
|
Top = 6
|
||||||
|
Width = 75
|
||||||
|
Align = alLeft
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Constraints.MinHeight = 25
|
||||||
|
Constraints.MinWidth = 75
|
||||||
|
Kind = bkHelp
|
||||||
|
NumGlyphs = 0
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object btnOK: TBitBtn
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
|
Left = 179
|
||||||
|
Height = 26
|
||||||
|
Top = 6
|
||||||
|
Width = 75
|
||||||
|
Align = alRight
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Caption = '&OK'
|
||||||
|
Constraints.MinHeight = 25
|
||||||
|
Constraints.MinWidth = 75
|
||||||
|
Kind = bkOK
|
||||||
|
NumGlyphs = 0
|
||||||
|
OnClick = btnOKClick
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object btnCancel: TBitBtn
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
|
Left = 260
|
||||||
|
Height = 26
|
||||||
|
Top = 6
|
||||||
|
Width = 77
|
||||||
|
Align = alRight
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Cancel = True
|
||||||
|
Caption = 'Cancel'
|
||||||
|
Constraints.MinHeight = 25
|
||||||
|
Constraints.MinWidth = 75
|
||||||
|
Kind = bkCancel
|
||||||
|
ModalResult = 2
|
||||||
|
NumGlyphs = 0
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
136
converter/replacenamesunit.pas
Normal file
136
converter/replacenamesunit.pas
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
unit ReplaceNamesUnit;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
|
Grids, Buttons, ExtCtrls, CodeToolsStructs, LazarusIDEStrConsts;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TGridUpdater }
|
||||||
|
|
||||||
|
TGridUpdater = class
|
||||||
|
private
|
||||||
|
fGrid: TStringGrid;
|
||||||
|
fReplaceMap: TStringToStringTree;
|
||||||
|
fSeenName: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
public
|
||||||
|
constructor Create(AGrid: TStringGrid; AReplaceMap: TStringToStringTree);
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure AddUnique(AOldIdent: string);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TReplaceNamesForm }
|
||||||
|
|
||||||
|
TReplaceNamesForm = class(TForm)
|
||||||
|
btnCancel: TBitBtn;
|
||||||
|
btnOK: TBitBtn;
|
||||||
|
BtnPanel: TPanel;
|
||||||
|
HelpButton: TBitBtn;
|
||||||
|
NamePairGrid: TStringGrid;
|
||||||
|
procedure btnOKClick(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
private
|
||||||
|
|
||||||
|
public
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
ReplaceNamesForm: TReplaceNamesForm;
|
||||||
|
|
||||||
|
procedure CopyFromMapToGrid(AGrid: TStringGrid; AMap: TStringToStringTree);
|
||||||
|
procedure CopyFromGridToMap(AGrid: TStringGrid; AMap: TStringToStringTree);
|
||||||
|
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
|
procedure CopyFromMapToGrid(AGrid: TStringGrid; AMap: TStringToStringTree);
|
||||||
|
var
|
||||||
|
OldIdent, NewIdent: string;
|
||||||
|
List: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
// Collect (maybe edited) properties from StringGrid to NameReplacements.
|
||||||
|
List:=TStringList.Create;
|
||||||
|
try
|
||||||
|
AMap.GetNames(List);
|
||||||
|
for i:=0 to List.Count-1 do begin
|
||||||
|
OldIdent:=List[i];
|
||||||
|
NewIdent:=AMap[OldIdent];
|
||||||
|
if AGrid.RowCount<i+1 then
|
||||||
|
AGrid.RowCount:=i+1;
|
||||||
|
AGrid.Cells[0,i]:=OldIdent;
|
||||||
|
AGrid.Cells[1,i]:=NewIdent;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
List.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure CopyFromGridToMap(AGrid: TStringGrid; AMap: TStringToStringTree);
|
||||||
|
var
|
||||||
|
OldIdent, NewIdent: string;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
// Collect (maybe edited) properties from StringGrid to NameReplacements.
|
||||||
|
for i:=1 to AGrid.RowCount-1 do begin // Skip the fixed row.
|
||||||
|
OldIdent:=AGrid.Cells[0,i];
|
||||||
|
NewIdent:=AGrid.Cells[1,i];
|
||||||
|
if NewIdent<>'' then
|
||||||
|
AMap[OldIdent]:=NewIdent;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TGridUpdater }
|
||||||
|
|
||||||
|
constructor TGridUpdater.Create(AGrid: TStringGrid; AReplaceMap: TStringToStringTree);
|
||||||
|
begin
|
||||||
|
fGrid:=AGrid;
|
||||||
|
fReplaceMap:=AReplaceMap;
|
||||||
|
i:=1;
|
||||||
|
fSeenName:=TStringList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TGridUpdater.Destroy;
|
||||||
|
begin
|
||||||
|
fSeenName.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGridUpdater.AddUnique(AOldIdent: string);
|
||||||
|
var
|
||||||
|
NewIdent: string;
|
||||||
|
begin
|
||||||
|
// Add only one instance of each property name.
|
||||||
|
if fSeenName.IndexOf(AOldIdent)<0 then begin
|
||||||
|
fSeenName.Append(AOldIdent);
|
||||||
|
NewIdent:=fReplaceMap[AOldIdent];
|
||||||
|
if fGrid.RowCount<i+1 then
|
||||||
|
fGrid.RowCount:=i+1;
|
||||||
|
fGrid.Cells[0,i]:=AOldIdent;
|
||||||
|
fGrid.Cells[1,i]:=NewIdent;
|
||||||
|
Inc(i);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TReplaceNamesForm }
|
||||||
|
|
||||||
|
procedure TReplaceNamesForm.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Caption:=lisReplacementPropTypes;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TReplaceNamesForm.btnOKClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ModalResult:=mrOK;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user