* Context menu for treeview. Adapt some action update handlers to treeview

git-svn-id: trunk@51123 -
This commit is contained in:
michael 2016-01-02 13:58:27 +00:00
parent d72933eb26
commit 0ef7c72e99
2 changed files with 105 additions and 8 deletions

View File

@ -129,10 +129,10 @@ object MainForm: TMainForm
Height = 418
Top = 26
Width = 458
ActivePage = TSConnections
ActivePage = TSAll
Align = alClient
Images = ILMain
TabIndex = 0
TabIndex = 2
TabOrder = 1
object TSConnections: TTabSheet
Caption = 'Connections'
@ -220,6 +220,7 @@ object MainForm: TMainForm
Align = alClient
DefaultItemHeight = 16
Images = ILMain
PopupMenu = PMAll
TabOrder = 0
OnDblClick = TVAllDblClick
end
@ -1717,7 +1718,7 @@ object MainForm: TMainForm
Action = AOpenConnection
end
object PMINewConnection: TMenuItem
Caption = '&New connection'
Action = ANewConnection
end
object PMIDeleteConnection: TMenuItem
Action = ADeleteConnection
@ -1776,4 +1777,31 @@ object MainForm: TMainForm
OnClick = ADeleteRecentDataDictExecute
end
end
object PMAll: TPopupMenu
Images = ILMain
OnPopup = PMAllPopup
left = 152
top = 256
object PMIOpenConnectionA: TMenuItem
Action = AOpenConnection
end
object PMINewConnectionA: TMenuItem
Action = ANewConnection
end
object PMIDeleteConnectionA: TMenuItem
Action = ADeleteConnection
end
object MenuItem10: TMenuItem
Caption = '-'
end
object PMIOpenDataDictA: TMenuItem
Action = AOpenRecentDatadict
end
object PMINewDataDictA: TMenuItem
Action = ANew
end
object PMIDeleteDataDictA: TMenuItem
Action = ADeleteRecentDataDict
end
end
end

View File

@ -76,6 +76,9 @@ type
ILMain: TImageList;
LVConnections: TListView;
LVDicts: TListView;
MenuItem10: TMenuItem;
PMIDeleteDataDictA: TMenuItem;
PMINewDataDictA: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
@ -83,12 +86,16 @@ type
MenuItem6: TMenuItem;
MenuItem7: TMenuItem;
MenuItem8: TMenuItem;
PMIOpenDataDictA: TMenuItem;
MIListView: TMenuItem;
MView: TMenuItem;
MICreateCode: TMenuItem;
PCItems: TPageControl;
PMIDeleteConnectionA: TMenuItem;
PMINewConnection: TMenuItem;
PMINewConnectionA: TMenuItem;
PMINewDataDict: TMenuItem;
PMIOpenConnectionA: TMenuItem;
PMIOpenDataDict: TMenuItem;
MIDeleteRecentConnection: TMenuItem;
MIOpenRecentConnection: TMenuItem;
@ -113,6 +120,7 @@ type
MIDataDict: TMenuItem;
PMRecentConnections: TPopupMenu;
PMDataDict: TPopupMenu;
PMAll: TPopupMenu;
PStatus: TPanel;
PStatusText: TPanel;
PBSTatus: TProgressBar;
@ -197,6 +205,7 @@ type
procedure OpenRecentDatadict(Sender: TObject);
procedure LVDictsKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure MIDataDictClick(Sender: TObject);
procedure PMAllPopup(Sender: TObject);
procedure SaveAsExecute(Sender: TObject);
procedure TVAllDblClick(Sender: TObject);
private
@ -1062,15 +1071,46 @@ begin
end;
procedure TMainForm.HaveRecentConnection(Sender: TObject);
Var
TN : TTreeNode;
LI : TListItem;
doEnable: Boolean;
begin
(Sender as Taction).Enabled:=(LVConnections.Selected<>Nil)
and (LVConnections.Selected.Data<>Nil);
if FTreeIntf then
begin
TN:=TVAll.Selected;
doEnable:=Assigned(TN) AND Assigned(TN.Data) AND TObject(TN.Data).InheritsFrom(TRecentConnection)
end
else
begin
LI:=LVConnections.Selected;
doEnable:=(LI<>Nil) and (LI.Data<>Nil);
end;
(Sender as Taction).Enabled:=doEnable;
end;
procedure TMainForm.HaveRecentDataDict(Sender: TObject);
Var
TN : TTreeNode;
LI : TListItem;
doEnable: Boolean;
begin
(Sender as Taction).Enabled:=(LVDicts.Selected<>Nil)
and (LVDicts.Selected.Data<>Nil);
if FTreeIntf then
begin
TN:=TVAll.Selected;
doEnable:=Assigned(TN)
AND Assigned(TN.Data)
AND TObject(TN.Data).InheritsFrom(TRecentDataDict)
end
else
begin
LI:=LVDicts.Selected;
doEnable:=(LI<>Nil) AND (LI.Data<>Nil);
end;
(Sender as Taction).Enabled:=doEnable;
end;
procedure TMainForm.HaveTabs(Sender: TObject);
@ -1080,7 +1120,10 @@ end;
procedure TMainForm.HaveTab(Sender: TObject);
begin
(Sender as TAction).Enabled:=(PCDD.PageCount>2);
if FTreeIntf then
(Sender as TAction).Enabled:=(PCDD.PageCount>0)
else
(Sender as TAction).Enabled:=(PCDD.PageCount>2);
end;
procedure TMainForm.HaveTables(Sender: TObject);
@ -1515,6 +1558,32 @@ begin
ShowDDImports;
end;
procedure TMainForm.PMAllPopup(Sender: TObject);
Type
TOption = (oConnection,oDataDict);
TOptions = Set of TOption;
Var
TN : TTreeNode;
S : TOptions;
begin
TN:=TVAll.Selected;
S:=[];
if Assigned(TN) and Assigned(TN.Data) then
if TObject(TN.Data).InheritsFrom(TRecentConnection) then
S:=[oConnection]
else if TObject(TN.Data).InheritsFrom(TRecentDatadict) then
S:=[oDataDict];
PMINewConnectionA.Visible:=True;
PMIOpenConnectionA.Visible:=oConnection in S;
PMIDeleteConnectionA.Visible:=oConnection in S;
PMINewDataDictA.Visible:=True;
PMIOpenDataDictA.Visible:=oDataDict in S;
PMIDeleteDataDictA.Visible:=oDataDict in S;
end;
function TMainForm.FindLi(LV: TListView; RI: TRecentItem): TListItem;