mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 11:00:01 +01:00 
			
		
		
		
	IDE: Installpkgsetdlg dialog: Display online packages when OPM is installed.
git-svn-id: trunk@56778 -
This commit is contained in:
		
							parent
							
								
									e0045baeb8
								
							
						
					
					
						commit
						31b7c27181
					
				@ -63,8 +63,11 @@ type
 | 
				
			|||||||
    FPackageType: TLazPackageType;
 | 
					    FPackageType: TLazPackageType;
 | 
				
			||||||
    FOrigin: TPkgLinkOrigin;
 | 
					    FOrigin: TPkgLinkOrigin;
 | 
				
			||||||
    FLastUsed: TDateTime;
 | 
					    FLastUsed: TDateTime;
 | 
				
			||||||
    FOPMFileName: String;
 | 
					    FOPMFileName: string;
 | 
				
			||||||
    FOPMFileDate: TDateTime;
 | 
					    FOPMFileDate: TDateTime;
 | 
				
			||||||
 | 
					    FAuthor: string;
 | 
				
			||||||
 | 
					    FDescription: string;
 | 
				
			||||||
 | 
					    FLicense: string;
 | 
				
			||||||
  public
 | 
					  public
 | 
				
			||||||
    constructor Create; override;
 | 
					    constructor Create; override;
 | 
				
			||||||
    destructor Destroy; override;
 | 
					    destructor Destroy; override;
 | 
				
			||||||
@ -80,11 +83,14 @@ type
 | 
				
			|||||||
    property LPKUrl: string read FURL write FURL;
 | 
					    property LPKUrl: string read FURL write FURL;
 | 
				
			||||||
    property LPLFilename: string read FLPLFilename write FLPLFilename;
 | 
					    property LPLFilename: string read FLPLFilename write FLPLFilename;
 | 
				
			||||||
    property LPLFileDate: TDateTime read FLPLFileDate write FLPLFileDate;
 | 
					    property LPLFileDate: TDateTime read FLPLFileDate write FLPLFileDate;
 | 
				
			||||||
    property PackageType: TLazPackageType read FPackageType;
 | 
					    property PackageType: TLazPackageType read FPackageType write FPackageType;
 | 
				
			||||||
    property Origin: TPkgLinkOrigin read FOrigin write FOrigin;
 | 
					    property Origin: TPkgLinkOrigin read FOrigin write FOrigin;
 | 
				
			||||||
    property LastUsed: TDateTime read FLastUsed write FLastUsed;
 | 
					    property LastUsed: TDateTime read FLastUsed write FLastUsed;
 | 
				
			||||||
    property OPMFileName: string read FOPMFileName write FOPMFileName;
 | 
					    property OPMFileName: string read FOPMFileName write FOPMFileName;
 | 
				
			||||||
    property OPMFileDate: TDateTime read FOPMFileDate write FOPMFileDate;
 | 
					    property OPMFileDate: TDateTime read FOPMFileDate write FOPMFileDate;
 | 
				
			||||||
 | 
					    property Author: string read FAuthor write FAuthor;
 | 
				
			||||||
 | 
					    property Description: string read FDescription write FDescription;
 | 
				
			||||||
 | 
					    property License: string read FLicense write FLicense;
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  { TPackageLinks }
 | 
					  { TPackageLinks }
 | 
				
			||||||
@ -105,6 +111,7 @@ type
 | 
				
			|||||||
    procedure RemoveUserLink(Link: TPackageLink); virtual; abstract;
 | 
					    procedure RemoveUserLink(Link: TPackageLink); virtual; abstract;
 | 
				
			||||||
    procedure RemoveUserLinks(APackageID: TLazPackageID); virtual; abstract;
 | 
					    procedure RemoveUserLinks(APackageID: TLazPackageID); virtual; abstract;
 | 
				
			||||||
    procedure ClearOnlineLinks; virtual; abstract;
 | 
					    procedure ClearOnlineLinks; virtual; abstract;
 | 
				
			||||||
 | 
					    procedure SaveUserLinks(Immediately: boolean = false); virtual; abstract;
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  { TOPMInterface }
 | 
					  { TOPMInterface }
 | 
				
			||||||
