IDE: code explorer: fixed check for updates, added menu item Rename

git-svn-id: trunk@22847 -
This commit is contained in:
mattias 2009-11-28 11:55:46 +00:00
parent 524cc9f759
commit 510e73913d
4 changed files with 73 additions and 11 deletions

View File

@ -156,6 +156,7 @@ object CodeExplorerView: TCodeExplorerView
top = 64
end
object TreePopupmenu: TPopupMenu
OnPopup = TreePopupmenuPopup
left = 64
top = 128
object MenuItem1: TMenuItem

View File

@ -55,8 +55,9 @@ LazarusResources.Add('TCodeExplorerView','FORMDATA',[
+'ons'#11#17'tvoAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'
+#11'tvoReadOnly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoT'
+'oolTips'#0#0#0#0#0#10'TImageList'#10'Imagelist1'#6'Height'#2#18#5'Width'#2
+#18#4'left'#2'@'#3'top'#2'@'#0#0#10'TPopupMenu'#13'TreePopupmenu'#4'left'#2
+'@'#3'top'#3#128#0#0#9'TMenuItem'#9'MenuItem1'#7'Caption'#6#9'New Item1'#7'V'
+'isible'#8#0#0#0#10'TIdleTimer'#10'IdleTimer1'#11'AutoEnabled'#9#8'Interval'
+#3#244#1#7'OnTimer'#7#15'IdleTimer1Timer'#4'left'#2'@'#3'top'#3#192#0#0#0#0
+#18#4'left'#2'@'#3'top'#2'@'#0#0#10'TPopupMenu'#13'TreePopupmenu'#7'OnPopup'
+#7#18'TreePopupmenuPopup'#4'left'#2'@'#3'top'#3#128#0#0#9'TMenuItem'#9'MenuI'
+'tem1'#7'Caption'#6#9'New Item1'#7'Visible'#8#0#0#0#10'TIdleTimer'#10'IdleTi'
+'mer1'#11'AutoEnabled'#9#8'Interval'#3#244#1#7'OnTimer'#7#15'IdleTimer1Timer'
+#4'left'#2'@'#3'top'#3#192#0#0#0#0
]);

View File

