diff --git a/boss_ide.res b/boss_ide.res deleted file mode 100644 index d3a0725..0000000 Binary files a/boss_ide.res and /dev/null differ diff --git a/src/IDE/Boss.IDE.BossInstall.pas b/src/IDE/Boss.IDE.BossInstall.pas index 67e9ad2..7422098 100644 --- a/src/IDE/Boss.IDE.BossInstall.pas +++ b/src/IDE/Boss.IDE.BossInstall.pas @@ -8,8 +8,7 @@ interface TMenuNotifierBossInstall = class(TNotifierObject, IOTANotifier, IOTAProjectMenuItemCreatorNotifier) public function CanHandle(const Ident: string): Boolean; - procedure AddMenu(const Project: IOTAProject; const IdentList: TStrings; - const ProjectManagerMenuList: IInterfaceList; IsMultiSelect: Boolean); + procedure AddMenu(const Project: IOTAProject; const IdentList: TStrings; const ProjectManagerMenuList: IInterfaceList; IsMultiSelect: Boolean); end; TButtonBoss = class(TNotifierObject, IOTALocalMenu, IOTAProjectManagerMenu) diff --git a/src/IDE/Boss.IDE.Installer.pas b/src/IDE/Boss.IDE.Installer.pas index d828b0c..1c98fce 100644 --- a/src/IDE/Boss.IDE.Installer.pas +++ b/src/IDE/Boss.IDE.Installer.pas @@ -2,8 +2,7 @@ interface -uses - ToolsApi; +uses ToolsApi; type TBossIDEInstaller = class @@ -14,10 +13,7 @@ TBossIDEInstaller = class implementation -uses - System.Classes, Providers.Message, System.SysUtils; - -{ TBossIDEInstaller } +uses System.Classes, Providers.Message, System.SysUtils; class function TBossIDEInstaller.InstallBpl(const AFile: string): Boolean; var @@ -32,7 +28,7 @@ class function TBossIDEInstaller.InstallBpl(const AFile: string): Boolean; except on E: Exception do begin - TProviderMessage.GetInstance.WriteLn('Failed to load ' + AFile); + TProviderMessage.GetInstance.WriteLn('Failed to install ' + AFile); TProviderMessage.GetInstance.WriteLn(#10 + E.Message); LResult := False; end; @@ -51,7 +47,12 @@ class function TBossIDEInstaller.RemoveBpl(const AFile: string): Boolean; LResult := (BorlandIDEServices as IOTAPAckageServices).UninstallPackage(AFile) end); except - LResult := False; + on E: Exception do + begin + TProviderMessage.GetInstance.WriteLn('Failed to remove ' + AFile); + TProviderMessage.GetInstance.WriteLn(#10 + E.Message); + LResult := False; + end; end; Result := LResult; end; diff --git a/src/IDE/Boss.IDE.PojectListener.pas b/src/IDE/Boss.IDE.PojectListener.pas index edb20ad..4b4b55e 100644 --- a/src/IDE/Boss.IDE.PojectListener.pas +++ b/src/IDE/Boss.IDE.PojectListener.pas @@ -2,8 +2,7 @@ interface -uses - ToolsAPI, System.Generics.Collections, System.SysUtils; +uses ToolsAPI, System.Generics.Collections, System.SysUtils; type TBossProjectListener = class(TNotifierObject, IOTAIDENotifier) @@ -21,7 +20,6 @@ TBossProjectListener = class(TNotifierObject, IOTAIDENotifier) procedure Modified; constructor Create; public - procedure AddListener(AType: TOTAFileNotification; ACallback: TProc); procedure RemoveListener(AType: TOTAFileNotification; ACallback: TProc); class function GetInstance: TBossProjectListener; @@ -30,14 +28,11 @@ TBossProjectListener = class(TNotifierObject, IOTAIDENotifier) implementation -uses - Winapi.Windows; +uses Winapi.Windows; var FInstance: TBossProjectListener; - { TBossProjectListener } - procedure TBossProjectListener.AddListener(AType: TOTAFileNotification; ACallback: TProc); var LListeners: TList>; @@ -93,7 +88,6 @@ procedure TBossProjectListener.FileNotification(NotifyCode: TOTAFileNotification begin if not FListeners.TryGetValue(NotifyCode, LListeners) then Exit; - for LCallback in LListeners do begin LCallback(FileName); @@ -117,9 +111,7 @@ procedure TBossProjectListener.RemoveListener(AType: TOTAFileNotification; ACall LListeners: TList>; begin if FListeners.TryGetValue(AType, LListeners) then - begin LListeners.Remove(ACallback); - end; end; end. diff --git a/src/IDE/Boss.IDE.Register.pas b/src/IDE/Boss.IDE.Register.pas index aa71353..0082a27 100644 --- a/src/IDE/Boss.IDE.Register.pas +++ b/src/IDE/Boss.IDE.Register.pas @@ -6,9 +6,8 @@ procedure Register; implementation -uses - ToolsAPI, Winapi.Windows, Boss.IDE.BossInstall, Boss.IDE.PojectListener, Boss.Modules.PackageProcessor, - Vcl.Graphics, DesignIntf, System.Types, Providers.Logo, Providers.Message, Boss.Ide.OpenToolApi.Tools; +uses ToolsAPI, Winapi.Windows, Boss.IDE.BossInstall, Boss.IDE.PojectListener, Boss.Modules.PackageProcessor, Vcl.Graphics, + DesignIntf, System.Types, Providers.Logo, Providers.Message, Boss.Ide.OpenToolApi.Tools; const C_INVALID_NOTIFIER = -1; @@ -39,18 +38,11 @@ procedure Register; end; LProjectManager := (BorlandIDEServices as IOTAProjectManager); - LServices := (BorlandIDEServices as IOTAServices); - - LMessageServices := (BorlandIDEServices as IOTAMessageServices); - FNotifierMenuIndex := LProjectManager.AddMenuItemCreatorNotifier(TMenuNotifierBossInstall.Create); - FNotifierProjectIndex := LServices.AddNotifier(TBossProjectListener.GetInstance); - TProviderMessage.GetInstance.Initialize(LMessageServices); - TBossProjectListener.GetInstance.AddListener(ofnActiveProjectChanged, TBossPackageProcessor.OnActiveProjectChanged); end; diff --git a/src/core/Boss.Modules.PackageProcessor.pas b/src/core/Boss.Modules.PackageProcessor.pas index 70369cb..143402d 100644 --- a/src/core/Boss.Modules.PackageProcessor.pas +++ b/src/core/Boss.Modules.PackageProcessor.pas @@ -2,8 +2,7 @@ interface -uses - System.IniFiles, System.Classes, System.Types; +uses System.IniFiles, System.Classes, System.Types; type TBossPackageProcessor = class @@ -29,22 +28,18 @@ TBossPackageProcessor = class procedure LoadBpls; procedure UnloadOlds; - class Procedure OnActiveProjectChanged(AProject: string); + class procedure OnActiveProjectChanged(AProject: string); class function GetInstance: TBossPackageProcessor; end; - const BPLS = 'BPLS'; DELIMITER = ';'; implementation -uses - System.IOUtils, Providers.Consts, Boss.IDE.Installer, Providers.Message, Vcl.Dialogs, ToolsAPI, - Boss.IDE.OpenToolApi.Tools, Winapi.ShellAPI, Winapi.Windows, Vcl.Menus, Boss.EventWrapper, Vcl.Forms, System.SysUtils; - -{ TBossPackageProcessor } +uses System.IOUtils, Providers.Consts, Boss.IDE.Installer, Providers.Message, Vcl.Dialogs, ToolsAPI, Boss.IDE.OpenToolApi.Tools, + Winapi.ShellAPI, Winapi.Windows, Vcl.Menus, Boss.EventWrapper, Vcl.Forms, System.SysUtils; var _Instance: TBossPackageProcessor; @@ -53,15 +48,14 @@ procedure ExecuteAndWait(const ACommand: string); var LStartup: TStartupInfo; LProcess: TProcessInformation; - LProgram: String; + LProgram: string; begin LProgram := Trim(ACommand); FillChar(LStartup, SizeOf(LStartup), 0); LStartup.cb := SizeOf(TStartupInfo); LStartup.wShowWindow := SW_HIDE; - if CreateProcess(nil, pchar(LProgram), nil, nil, true, CREATE_NO_WINDOW, - nil, nil, LStartup, LProcess) then + if CreateProcess(nil, pchar(LProgram), nil, nil, true, CREATE_NO_WINDOW, nil, nil, LStartup, LProcess) then begin while WaitForSingleObject(LProcess.hProcess, 10) > 0 do begin @@ -71,15 +65,12 @@ procedure ExecuteAndWait(const ACommand: string); CloseHandle(LProcess.hThread); end else - begin RaiseLastOSError; - end; end; function TBossPackageProcessor.GetEnv(AEnv: string): string; begin - Result := FHomeDrive + FHomePath + TPath.DirectorySeparatorChar + C_BOSS_CACHE_FOLDER + TPath.DirectorySeparatorChar - + C_ENV + AEnv; + Result := FHomeDrive + FHomePath + TPath.DirectorySeparatorChar + C_BOSS_CACHE_FOLDER + TPath.DirectorySeparatorChar + C_ENV + AEnv; end; procedure DeleteDirectory(const DirName: string); @@ -88,14 +79,14 @@ procedure DeleteDirectory(const DirName: string); begin FillChar(FileOp, SizeOf(FileOp), 0); FileOp.wFunc := FO_DELETE; - FileOp.pFrom := PChar(DirName+#0); + FileOp.pFrom := pchar(DirName + #0); FileOp.fFlags := FOF_SILENT or FOF_NOERRORUI or FOF_NOCONFIRMATION; SHFileOperation(FileOp); end; procedure TBossPackageProcessor.MakeLink(AProjectPath, AEnv: string); var - LCommand: PChar; + LCommand: pchar; LFile: string; begin try @@ -106,9 +97,8 @@ procedure TBossPackageProcessor.MakeLink(AProjectPath, AEnv: string); for LFile in TDirectory.GetFiles(AProjectPath + TPath.DirectorySeparatorChar + C_MODULES_FOLDER + '.' + AEnv) do begin - TFile.Copy(LFile, TPath.Combine(GetEnv(AEnv), TPath.GetFileName(LFile)), True); + TFile.Copy(LFile, TPath.Combine(GetEnv(AEnv), TPath.GetFileName(LFile)), true); end; - except on E: Exception do TProviderMessage.GetInstance.WriteLn('Failed on make link: ' + E.Message); @@ -126,7 +116,7 @@ constructor TBossPackageProcessor.Create; if not FDataFile.Values[BPLS].IsEmpty then begin - FDataFile.Delimiter := ';'; + FDataFile.DELIMITER := ';'; FDataFile.DelimitedText := FDataFile.Values[BPLS]; end; @@ -151,11 +141,10 @@ function TBossPackageProcessor.GetBplList: TStringDynArray; LIndex: Integer; I: Integer; begin - Result := Nil; + Result := nil; if not DirectoryExists(GetEnv(C_ENV_BPL)) then Exit(); - LOrderFileName := GetEnv(C_ENV_BPL) + TPath.DirectorySeparatorChar + C_BPL_ORDER; if FileExists(LOrderFileName) then begin @@ -178,8 +167,7 @@ function TBossPackageProcessor.GetBplList: TStringDynArray; function TBossPackageProcessor.GetDataCachePath: string; begin - Result := FHomeDrive + FHomePath + TPath.DirectorySeparatorChar + - C_BOSS_CACHE_FOLDER + TPath.DirectorySeparatorChar + C_DATA_FILE; + Result := FHomeDrive + FHomePath + TPath.DirectorySeparatorChar + C_BOSS_CACHE_FOLDER + TPath.DirectorySeparatorChar + C_DATA_FILE; end; class function TBossPackageProcessor.GetInstance: TBossPackageProcessor; @@ -223,7 +211,7 @@ procedure TBossPackageProcessor.DoLoadBpls(ABpls: TStringDynArray); on E: Exception do begin TProviderMessage.GetInstance.WriteLn('Failed to get info of ' + LBpl); - TProviderMessage.GetInstance.WriteLn(#10 + E.message); + TProviderMessage.GetInstance.WriteLn(#10 + E.Message); LBplsRedo := LBplsRedo + [LBpl]; Continue; end; @@ -235,13 +223,13 @@ procedure TBossPackageProcessor.DoLoadBpls(ABpls: TStringDynArray); begin TProviderMessage.GetInstance.WriteLn('Instaled: ' + LBpl); FDataFile.Add(LBpl); - LInstalledNew := True; + LInstalledNew := true; end else LBplsRedo := LBplsRedo + [LBpl]; end; end; - + SaveData; if LInstalledNew then @@ -291,7 +279,7 @@ class procedure TBossPackageProcessor.OnActiveProjectChanged(AProject: string); end; procedure TBossPackageProcessor.SaveData; -begin +begin FDataFile.SaveToFile(GetDataCachePath); end; @@ -309,9 +297,9 @@ procedure TBossPackageProcessor.UnloadOlds; Application.ProcessMessages; end; - FDataFile.Clear; + FDataFile.Clear; SaveData; - + LMenu := NativeServices.MainMenu.Items.Find('Tools'); NativeServices.MenuBeginUpdate; @@ -333,7 +321,6 @@ procedure TBossPackageProcessor.UnloadOlds; initialization finalization - -_Instance.Free; + _Instance.Free; end. diff --git a/src/core/wrapper/Boss.Commands.pas b/src/core/wrapper/Boss.Commands.pas index 13dd533..aefdc94 100644 --- a/src/core/wrapper/Boss.Commands.pas +++ b/src/core/wrapper/Boss.Commands.pas @@ -2,17 +2,14 @@ interface -uses - Vcl.StdCtrls; +uses Vcl.StdCtrls; procedure Runner(ACommand, APath: string; ALoadPackages: Boolean); - procedure RunBossInstall(APath: string; ALoadPackages: Boolean); implementation -uses - Winapi.Windows, Vcl.Forms, System.SysUtils, System.Classes, System.Threading, Providers.Message, +uses Winapi.Windows, Vcl.Forms, System.SysUtils, System.Classes, System.Threading, Providers.Message, Boss.Modules.PackageProcessor, DosCommand; procedure RunBossInstall(APath: string; ALoadPackages: Boolean); @@ -25,12 +22,14 @@ procedure Runner(ACommand, APath: string; ALoadPackages: Boolean); LDosCommand: TDosCommand; begin LDosCommand := TDosCommand.Create(nil); - LDosCommand.OnNewLine := procedure(ASender: TObject; const ANewLine: string; AOutputType: TOutputType) + LDosCommand.OnNewLine := + procedure(ASender: TObject; const ANewLine: string; AOutputType: TOutputType) begin TProviderMessage.GetInstance.WriteLn(ANewLine); end; - LDosCommand.OnTerminated := procedure(ASender: TObject) + LDosCommand.OnTerminated := + procedure(ASender: TObject) begin LDosCommand.Free; if ALoadPackages then @@ -43,7 +42,6 @@ procedure Runner(ACommand, APath: string; ALoadPackages: Boolean); LDosCommand.CurrentDir := APath; LDosCommand.CommandLine := ACommand; LDosCommand.Execute; - end; end. diff --git a/src/thrid/Boss.Ide.CnCommon.lite.pas b/src/thrid/Boss.Ide.CnCommon.lite.pas index 08c7fc2..85b8383 100644 --- a/src/thrid/Boss.Ide.CnCommon.lite.pas +++ b/src/thrid/Boss.Ide.CnCommon.lite.pas @@ -2,8 +2,7 @@ interface -uses - System.Classes; +uses System.Classes; function _CnExtractFileDir(const FileName: string): string; function _CnExtractFilePath(const FileName: string): string; @@ -19,8 +18,7 @@ function AddDirSuffix(const Dir: string): string; implementation -uses - System.SysUtils, Winapi.Windows; +uses System.SysUtils, Winapi.Windows; procedure MultiSzToStrings(const Dest: TStrings; const Source: PChar); var @@ -83,7 +81,8 @@ function _CnExtractFileExt(const FileName: string): string; begin I := LastDelimiter('.' + PathDelim + DriveDelim, FileName); if (I > 0) and (FileName[I] = '.') then - Result := Copy(FileName, I, MaxInt) else + Result := Copy(FileName, I, MaxInt) + else Result := ''; end; {$ELSE} @@ -156,6 +155,7 @@ function LinkPath(const Head, Tail: string): string; TailHasRoot := (AnsiPos(':\', Tail) = 2) or // C:\Test (AnsiPos('\\', Tail) = 1) or // \\Name\C\Test (AnsiPos('://', Tail) > 0); // ftp://ftp.abc.com + if TailHasRoot then begin Result := Tail; @@ -180,7 +180,8 @@ function LinkPath(const Head, Tail: string): string; Result := Copy(AHead, 1, i + 1) + ATail else Result := AHead + ATail; - end else if HeadIsUrl then + end + else if HeadIsUrl then begin S := Copy(AHead, UrlPos + 3, MaxInt); i := AnsiPos('\', S); @@ -217,7 +218,8 @@ function LinkPath(const Head, Tail: string): string; function MakeDir(const Path: string): string; begin Result := Trim(Path); - if Result = '' then Exit; + if Result = '' then + Exit; if CharInSet(Result[Length(Result)], ['/', '\']) then Delete(Result, Length(Result), 1); end; @@ -230,7 +232,8 @@ function MakePath(const Dir: string): string; function AddDirSuffix(const Dir: string): string; begin Result := Trim(Dir); - if Result = '' then Exit; + if Result = '' then + Exit; if not IsPathDelimiter(Result, Length(Result)) then Result := Result + {$IFDEF MSWINDOWS} '\'; {$ELSE} '/'; {$ENDIF}; end;