@ -114,7 +121,10 @@ type
 | 
				
			|||||||
    FPackageListAvailable: TNotifyEvent;
 | 
					    FPackageListAvailable: TNotifyEvent;
 | 
				
			||||||
  public
 | 
					  public
 | 
				
			||||||
    {confirmation/install/extract/download dialogs will be displayed in the center of WorkArea}
 | 
					    {confirmation/install/extract/download dialogs will be displayed in the center of WorkArea}
 | 
				
			||||||
 | 
					    function DownloadPackages(APkgLinks: TList): TModalResult; virtual; abstract;
 | 
				
			||||||
    function InstallPackages(APkgLinks: TList; var ANeedToRebuild: Boolean): TModalResult; virtual; abstract;
 | 
					    function InstallPackages(APkgLinks: TList; var ANeedToRebuild: Boolean): TModalResult; virtual; abstract;
 | 
				
			||||||
 | 
					    function IsPackageAvailable(APkgLink: TPackageLink; AType: Integer): Boolean; virtual; abstract;
 | 
				
			||||||
 | 
					    function FindOnlineLink(const AName: String): TPackageLink; virtual; abstract;
 | 
				
			||||||
    property OnPackageListAvailable: TNotifyEvent read FPackageListAvailable write FPackageListAvailable;
 | 
					    property OnPackageListAvailable: TNotifyEvent read FPackageListAvailable write FPackageListAvailable;
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3576,6 +3576,9 @@ resourcestring
 | 
				
			|||||||
  lisThePackageIsAlreadyInTheList = 'The package %s is already in the list';
 | 
					  lisThePackageIsAlreadyInTheList = 'The package %s is already in the list';
 | 
				
			||||||
  lisConflict = 'Conflict';
 | 
					  lisConflict = 'Conflict';
 | 
				
			||||||
  lisThereIsAlreadyAPackageInTheList = 'There is already a package %s in the list';
 | 
					  lisThereIsAlreadyAPackageInTheList = 'There is already a package %s in the list';
 | 
				
			||||||
 | 
					  lisDownload = 'Download';
 | 
				
			||||||
 | 
					  lisDonwloadOnlinePackages = 'The following package(s) are not available locally:  %s .' + sLineBreak +
 | 
				
			||||||
 | 
					    'In order to install it, you must download them first. Download now?';
 | 
				
			||||||
  lisNotADesigntimePackage = 'Not a designtime package';
 | 
					  lisNotADesigntimePackage = 'Not a designtime package';
 | 
				
			||||||
  lisThePackageCanNotBeInstalledBecauseItRequiresWhichI = 'The package %s cannot be '
 | 
					  lisThePackageCanNotBeInstalledBecauseItRequiresWhichI = 'The package %s cannot be '
 | 
				
			||||||
    +'installed, because it requires the package "%s", which is a runtime only package.';
 | 
					    +'installed, because it requires the package "%s", which is a runtime only package.';
 | 
				
			||||||
@ -4307,7 +4310,7 @@ resourcestring
 | 
				
			|||||||
  lisPkgMangTheFollowingPackagesFailedToLoad = 'The following packages failed to load:';
 | 
					  lisPkgMangTheFollowingPackagesFailedToLoad = 'The following packages failed to load:';
 | 
				
			||||||
  lisMissingPackages = 'Missing Packages';
 | 
					  lisMissingPackages = 'Missing Packages';
 | 
				
			||||||
  lisNotInstalledPackages = 'Not installed packages';
 | 
					  lisNotInstalledPackages = 'Not installed packages';
 | 
				
			||||||
  lisInstallPackagesMsg = 'The following packages are not installed, but available online: %s.' +
 | 
					  lisInstallPackagesMsg = 'The following packages are not installed, but available in the main repository: %s.' +
 | 
				
			||||||
    sLineBreak + 'Do you wish to install missing packages?';
 | 
					    sLineBreak + 'Do you wish to install missing packages?';
 | 
				
			||||||
  lisOtherSourcesPathOfPackageContainsDirectoryWhichIsA = 'other sources path '
 | 
					  lisOtherSourcesPathOfPackageContainsDirectoryWhichIsA = 'other sources path '
 | 
				
			||||||
    +'of package "%s" contains directory "%s", which is already in the unit '
 | 
					    +'of package "%s" contains directory "%s", which is already in the unit '
 | 
				
			||||||
@ -4537,6 +4540,7 @@ resourcestring
 | 
				
			|||||||
  lisSelectedForUninstallation = 'selected for uninstallation';
 | 
					  lisSelectedForUninstallation = 'selected for uninstallation';
 | 
				
			||||||
  lisInstalled = 'installed';
 | 
					  lisInstalled = 'installed';
 | 
				
			||||||
  lisNotInstalled = 'not installed';
 | 
					  lisNotInstalled = 'not installed';
 | 
				
			||||||
 | 
					  lisOnlinePackage = 'available in the main repository';
 | 
				
			||||||
  lisOIPThisPackageIsInstalledButTheLpkFileWasNotFound = '%sThis package is '
 | 
					  lisOIPThisPackageIsInstalledButTheLpkFileWasNotFound = '%sThis package is '
 | 
				
			||||||
    +'installed, but the lpk file was not found';
 | 
					    +'installed, but the lpk file was not found';
 | 
				
			||||||
  lisOIPDescriptionDescription = '%sDescription:  %s';
 | 
					  lisOIPDescriptionDescription = '%sDescription:  %s';
 | 
				
			||||||
 | 
				
			|||||||
