Changeset 13 for trunk/UCore.pas


Ignore:
Timestamp:
May 30, 2015, 1:02:36 PM (9 years ago)
Author:
chronos
Message:
  • Added: New test form where general functionality of selected backend can be tested.
  • Added: Basic git backend implementation.
  • Added: Project group form and ability to open/save group of projects as configuration to XML file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r10 r13  
    1919    ACommandCommit: TAction;
    2020    ACommandStatus: TAction;
     21    AProjectGroupSaveAs: TAction;
     22    AProjectGroupSave: TAction;
     23    AProjectGroupClose: TAction;
     24    AProjectGroupOpen: TAction;
     25    AProjectGroupNew: TAction;
     26    AViewTest: TAction;
    2127    AProjectCheckout: TAction;
    2228    AProjectClose: TAction;
     
    2834    AViewFavorites: TAction;
    2935    ImageList1: TImageList;
    30     LastOpenedList1: TLastOpenedList;
     36    LastOpenedListProject: TLastOpenedList;
    3137    LastOpenedListNewDir: TLastOpenedList;
     38    LastOpenedListProjectGroup: TLastOpenedList;
    3239    LastOpenedListRepoURL: TLastOpenedList;
    3340    OpenDialog1: TOpenDialog;
     41    SaveDialog1: TSaveDialog;
    3442    XMLConfig1: TXMLConfig;
    3543    procedure ACommandCheckoutExecute(Sender: TObject);
     
    3947    procedure AProjectCheckoutExecute(Sender: TObject);
    4048    procedure AProjectCloseExecute(Sender: TObject);
     49    procedure AProjectGroupCloseExecute(Sender: TObject);
     50    procedure AProjectGroupNewExecute(Sender: TObject);
     51    procedure AProjectGroupOpenExecute(Sender: TObject);
     52    procedure AProjectGroupSaveAsExecute(Sender: TObject);
     53    procedure AProjectGroupSaveExecute(Sender: TObject);
    4154    procedure AProjectOpenExecute(Sender: TObject);
    4255    procedure AQuitExecute(Sender: TObject);
    4356    procedure ASettingsExecute(Sender: TObject);
     57    procedure AViewTestExecute(Sender: TObject);
    4458    procedure DataModuleCreate(Sender: TObject);
    4559    procedure DataModuleDestroy(Sender: TObject);
    46     procedure LastOpenedList1Change(Sender: TObject);
     60    procedure LastOpenedListProjectChange(Sender: TObject);
     61    procedure LastOpenedListProjectGroupChange(Sender: TObject);
    4762  private
    4863    procedure UpdateInterface;
     
    5368    Backends: TObjectList; // TList<TBackend>
    5469    Project: TProject;
     70    ProjectGroup: TProjectGroup;
     71    UserName: string;
     72    Email: string;
    5573    procedure LoadConfig;
    5674    procedure SaveConfig;
     
    5876    procedure Done;
    5977    procedure ProjectOpen(Directory: string);
     78    procedure ProjectGroupOpen(FileName: string);
    6079  end;
    6180
     
    6988uses
    7089  UFormMain, UFormBrowse, UFormSettings, UFormCommit, UFormCheckout,
    71   USubversion, UBazaar, UCVS;
     90  USubversion, UBazaar, UCVS, UGit, UFormTest, UFormProjectGroup;
    7291
    7392{ TCore }
     
    8099procedure TCore.ASettingsExecute(Sender: TObject);
    81100begin
    82   FormSettings.ShowModal;
     101  FormSettings.Load(XMLConfig1);
     102  if FormSettings.ShowModal = mrOk then begin
     103    FormSettings.Save(XMLConfig1);
     104  end;
     105end;
     106
     107procedure TCore.AViewTestExecute(Sender: TObject);
     108begin
     109  FormTest.Show;
    83110end;
    84111
     
    95122end;
    96123
    97 procedure TCore.LastOpenedList1Change(Sender: TObject);
    98 begin
    99   LastOpenedList1.LoadToMenuItem(FormMain.MenuItemOpenRecent, FormMain.OpenRecentExecute);
     124procedure TCore.LastOpenedListProjectChange(Sender: TObject);
     125begin
     126  LastOpenedListProject.LoadToMenuItem(FormMain.MenuItemOpenRecent, FormMain.OpenRecentExecute);
     127end;
     128
     129procedure TCore.LastOpenedListProjectGroupChange(Sender: TObject);
     130begin
     131  LastOpenedListProjectGroup.LoadToMenuItem(FormMain.MenuItemRecentProjectGroup, FormMain.ProjectGroupOpenRecentExecute);
    100132end;
    101133
     
    103135begin
    104136  AProjectClose.Enabled := Assigned(Project);
     137  AProjectGroupClose.Enabled := Assigned(ProjectGroup);
     138  AProjectGroupSave.Enabled := Assigned(ProjectGroup);
     139  AProjectGroupSaveAs.Enabled := Assigned(ProjectGroup);
    105140  FormMain.UpdateInterface;
    106141end;
     
    111146  RegisterBackend(TBackendBazaar.Create);
    112147  RegisterBackend(TBackendCVS.Create);
     148  RegisterBackend(TBackendGit.Create);
    113149end;
    114150
     
    130166procedure TCore.LoadConfig;
    131167begin
    132   LastOpenedList1.LoadFromXMLConfig(XMLConfig1, 'LastOpenedProjects');
     168  LastOpenedListProject.LoadFromXMLConfig(XMLConfig1, 'LastOpenedProjects');
    133169  LastOpenedListRepoURL.LoadFromXMLConfig(XMLConfig1, 'LastOpenedRepoURL');
    134170  LastOpenedListNewDir.LoadFromXMLConfig(XMLConfig1, 'LastOpenedNewDir');
     171  LastOpenedListProjectGroup.LoadFromXMLConfig(XMLConfig1, 'LastOpenedListProjectGroup');
     172  UserName := XMLConfig1.GetValue('UserName', '');
     173  Email := XMLConfig1.GetValue('Email', '');
    135174end;
    136175
    137176procedure TCore.SaveConfig;
    138177begin
    139   LastOpenedList1.SaveToXMLConfig(XMLConfig1, 'LastOpenedProjects');
     178  LastOpenedListProject.SaveToXMLConfig(XMLConfig1, 'LastOpenedProjects');
    140179  LastOpenedListRepoURL.SaveToXMLConfig(XMLConfig1, 'LastOpenedRepoURL');
    141180  LastOpenedListNewDir.SaveToXMLConfig(XMLConfig1, 'LastOpenedNewDir');
     181  LastOpenedListProjectGroup.SaveToXMLConfig(XMLConfig1, 'LastOpenedListProjectGroup');
     182  XMLConfig1.SetValue('UserName', UserName);
     183  XMLConfig1.SetValue('Email', Email);
    142184end;
    143185
     
    146188  RegisterBackends;
    147189  LoadConfig;
    148   if (LastOpenedList1.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedList1.Items[0]) then
    149     ProjectOpen(LastOpenedList1.Items[0]);
     190  if (LastOpenedListProject.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedListProject.Items[0]) then
     191    ProjectOpen(LastOpenedListProject.Items[0]);
    150192end;
    151193
     
    160202  Project := TProject.Create;
    161203  Project.Backend := DetectBackend(Directory);
     204  Project.WorkingCopy.UserName := Core.UserName;
     205  Project.WorkingCopy.Email := Core.Email;
    162206  if Assigned(Project.Backend) then begin
    163207    Project.Directory := Directory;
     
    165209    FormBrowse.Directory := Project.Directory;
    166210    FormBrowse.ReloadList;
    167     LastOpenedList1.AddItem(Project.Directory);
     211    LastOpenedListProject.AddItem(Project.Directory);
    168212  end else ShowMessage('Directory not recognized as working copy of any of supported VCS systems');
     213end;
     214
     215procedure TCore.ProjectGroupOpen(FileName: string);
     216begin
     217  AProjectGroupClose.Execute;
     218  ProjectGroup := TProjectGroup.Create;
     219  ProjectGroup.FileName := FileName;
     220  UpdateInterface;
     221  FormProjectGroup.ReloadTree;
     222  LastOpenedListProjectGroup.AddItem(FileName);
    169223end;
    170224
     
    187241  FormBrowse.ReloadList;
    188242  UpdateInterface;
     243end;
     244
     245procedure TCore.AProjectGroupCloseExecute(Sender: TObject);
     246begin
     247  FreeAndNil(ProjectGroup);
     248  UpdateInterface;
     249  FormProjectGroup.ReloadTree;
     250end;
     251
     252procedure TCore.AProjectGroupNewExecute(Sender: TObject);
     253begin
     254  AProjectClose.Execute;
     255  ProjectGroup := TProjectGroup.Create;
     256  ProjectGroup.FileName := 'New project group.vcgrp';
     257  UpdateInterface;
     258  FormProjectGroup.ReloadTree;
     259end;
     260
     261procedure TCore.AProjectGroupOpenExecute(Sender: TObject);
     262begin
     263  if LastOpenedListProjectGroup.Items.Count > 0 then
     264    OpenDialog1.FileName := LastOpenedListProjectGroup.Items[0];
     265  if OpenDialog1.Execute then begin
     266    AProjectClose.Execute;
     267    ProjectGroupOpen(OpenDialog1.FileName);
     268  end;
     269end;
     270
     271procedure TCore.AProjectGroupSaveAsExecute(Sender: TObject);
     272begin
     273  SaveDialog1.FileName := ProjectGroup.FileName;
     274  if SaveDialog1.Execute then begin
     275    ProjectGroup.SaveToFile(SaveDialog1.FileName);
     276    UpdateInterface;
     277  end;
     278end;
     279
     280procedure TCore.AProjectGroupSaveExecute(Sender: TObject);
     281begin
     282  if FileExistsUTF8(ProjectGroup.FileName) then ProjectGroup.SaveToFile(ProjectGroup.FileName)
     283    else AProjectGroupSaveAs.Execute;
    189284end;
    190285
Note: See TracChangeset for help on using the changeset viewer.