Changeset 6 for trunk/Forms


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/Forms
Files:
6 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
Note: See TracChangeset for help on using the changeset viewer.