@ -48,9 +48,9 @@ uses
 | 
				
			|||||||
  // LazUtils
 | 
					  // LazUtils
 | 
				
			||||||
  LazFileUtils, Laz2_XMLCfg,
 | 
					  LazFileUtils, Laz2_XMLCfg,
 | 
				
			||||||
  // IdeIntf
 | 
					  // IdeIntf
 | 
				
			||||||
  PackageDependencyIntf, PackageIntf, IDEImagesIntf, IDEHelpIntf, IDEDialogs, IDEWindowIntf,
 | 
					  PackageDependencyIntf, PackageIntf, IDEImagesIntf, IDEHelpIntf, IDEDialogs, IDEWindowIntf, PackageLinkIntf,
 | 
				
			||||||
  // IDE
 | 
					  // IDE
 | 
				
			||||||
  LazarusIDEStrConsts, InputHistory, LazConf, PackageDefs, PackageSystem, LPKCache;
 | 
					  LazarusIDEStrConsts, InputHistory, LazConf, PackageDefs, PackageSystem, LPKCache, PackageLinks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type
 | 
					type
 | 
				
			||||||
  TOnCheckInstallPackageList =
 | 
					  TOnCheckInstallPackageList =
 | 
				
			||||||
@ -120,6 +120,7 @@ type
 | 
				
			|||||||
    ImgIndexUninstallPackage: integer;
 | 
					    ImgIndexUninstallPackage: integer;
 | 
				
			||||||
    ImgIndexCirclePackage: integer;
 | 
					    ImgIndexCirclePackage: integer;
 | 
				
			||||||
    ImgIndexMissingPackage: integer;
 | 
					    ImgIndexMissingPackage: integer;
 | 
				
			||||||
 | 
					    ImgIndexAvailableOnline: integer;
 | 
				
			||||||
    ImgIndexOverlayUnknown: integer;
 | 
					    ImgIndexOverlayUnknown: integer;
 | 
				
			||||||
    ImgIndexOverlayBasePackage: integer;
 | 
					    ImgIndexOverlayBasePackage: integer;
 | 
				
			||||||
    ImgIndexOverlayFPCPackage: integer;
 | 
					    ImgIndexOverlayFPCPackage: integer;
 | 
				
			||||||
@ -130,7 +131,8 @@ type
 | 
				
			|||||||
    procedure SetOldInstalledPackages(const AValue: TPkgDependency);
 | 
					    procedure SetOldInstalledPackages(const AValue: TPkgDependency);
 | 
				
			||||||
    procedure AssignOldInstalledPackagesToList;
 | 
					    procedure AssignOldInstalledPackagesToList;
 | 
				
			||||||
    function PackageInInstallList(PkgName: string): boolean;
 | 
					    function PackageInInstallList(PkgName: string): boolean;
 | 
				
			||||||
    function GetPkgImgIndex(Installed: TPackageInstallType; InInstallList: boolean): integer;
 | 
					    function GetPkgImgIndex(Installed: TPackageInstallType; InInstallList,
 | 
				
			||||||
 | 
					      IsOnline: boolean): integer;
 | 
				
			||||||
    procedure UpdateAvailablePackages(Immediately: boolean = false);
 | 
					    procedure UpdateAvailablePackages(Immediately: boolean = false);
 | 
				
			||||||
    procedure UpdateNewInstalledPackages;
 | 
					    procedure UpdateNewInstalledPackages;
 | 
				
			||||||
    function DependencyToStr(Dependency: TPkgDependency): string;
 | 
					    function DependencyToStr(Dependency: TPkgDependency): string;
 | 
				
			||||||
@ -148,6 +150,7 @@ type
 | 
				
			|||||||
    procedure AddToUninstall;
 | 
					    procedure AddToUninstall;
 | 
				
			||||||
    procedure PkgInfosChanged;
 | 
					    procedure PkgInfosChanged;
 | 
				
			||||||
    procedure ChangePkgVersion(PkgInfo: TLPKInfo; NewVersion: TPkgVersion);
 | 
					    procedure ChangePkgVersion(PkgInfo: TLPKInfo; NewVersion: TPkgVersion);
 | 
				
			||||||
 | 
					    function FindOnlinePackageLink(const AName: String): TPackageLink;
 | 
				
			||||||
  public
 | 
					  public
 | 
				
			||||||
    function GetNewInstalledPackages: TObjectList;
 | 
					    function GetNewInstalledPackages: TObjectList;
 | 
				
			||||||
    property OldInstalledPackages: TPkgDependency read FOldInstalledPackages
 | 
					    property OldInstalledPackages: TPkgDependency read FOldInstalledPackages
 | 
				
			||||||
