mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 02:57:17 +01:00
cody: identifiers: popup menu: delete unit, delete package
git-svn-id: trunk@39634 -
This commit is contained in:
parent
3323685c50
commit
f4be9e7bc4
@ -178,5 +178,16 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg
|
|||||||
Caption = 'UseMenuItem'
|
Caption = 'UseMenuItem'
|
||||||
OnClick = UseIdentifierClick
|
OnClick = UseIdentifierClick
|
||||||
end
|
end
|
||||||
|
object DeleteSeparatorMenuItem: TMenuItem
|
||||||
|
Caption = '-'
|
||||||
|
end
|
||||||
|
object DeleteUnitMenuItem: TMenuItem
|
||||||
|
Caption = 'DeleteUnitMenuItem'
|
||||||
|
OnClick = DeleteUnitClick
|
||||||
|
end
|
||||||
|
object DeletePackageMenuItem: TMenuItem
|
||||||
|
Caption = 'DeletePackageMenuItem'
|
||||||
|
OnClick = DeletePackageClick
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -144,12 +144,17 @@ type
|
|||||||
InfoLabel: TLabel;
|
InfoLabel: TLabel;
|
||||||
ItemsListBox: TListBox;
|
ItemsListBox: TListBox;
|
||||||
JumpMenuItem: TMenuItem;
|
JumpMenuItem: TMenuItem;
|
||||||
|
DeleteSeparatorMenuItem: TMenuItem;
|
||||||
|
DeleteUnitMenuItem: TMenuItem;
|
||||||
|
DeletePackageMenuItem: TMenuItem;
|
||||||
UseMenuItem: TMenuItem;
|
UseMenuItem: TMenuItem;
|
||||||
PackageLabel: TLabel;
|
PackageLabel: TLabel;
|
||||||
PopupMenu1: TPopupMenu;
|
PopupMenu1: TPopupMenu;
|
||||||
StartsSpeedButton: TSpeedButton;
|
StartsSpeedButton: TSpeedButton;
|
||||||
UnitLabel: TLabel;
|
UnitLabel: TLabel;
|
||||||
procedure ButtonPanel1HelpButtonClick(Sender: TObject);
|
procedure ButtonPanel1HelpButtonClick(Sender: TObject);
|
||||||
|
procedure DeletePackageClick(Sender: TObject);
|
||||||
|
procedure DeleteUnitClick(Sender: TObject);
|
||||||
procedure UseIdentifierClick(Sender: TObject);
|
procedure UseIdentifierClick(Sender: TObject);
|
||||||
procedure ContainsSpeedButtonClick(Sender: TObject);
|
procedure ContainsSpeedButtonClick(Sender: TObject);
|
||||||
procedure FilterEditChange(Sender: TObject);
|
procedure FilterEditChange(Sender: TObject);
|
||||||
@ -184,6 +189,7 @@ type
|
|||||||
procedure SortItems;
|
procedure SortItems;
|
||||||
procedure UpdateIdentifierInfo;
|
procedure UpdateIdentifierInfo;
|
||||||
function GetFilterEditText: string;
|
function GetFilterEditText: string;
|
||||||
|
function FindSelectedIdentifier: TCodyIdentifier;
|
||||||
function FindSelectedItem(out Identifier, UnitFilename,
|
function FindSelectedItem(out Identifier, UnitFilename,
|
||||||
GroupName, GroupFilename: string): boolean;
|
GroupName, GroupFilename: string): boolean;
|
||||||
procedure UpdateCurOwnerOfUnit;
|
procedure UpdateCurOwnerOfUnit;
|
||||||
@ -740,6 +746,55 @@ begin
|
|||||||
OpenCodyHelp('#Identifier_Dictionary');
|
OpenCodyHelp('#Identifier_Dictionary');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCodyIdentifiersDlg.DeletePackageClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
Identifier: string;
|
||||||
|
UnitFilename: string;
|
||||||
|
GroupName: string;
|
||||||
|
GroupFilename: string;
|
||||||
|
Group: TUDUnitGroup;
|
||||||
|
s: String;
|
||||||
|
begin
|
||||||
|
if not FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename)
|
||||||
|
then exit;
|
||||||
|
if GroupFilename='' then exit;
|
||||||
|
s:='Really delete the package from the database?'#13
|
||||||
|
+'Note: This is does not change the source or any configuration.'#13
|
||||||
|
+#13'"'+GroupFilename+'"';
|
||||||
|
if IDEMessageDialog('Delete package?',s,mtConfirmation,[mbYes,mbNo],'')<>mrYes
|
||||||
|
then exit;
|
||||||
|
Group:=CodyUnitDictionary.FindGroupWithFilename(GroupFilename);
|
||||||
|
if Group=nil then exit;
|
||||||
|
CodyUnitDictionary.DeleteGroup(Group,true);
|
||||||
|
UpdateGeneralInfo;
|
||||||
|
UpdateItemsList;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCodyIdentifiersDlg.DeleteUnitClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
Identifier: string;
|
||||||
|
UnitFilename: string;
|
||||||
|
GroupName: string;
|
||||||
|
GroupFilename: string;
|
||||||
|
CurUnit: TUDUnit;
|
||||||
|
s: String;
|
||||||
|
begin
|
||||||
|
if not FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename)
|
||||||
|
then exit;
|
||||||
|
s:='Really delete the unit from the database?'#13
|
||||||
|
+'Note: This is does not change the source or any configuration.'#13
|
||||||
|
+#13'unit: "'+UnitFilename+'"';
|
||||||
|
if GroupFilename<>'' then
|
||||||
|
s+=#13'in "'+GroupFilename+'"';
|
||||||
|
if IDEMessageDialog('Delete unit?',s,mtConfirmation,[mbYes,mbNo],'')<>mrYes
|
||||||
|
then exit;
|
||||||
|
CurUnit:=CodyUnitDictionary.FindUnitWithFilename(UnitFilename);
|
||||||
|
if CurUnit=nil then exit;
|
||||||
|
CodyUnitDictionary.DeleteUnit(CurUnit,true);
|
||||||
|
UpdateGeneralInfo;
|
||||||
|
UpdateItemsList;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCodyIdentifiersDlg.ContainsSpeedButtonClick(Sender: TObject);
|
procedure TCodyIdentifiersDlg.ContainsSpeedButtonClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
UpdateItemsList;
|
UpdateItemsList;
|
||||||
@ -862,11 +917,19 @@ var
|
|||||||
begin
|
begin
|
||||||
if FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename) then
|
if FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename) then
|
||||||
begin
|
begin
|
||||||
|
UseMenuItem.Caption:='Use '+Identifier;
|
||||||
UseMenuItem.Enabled:=true;
|
UseMenuItem.Enabled:=true;
|
||||||
|
JumpMenuItem.Caption:='Jump to '+Identifier;
|
||||||
JumpMenuItem.Enabled:=true;
|
JumpMenuItem.Enabled:=true;
|
||||||
|
DeleteUnitMenuItem.Caption:='Delete unit '+ExtractFilename(UnitFilename);
|
||||||
|
DeleteUnitMenuItem.Enabled:=true;
|
||||||
|
DeletePackageMenuItem.Caption:='Delete package '+ExtractFilename(GroupFilename);
|
||||||
|
DeletePackageMenuItem.Enabled:=true;
|
||||||
end else begin
|
end else begin
|
||||||
UseMenuItem.Enabled:=false;
|
UseMenuItem.Enabled:=false;
|
||||||
JumpMenuItem.Enabled:=false;
|
JumpMenuItem.Enabled:=false;
|
||||||
|
DeleteUnitMenuItem.Enabled:=false;
|
||||||
|
DeletePackageMenuItem.Enabled:=false;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1123,10 +1186,20 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCodyIdentifiersDlg.FindSelectedIdentifier: TCodyIdentifier;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
if FItems=nil then exit;
|
||||||
|
i:=ItemsListBox.ItemIndex;
|
||||||
|
if (i<0) or (i>=FItems.Count) then exit;
|
||||||
|
Result:=TCodyIdentifier(FItems[i]);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCodyIdentifiersDlg.FindSelectedItem(out Identifier, UnitFilename,
|
function TCodyIdentifiersDlg.FindSelectedItem(out Identifier, UnitFilename,
|
||||||
GroupName, GroupFilename: string): boolean;
|
GroupName, GroupFilename: string): boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
|
||||||
Item: TCodyIdentifier;
|
Item: TCodyIdentifier;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
@ -1134,10 +1207,8 @@ begin
|
|||||||
UnitFilename:='';
|
UnitFilename:='';
|
||||||
GroupName:='';
|
GroupName:='';
|
||||||
GroupFilename:='';
|
GroupFilename:='';
|
||||||
if FItems=nil then exit;
|
Item:=FindSelectedIdentifier;
|
||||||
i:=ItemsListBox.ItemIndex;
|
if Item=nil then exit;
|
||||||
if (i<0) or (i>=FItems.Count) then exit;
|
|
||||||
Item:=TCodyIdentifier(FItems[i]);
|
|
||||||
Identifier:=Item.Identifier;
|
Identifier:=Item.Identifier;
|
||||||
UnitFilename:=Item.UnitFile;
|
UnitFilename:=Item.UnitFile;
|
||||||
GroupName:=Item.GroupName;
|
GroupName:=Item.GroupName;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user