@ -48,8 +48,8 @@ uses
// IDE Intf
LazIDEIntf, IDECommands, MenuIntf, SrcEditorIntf,
// IDE
LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs, InputHistory, IDEProcs,
TodoList, CodeExplOpts;
KeyMapping, LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs, InputHistory,
IDEProcs, TodoList, CodeExplOpts;
type
TCodeExplorerView = class;
@ -157,6 +157,8 @@ type
procedure OptionsSpeedButtonClick(Sender: TObject);
procedure RefreshMenuitemClick(Sender: TObject);
procedure RefreshSpeedButtonClick(Sender: TObject);
procedure RenameMenuItemClick(Sender: TObject);
procedure TreePopupmenuPopup(Sender: TObject);
private
FCodeFilename: string;
fCategoryNodes: array[TCodeExplorerCategory] of TTreeNode;
@ -239,7 +241,7 @@ type
procedure RefreshCode(OnlyVisible: boolean);
procedure RefreshDirectives(OnlyVisible: boolean);
procedure ClearCTNodes(ATreeView: TTreeView);// remove temporary references
procedure JumpToSelection; // jump in source editor
function JumpToSelection: boolean; // jump in source editor
function SelectSourceEditorNode: boolean;
function SelectCodePosition(CodeBuf: TCodeBuffer; X, Y: integer): boolean; // select deepest node
function FindCodeTVNodeAtCleanPos(CleanPos: integer): TTreeNode;
@ -402,6 +404,7 @@ begin
CEJumpToIDEMenuCommand.OnClick:=@JumpToMenuitemCLICK;
CERefreshIDEMenuCommand.OnClick:=@RefreshMenuitemCLICK;
CEDockingIDEMenuCommand.OnClick:=@DockingMenuItemClick;
CERenameIDEMenuCommand.OnClick:=@RenameMenuItemClick;
{$IFNDEF EnableIDEDocking}
CEDockingIDEMenuCommand.Visible:=false;
{$ENDIF}
@ -470,7 +473,7 @@ end;
procedure TCodeExplorerView.IdleTimer1Timer(Sender: TObject);
begin
if ((cevCheckOnIdle in FFlags) or (CodeExplorerOptions.Refresh=cerOnIdle))
and (not Active) then
and (not Active) and (not (fsModal in Screen.ActiveCustomForm.FormState)) then
Refresh(true);
end;
@ -518,6 +521,48 @@ begin
Refresh(true);
end;
procedure TCodeExplorerView.RenameMenuItemClick(Sender: TObject);
begin
if not JumpToSelection then begin
MessageDlg(lisCCOErrorCaption, lisTreeNeedsRefresh, mtError, [mbOk], 0);
Refresh(true);
exit;
end;
ExecuteIDECommand(SourceEditorWindow,ecRenameIdentifier);
end;
procedure TCodeExplorerView.TreePopupmenuPopup(Sender: TObject);
var
CurTreeView: TCustomTreeView;
CurItem: TTreeNode;
CanRename: boolean;
CurNode: TViewNodeData;
begin
CanRename:=false;
CurTreeView:=GetCurrentTreeView;
if CurTreeView<>nil then begin
if tvoAllowMultiselect in CurTreeView.Options then
CurItem:=CurTreeView.GetFirstMultiSelected
else
CurItem:=CurTreeView.Selected;
if CurItem<>nil then begin
CurNode:=TViewNodeData(CurItem.Data);
if CurNode.StartPos>0 then begin
case CurrentPage of
cepCode:
if (CurNode.Desc in AllIdentifierDefinitions)
and (CurItem.GetNextMultiSelected=nil) then
CanRename:=true;
cepDirectives:
;
end;
end;
end;
end;
CERenameIDEMenuCommand.Visible:=CanRename;
DebugLn(['TCodeExplorerView.TreePopupmenuPopup ',CERenameIDEMenuCommand.Visible]);
end;
function TCodeExplorerView.GetCodeNodeDescription(ACodeTool: TCodeTool;
CodeNode: TCodeTreeNode): string;
begin
@ -1666,7 +1711,7 @@ begin
and (ACodeTool.Scanner<>nil)
and (ACodeTool.Scanner.ChangeStep=FLastCodeChangeStep)
and (Mode=FLastMode)
and (FLastCodeChangeStep=CodeExplorerOptions.ChangeStep) then begin
and (fLastCodeOptionsChangeStep=CodeExplorerOptions.ChangeStep) then begin
// still the same source and options
exit;
end;
@ -1814,7 +1859,7 @@ begin
end;
end;
procedure TCodeExplorerView.JumpToSelection;
function TCodeExplorerView.JumpToSelection: boolean;
var
CurItem: TTreeNode;
CurNode: TViewNodeData;
@ -1823,17 +1868,22 @@ var
CodeBuffer: TCodeBuffer;
ACodeTool: TCodeTool;
CurTreeView: TCustomTreeView;
SrcEdit: TSourceEditorInterface;
begin
Result:=false;
CurTreeView:=GetCurrentTreeView;
DebugLn(['TCodeExplorerView.JumpToSelection AAA1']);
if CurTreeView=nil then exit;
DebugLn(['TCodeExplorerView.JumpToSelection AAA2']);
if tvoAllowMultiselect in CurTreeView.Options then
CurItem:=CurTreeView.GetFirstMultiSelected
else
CurItem:=CurTreeView.Selected;
if CurItem=nil then exit;
CurNode:=TViewNodeData(CurItem.Data);
DebugLn(['TCodeExplorerView.JumpToSelection AAA3 ',CurNode.StartPos]);
if CurNode.StartPos<1 then exit;
CodeBuffer:=nil;
case CurrentPage of
cepCode:
begin
@ -1858,8 +1908,17 @@ begin
else
exit;
end;
DebugLn(['TCodeExplorerView.JumpToSelection AAA1']);
if Assigned(OnJumpToCode) then
OnJumpToCode(Self,Caret.Code.Filename,Point(Caret.X,Caret.Y),NewTopLine);
SrcEdit:=SourceEditorWindow.ActiveEditor;
DebugLn(['TCodeExplorerView.JumpToSelection AAA2 ',SrcEdit.FileName,' ',dbgs(SrcEdit.CursorTextXY),' X=',Caret.X,' Y=',Caret.Y]);
// check if jump was successful
if (SrcEdit.CodeToolsBuffer<>CodeBuffer)
or (SrcEdit.CursorTextXY.X<>Caret.X) or (SrcEdit.CursorTextXY.Y<>Caret.Y) then
exit;
DebugLn(['TCodeExplorerView.JumpToSelection AAA3']);
Result:=true;
end;
function TCodeExplorerView.SelectSourceEditorNode: boolean;

View File

@ -1693,6 +1693,7 @@ resourcestring
dlgCCOTestMissingPPU = 'Test: Checking missing fpc ppu ...';
dlgCCOTestCompilerDate = 'Test: Checking compiler date ...';
lisCCOErrorCaption = 'Error';
lisTreeNeedsRefresh = 'Tree needs refresh';
lisEMDEmtpyMethods = 'Emtpy Methods';
lisEMDSearchInTheseClassSections = 'Search in these class sections:';
lisUnableToLoadPackage = 'Unable to load package %s%s%s';