@ -203,6 +206,7 @@ begin
 | 
				
			|||||||
  ImgIndexUninstallPackage := IDEImages.LoadImage('pkg_package_uninstall');
 | 
					  ImgIndexUninstallPackage := IDEImages.LoadImage('pkg_package_uninstall');
 | 
				
			||||||
  ImgIndexCirclePackage := IDEImages.LoadImage('pkg_package_circle');
 | 
					  ImgIndexCirclePackage := IDEImages.LoadImage('pkg_package_circle');
 | 
				
			||||||
  ImgIndexMissingPackage := IDEImages.LoadImage('pkg_conflict');
 | 
					  ImgIndexMissingPackage := IDEImages.LoadImage('pkg_conflict');
 | 
				
			||||||
 | 
					  ImgIndexAvailableOnline := IDEImages.LoadImage('pkg_install');
 | 
				
			||||||
  ImgIndexOverlayUnknown := IDEImages.LoadImage('state_unknown');
 | 
					  ImgIndexOverlayUnknown := IDEImages.LoadImage('state_unknown');
 | 
				
			||||||
  ImgIndexOverlayBasePackage := IDEImages.LoadImage('pkg_core_overlay');
 | 
					  ImgIndexOverlayBasePackage := IDEImages.LoadImage('pkg_core_overlay');
 | 
				
			||||||
  ImgIndexOverlayFPCPackage := IDEImages.LoadImage('pkg_fpc_overlay');
 | 
					  ImgIndexOverlayFPCPackage := IDEImages.LoadImage('pkg_fpc_overlay');
 | 
				
			||||||
@ -381,6 +385,7 @@ var
 | 
				
			|||||||
  PkgName: String;
 | 
					  PkgName: String;
 | 
				
			||||||
  ImgIndex: Integer;
 | 
					  ImgIndex: Integer;
 | 
				
			||||||
  Unknown: Boolean;
 | 
					  Unknown: Boolean;
 | 
				
			||||||
 | 
					  PackageLink: TPackageLink;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  Tree:=Sender as TTreeView;
 | 
					  Tree:=Sender as TTreeView;
 | 
				
			||||||
  if Stage=cdPostPaint then begin
 | 
					  if Stage=cdPostPaint then begin
 | 
				
			||||||
@ -397,6 +402,10 @@ begin
 | 
				
			|||||||
    finally
 | 
					    finally
 | 
				
			||||||
      LPKInfoCache.LeaveCritSection;
 | 
					      LPKInfoCache.LeaveCritSection;
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
 | 
					    if Sender = InstallTreeView then
 | 
				
			||||||
 | 
					      PackageLink := nil
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      PackageLink := FindOnlinePackageLink(Info.ID.Name);
 | 
				
			||||||
    Images:=Tree.Images;
 | 
					    Images:=Tree.Images;
 | 
				
			||||||
    CurCanvas:=Tree.Canvas;
 | 
					    CurCanvas:=Tree.Canvas;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -404,7 +413,7 @@ begin
 | 
				
			|||||||
    x:=Node.DisplayIconLeft+1;
 | 
					    x:=Node.DisplayIconLeft+1;
 | 
				
			||||||
    y:=(NodeRect.Top+NodeRect.Bottom-Images.Height) div 2;
 | 
					    y:=(NodeRect.Top+NodeRect.Bottom-Images.Height) div 2;
 | 
				
			||||||
    // draw image
 | 
					    // draw image
 | 
				
			||||||
    ImgIndex:=GetPkgImgIndex(Installed,PackageInInstallList(PkgName));
 | 
					    ImgIndex:=GetPkgImgIndex(Installed,PackageInInstallList(PkgName), PackageLink <> nil);
 | 
				
			||||||
    Images.Draw(CurCanvas,x,y,ImgIndex);
 | 
					    Images.Draw(CurCanvas,x,y,ImgIndex);
 | 
				
			||||||
    // draw overlays
 | 
					    // draw overlays
 | 
				
			||||||
    if InLazSrc then
 | 
					    if InLazSrc then
 | 
				
			||||||
@ -513,7 +522,7 @@ begin
 | 
				
			|||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function TInstallPkgSetDialog.GetPkgImgIndex(Installed: TPackageInstallType;
 | 
					function TInstallPkgSetDialog.GetPkgImgIndex(Installed: TPackageInstallType;
 | 
				
			||||||
  InInstallList: boolean): integer;
 | 
					  InInstallList, IsOnline: boolean): integer;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  if Installed<>pitNope then begin
 | 
					  if Installed<>pitNope then begin
 | 
				
			||||||
    // is not currently installed
 | 
					    // is not currently installed
 | 
				
			||||||
