started IDE progress dialog and splitted project sessions

git-svn-id: trunk@8120 -
This commit is contained in:
mattias 2005-11-09 19:40:59 +00:00
parent 8d90a2d6ea
commit c54f333978
14 changed files with 242 additions and 54 deletions

3
.gitattributes vendored
View File

@ -958,6 +958,9 @@ ide/newprojectdlg.pp svneol=native#text/pascal
ide/objectlists.pas svneol=native#text/pascal
ide/outputfilter.pas svneol=native#text/pascal
ide/patheditordlg.pas svneol=native#text/pascal
ide/progressdlg.lfm svneol=native#text/plain
ide/progressdlg.lrs svneol=native#text/plain
ide/progressdlg.pas svneol=native#text/plain
ide/project.pp svneol=native#text/pascal
ide/projectdefs.pas svneol=native#text/pascal
ide/projectinspector.pas svneol=native#text/pascal

View File

@ -294,7 +294,7 @@ type
function GetPreviousToken(aEditor: TCustomSynEdit): string;
public
constructor Create(AOwner: TComponent); override;
destructor destroy; override;
destructor Destroy; override;
procedure Execute(token: string; aEditor: TCustomSynEdit);
property Editors[i: integer]: TCustomSynEdit read GetEditor;
procedure AddEditor(aEditor: TCustomSynEdit);
@ -1423,10 +1423,6 @@ var
ShortCutShift: TShiftState;
begin
ShortCutToKey(FShortCut, ShortCutKey, ShortCutShift);
//inserted by shane
ShortCutKey := word(' ');
ShortCutShift := [ssCtrl];
//shane
i := fEditors.IndexOf(Sender);
if i <> -1 then begin

View File

@ -2880,6 +2880,8 @@ resourcestring
lisLazDocBrowseExampleButton = 'Browse';
lisEnableMakros = 'Enable Makros';
lisCTSelectCodeMacro = 'Select Code Macro';
lisPDProgress = 'Progress';
lisPDAbort = 'Abort';
implementation
end.

View File

@ -7098,7 +7098,8 @@ end;
function TMainIDE.SomethingOfProjectIsModified: boolean;
begin
Result:=(Project1<>nil)
and (Project1.SomethingModified or SourceNotebook.SomethingModified);
and (Project1.SomethingModified(true,true)
or SourceNotebook.SomethingModified);
end;
function TMainIDE.DoSaveAll(Flags: TSaveFlags): TModalResult;

View File

@ -69,7 +69,7 @@ uses
ProjectIntf, ProjectDefs, Project, PublishModule, BuildLazDialog, Compiler,
LazIDEIntf,
ComponentReg,
TransferMacros, PropEdits, OutputFilter, IDEDefs, MsgView,
TransferMacros, PropEdits, OutputFilter, IDEDefs, MsgView, ProgressDlg,
EnvironmentOpts, EditorOptions, CompilerOptions, KeyMapping, IDEProcs,
IDEOptionDefs, CodeToolsDefines, SrcEditorIntf;
@ -208,6 +208,9 @@ type
function GetPrimaryConfigPath: String; override;
function GetSecondaryConfigPath: String; override;
procedure CopySecondaryConfigFile(const AFilename: String); override;
function ShowProgress(const SomeText: string;
Step, MaxStep: integer): boolean; override;
end;
var
@ -379,6 +382,12 @@ begin
LazConf.CopySecondaryConfigFile(AFilename);
end;
function TMainIDEInterface.ShowProgress(const SomeText: string; Step,
MaxStep: integer): boolean;
begin
Result:=ProgressDlg.ShowProgress(SomeText,Step,MaxStep);
end;
{ TFileDescPascalUnitWithForm }
constructor TFileDescPascalUnitWithForm.Create;

45
ide/progressdlg.lfm Normal file
View File

