View Issue Details

IDProjectCategoryView StatusLast Update
0003958JEDI VCL00 JVCL Componentspublic2007-06-24 07:21
ReporterKiriakosAssigned ToAHUser 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.34 
Summary0003958: JvDocking - Improve SaveDockTreeToAppStorage
DescriptionWe can reduce the size of the the saved information and the speed of saving and loading docking layouts by introducing the following change in JvDockInfo.pas. (It does not store default integer and boolean values).

{$IFDEF USEJVCL}

procedure TJvDockInfoTree.ScanTreeZone(TreeZone: TJvDockBaseZone);
var
  I: Integer;
  OldPath: string;

  procedure WriteIntegerIfNonZero(const Path: string; Value: Integer);
  begin
    if Value <> 0 then
      fAppStorage.WriteInteger(Path, Value);
  end;

  procedure WriteBooleanIfFalse(const Path: string; Value: Boolean);
  begin
    if not Value then // True is the default in AppStorage.ReadBoolean
      fAppStorage.WriteBoolean(Path, Value);
  end;


begin
  if FJvDockInfoStyle = isJVCLReadInfo then { JVCL Mode persistance : READ }
  begin
    for I := 0 to TreeZone.GetChildCount - 1 do
      with TJvDockInfoZone(TreeZone.GetChildZone(I)) do
        DockControl := FindDockForm(DockFormName);
    SetDockControlInfo(TJvDockInfoZone(TreeZone));
  end
  else
  if FJvDockInfoStyle = isJVCLWriteInfo then { JVCL Mode persistance : WRITE }
  begin
    if TreeZone <> TopTreeZone then
      with TJvDockInfoZone(TreeZone), FAppStorage do
      begin
        OldPath := Path;
        try
          Path := ConcatPaths([Path, AppStoragePath, 'Forms']);
          WriteString('FormNames', ReadString('FormNames') + DockFormName + ';');
          Path := ConcatPaths([Path, DockFormName]);
          WriteString('ParentName', ParentName);
          WriteIntegerIfNonZero('DockLeft', DockRect.Left);
          WriteIntegerIfNonZero('DockTop', DockRect.Top);
          WriteIntegerIfNonZero('DockRight', DockRect.Right);
          WriteIntegerIfNonZero('DockBottom', DockRect.Bottom);
          WriteString('LastDockSiteName', LastDockSiteName);
          WriteIntegerIfNonZero('UnDockLeft', UnDockLeft);
          WriteIntegerIfNonZero('UnDockTop', UnDockTop);
          WriteIntegerIfNonZero('LRDockWidth', LRDockWidth);
          WriteIntegerIfNonZero('TBDockHeight', TBDockHeight);
          WriteIntegerIfNonZero('UnDockWidth', UnDockWidth);
          WriteIntegerIfNonZero('UnDockHeight', UnDockHeight);
          WriteIntegerIfNonZero('VSPaneWidth', VSPaneWidth);
          WriteBooleanIfFalse('Visible', Visible);
          WriteIntegerIfNonZero('BorderStyle', Integer(BorderStyle));
          WriteIntegerIfNonZero('FormStyle', Integer(FormStyle));
          WriteIntegerIfNonZero('WindowState', Integer(WindowState));
          WriteIntegerIfNonZero('DockFormStyle', Integer(DockFormStyle));
          WriteBooleanIfFalse('CanDocked', CanDocked);
          WriteBooleanIfFalse('EachOtherDocked', EachOtherDocked);
          WriteBooleanIfFalse('LeftDocked', LeftDocked);
          WriteBooleanIfFalse('TopDocked', TopDocked);
          WriteBooleanIfFalse('RightDocked', RightDocked);
          WriteBooleanIfFalse('BottomDocked', BottomDocked);
          WriteBooleanIfFalse('CustomDocked', CustomDocked); {NEW!}
          WriteString('DockClientData', DockClientData);
        finally
          FAppStorage.Path := OldPath;
        end;
      end;
  end;
  inherited ScanTreeZone(TreeZone);
end;

TagsNo tags attached.

Activities

obones

2007-01-04 04:24

administrator   ~0010528

Wouldn't it be better to use the same behaviour as the DFM streaming system that uses the default values for properties? And this default value is not always 0 or True.

Kiriakos

2007-03-10 05:54

reporter   ~0011301

That would require using WritePersistent on a TreeZone (TJvDockInfoZone type). Currently TJvDockInfoZone inherits from TObject and not TPersistent. So a few more changes would be required.

The suggested change achieves huge reduction in storage space with minimal code changes.

remkobonte

2007-03-20 15:32

developer   ~0011524

Sounds like a good idea, but the problem I see is the DefaultIfValueNotExists property of TJvAppStorageOptions. If for some reason the user chooses to set DefaultIfValueNotExists to False, then it is undefined how the code works..

Kiriakos

2007-03-20 20:55

reporter   ~0011528

Absolutely right! Did not see that.

One painless solution is in TJvDockInfoTree.CreateZoneAndAddInfoFromAppStorage to set DefaultIfValueNotExists to True storing the old value and then restoring it at exit.

obones

2007-06-19 08:30

administrator   ~0013460

Please provide patch files, it makes integration MUCH easier especially when other changes have been made in between. Use TortoiseSVN to create the patch files as it makes merging much easier for us. Thanks.

2007-06-23 10:28

 