@ -533,11 +542,33 @@ begin
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
    else begin
 | 
					    else begin
 | 
				
			||||||
      // is not installed and will be not be installed
 | 
					      // is not installed and will be not be installed
 | 
				
			||||||
 | 
					      if IsOnline then
 | 
				
			||||||
 | 
					        Result := ImgIndexAvailableOnline
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
        Result:=ImgIndexPackage;
 | 
					        Result:=ImgIndexPackage;
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function TInstallPkgSetDialog.FindOnlinePackageLink(const AName: String): TPackageLink;
 | 
				
			||||||
 | 
					var
 | 
				
			||||||
 | 
					  PackageLink: TPackageLink;
 | 
				
			||||||
 | 
					  PkgName: String;
 | 
				
			||||||
 | 
					  P: Integer;
 | 
				
			||||||
 | 
					begin
 | 
				
			||||||
 | 
					  Result := nil;
 | 
				
			||||||
 | 
					  if OPMInterface = nil then
 | 
				
			||||||
 | 
					    Exit;
 | 
				
			||||||
 | 
					  PkgName := Trim(AName);
 | 
				
			||||||
 | 
					  P := Pos(' ', PkgName);
 | 
				
			||||||
 | 
					  if P > 0 then
 | 
				
			||||||
 | 
					    PkgName := Copy(PkgName, 1, P - 1);
 | 
				
			||||||
 | 
					  PackageLink := OPMInterface.FindOnlineLink(PkgName);
 | 
				
			||||||
 | 
					  if PackageLink <> nil then
 | 
				
			||||||
 | 
					    Result := PackageLink;
 | 
				
			||||||
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TInstallPkgSetDialog.UpdateAvailablePackages(Immediately: boolean);
 | 
					procedure TInstallPkgSetDialog.UpdateAvailablePackages(Immediately: boolean);
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  ANode: TAvlTreeNode;
 | 
					  ANode: TAvlTreeNode;
 | 
				
			||||||
@ -545,6 +576,7 @@ var
 | 
				
			|||||||
  Info: TLPKInfo;
 | 
					  Info: TLPKInfo;
 | 
				
			||||||
  List: TStringList;
 | 
					  List: TStringList;
 | 
				
			||||||
  i: Integer;
 | 
					  i: Integer;
 | 
				
			||||||
 | 
					  PackageLink: TPackageLink;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  if not Immediately then begin
 | 
					  if not Immediately then begin
 | 
				
			||||||
    fAvailablePkgsNeedUpdate:=true;
 | 
					    fAvailablePkgsNeedUpdate:=true;
 | 
				
			||||||
@ -561,6 +593,15 @@ begin
 | 
				
			|||||||
      while ANode<>nil do begin
 | 
					      while ANode<>nil do begin
 | 
				
			||||||
        Info:=TLPKInfo(ANode.Data);
 | 
					        Info:=TLPKInfo(ANode.Data);
 | 
				
			||||||
        ANode:=LPKInfoCache.LPKByID.FindSuccessor(ANode);
 | 
					        ANode:=LPKInfoCache.LPKByID.FindSuccessor(ANode);
 | 
				
			||||||
 | 
					        PackageLink := FindOnlinePackageLink(Info.ID.Name);
 | 
				
			||||||
 | 
					        if (PackageLink <> nil) and (PackageLink.PackageType in [lptDesignTime,lptRunAndDesignTime]) then begin
 | 
				
			||||||
 | 
					          if (not PackageInInstallList(Info.ID.Name)) then begin
 | 
				
			||||||
 | 
					            Info.PkgType := PackageLink.PackageType;
 | 
				
			||||||
 | 
					            Info.ID.Version.Assign(PackageLink.Version);
 | 
				
			||||||
 | 
					            List.Add(Info.ID.IDAsString);
 | 
				
			||||||
 | 
					            Continue;
 | 
				
			||||||
 | 
					          end;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
        if Info.LPKParsed=lpkiParsedError then continue;
 | 
					        if Info.LPKParsed=lpkiParsedError then continue;
 | 
				
			||||||
        if (Info.LPKParsed in [lpkiNotParsed,lpkiParsing])
 | 
					        if (Info.LPKParsed in [lpkiNotParsed,lpkiParsing])
 | 
				
			||||||
        or (Info.PkgType in [lptDesignTime,lptRunAndDesignTime])
 | 
					        or (Info.PkgType in [lptDesignTime,lptRunAndDesignTime])
 | 
				
			||||||
@ -704,13 +745,18 @@ var
 | 
				
			|||||||