@ -0,0 +1,45 @@
object IDEProgressDialog: TIDEProgressDialog
ActiveControl = AbortButton
Caption = 'IDEProgressDialog'
ClientHeight = 132
ClientWidth = 400
OnCreate = FormCreate
PixelsPerInch = 75
HorzScrollBar.Page = 399
VertScrollBar.Page = 131
Left = 286
Height = 132
Top = 202
Width = 400
object DescriptionLabel: TLabel
Anchors = [akTop]
AutoSize = False
Caption = 'DescriptionLabel'
Color = clNone
ParentColor = False
WordWrap = True
Left = 152
Height = 13
Top = 16
Width = 95
end
object AbortButton: TButton
Anchors = [akBottom]
BorderSpacing.InnerBorder = 2
Caption = 'AbortButton'
ModalResult = 3
TabOrder = 0
Left = 130
Height = 33
Top = 92
Width = 139
end
object ProgressBar: TProgressBar
Anchors = [akTop]
Max = 100
Left = 15
Height = 20
Top = 64
Width = 370
end
end

17
ide/progressdlg.lrs Normal file
View File

@ -0,0 +1,17 @@
{ Dies ist eine automatisch erzeugte Lazarus-Ressourcendatei }
LazarusResources.Add('TIDEProgressDialog','FORMDATA',[
'TPF0'#18'TIDEProgressDialog'#17'IDEProgressDialog'#13'ActiveControl'#7#11'Ab'
+'ortButton'#7'Caption'#6#17'IDEProgressDialog'#12'ClientHeight'#3#132#0#11'C'
+'lientWidth'#3#144#1#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'K'#18
+'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3#131#0#4'Left'#3#30#1#6
+'Height'#3#132#0#3'Top'#3#202#0#5'Width'#3#144#1#0#6'TLabel'#16'DescriptionL'
+'abel'#7'Anchors'#11#5'akTop'#0#8'AutoSize'#8#7'Caption'#6#16'DescriptionLab'
+'el'#5'Color'#7#6'clNone'#11'ParentColor'#8#8'WordWrap'#9#4'Left'#3#152#0#6
+'Height'#2#13#3'Top'#2#16#5'Width'#2'_'#0#0#7'TButton'#11'AbortButton'#7'Anc'
+'hors'#11#8'akBottom'#0#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#11'Ab'
+'ortButton'#11'ModalResult'#2#3#8'TabOrder'#2#0#4'Left'#3#130#0#6'Height'#2
+'!'#3'Top'#2'\'#5'Width'#3#139#0#0#0#12'TProgressBar'#11'ProgressBar'#7'Anch'
+'ors'#11#5'akTop'#0#3'Max'#2'd'#4'Left'#2#15#6'Height'#2#20#3'Top'#2'@'#5'Wi'
+'dth'#3'r'#1#0#0#0
]);

80
ide/progressdlg.pas Normal file
View File

@ -0,0 +1,80 @@
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
A dialog for showing the progress of a boring calculation.
}
unit ProgressDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
StdCtrls, ComCtrls, LazarusIDEStrConsts;
type
{ TIDEProgressDialog }
TIDEProgressDialog = class(TForm)
AbortButton: TButton;
DescriptionLabel: TLabel;
ProgressBar: TProgressBar;
procedure FormCreate(Sender: TObject);
private
public
procedure ApplicationIdle(Sender: TObject);
end;
function ShowProgress(const SomeText: string;
Step, MaxStep: integer): boolean;
implementation
function ShowProgress(const SomeText: string; Step, MaxStep: integer): boolean;
begin
Result:=true;
end;
{ TIDEProgressDialog }
procedure TIDEProgressDialog.FormCreate(Sender: TObject);
begin
Caption:=lisPDProgress;
DescriptionLabel.Caption:='...';
AbortButton.Caption:=lisPDAbort;
Application.AddOnIdleHandler(@ApplicationIdle);
end;
procedure TIDEProgressDialog.ApplicationIdle(Sender: TObject);
begin
ModalResult:=mrOk;
end;
initialization
{$I progressdlg.lrs}
end.

View File