JvDockInfo.diff (3,520 bytes)
411a412
>   OldDefaultIfValueNotExists : Boolean;
474a476,477
>     OldDefaultIfValueNotExists := FAppStorage.StorageOptions.DefaultIfValueNotExists;
>     FAppStorage.StorageOptions.DefaultIfValueNotExists := True;
499a503
>       FAppStorage.StorageOptions.DefaultIfValueNotExists := OldDefaultIfValueNotExists;
780a785,798
> 
>   procedure WriteIntegerIfNonZero(const Path: string; Value: Integer);
>   begin
>     if Value <> 0 then
>       fAppStorage.WriteInteger(Path, Value);
>   end;
> 
>   procedure WriteBooleanIfFalse(const Path: string; Value: Boolean);
>   begin
>     if not Value then
>       fAppStorage.WriteBoolean(Path, Value);
>   end;
> 
> 
801,804c819,822
<           WriteInteger('DockLeft', DockRect.Left);
<           WriteInteger('DockTop', DockRect.Top);
<           WriteInteger('DockRight', DockRect.Right);
<           WriteInteger('DockBottom', DockRect.Bottom);
---
>           WriteIntegerIfNonZero('DockLeft', DockRect.Left);
>           WriteIntegerIfNonZero('DockTop', DockRect.Top);
>           WriteIntegerIfNonZero('DockRight', DockRect.Right);
>           WriteIntegerIfNonZero('DockBottom', DockRect.Bottom);
806,824c824,842
<           WriteInteger('UnDockLeft', UnDockLeft);
<           WriteInteger('UnDockTop', UnDockTop);
<           WriteInteger('LRDockWidth', LRDockWidth);
<           WriteInteger('TBDockHeight', TBDockHeight);
<           WriteInteger('UnDockWidth', UnDockWidth);
<           WriteInteger('UnDockHeight', UnDockHeight);
<           WriteInteger('VSPaneWidth', VSPaneWidth);
<           WriteBoolean('Visible', Visible);
<           WriteInteger('BorderStyle', Integer(BorderStyle));
<           WriteInteger('FormStyle', Integer(FormStyle));
<           WriteInteger('WindowState', Integer(WindowState));
<           WriteInteger('DockFormStyle', Integer(DockFormStyle));
<           WriteBoolean('CanDocked', CanDocked);
<           WriteBoolean('EachOtherDocked', EachOtherDocked);
<           WriteBoolean('LeftDocked', LeftDocked);
<           WriteBoolean('TopDocked', TopDocked);
<           WriteBoolean('RightDocked', RightDocked);
<           WriteBoolean('BottomDocked', BottomDocked);
<           WriteBoolean('CustomDocked', CustomDocked); {NEW!}
---
>           WriteIntegerIfNonZero('UnDockLeft', UnDockLeft);
>           WriteIntegerIfNonZero('UnDockTop', UnDockTop);
>           WriteIntegerIfNonZero('LRDockWidth', LRDockWidth);
>           WriteIntegerIfNonZero('TBDockHeight', TBDockHeight);
>           WriteIntegerIfNonZero('UnDockWidth', UnDockWidth);
>           WriteIntegerIfNonZero('UnDockHeight', UnDockHeight);
>           WriteIntegerIfNonZero('VSPaneWidth', VSPaneWidth);
>           WriteBooleanIfFalse('Visible', Visible);
>           WriteIntegerIfNonZero('BorderStyle', Integer(BorderStyle));
>           WriteIntegerIfNonZero('FormStyle', Integer(FormStyle));
>           WriteIntegerIfNonZero('WindowState', Integer(WindowState));
>           WriteIntegerIfNonZero('DockFormStyle', Integer(DockFormStyle));
>           WriteBooleanIfFalse('CanDocked', CanDocked);
>           WriteBooleanIfFalse('EachOtherDocked', EachOtherDocked);
>           WriteBooleanIfFalse('LeftDocked', LeftDocked);
>           WriteBooleanIfFalse('TopDocked', TopDocked);
>           WriteBooleanIfFalse('RightDocked', RightDocked);
>           WriteBooleanIfFalse('BottomDocked', BottomDocked);
>           WriteBooleanIfFalse('CustomDocked', CustomDocked); {NEW!}
JvDockInfo.diff (3,520 bytes)

Kiriakos

2007-06-23 10:28

reporter   ~0013519

Patch file attached.

AHUser

2007-06-24 07:21

developer   ~0013534

Added to SVN

Issue History

Date Modified Username Field Change
2006-10-16 05:37 Kiriakos New Issue
2007-01-04 04:24 obones Note Added: 0010528
2007-01-04 04:24 obones Status new => feedback
2007-03-10 05:54 Kiriakos Note Added: 0011301
2007-03-20 15:32 remkobonte Note Added: 0011524
2007-03-20 20:55 Kiriakos Note Added: 0011528
2007-06-19 08:30 obones Note Added: 0013460
2007-06-23 10:28 Kiriakos File Added: JvDockInfo.diff
2007-06-23 10:28 Kiriakos Note Added: 0013519
2007-06-24 07:21 AHUser Status feedback => resolved
2007-06-24 07:21 AHUser Fixed in Version => Daily / SVN
2007-06-24 07:21 AHUser Resolution open => fixed
2007-06-24 07:21 AHUser Assigned To => AHUser
2007-06-24 07:21 AHUser Note Added: 0013534