var
 | 
					var
 | 
				
			||||||
  PkgID: String;
 | 
					  PkgID: String;
 | 
				
			||||||
  Info: TLPKInfo;
 | 
					  Info: TLPKInfo;
 | 
				
			||||||
 | 
					  PackageLink: TPackageLink;
 | 
				
			||||||
 | 
					  Author, Description, License: String;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  if Tree = nil then Exit;
 | 
					  if Tree = nil then Exit;
 | 
				
			||||||
  PkgID := '';
 | 
					  PkgID := '';
 | 
				
			||||||
  if Tree.Selected <> nil then
 | 
					  if Tree.Selected <> nil then
 | 
				
			||||||
    PkgID := Tree.Selected.Text;
 | 
					    PkgID := Tree.Selected.Text;
 | 
				
			||||||
  if PkgID = '' then Exit;
 | 
					  if PkgID = '' then Exit;
 | 
				
			||||||
 | 
					  if Tree = InstallTreeView then
 | 
				
			||||||
 | 
					    PackageLink := nil
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    PackageLink := FindOnlinePackageLink(PkgID);
 | 
				
			||||||
  LPKInfoCache.EnterCritSection;
 | 
					  LPKInfoCache.EnterCritSection;
 | 
				
			||||||
  try
 | 
					  try
 | 
				
			||||||
    Info:=LPKInfoCache.FindPkgInfoWithIDAsString(PkgID);
 | 
					    Info:=LPKInfoCache.FindPkgInfoWithIDAsString(PkgID);
 | 
				
			||||||
@ -735,13 +781,26 @@ begin
 | 
				
			|||||||
      end;
 | 
					      end;
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if Info.Author<>'' then
 | 
					    if PackageLink = nil then
 | 
				
			||||||
      PkgInfoMemo.Lines.Add(lisPckOptsAuthor + ': ' + Info.Author);
 | 
					    begin
 | 
				
			||||||
    if Info.Description<>'' then
 | 
					      Author := Info.Author;
 | 
				
			||||||
      PkgInfoMemo.Lines.Add(lisPckOptsDescriptionAbstract
 | 
					      Description := Info.Description;
 | 
				
			||||||
                            + ': ' + Info.Description);
 | 
					      License := Info.License;
 | 
				
			||||||
    if Info.License<>'' then
 | 
					    end
 | 
				
			||||||
      PkgInfoMemo.Lines.Add(lisPckOptsLicense + ': ' + Info.License);
 | 
					    else
 | 
				
			||||||
 | 
					    begin
 | 
				
			||||||
 | 
					      Author := PackageLink.Author;
 | 
				
			||||||
 | 
					      Description := PackageLink.Description;
 | 
				
			||||||
 | 
					      License := PackageLink.License;
 | 
				
			||||||
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if Author<>'' then
 | 
				
			||||||
 | 
					      PkgInfoMemo.Lines.Add(lisPckOptsAuthor + ': ' + Author);
 | 
				
			||||||
 | 
					    if Description<>'' then
 | 
				
			||||||
 | 
					      PkgInfoMemo.Lines.Add(lisPckOptsDescriptionAbstract + ': ' + Description);
 | 
				
			||||||
 | 
					    if License<>'' then
 | 
				
			||||||
 | 
					      PkgInfoMemo.Lines.Add(lisPckOptsLicense + ': ' + License);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PkgInfoMemo.Lines.Add(Format(lisOIPFilename, [Info.LPKFilename]));
 | 
					    PkgInfoMemo.Lines.Add(Format(lisOIPFilename, [Info.LPKFilename]));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    InfoStr:=lisCurrentState;
 | 
					    InfoStr:=lisCurrentState;
 | 
				
			||||||
@ -756,6 +815,8 @@ begin
 | 
				
			|||||||
      if PackageInInstallList(Info.ID.Name)=true then
 | 
					      if PackageInInstallList(Info.ID.Name)=true then
 | 
				
			||||||
        AddState(lisSelectedForInstallation);
 | 
					        AddState(lisSelectedForInstallation);
 | 
				
			||||||
      AddState(lisNotInstalled);
 | 
					      AddState(lisNotInstalled);
 | 
				
			||||||
 | 
					      if PackageLink <> nil then
 | 
				
			||||||
 | 
					        AddState(lisOnlinePackage);
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
    if Info.Base then
 | 
					    if Info.Base then
 | 
				
			||||||
      AddState(lisPckExplBase);
 | 
					      AddState(lisPckExplBase);
 | 
				
			||||||