@ -113,6 +113,7 @@ type
FProject: TProject;
FResourceFilename: string;
FRunFileIfActive: boolean;
FSessionModified: boolean;
fSource: TCodeBuffer;
fSyntaxHighlighter: TLazSyntaxHighlighter;
fTopLine: integer;
@ -214,7 +215,8 @@ type
property FileReadOnly: Boolean read fFileReadOnly write SetFileReadOnly;
property HasResources: boolean read GetHasResources write fHasResources;
property Loaded: Boolean read fLoaded write SetLoaded;
property Modified: boolean read fModified write fModified;
property Modified: boolean read fModified write fModified;// not Session data
property SessionModified: boolean read FSessionModified write FSessionModified;
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
property OnLoadSaveFilename: TOnLoadSaveFilename
read fOnLoadSaveFilename write fOnLoadSaveFilename;
@ -392,7 +394,6 @@ type
fLastReadLPIFileDate: TDateTime;
fLastReadLPIFilename: string;
fMainUnitID: Integer;
fModified: boolean;
FOnBeginUpdate: TNotifyEvent;
FOnEndUpdate: TEndUpdateProjectEvent;
fOnFileBackup: TOnFileBackup;
@ -428,7 +429,6 @@ type
procedure SetAutoOpenDesignerFormsDisabled(const AValue: boolean);
procedure SetCompilerOptions(const AValue: TProjectCompilerOptions);
procedure SetTargetFilename(const NewTargetFilename: string);
procedure SetUnits(Index:integer; AUnitInfo: TUnitInfo);
procedure SetMainUnitID(const AValue: Integer);
procedure UpdateProjectDirectory;
procedure UpdateSourceDirectories;
@ -438,11 +438,11 @@ type
function GetMainFileID: Integer; override;
procedure SetMainFileID(const AValue: Integer); override;
function GetFiles(Index: integer): TLazProjectFile; override;
procedure SetFiles(Index: integer; const AValue: TLazProjectFile); override;
procedure SetFlags(const AValue: TProjectFlags); override;
function GetProjectInfoFile: string; override;
procedure SetProjectInfoFile(const NewFilename: string); override;
procedure SetModified(const AValue: boolean); override;
procedure SetSessionModified(const AValue: boolean); override;
protected
// special unit lists
procedure AddToList(AnUnitInfo: TUnitInfo; ListType: TUnitInfoList);
@ -459,10 +459,11 @@ type
procedure Clear;
procedure BeginUpdate(Change: boolean);
procedure EndUpdate;
procedure UnitModified(AnUnitInfo: TUnitInfo);
// load/save
function IsVirtual: boolean;
function SomethingModified: boolean;
function SomethingModified(CheckData, CheckSession: boolean): boolean;
procedure MainSourceFilenameChanged;
procedure GetUnitsChangedOnDisk(var AnUnitList: TList);
function ReadProject(const LPIFilename: string): TModalResult;
@ -602,10 +603,8 @@ type
property TargetFileExt: String read FTargetFileExt write FTargetFileExt;
property TargetFilename: string
read GetTargetFilename write SetTargetFilename;
property Units[Index: integer]: TUnitInfo read GetUnits write SetUnits;
property Units[Index: integer]: TUnitInfo read GetUnits;
property UpdateLock: integer read FUpdateLock;
//lazdoc
property LazDocPathList: TStrings read FLazDocPathList write FLazDocPathList;
end;
const
@ -787,6 +786,7 @@ begin
FIgnoreFileDateOnDiskValid:=false;
inherited SetIsPartOfProject(false);
fModified := false;
FSessionModified := false;
FRunFileIfActive:=false;
fSyntaxHighlighter := lshText;
fTopLine := -1;
@ -889,7 +889,7 @@ begin
end;
fUnitName:=NewUnitName;
Modified:=true;
if Project<>nil then Project.Modified:=true;
if (Project<>nil) then Project.UnitModified(Self);
end;
end;
@ -1086,7 +1086,7 @@ begin
NewSource:=Beautified(
Descriptor.CreateSource(Filename,NewUnitName,fComponentName));
fSource.Source:=NewSource;
fModified:=true;
Modified:=true;
end;
function TUnitInfo.GetHasResources:boolean;
@ -1259,7 +1259,6 @@ begin
FJumpHistory.OnCheckPosition:=@JumpHistoryCheckPosition;
FJumpHistory.OnLoadSaveFilename:=@OnLoadSaveFilename;
fMainUnitID := -1;
fModified := false;
fProjectInfoFile := '';
FSourceDirectories:=TFileReferenceList.Create;
FSourceDirectories.OnChanged:=@SourceDirectoriesChanged;
@ -1446,6 +1445,8 @@ begin
InvalidateFileStateCache;
xmlconfig.Flush;
Modified:=false;
SessionModified:=false;
Result:=mrOk;
except
on E: Exception do begin
@ -1703,7 +1704,7 @@ begin
end;
end;
EndUpdate;
Modified:=true;
UnitModified(AnUnit);
end;
{------------------------------------------------------------------------------
@ -1722,7 +1723,7 @@ begin
BeginUpdate(true);
OldUnitInfo:=Units[Index];
Modified:=true;
UnitModified(OldUnitInfo);
if (MainUnitID>=0) then begin
// remove unit from uses section and from createforms in program file
@ -1792,7 +1793,8 @@ begin
fIconPath := '';
FJumpHistory.Clear;
fMainUnitID := -1;
fModified := false;
Modified := false;
SessionModified := false;
fProjectInfoFile := '';
FSourceDirectories.Clear;
UpdateProjectDirectory;
@ -1823,6 +1825,14 @@ begin
end;
end;
procedure TProject.UnitModified(AnUnitInfo: TUnitInfo);
begin
if AnUnitInfo.IsPartOfProject then
Modified:=true
else
SessionModified:=true;
end;
function TProject.GetUnits(Index:integer):TUnitInfo;
begin
Result:=TUnitInfo(FUnitList[Index]);
@ -1848,25 +1858,20 @@ begin
Result:=Units[Index];
end;
procedure TProject.SetFiles(Index: integer; const AValue: TLazProjectFile);
begin
Units[Index]:=AValue as TUnitInfo;
end;
procedure TProject.SetModified(const AValue: boolean);
begin
if AValue=Modified then exit;
inherited SetModified(AValue);
if not Modified then PublishOptions.Modified:=false;
if not Modified then begin
PublishOptions.Modified:=false;
CompilerOptions.Modified:=false;
end;
end;
procedure TProject.SetUnits(Index:integer; AUnitInfo: TUnitInfo);
procedure TProject.SetSessionModified(const AValue: boolean);
begin
if AUnitInfo<>TUnitInfo(FUnitList[Index]) then begin
FUnitList[Index]:=AUnitInfo;
Modified:=true;
if AUnitInfo<>nil then AUnitInfo.Project:=Self;
end;
if AValue=SessionModified then exit;
inherited SetSessionModified(AValue);
end;
function TProject.UnitCount:integer;
@ -2162,7 +2167,7 @@ begin
Bookmarks[i].EditorIndex:=Bookmarks[i].EditorIndex-1;
dec(i);
end;
Modified:=true;
SessionModified:=true;
end;
procedure TProject.InsertEditorIndex(EditorIndex:integer);
@ -2189,7 +2194,7 @@ begin
Bookmarks[i].EditorIndex:=MoveIndex(Bookmarks[i].EditorIndex);
dec(i);
end;
Modified:=true;
SessionModified:=true;
end;
procedure TProject.MoveEditorIndex(OldEditorIndex, NewEditorIndex: integer);
@ -2232,7 +2237,7 @@ begin
Bookmarks[i].EditorIndex:=MoveIndex(Bookmarks[i].EditorIndex);
dec(i);
end;
Modified:=true;
SessionModified:=true;
end;
procedure TProject.AddToOrRemoveFromEditorWithIndexList(AnUnitInfo: TUnitInfo);
@ -2676,12 +2681,24 @@ begin
Result:=(i>=0) and (Units[i].EditorIndex>=0);
end;
function TProject.SomethingModified: boolean;
function TProject.SomethingModified(CheckData, CheckSession: boolean): boolean;
var i: integer;
begin
Result:=Modified or SessionModified;
for i:=0 to UnitCount-1 do Result:=Result or Units[i].Modified;
Result:=Result or CompilerOptions.Modified;
Result:=true;
if CheckData then begin
if Modified then exit;
if CompilerOptions.Modified then exit;
for i:=0 to UnitCount-1 do
if (Units[i].IsPartOfProject) and Units[i].Modified then exit;
end;
if CheckSession then begin
if SessionModified then exit;
for i:=0 to UnitCount-1 do begin
if Units[i].SessionModified then exit;
if (not Units[i].IsPartOfProject) and Units[i].Modified then exit;
end;
end;
Result:=false;
end;
procedure TProject.MainSourceFilenameChanged;

View File

@ -1,2 +1,2 @@
// Created by Svn2RevisionInc
const RevisionStr = '8071:8075M';
const RevisionStr = '8117M';

View File

@ -129,9 +129,11 @@ type
procedure DoJumpToCodeToolBossError; virtual; abstract;
procedure SaveSourceEditorChangesToCodeCache(PageIndex: integer); virtual; abstract;
function ShowProgress(const SomeText: string;
Step, MaxStep: integer): boolean; virtual; abstract; // False if canceled by user
public
property ActiveProject: TLazProject read GetActiveProject;
end;
var

View File

@ -481,12 +481,11 @@ type
{ TLazProject - interface class to a Lazarus project }
{ TLazProject }
TLazProject = class(TPersistent)
private
FLazCompilerOptions: TLazCompilerOptions;
fModified: boolean;
FProjectSessionFile: string;
FSessionModified: boolean;
fTitle: String;
FSessionStorage: TProjectSessionStorage;
@ -498,11 +497,11 @@ type
function GetMainFileID: Integer; virtual; abstract;
procedure SetMainFileID(const AValue: Integer); virtual; abstract;
function GetFiles(Index: integer): TLazProjectFile; virtual; abstract;
procedure SetFiles(Index: integer; const AValue: TLazProjectFile); virtual; abstract;
procedure SetTitle(const AValue: String); virtual;
procedure SetFlags(const AValue: TProjectFlags); virtual;
function GetProjectInfoFile: string; virtual; abstract;
procedure SetProjectInfoFile(const NewFilename: string); virtual; abstract;
procedure SetProjectSessionFile(const AValue: string); virtual;
procedure SetSessionStorage(const AValue: TProjectSessionStorage); virtual;
procedure SetModified(const AValue: boolean); virtual;
procedure SetSessionModified(const AValue: boolean); virtual;
@ -520,7 +519,7 @@ type
function ShortDescription: string;
public
property MainFileID: Integer read GetMainFileID write SetMainFileID;
property Files[Index: integer]: TLazProjectFile read GetFiles write SetFiles;
property Files[Index: integer]: TLazProjectFile read GetFiles;
property FileCount: integer read GetFileCount;
property MainFile: TLazProjectFile read GetMainFile;
property Title: String read fTitle write SetTitle;
@ -529,12 +528,17 @@ type
write SetLazCompilerOptions;
property ProjectInfoFile: string
read GetProjectInfoFile write SetProjectInfoFile;
property ProjectSessionFile: string
read FProjectSessionFile write SetProjectSessionFile;
property SessionStorage: TProjectSessionStorage read FSessionStorage
write SetSessionStorage;
property Modified: boolean read fModified
write SetModified; // project data (not units, session)
write SetModified; // project data (not units, session),
// units have their own Modified
property SessionModified: boolean read FSessionModified
write SetSessionModified; // project session data (not units, data)
write SetSessionModified;
// project session data (not units, data),
// units have their own SessionModified
property LazDocPathList: TStrings read FLazDocPathList write FLazDocPathList;
end;
@ -992,6 +996,13 @@ begin
FSessionModified:=AValue;
end;
procedure TLazProject.SetProjectSessionFile(const AValue: string);
begin
if FProjectSessionFile=AValue then exit;
FProjectSessionFile:=AValue;
SessionModified:=true;
end;
procedure TLazProject.SetLazCompilerOptions(const AValue: TLazCompilerOptions);
begin
if FLazCompilerOptions=AValue then exit;

View File

@ -1150,12 +1150,17 @@ Begin
begin
if not
((AWinControl = nil)
or (AWinControl <> Self) and (GetParentForm(AWinControl) = Self)
and ((csLoading in ComponentState) or not (Visible and Enabled)
or AWinControl.CanFocus))
then
or ((AWinControl <> Self)
and (GetParentForm(AWinControl) = Self)
and ((csLoading in ComponentState)
or AWinControl.CanFocus)))
then begin
{$IFDEF VerboseFocus}
RaiseGDBException(SCannotFocus);
// EInvalidOperation.Create(SCannotFocus);
{$ELSE}
EInvalidOperation.Create(SCannotFocus);
{$ENDIF}
end;
{$IFDEF VerboseFocus}
DbgOut('TCustomForm.SetActiveControl ',Name,':',ClassName,' FActive=',DbgS(FActive));
if FActiveControl<>nil then

View File

@ -1570,7 +1570,7 @@ begin
begin
Control := Self;
repeat
if not (Control.IsVisible and Control.Enabled) then Exit;
if not (Control.IsControlVisible and Control.Enabled) then Exit;
if Control = Form then break;
Control := Control.Parent;
until false;