Changeset 6


Ignore:
Timestamp:
May 6, 2015, 11:19:49 AM (10 years ago)
Author:
chronos
Message:
  • Added: Now opened projects are remembered between application restarts.
  • Added: Show basic list of files in selected project.
  • Added: Packages Common and TemplateGenerics.
Location:
trunk
Files:
98 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormBrowse.lfm

    r4 r6  
    77  ClientHeight = 526
    88  ClientWidth = 722
    9   LCLVersion = '1.3'
     9  LCLVersion = '1.5'
    1010  object TreeView1: TTreeView
    1111    Left = 0
     
    3232      item
    3333        Caption = 'Name'
     34        Width = 300
    3435      end   
    3536      item
    3637        Caption = 'Revision'
     38        Width = 80
    3739      end   
    3840      item
    3941        Caption = 'Last change date'
     42        Width = 100
    4043      end   
    4144      item
    4245        Caption = 'Last author'
     46        Width = 100
    4347      end   
    4448      item
     
    4650        Width = 259
    4751      end>
     52    OwnerData = True
    4853    ReadOnly = True
    4954    RowSelect = True
    5055    TabOrder = 2
    5156    ViewStyle = vsReport
     57    OnData = ListView1Data
    5258  end
    5359end
  • trunk/Forms/UFormBrowse.pas

    r3 r6  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ExtCtrls;
     9  ExtCtrls, UFindFile;
    1010
    1111type
     
    1717    Splitter1: TSplitter;
    1818    TreeView1: TTreeView;
     19    procedure ListView1Data(Sender: TObject; Item: TListItem);
    1920  private
    20     { private declarations }
     21    FileList: TStringList;
    2122  public
     23    Directory: string;
    2224    procedure ReloadList;
    2325  end;
     
    3234{ TFormBrowse }
    3335
     36procedure TFormBrowse.ListView1Data(Sender: TObject; Item: TListItem);
     37begin
     38  if (Item.Index >= 0) and (Item.Index < FileList.Count) then begin
     39    Item.Caption := ExtractFileName(FileList[Item.Index]);
     40  end;
     41end;
     42
    3443procedure TFormBrowse.ReloadList;
     44var
     45  FindFile: TFindFile;
     46  I: Integer;
    3547begin
    36 
     48  FindFile := TFindFile.Create(nil);
     49  FindFile.Path := Directory;
     50  FindFile.FileMask := '*.*';
     51  FindFile.InSubFolders := False;
     52  FileList := FindFile.SearchForFiles;
     53  for I := FileList.Count - 1 downto 0 do
     54    if ExtractFileName(FileList[I]) = '.' then FileList.Delete(I);
     55  ListView1.Items.Count := FileList.Count;
     56  ListView1.Refresh;
    3757end;
    3858
  • trunk/Forms/UFormConsole.lfm

    r5 r6  
    33  Height = 727
    44  Top = 261
    5   Width = 984
     5  Width = 975
    66  Caption = 'Console'
    77  ClientHeight = 727
    8   ClientWidth = 984
     8  ClientWidth = 975
    99  OnClose = FormClose
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
    1212  OnShow = FormShow
    13   LCLVersion = '1.3'
    14   object MemoOutput: TMemo
     13  Position = poMainFormCenter
     14  LCLVersion = '1.5'
     15  object Memo1: TMemo
    1516    Left = 4
    1617    Height = 674
    1718    Top = 48
    18     Width = 975
     19    Width = 966
    1920    Align = alCustom
    2021    Anchors = [akTop, akLeft, akRight, akBottom]
     
    2627    TabOrder = 0
    2728  end
     29  object ButtonAbort: TButton
     30    Left = 895
     31    Height = 25
     32    Top = 8
     33    Width = 75
     34    Anchors = [akTop, akRight]
     35    Caption = 'Abort'
     36    OnClick = ButtonAbortClick
     37    TabOrder = 1
     38  end
    2839  object EditCommand: TEdit
    2940    Left = 4
    3041    Height = 32
    3142    Top = 7
    32     Width = 893
     43    Width = 884
    3344    Anchors = [akTop, akLeft, akRight]
    3445    ReadOnly = True
    35     TabOrder = 1
     46    TabOrder = 2
    3647  end
    37   object ToolBar1: TToolBar
    38     Left = 902
    39     Height = 34
    40     Top = 8
    41     Width = 77
    42     Align = alCustom
    43     Anchors = [akTop, akRight]
    44     Caption = 'ToolBar1'
    45     EdgeInner = esNone
    46     EdgeOuter = esNone
    47     ShowCaptions = True
    48     TabOrder = 2
    49     object ToolButton1: TToolButton
    50       Left = 1
    51       Top = 0
    52       Action = AAbort
    53       AutoSize = True
    54       DropdownMenu = PopupMenu1
    55       Style = tbsDropDown
    56     end
    57   end
    58   object ActionList1: TActionList
    59     left = 265
    60     top = 130
    61     object AAbort: TAction
    62       Caption = 'Abort'
    63       OnExecute = AAbortExecute
    64     end
    65     object ARestart: TAction
    66       Caption = 'Restart'
    67     end
    68   end
    69   object PopupMenu1: TPopupMenu
    70     left = 264
    71     top = 232
    72     object MenuItem1: TMenuItem
    73       Action = AAbort
    74     end
    75     object MenuItem2: TMenuItem
    76       Action = ARestart
    77     end
     48  object Timer1: TTimer
     49    Enabled = False
     50    Interval = 1
     51    OnTimer = Timer1Timer
     52    left = 72
     53    top = 112
    7854  end
    7955end
  • trunk/Forms/UFormConsole.pas

    r5 r6  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Buttons, ComCtrls, ActnList, Menus, Process;
     9  ExtCtrls, Process;
    1010
    1111type
     
    1414
    1515  TFormConsole = class(TForm)
    16     AAbort: TAction;
    17     ARestart: TAction;
    18     ActionList1: TActionList;
     16    ButtonAbort: TButton;
    1917    EditCommand: TEdit;
    20     MemoOutput: TMemo;
    21     MenuItem1: TMenuItem;
    22     MenuItem2: TMenuItem;
    23     PopupMenu1: TPopupMenu;
    24     ToolBar1: TToolBar;
    25     ToolButton1: TToolButton;
    26     procedure AAbortExecute(Sender: TObject);
     18    Memo1: TMemo;
     19    Timer1: TTimer;
     20    procedure ButtonAbortClick(Sender: TObject);
    2721    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2822    procedure FormCreate(Sender: TObject);
    2923    procedure FormDestroy(Sender: TObject);
    3024    procedure FormShow(Sender: TObject);
     25    procedure Timer1Timer(Sender: TObject);
    3126  private
    3227    Process: TProcess;
     
    3631    Parameters: TStringList;
    3732    WorkingDir: string;
    38     Environment: TStringList;
     33    Environment: string;
    3934    Aborted: Boolean;
    40     Duration: TDateTime;
     35    Log: TStringList;
    4136    procedure Perform;
    4237  end;
     
    4742implementation
    4843
    49 uses
    50   UFormMain;
    51 
    5244{$R *.lfm}
    5345
     
    5749begin
    5850  Parameters := TStringList.Create;
    59   Parameters.QuoteChar := ' ';
    60   Parameters.Delimiter := ' ';
    61   Environment := TStringList.Create;
    62   Environment.QuoteChar := ' ';
    63   Environment.Delimiter := ' ';
     51  Log := TStringList.Create;
    6452end;
    6553
    6654procedure TFormConsole.FormDestroy(Sender: TObject);
    6755begin
    68   Environment.Free;
     56  Log.Free;
    6957  Parameters.Free;
    7058end;
     
    7260procedure TFormConsole.FormShow(Sender: TObject);
    7361begin
    74   //FormMain.PersistentForm1.Load(Self);
    75   MemoOutput.Clear;
    76   AAbort.Enabled := False;
     62  Memo1.Clear;
     63  ButtonAbort.Enabled := False;
     64  Timer1.Enabled := True;
    7765end;
    7866
    79 procedure TFormConsole.AAbortExecute(Sender: TObject);
     67procedure TFormConsole.Timer1Timer(Sender: TObject);
     68begin
     69  Timer1.Enabled := False;
     70  Perform;
     71end;
     72
     73procedure TFormConsole.ButtonAbortClick(Sender: TObject);
    8074begin
    8175  if Assigned(Process) then begin
     
    8882  );
    8983begin
    90   AAbort.Execute;
    91   //FormMain.PersistentForm1.Save(Self);
     84  ButtonAbort.Click;
    9285end;
    9386
     
    9992  Line: string;
    10093  CommandLine: string;
    101   TimeStart: TDateTime;
    10294begin
    103   TimeStart := Now;
    104   if not Visible then Show;
    10595  Text := '';
    10696  try
    10797    Process := TProcess.Create(nil);
    10898    Aborted := False;
    109     AAbort.Enabled := True;
     99    ButtonAbort.Enabled := True;
    110100    if WorkingDir <> '' then
    111101      Process.CurrentDirectory := WorkingDir;
    112102    //WorkingDir := '';
    113     if Environment.Count <> 0 then
    114       Process.Environment.Assign(Environment);
    115 //    Environment := '';
     103    if Environment <> '' then
     104      Process.Environment.Text := Environment;
     105    Environment := '';
    116106    //Process.Executable := Executable;
    117107    //Process.Parameters.Assign(Parameters);
    118     Process.CommandLine := Executable + ' ' + Parameters.DelimitedText;
    119     CommandLine := Executable + ' ' + Parameters.DelimitedText;
    120     //if CommandLine[Length(CommandLine)] = #$a then
    121     //  SetLength(CommandLine, Length(CommandLine) - 1);
     108    Process.CommandLine := Executable + ' ' + Parameters.Text;
     109    CommandLine := Executable + ' ' + StringReplace(Parameters.Text, LineEnding, ' ', [rfReplaceAll]);
     110    if CommandLine[Length(CommandLine)] = LineEnding then
     111      SetLength(CommandLine, Length(CommandLine) - 1);
    122112    EditCommand.Text := CommandLine;
    123113    Process.Options := [poUsePipes, poNoConsole];
     
    135125          Line := Copy(Text, 1, Pos(LineEnding, Text) - 1);
    136126          Delete(Text, 1, Length(Line) + Length(LineEnding));
    137           MemoOutput.Lines.Add(Line);
     127          Memo1.Lines.Add(Line);
    138128        end;
    139129      end;
     
    147137          Line := Copy(Text, 1, Pos(LineEnding, Text) - 1);
    148138          Delete(Text, 1, Length(Line) + Length(LineEnding));
    149           MemoOutput.Lines.Add(Line);
     139          Memo1.Lines.Add(Line);
    150140        end;
    151141      end;
     
    154144    end;
    155145  finally
    156     MemoOutput.Lines.Add(Text);
     146    Memo1.Lines.Add(Text);
    157147    FreeAndNil(Process);
    158148  end;
    159   Duration := Now - TimeStart;
    160   AAbort.Enabled := False;
    161   //ToolButton1.ModalResult := mrOK;
     149  Log.Assign(Memo1.Lines);
     150  ButtonAbort.Enabled := False;
     151  //ModalResult := mrOK;
     152  //Close;
    162153end;
    163154
  • trunk/Forms/UFormMain.lfm

    r5 r6  
    88  ClientWidth = 667
    99  Menu = MainMenu1
    10   LCLVersion = '1.3'
     10  OnActivate = FormActivate
     11  OnClose = FormClose
     12  OnShow = FormShow
     13  LCLVersion = '1.5'
     14  WindowState = wsMaximized
    1115  object ToolBarMain: TToolBar
    1216    Left = 0
     
    3337      object MenuItem8: TMenuItem
    3438        Action = Core.AProjectOpen
     39      end
     40      object MenuItemOpenRecent: TMenuItem
     41        Caption = 'Open recent'
    3542      end
    3643      object MenuItem10: TMenuItem
  • trunk/Forms/UFormMain.pas

    r5 r6  
    2323    MenuItem15: TMenuItem;
    2424    MenuItem16: TMenuItem;
     25    MenuItemOpenRecent: TMenuItem;
    2526    MenuItem2: TMenuItem;
    2627    MenuItem3: TMenuItem;
     
    3536    StatusBar1: TStatusBar;
    3637    ToolBarMain: TToolBar;
     38    procedure FormActivate(Sender: TObject);
     39    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     40    procedure FormShow(Sender: TObject);
    3741  private
    38     { private declarations }
     42    Initialized: Boolean;
    3943  public
     44    procedure OpenRecentExecute(Sender: TObject);
    4045    procedure UpdateInterface;
     46    procedure DockInit;
    4147  end;
    4248
     
    4955
    5056uses
    51   UCore;
     57  UCore, UFormBrowse;
    5258
    5359{ TFormMain }
     60
     61procedure TFormMain.FormShow(Sender: TObject);
     62begin
     63  DockInit;
     64end;
     65
     66procedure TFormMain.OpenRecentExecute(Sender: TObject);
     67begin
     68  Core.ProjectOpen(Core.LastOpenedList1.Items[TMenuItem(Sender).MenuIndex]);
     69end;
     70
     71procedure TFormMain.FormActivate(Sender: TObject);
     72begin
     73  if not Initialized then begin
     74    Initialized := True;
     75    Core.Init;
     76  end;
     77end;
     78
     79procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     80begin
     81  Core.Done;
     82end;
    5483
    5584procedure TFormMain.UpdateInterface;
     
    5988  if Assigned(Core.Project) then
    6089    Caption := Core.Project.Directory + ' - ' + AppName
    61     else Caption := AppName
     90    else Caption := AppName;
     91end;
     92
     93procedure TFormMain.DockInit;
     94begin
     95  FormBrowse.ManualDock(Self, nil, alClient);
     96  FormBrowse.Align := alClient;
     97  FormBrowse.Show;
    6298end;
    6399
  • trunk/UCore.lfm

    r5 r6  
    6161  end
    6262  object OpenDialog1: TOpenDialog
    63     left = 396
    64     top = 113
     63    left = 260
     64    top = 96
     65  end
     66  object XMLConfig1: TXMLConfig
     67    Filename = 'Config.xml'
     68    StartEmpty = False
     69    RootName = 'CONFIG'
     70    left = 96
     71    top = 96
     72  end
     73  object LastOpenedList1: TLastOpenedList
     74    MaxCount = 10
     75    OnChange = LastOpenedList1Change
     76    left = 96
     77    top = 168
    6578  end
    6679end
  • trunk/UCore.pas

    r5 r6  
    66
    77uses
    8   Classes, SysUtils, FileUtil, ActnList, Controls, UVCS, UProject, Forms,
    9   Dialogs;
     8  Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, UVCS, UProject,
     9  ULastOpenedList, Forms, Dialogs;
    1010
    1111type
     
    2828    AViewFavorites: TAction;
    2929    ImageList1: TImageList;
     30    LastOpenedList1: TLastOpenedList;
    3031    OpenDialog1: TOpenDialog;
     32    XMLConfig1: TXMLConfig;
    3133    procedure ACommandCheckoutExecute(Sender: TObject);
    3234    procedure ACommandCleanupExecute(Sender: TObject);
     
    3840    procedure DataModuleCreate(Sender: TObject);
    3941    procedure DataModuleDestroy(Sender: TObject);
     42    procedure LastOpenedList1Change(Sender: TObject);
    4043  private
    4144    procedure UpdateInterface;
    4245  public
    4346    Project: TProject;
     47    procedure LoadConfig;
     48    procedure SaveConfig;
     49    procedure Init;
     50    procedure Done;
     51    procedure ProjectOpen(Directory: string);
    4452  end;
    4553
     
    5260
    5361uses
    54   UFormMain;
     62  UFormMain, UFormBrowse;
    5563
    5664{ TCore }
     
    7179end;
    7280
     81procedure TCore.LastOpenedList1Change(Sender: TObject);
     82begin
     83  LastOpenedList1.LoadToMenuItem(FormMain.MenuItemOpenRecent, FormMain.OpenRecentExecute);
     84end;
     85
    7386procedure TCore.UpdateInterface;
    7487begin
    7588  AProjectClose.Enabled := Assigned(Project);
    7689  FormMain.UpdateInterface;
     90end;
     91
     92procedure TCore.LoadConfig;
     93begin
     94  LastOpenedList1.LoadFromXMLConfig(XMLConfig1, 'LastOpenedProjects');
     95end;
     96
     97procedure TCore.SaveConfig;
     98begin
     99  LastOpenedList1.SaveToXMLConfig(XMLConfig1, 'LastOpenedProjects');
     100end;
     101
     102procedure TCore.Init;
     103begin
     104  LoadConfig;
     105  if (LastOpenedList1.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedList1.Items[0]) then
     106    ProjectOpen(LastOpenedList1.Items[0]);
     107end;
     108
     109procedure TCore.Done;
     110begin
     111  SaveConfig;
     112end;
     113
     114procedure TCore.ProjectOpen(Directory: string);
     115begin
     116  AProjectClose.Execute;
     117  Project := TProject.Create;
     118  Project.VCSType := vtSubversion;
     119  Project.Directory := Directory;
     120  UpdateInterface;
     121  FormBrowse.Directory := Project.Directory;
     122  FormBrowse.ReloadList;
     123  LastOpenedList1.AddItem(Project.Directory);
    77124end;
    78125
     
    85132    else OldDir := '';
    86133  if SelectDirectory('Open project', OldDir, Dir) then begin
    87     AProjectClose.Execute;
    88     Project := TProject.Create;
    89     Project.Directory := Dir;
    90     UpdateInterface;
     134    ProjectOpen(Dir);
    91135  end;
    92136end;
  • trunk/Units/USubversion.pas

    r5 r6  
    1414  TSubversion = class(TWorkingCopy)
    1515  protected
    16     procedure Execute(Command: string); override;
     16    procedure Execute(Parameters: array of string);
    1717  public
    1818    procedure Checkout; override;
     
    2828{ TSubversion }
    2929
    30 procedure TSubversion.Execute(Command: string);
     30procedure TSubversion.Execute(Parameters: array of string);
     31var
     32  Params: TStringList;
    3133begin
    32   inherited Execute('svn ' + Command);
     34  Params := TStringList.Create;
     35  try
     36    Params.AddStrings(Parameters);
     37    ExecuteProcess('svn', Params);
     38  finally
     39    Params.Free;
     40  end;
    3341end;
    3442
    3543procedure TSubversion.Checkout;
    3644begin
    37   Execute('checkout');
     45  Execute(['checkout']);
    3846end;
    3947
    4048procedure TSubversion.Update;
    4149begin
    42   Execute('update');
     50  Execute(['update']);
    4351end;
    4452
    4553procedure TSubversion.CleanUp;
    4654begin
    47   Execute('cleanup');
     55  Execute(['cleanup']);
    4856end;
    4957
    5058procedure TSubversion.Commit;
    5159begin
    52   Execute('commit');
     60  Execute(['commit']);
    5361end;
    5462
    5563procedure TSubversion.Move;
    5664begin
    57   Execute('move');
     65  Execute(['move']);
    5866end;
    5967
    6068procedure TSubversion.Merge;
    6169begin
    62   Execute('merge');
     70  Execute(['merge']);
    6371end;
    6472
  • trunk/Units/UVCS.pas

    r5 r6  
    1717    procedure SetPath(AValue: string);
    1818  protected
    19     procedure Execute(Command: string); virtual;
     19    procedure ExecuteProcess(Command: string; Parameters: TStrings); virtual;
    2020  public
    2121    procedure Checkout; virtual;
     
    4848end;
    4949
    50 procedure TWorkingCopy.Execute(Command: string);
     50procedure TWorkingCopy.ExecuteProcess(Command: string; Parameters: TStrings);
    5151begin
    52   FormConsole.Executable := 'svn';
    53   FormConsole.Parameters.Add(Command);
     52  FormConsole.Executable := Command;
     53  FormConsole.Parameters.Assign(Parameters);
    5454  FormConsole.WorkingDir := Path;
    55   FormConsole.Perform;
     55  FormConsole.ShowModal;
    5656end;
    5757
  • trunk/VCSCommander.lpi

    r5 r6  
    6767      </local>
    6868    </RunParams>
    69     <RequiredPackages Count="1">
     69    <RequiredPackages Count="4">
    7070      <Item1>
     71        <PackageName Value="TemplateGenerics"/>
     72        <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/>
     73      </Item1>
     74      <Item2>
     75        <PackageName Value="FCL"/>
     76      </Item2>
     77      <Item3>
     78        <PackageName Value="Common"/>
     79        <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/>
     80      </Item3>
     81      <Item4>
    7182        <PackageName Value="LCL"/>
    72       </Item1>
     83      </Item4>
    7384    </RequiredPackages>
    7485    <Units Count="10">
  • trunk/VCSCommander.lpr

    r5 r6  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, UFormMain, UCore, UFormBrowse, UVCS, UFormFavorites, UFormSettings,
    11   UFormConsole, USubversion, UProject
     10  Forms, UFormMain, UCore, Common, TemplateGenerics, UFormBrowse, UVCS,
     11  UFormFavorites, UFormSettings, UFormConsole, USubversion, UProject
    1212  { you can add units after this };
    1313
     
    2222  Application.CreateForm(TFormFavorites, FormFavorites);
    2323  Application.CreateForm(TFormSettings, FormSettings);
     24  Application.CreateForm(TFormConsole, FormConsole);
    2425  Application.Run;
    2526end.
Note: See TracChangeset for help on using the changeset viewer.