@ -954,11 +1015,15 @@ var
 | 
				
			|||||||
  TVNode: TTreeNode;
 | 
					  TVNode: TTreeNode;
 | 
				
			||||||
  PkgName: String;
 | 
					  PkgName: String;
 | 
				
			||||||
  FilteredBranch: TTreeFilterBranch;
 | 
					  FilteredBranch: TTreeFilterBranch;
 | 
				
			||||||
 | 
					  PkgLinks: TList;
 | 
				
			||||||
 | 
					  PkgLinksStr: String;
 | 
				
			||||||
 | 
					  PkgLink: TPackageLink;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  NewSelectedIndex:=-1;
 | 
					  NewSelectedIndex:=-1;
 | 
				
			||||||
  LastNonSelectedIndex:=-1;
 | 
					  LastNonSelectedIndex:=-1;
 | 
				
			||||||
  Additions:=TObjectList.Create(false);
 | 
					  Additions:=TObjectList.Create(false);
 | 
				
			||||||
  AddedPkgNames:=TStringList.Create;
 | 
					  AddedPkgNames:=TStringList.Create;
 | 
				
			||||||
 | 
					  PkgLinks := TList.Create;
 | 
				
			||||||
  NewPackageID:=TLazPackageID.Create;
 | 
					  NewPackageID:=TLazPackageID.Create;
 | 
				
			||||||
  FilteredBranch := AvailableFilterEdit.GetExistingBranch(Nil); // All items are top level.
 | 
					  FilteredBranch := AvailableFilterEdit.GetExistingBranch(Nil); // All items are top level.
 | 
				
			||||||
  try
 | 
					  try
 | 
				
			||||||
@ -982,10 +1047,54 @@ begin
 | 
				
			|||||||
        exit;
 | 
					        exit;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
      // ok => add to list
 | 
					      // ok => add to list
 | 
				
			||||||
 | 
					      PkgLink := FindOnlinePackageLink(NewPackageID.Name);
 | 
				
			||||||
 | 
					      if PkgLink <> nil then begin
 | 
				
			||||||
 | 
					        if not FileExists(PkgLink.OPMFileName) then
 | 
				
			||||||
 | 
					          PkgLinks.Add(PkgLink)
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        begin
 | 
				
			||||||
 | 
					          PkgLink := LazPackageLinks.AddUserLink(PkgLink.OPMFileName, PkgLink.Name);
 | 
				
			||||||
 | 
					          if PkgLink <> nil then
 | 
				
			||||||
 | 
					            LazPackageLinks.SaveUserLinks;
 | 
				
			||||||
          Additions.Add(NewPackageID);
 | 
					          Additions.Add(NewPackageID);
 | 
				
			||||||
          NewPackageID:=TLazPackageID.Create;
 | 
					          NewPackageID:=TLazPackageID.Create;
 | 
				
			||||||
          AddedPkgNames.Add(PkgName);
 | 
					          AddedPkgNames.Add(PkgName);
 | 
				
			||||||
        end;
 | 
					        end;
 | 
				
			||||||
 | 
					      end else begin
 | 
				
			||||||
 | 
					        Additions.Add(NewPackageID);
 | 
				
			||||||
 | 
					        NewPackageID:=TLazPackageID.Create;
 | 
				
			||||||
 | 
					        AddedPkgNames.Add(PkgName);
 | 
				
			||||||
 | 
					      end;
 | 
				
			||||||
 | 
					    end;
 | 
				
			||||||
 | 
					    //download online packages
 | 
				
			||||||
 | 
					    if (OPMInterface <> nil) and (PkgLinks.Count > 0) then
 | 
				
			||||||
 | 
					    begin
 | 
				
			||||||
 | 
					      PkgLinksStr := '';
 | 
				
			||||||
 | 
					      for I := 0 to PkgLinks.Count - 1 do begin
 | 
				
			||||||
 | 
					        if PkgLinksStr = '' then
 | 
				
			||||||
 | 
					          PkgLinksStr := '"' + TPackageLink(PkgLinks.Items[I]).Name + '"'
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          PkgLinksStr := PkgLinksStr + ', ' + '"' + TPackageLink(PkgLinks.Items[I]).Name + '"';
 | 
				
			||||||
 | 
					      end;
 | 
				
			||||||
 | 
					      if IDEMessageDialog(lisDownload, Format(lisDonwloadOnlinePackages, [PkgLinksStr]), mtConfirmation, [mbYes, mbNo]) = mrYes then begin
 | 
				
			||||||
 | 
					        if OPMInterface.DownloadPackages(PkgLinks) = mrOK then begin
 | 
				
			||||||
 | 
					          for I := PkgLinks.Count - 1 downto 0 do begin
 | 
				
			||||||
 | 
					            if OPMInterface.IsPackageAvailable(TPackageLink(PkgLinks.Items[I]), 1) then begin
 | 
				
			||||||
 | 
					              Additions.Add(NewPackageID);
 | 
				
			||||||
 | 
					              NewPackageID:=TLazPackageID.Create;
 | 
				
			||||||
 | 
					              AddedPkgNames.Add(PkgName);
 | 
				
			||||||
 | 
					              PkgLink := LazPackageLinks.AddUserLink(TPackageLink(PkgLinks.Items[I]).OPMFileName, TPackageLink(PkgLinks.Items[I]).Name);
 | 
				
			||||||
 | 
					              if PkgLink <> nil then
 | 
				
			||||||
 | 
					                LazPackageLinks.SaveUserLinks;
 | 
				
			||||||
 | 
					            end;
 | 
				
			||||||
 | 
					          end;
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          Dec(NewSelectedIndex);
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        Dec(NewSelectedIndex);
 | 
				
			||||||
 | 
					    end;
 | 
				
			||||||
    // all ok => add to installed packages
 | 
					    // all ok => add to installed packages
 | 
				
			||||||
    for i:=0 to Additions.Count-1 do
 | 
					    for i:=0 to Additions.Count-1 do
 | 
				
			||||||
      FNewInstalledPackages.Add(Additions[i]);
 | 
					      FNewInstalledPackages.Add(Additions[i]);
 | 
				
			||||||
@ -1006,6 +1115,7 @@ begin
 | 
				
			|||||||
    NewPackageID.Free;
 | 
					    NewPackageID.Free;
 | 
				
			||||||
    AddedPkgNames.Free;
 | 
					    AddedPkgNames.Free;
 | 
				
			||||||
    Additions.Free;
 | 
					    Additions.Free;
 | 
				
			||||||
 | 
					    PkgLinks.Free;
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -57,7 +57,7 @@ uses
 | 
				
			|||||||
  // LazUtils
 | 
					  // LazUtils
 | 
				
			||||||
  LazFileUtils, Laz2_XMLCfg, LazLoggerBase, LazMethodList,
 | 
					  LazFileUtils, Laz2_XMLCfg, LazLoggerBase, LazMethodList,
 | 
				
			||||||
  // IdeIntf
 | 
					  // IdeIntf
 | 
				
			||||||
  PackageDependencyIntf, PackageIntf,
 | 
					  PackageDependencyIntf, PackageIntf, PackageLinkIntf,
 | 
				
			||||||
  // IDE
 | 
					  // IDE
 | 
				
			||||||
  EnvironmentOpts, PackageLinks, PackageDefs, PackageSystem;
 | 
					  EnvironmentOpts, PackageLinks, PackageDefs, PackageSystem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -357,9 +357,14 @@ procedure TLPKInfoCache.OnIterateAvailablePackages(APackage: TLazPackageID);
 | 
				
			|||||||
begin
 | 
					begin
 | 
				
			||||||
  if APackage is TLazPackage then
 | 
					  if APackage is TLazPackage then
 | 
				
			||||||
    fAvailableFiles.Add(TLazPackage(APackage).Filename)
 | 
					    fAvailableFiles.Add(TLazPackage(APackage).Filename)
 | 
				
			||||||
  else if APackage is TLazPackageLink then
 | 
					  else if APackage is TLazPackageLink then begin
 | 
				
			||||||
 | 
					    if (OPMInterface<>nil) and (TLazPackageLink(APackage).Origin=ploOnline) and
 | 
				
			||||||
 | 
					        (not OPMInterface.IsPackageAvailable(TLazPackageLink(APackage), 2)) then
 | 
				
			||||||
 | 
					      fAvailableFiles.Add(TLazPackageLink(APackage).OPMFileName)
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
      fAvailableFiles.Add(TLazPackageLink(APackage).LPKFilename);
 | 
					      fAvailableFiles.Add(TLazPackageLink(APackage).LPKFilename);
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TLPKInfoCache.QueueEmpty;
 | 
					procedure TLPKInfoCache.QueueEmpty;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
 | 
				
			|||||||
@ -131,7 +131,7 @@ type
 | 
				
			|||||||
    procedure BeginUpdate;
 | 
					    procedure BeginUpdate;
 | 
				
			||||||
    procedure EndUpdate;
 | 
					    procedure EndUpdate;
 | 
				
			||||||
    function IsUpdating: boolean;
 | 
					    function IsUpdating: boolean;
 | 
				
			||||||
    procedure SaveUserLinks(Immediately: boolean = false);
 | 
					    procedure SaveUserLinks(Immediately: boolean = false); override;
 | 
				
			||||||
    function NeedSaveUserLinks(const ConfigFilename: string): boolean;
 | 
					    function NeedSaveUserLinks(const ConfigFilename: string): boolean;
 | 
				
			||||||
    procedure WriteLinkTree(LinkTree: TAvlTree);
 | 
					    procedure WriteLinkTree(LinkTree: TAvlTree);
 | 
				
			||||||
    procedure IncreaseChangeStamp;
 | 
					    procedure IncreaseChangeStamp;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user