Changeset 66


Ignore:
Timestamp:
Oct 18, 2010, 10:00:00 AM (14 years ago)
Author:
george
Message:
  • Added: Storing application setting in system registry.
  • Added: Loading project files.
  • Added: Remembering last opened files.
Location:
branches/Transpascal
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/Transpascal/Forms/UMainForm.lfm

    r63 r66  
    7979        Action = AProjectOpen
    8080      end
     81      object MenuItemOpenRecent: TMenuItem
     82        Caption = 'Open recent'
     83      end
    8184      object MenuItem4: TMenuItem
    8285        Action = AProjectSave
     
    108111      Caption = 'Open...'
    109112      Hint = 'Open project'
     113      OnExecute = AProjectOpenExecute
    110114    end
    111115    object AProjectSave: TAction
     
    118122      Caption = 'Save as...'
    119123      Hint = 'Save project with custom name'
     124      OnExecute = AProjectSaveAsExecute
    120125    end
    121126    object AProjectClose: TAction
     
    145150    top = 56
    146151  end
     152  object OpenDialog1: TOpenDialog
     153    Filter = 'Project file (*.*)|*.tppr|Any file (*.*)|*.*'
     154    left = 115
     155    top = 52
     156  end
     157  object SaveDialog1: TSaveDialog
     158    Filter = 'Project file (*.*)|*.tppr|Any file (*.*)|*.*'
     159    left = 115
     160    top = 104
     161  end
    147162end
  • branches/Transpascal/Forms/UMainForm.pas

    r64 r66  
    77uses
    88  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    9   Dialogs, StdCtrls, UCompiler, UProducerAsm8051,
     9  Dialogs, StdCtrls, UCompiler, UProducerAsm8051, Registry,
    1010  UProducerC, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, UProducerTreeView,
    1111  UProducerPascal, Contnrs, UProject, FileUtil, Menus, ActnList, UCoolDocking,
    12   UCompiledForm, UCodeTreeForm;
     12  UCompiledForm, UCodeTreeForm, URegistry, ULastOpenedList, UApplicationInfo;
    1313
    1414const
    15   ProjectDir = '../../Project/';
     15  RegistryRootKey = HKEY_CURRENT_USER;
     16  RegistryKey = 'Software\Transpascal';
    1617
    1718type
     
    4041    MenuItem8: TMenuItem;
    4142    DockPanel: TPanel;
     43    MenuItemOpenRecent: TMenuItem;
     44    OpenDialog1: TOpenDialog;
     45    SaveDialog1: TSaveDialog;
    4246    Splitter3: TSplitter;
    4347    ToolBar1: TToolBar;
     48    procedure AProjectOpenExecute(Sender: TObject);
     49    procedure AProjectSaveAsExecute(Sender: TObject);
    4450    procedure ComboBox1Change(Sender: TObject);
    4551    procedure ComboBoxTargetSelectionChange(Sender: TObject);
     
    5056    procedure FormDestroy(Sender: TObject);
    5157  private
     58    LastOpenedFiles: TLastOpenedList;
     59    ReopenLastOpenedFile: Boolean;
     60    procedure OpenRecentClick(Sender: TObject);
    5261    procedure LoadErrorMessages;
    53     procedure UpdateProjectTree;
    54     procedure UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup);
    5562    procedure DockInit;
     63    procedure LoadFromRegistry;
     64    procedure SaveToRegistry;
     65    procedure OpenProject(FileName: string);
    5666  public
    5767    Project: TProject;
     
    96106  Compiler.Init;
    97107  Compiler.Parser.OnGetSource := GetSource;
     108  if Project.Items.Count > 0 then
    98109  with TProjectFile(Project.Items[0]) do begin
    99110    Compiler.Compile(Parent.GetDir + Name, Source);
     
    117128end;
    118129
    119 procedure TMainForm.UpdateProjectTree;
    120 var
    121   NewNode: TTreeNode;
    122 begin
    123   with ProjectManager, TreeViewProject, Items do begin
    124     BeginUpdate;
    125     Clear;
    126     NewNode := AddChild(nil, Project.Name);
    127     UpdateProjectGroup(NewNode, Project);
    128     NewNode.Expand(True);
    129     EndUpdate;
    130     TreeViewProject.TopItem.Items[0].Selected := True;
    131   end;
    132 end;
    133 
    134 procedure TMainForm.UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup);
    135 var
    136   I: Integer;
    137   NewNode: TTreeNode;
    138 begin
    139   with ProjectManager do
    140   for I := 0 to Group.Items.Count - 1 do begin
    141     NewNode := TreeViewProject.Items.AddChild(Node,
    142       TProjectNode(Group.Items[I]).Name);
    143     NewNode.Data := Pointer(Group.Items[I]);
    144     if TProjectNode(Group.Items[I]) is TProjectGroup then
    145       UpdateProjectGroup(NewNode, TProjectGroup(Group.Items[I]));
    146   end;
    147 end;
    148 
    149130function TMainForm.GetSource(Name: string; Source: TStringList): Boolean;
    150131var
     
    195176end;
    196177
     178procedure TMainForm.LoadFromRegistry;
     179begin
     180  with TRegistryEx.Create do
     181    try
     182      RootKey := HKEY_CURRENT_USER;
     183      OpenKey(RegistryKey, True);
     184      ReopenLastOpenedFile := ReadBoolWithDefault('ReopenLastOpenedFile', True);
     185    finally
     186      Free;
     187    end;
     188  LastOpenedFiles.LoadFromRegistry(RegistryRootKey, RegistryKey);
     189end;
     190
     191procedure TMainForm.SaveToRegistry;
     192begin
     193  with TRegistryEx.Create do
     194    try
     195      RootKey := RegistryRootKey;
     196      OpenKey(RegistryKey, True);
     197      WriteBool('ReopenLastOpenedFile', ReopenLastOpenedFile);
     198    finally
     199      Free;
     200    end;
     201  LastOpenedFiles.SaveToRegistry(RegistryRootKey, RegistryKey);
     202  LastOpenedFiles.ReloadMenu;
     203end;
     204
     205procedure TMainForm.OpenProject(FileName: string);
     206begin
     207  Project.LoadFromFile(FileName);
     208  LastOpenedFiles.Add(FileName);
     209  LastOpenedFiles.ReloadMenu;
     210  ProjectManager.UpdateProjectTree;
     211  Caption := ApplicationInfo.Name + ' - ' + Project.Name;
     212end;
     213
    197214procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
    198215begin
    199216  Project.Save;
     217  SaveToRegistry;
    200218end;
    201219
     
    204222  Compiler := TCompiler.Create;
    205223  Project := TProject.Create;
     224  LastOpenedFiles := TLastOpenedList.Create;
     225  LastOpenedFiles.MenuItem := MenuItemOpenRecent;
     226  LastOpenedFiles.ClickAction := OpenRecentClick;
    206227end;
    207228
    208229procedure TMainForm.FormDestroy(Sender: TObject);
    209230begin
     231  LastOpenedFiles.Free;
    210232  Project.Free;
    211233  Compiler.Free;
    212234end;
    213235
     236procedure TMainForm.OpenRecentClick(Sender: TObject);
     237begin
     238  if Sender is TMenuItem then
     239     OpenProject(StringReplace(TMenuItem(Sender).Caption, '&', '', [rfReplaceAll]));
     240end;
     241
    214242procedure TMainForm.FormShow(Sender: TObject);
    215243var
    216244  NewProjectFile: TProjectFile;
    217245begin
     246  LoadFromRegistry;
    218247  DockInit;
    219248
    220   Project.RootDir := '../../Project/';
    221   Project.Name := 'Project';
    222 
    223   NewProjectFile := TProjectFile.Create;
    224   NewProjectFile.Parent := Project;
    225   NewProjectFile.Name := 'Project.pas';
    226   Project.Items.Add(NewProjectFile);
    227 
    228   NewProjectFile := TProjectFile.Create;
    229   NewProjectFile.Parent := Project;
    230   NewProjectFile.Name := 'System.pas';
    231   Project.Items.Add(NewProjectFile);
    232 
    233   NewProjectFile := TProjectFile.Create;
    234   NewProjectFile.Parent := Project;
    235   NewProjectFile.Name := 'MemoryManager.pas';
    236   Project.Items.Add(NewProjectFile);
    237 
    238   Project.Load;
    239   UpdateProjectTree;
     249  if ReopenLastOpenedFile and (LastOpenedFiles.Count > 0) then begin
     250    OpenProject(LastOpenedFiles[0]);
     251  end;
    240252
    241253  WindowState := wsMaximized;
     254end;
     255
     256procedure TMainForm.ComboBox1Change(Sender: TObject);
     257begin
    242258  ButtonCompileClick(Self);
    243259end;
    244260
    245 procedure TMainForm.ComboBox1Change(Sender: TObject);
     261procedure TMainForm.AProjectOpenExecute(Sender: TObject);
     262begin
     263  if OpenDialog1.Execute then begin
     264    OpenProject(OpenDialog1.FileName);
     265  end;
     266end;
     267
     268procedure TMainForm.AProjectSaveAsExecute(Sender: TObject);
     269begin
     270  if SaveDialog1.Execute then begin
     271    Project.SaveToFile(SaveDialog1.FileName);
     272  end;
     273end;
     274
     275procedure TMainForm.ComboBoxTargetSelectionChange(Sender: TObject);
    246276begin
    247277  ButtonCompileClick(Self);
    248278end;
    249279
    250 procedure TMainForm.ComboBoxTargetSelectionChange(Sender: TObject);
    251 begin
    252   ButtonCompileClick(Self);
    253 end;
    254 
    255280end.
  • branches/Transpascal/Forms/UProjectManager.pas

    r63 r66  
    1515    procedure TreeViewProjectChange(Sender: TObject; Node: TTreeNode);
    1616  private
    17     { private declarations }
     17    procedure UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup);
    1818  public
    19     { public declarations }
    20   end; 
     19    procedure UpdateProjectTree;
     20  end;
    2121
    2222var
     
    6969end;
    7070
     71procedure TProjectManager.UpdateProjectTree;
     72var
     73  NewNode: TTreeNode;
     74begin
     75  with MainForm, TreeViewProject, Items do begin
     76    BeginUpdate;
     77    Clear;
     78    NewNode := AddChild(nil, Project.Name);
     79    UpdateProjectGroup(NewNode, Project);
     80    NewNode.Expand(True);
     81    EndUpdate;
     82    TreeViewProject.TopItem.Items[0].Selected := True;
     83  end;
     84end;
     85
     86procedure TProjectManager.UpdateProjectGroup(Node: TTreeNode; Group: TProjectGroup);
     87var
     88  I: Integer;
     89  NewNode: TTreeNode;
     90begin
     91  with MainForm do
     92  for I := 0 to Group.Items.Count - 1 do begin
     93    NewNode := TreeViewProject.Items.AddChild(Node,
     94      TProjectNode(Group.Items[I]).Name);
     95    NewNode.Data := Pointer(Group.Items[I]);
     96    if TProjectNode(Group.Items[I]) is TProjectGroup then
     97      UpdateProjectGroup(NewNode, TProjectGroup(Group.Items[I]));
     98  end;
     99end;
     100
     101
     102
    71103end.
    72104
  • branches/Transpascal/Transpascal.lpi

    r65 r66  
    4646      </Item4>
    4747    </RequiredPackages>
    48     <Units Count="33">
     48    <Units Count="37">
    4949      <Unit0>
    5050        <Filename Value="Transpascal.lpr"/>
    5151        <IsPartOfProject Value="True"/>
    5252        <UnitName Value="Transpascal"/>
    53         <EditorIndex Value="13"/>
     53        <EditorIndex Value="14"/>
    5454        <WindowIndex Value="0"/>
    5555        <TopLine Value="4"/>
    56         <CursorPos X="45" Y="17"/>
    57         <UsageCount Value="171"/>
     56        <CursorPos X="45" Y="18"/>
     57        <UsageCount Value="173"/>
    5858        <Loaded Value="True"/>
    5959        <DefaultSyntaxHighlighter Value="Delphi"/>
     
    6666        <ResourceBaseClass Value="Form"/>
    6767        <UnitName Value="UMainForm"/>
     68        <IsVisibleTab Value="True"/>
    6869        <EditorIndex Value="10"/>
    6970        <WindowIndex Value="0"/>
    7071        <TopLine Value="1"/>
    71         <CursorPos X="22" Y="15"/>
    72         <UsageCount Value="171"/>
     72        <CursorPos X="77" Y="12"/>
     73        <UsageCount Value="173"/>
    7374        <Loaded Value="True"/>
    7475        <LoadedDesigner Value="True"/>
     
    8283        <TopLine Value="1"/>
    8384        <CursorPos X="1" Y="6"/>
    84         <UsageCount Value="171"/>
     85        <UsageCount Value="173"/>
    8586        <DefaultSyntaxHighlighter Value="Delphi"/>
    8687      </Unit2>
     
    216217        <EditorIndex Value="6"/>
    217218        <WindowIndex Value="0"/>
    218         <TopLine Value="126"/>
    219         <CursorPos X="6" Y="1"/>
    220         <UsageCount Value="43"/>
     219        <TopLine Value="212"/>
     220        <CursorPos X="1" Y="225"/>
     221        <UsageCount Value="45"/>
    221222        <Loaded Value="True"/>
    222223        <DefaultSyntaxHighlighter Value="Delphi"/>
     
    236237        <TopLine Value="1"/>
    237238        <CursorPos X="33" Y="1"/>
    238         <UsageCount Value="14"/>
     239        <UsageCount Value="15"/>
    239240        <Loaded Value="True"/>
    240241      </Unit21>
     
    246247        <TopLine Value="81"/>
    247248        <CursorPos X="20" Y="82"/>
    248         <UsageCount Value="12"/>
     249        <UsageCount Value="13"/>
    249250        <Loaded Value="True"/>
    250251      </Unit22>
     
    256257        <TopLine Value="173"/>
    257258        <CursorPos X="4" Y="192"/>
    258         <UsageCount Value="11"/>
     259        <UsageCount Value="12"/>
    259260        <Loaded Value="True"/>
    260261      </Unit23>
     
    262263        <Filename Value="Compiler\Analyze\UParser.pas"/>
    263264        <UnitName Value="UParser"/>
    264         <IsVisibleTab Value="True"/>
    265265        <EditorIndex Value="5"/>
    266266        <WindowIndex Value="0"/>
    267         <TopLine Value="1099"/>
    268         <CursorPos X="46" Y="1119"/>
    269         <UsageCount Value="12"/>
     267        <TopLine Value="495"/>
     268        <CursorPos X="43" Y="512"/>
     269        <UsageCount Value="13"/>
    270270        <Loaded Value="True"/>
    271271      </Unit24>
     
    286286        <EditorIndex Value="2"/>
    287287        <WindowIndex Value="0"/>
    288         <TopLine Value="31"/>
    289         <CursorPos X="15" Y="40"/>
    290         <UsageCount Value="27"/>
     288        <TopLine Value="71"/>
     289        <CursorPos X="20" Y="76"/>
     290        <UsageCount Value="29"/>
    291291        <Loaded Value="True"/>
    292292        <LoadedDesigner Value="True"/>
     
    303303        <TopLine Value="7"/>
    304304        <CursorPos X="32" Y="16"/>
    305         <UsageCount Value="27"/>
     305        <UsageCount Value="29"/>
    306306        <Loaded Value="True"/>
    307307        <LoadedDesigner Value="True"/>
     
    314314        <ResourceBaseClass Value="Form"/>
    315315        <UnitName Value="UMessagesForm"/>
    316         <EditorIndex Value="11"/>
     316        <EditorIndex Value="12"/>
    317317        <WindowIndex Value="0"/>
    318318        <TopLine Value="1"/>
    319319        <CursorPos X="36" Y="9"/>
    320         <UsageCount Value="27"/>
     320        <UsageCount Value="29"/>
    321321        <Loaded Value="True"/>
    322322        <LoadedDesigner Value="True"/>
     
    334334        <TopLine Value="5"/>
    335335        <CursorPos X="28" Y="21"/>
    336         <UsageCount Value="26"/>
     336        <UsageCount Value="28"/>
    337337        <Loaded Value="True"/>
    338338        <LoadedDesigner Value="True"/>
     
    345345        <ResourceBaseClass Value="Form"/>
    346346        <UnitName Value="UCodeTreeForm"/>
    347         <EditorIndex Value="12"/>
     347        <EditorIndex Value="13"/>
    348348        <WindowIndex Value="0"/>
    349349        <TopLine Value="1"/>
    350350        <CursorPos X="1" Y="1"/>
    351         <UsageCount Value="26"/>
     351        <UsageCount Value="28"/>
    352352        <Loaded Value="True"/>
    353353        <LoadedDesigner Value="True"/>
     
    361361        <TopLine Value="350"/>
    362362        <CursorPos X="3" Y="355"/>
    363         <UsageCount Value="12"/>
     363        <UsageCount Value="13"/>
    364364        <Loaded Value="True"/>
    365365      </Unit31>
     
    371371        <TopLine Value="316"/>
    372372        <CursorPos X="14" Y="329"/>
    373         <UsageCount Value="12"/>
     373        <UsageCount Value="13"/>
    374374        <Loaded Value="True"/>
    375375      </Unit32>
     376      <Unit33>
     377        <Filename Value="E:\Programy\Lazarus\lcl\include\customform.inc"/>
     378        <EditorIndex Value="11"/>
     379        <WindowIndex Value="0"/>
     380        <TopLine Value="1756"/>
     381        <CursorPos X="35" Y="1768"/>
     382        <UsageCount Value="10"/>
     383        <Loaded Value="True"/>
     384      </Unit33>
     385      <Unit34>
     386        <Filename Value="Common\URegistry.pas"/>
     387        <IsPartOfProject Value="True"/>
     388        <UnitName Value="URegistry"/>
     389        <UsageCount Value="21"/>
     390      </Unit34>
     391      <Unit35>
     392        <Filename Value="Common\ULastOpenedList.pas"/>
     393        <IsPartOfProject Value="True"/>
     394        <UnitName Value="ULastOpenedList"/>
     395        <UsageCount Value="21"/>
     396        <DefaultSyntaxHighlighter Value="Delphi"/>
     397      </Unit35>
     398      <Unit36>
     399        <Filename Value="UApplicationInfo.pas"/>
     400        <IsPartOfProject Value="True"/>
     401        <UnitName Value="UApplicationInfo"/>
     402        <UsageCount Value="20"/>
     403        <DefaultSyntaxHighlighter Value="Delphi"/>
     404      </Unit36>
    376405    </Units>
    377     <JumpHistory Count="30" HistoryIndex="26">
     406    <JumpHistory Count="30" HistoryIndex="29">
    378407      <Position1>
    379         <Filename Value="Compiler\Analyze\UParser.pas"/>
    380         <Caret Line="1074" Column="1" TopLine="1067"/>
     408        <Filename Value="UProject.pas"/>
     409        <Caret Line="163" Column="3" TopLine="160"/>
    381410      </Position1>
    382411      <Position2>
    383         <Filename Value="Compiler\Analyze\UParser.pas"/>
    384         <Caret Line="1075" Column="1" TopLine="1067"/>
     412        <Filename Value="UProject.pas"/>
     413        <Caret Line="140" Column="1" TopLine="136"/>
    385414      </Position2>
    386415      <Position3>
    387         <Filename Value="Compiler\Analyze\UParser.pas"/>
    388         <Caret Line="1076" Column="1" TopLine="1067"/>
     416        <Filename Value="UProject.pas"/>
     417        <Caret Line="225" Column="1" TopLine="212"/>
    389418      </Position3>
    390419      <Position4>
    391         <Filename Value="Compiler\Analyze\UParser.pas"/>
    392         <Caret Line="1077" Column="1" TopLine="1067"/>
     420        <Filename Value="UProject.pas"/>
     421        <Caret Line="138" Column="1" TopLine="125"/>
    393422      </Position4>
    394423      <Position5>
    395         <Filename Value="Compiler\Analyze\UParser.pas"/>
    396         <Caret Line="1078" Column="1" TopLine="1067"/>
     424        <Filename Value="UProject.pas"/>
     425        <Caret Line="139" Column="1" TopLine="125"/>
    397426      </Position5>
    398427      <Position6>
    399         <Filename Value="Compiler\Analyze\UParser.pas"/>
    400         <Caret Line="1089" Column="1" TopLine="1067"/>
     428        <Filename Value="UProject.pas"/>
     429        <Caret Line="143" Column="1" TopLine="125"/>
    401430      </Position6>
    402431      <Position7>
    403         <Filename Value="Compiler\USourceCode.pas"/>
    404         <Caret Line="723" Column="1" TopLine="710"/>
     432        <Filename Value="UProject.pas"/>
     433        <Caret Line="144" Column="1" TopLine="125"/>
    405434      </Position7>
    406435      <Position8>
    407         <Filename Value="Compiler\Analyze\UParser.pas"/>
    408         <Caret Line="1074" Column="1" TopLine="1067"/>
     436        <Filename Value="Forms\UMainForm.pas"/>
     437        <Caret Line="192" Column="47" TopLine="186"/>
    409438      </Position8>
    410439      <Position9>
    411         <Filename Value="Compiler\Analyze\UParser.pas"/>
    412         <Caret Line="1075" Column="1" TopLine="1067"/>
     440        <Filename Value="Forms\UMainForm.pas"/>
     441        <Caret Line="193" Column="35" TopLine="186"/>
    413442      </Position9>
    414443      <Position10>
    415         <Filename Value="Compiler\Analyze\UParser.pas"/>
    416         <Caret Line="1076" Column="1" TopLine="1067"/>
     444        <Filename Value="Forms\UMainForm.pas"/>
     445        <Caret Line="56" Column="30" TopLine="39"/>
    417446      </Position10>
    418447      <Position11>
    419         <Filename Value="Compiler\Analyze\UParser.pas"/>
    420         <Caret Line="1077" Column="1" TopLine="1067"/>
     448        <Filename Value="Forms\UMainForm.pas"/>
     449        <Caret Line="15" Column="40" TopLine="1"/>
    421450      </Position11>
    422451      <Position12>
    423         <Filename Value="Compiler\Analyze\UParser.pas"/>
    424         <Caret Line="1079" Column="1" TopLine="1067"/>
     452        <Filename Value="Forms\UMainForm.pas"/>
     453        <Caret Line="9" Column="60" TopLine="1"/>
    425454      </Position12>
    426455      <Position13>
    427         <Filename Value="Compiler\Analyze\UParser.pas"/>
    428         <Caret Line="1080" Column="1" TopLine="1067"/>
     456        <Filename Value="Forms\UMainForm.pas"/>
     457        <Caret Line="56" Column="20" TopLine="47"/>
    429458      </Position13>
    430459      <Position14>
    431         <Filename Value="Compiler\Analyze\UParser.pas"/>
    432         <Caret Line="1081" Column="1" TopLine="1067"/>
     460        <Filename Value="Forms\UMainForm.pas"/>
     461        <Caret Line="15" Column="31" TopLine="1"/>
    433462      </Position14>
    434463      <Position15>
    435         <Filename Value="Compiler\Analyze\UParser.pas"/>
    436         <Caret Line="1094" Column="1" TopLine="1075"/>
     464        <Filename Value="Forms\UMainForm.pas"/>
     465        <Caret Line="201" Column="17" TopLine="188"/>
    437466      </Position15>
    438467      <Position16>
    439         <Filename Value="Compiler\Analyze\UParser.pas"/>
    440         <Caret Line="1160" Column="1" TopLine="1147"/>
     468        <Filename Value="Forms\UMainForm.pas"/>
     469        <Caret Line="15" Column="3" TopLine="1"/>
    441470      </Position16>
    442471      <Position17>
    443         <Filename Value="Compiler\Analyze\UParser.pas"/>
    444         <Caret Line="1085" Column="13" TopLine="1072"/>
     472        <Filename Value="Forms\UMainForm.pas"/>
     473        <Caret Line="184" Column="44" TopLine="171"/>
    445474      </Position17>
    446475      <Position18>
    447         <Filename Value="Compiler\Analyze\UParser.pas"/>
    448         <Caret Line="1079" Column="1" TopLine="1072"/>
     476        <Filename Value="Forms\UMainForm.pas"/>
     477        <Caret Line="191" Column="26" TopLine="178"/>
    449478      </Position18>
    450479      <Position19>
    451         <Filename Value="Compiler\Analyze\UParser.pas"/>
    452         <Caret Line="1080" Column="1" TopLine="1072"/>
     480        <Filename Value="Forms\UMainForm.pas"/>
     481        <Caret Line="198" Column="32" TopLine="184"/>
    453482      </Position19>
    454483      <Position20>
    455         <Filename Value="Compiler\Analyze\UParser.pas"/>
    456         <Caret Line="1081" Column="1" TopLine="1063"/>
     484        <Filename Value="Forms\UMainForm.pas"/>
     485        <Caret Line="190" Column="17" TopLine="180"/>
    457486      </Position20>
    458487      <Position21>
    459         <Filename Value="Compiler\Analyze\UParser.pas"/>
    460         <Caret Line="1086" Column="25" TopLine="1077"/>
     488        <Filename Value="Forms\UMainForm.pas"/>
     489        <Caret Line="60" Column="47" TopLine="42"/>
    461490      </Position21>
    462491      <Position22>
    463         <Filename Value="Compiler\Analyze\UParser.pas"/>
    464         <Caret Line="1079" Column="1" TopLine="1074"/>
     492        <Filename Value="Forms\UMainForm.pas"/>
     493        <Caret Line="65" Column="45" TopLine="47"/>
    465494      </Position22>
    466495      <Position23>
    467         <Filename Value="Compiler\Analyze\UParser.pas"/>
    468         <Caret Line="1080" Column="1" TopLine="1074"/>
     496        <Filename Value="Forms\UMainForm.pas"/>
     497        <Caret Line="255" Column="12" TopLine="246"/>
    469498      </Position23>
    470499      <Position24>
    471         <Filename Value="Compiler\Analyze\UParser.pas"/>
    472         <Caret Line="1081" Column="1" TopLine="1074"/>
     500        <Filename Value="Forms\UMainForm.pas"/>
     501        <Caret Line="223" Column="38" TopLine="217"/>
    473502      </Position24>
    474503      <Position25>
    475         <Filename Value="Compiler\Analyze\UParser.pas"/>
    476         <Caret Line="1088" Column="1" TopLine="1074"/>
     504        <Filename Value="Forms\UMainForm.pas"/>
     505        <Caret Line="246" Column="45" TopLine="233"/>
    477506      </Position25>
    478507      <Position26>
    479         <Filename Value="Compiler\Analyze\UParser.pas"/>
    480         <Caret Line="1090" Column="1" TopLine="1074"/>
     508        <Filename Value="Forms\UMainForm.pas"/>
     509        <Caret Line="245" Column="44" TopLine="233"/>
    481510      </Position26>
    482511      <Position27>
    483         <Filename Value="Compiler\Analyze\UParser.pas"/>
    484         <Caret Line="1091" Column="1" TopLine="1074"/>
     512        <Filename Value="Forms\UMainForm.pas"/>
     513        <Caret Line="63" Column="40" TopLine="45"/>
    485514      </Position27>
    486515      <Position28>
    487         <Filename Value="Compiler\Analyze\UParser.pas"/>
    488         <Caret Line="1102" Column="21" TopLine="1092"/>
     516        <Filename Value="Forms\UMainForm.pas"/>
     517        <Caret Line="247" Column="1" TopLine="233"/>
    489518      </Position28>
    490519      <Position29>
    491         <Filename Value="Compiler\USourceCode.pas"/>
    492         <Caret Line="192" Column="4" TopLine="173"/>
     520        <Filename Value="Forms\UMainForm.pas"/>
     521        <Caret Line="230" Column="39" TopLine="213"/>
    493522      </Position29>
    494523      <Position30>
    495         <Filename Value="Compiler\USourceCode.pas"/>
    496         <Caret Line="193" Column="16" TopLine="180"/>
     524        <Filename Value="Compiler\Analyze\UParser.pas"/>
     525        <Caret Line="507" Column="31" TopLine="495"/>
    497526      </Position30>
    498527    </JumpHistory>
     
    502531    <PathDelim Value="\"/>
    503532    <SearchPaths>
    504       <OtherUnitFiles Value="Forms"/>
     533      <OtherUnitFiles Value="Forms;Common"/>
    505534      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    506535    </SearchPaths>
  • branches/Transpascal/Transpascal.lpr

    r62 r66  
    99  Forms, CoolDocking, Interfaces, SysUtils,
    1010  UMainForm in 'UMainForm.pas' {MainForm},
    11   UTextSource in 'UTextSource.pas', UProject, TranspascalCompiler,
    12 UProjectManager, UCodeForm, UMessagesForm, UCompiledForm, UCodeTreeForm;
     11  UTextSource in 'UTextSource.pas', UProject, UApplicationInfo, URegistry,
     12  ULastOpenedList, TranspascalCompiler, UProjectManager, UCodeForm,
     13  UMessagesForm, UCompiledForm, UCodeTreeForm;
    1314
    1415{$R *.res}
  • branches/Transpascal/UProject.pas

    r60 r66  
    66
    77uses
    8   Classes, SysUtils, Contnrs, Dialogs;
     8  Classes, SysUtils, Contnrs, Dialogs, DOM, XMLWrite, XMLRead;
    99
    1010type
     
    1515    Parent: TProjectNode;
    1616    Name: string;
     17    procedure SaveToXMLNode(Node: TDOMNode); virtual;
     18    procedure LoadFromXMLNode(Node: TDOMNode); virtual;
    1719    procedure Load; virtual;
    1820    procedure Save; virtual;
     
    2628    constructor Create;
    2729    destructor Destroy; override;
     30    procedure SaveToXMLNode(Node: TDOMNode); override;
     31    procedure LoadFromXMLNode(Node: TDOMNode); override;
    2832    procedure Load; override;
    2933    procedure Save; override;
     
    3842    procedure Load; override;
    3943    procedure Save; override;
     44    procedure SaveToXMLNode(Node: TDOMNode); override;
     45    procedure LoadFromXMLNode(Node: TDOMNode); override;
    4046    function SearchFile(FileName: string): TProjectFile;
    4147  end;
     
    4349  TProject = class(TProjectGroup)
    4450    RootDir: string;
     51    procedure LoadFromFile(FileName: string);
     52    procedure SaveToFile(FileName: string);
    4553    function GetDir(IncludeRoot: Boolean = False): string; override;
     54    procedure Load; override;
     55    procedure Save; override;
     56    procedure SaveToXMLNode(Node: TDOMNode); override;
     57    procedure LoadFromXMLNode(Node: TDOMNode); override;
     58    procedure Clear;
    4659  end;
    4760
     
    7790  for I := 0 to Items.Count - 1 do
    7891    TProjectNode(Items[I]).Save;
     92end;
     93
     94procedure TProjectGroup.SaveToXMLNode(Node: TDOMNode);
     95begin
     96  inherited SaveToXMLNode(Node);
    7997end;
    8098
     
    111129end;
    112130
     131procedure TProjectFile.SaveToXMLNode(Node: TDOMNode);
     132begin
     133  inherited SaveToXMLNode(Node);
     134end;
     135
     136procedure TProjectFile.LoadFromXMLNode(Node: TDOMNode);
     137begin
     138  inherited LoadFromXMLNode(Node);
     139  Load;
     140end;
     141
    113142procedure TProjectFile.Load;
    114143begin
     
    125154{ TProjectNode }
    126155
     156procedure TProjectNode.SaveToXMLNode(Node: TDOMNode);
     157begin
     158
     159end;
     160
     161procedure TProjectNode.LoadFromXMLNode(Node: TDOMNode);
     162begin
     163  Name := UTF8Encode(string(TDOMElement(Node).GetAttribute('Name')));
     164end;
     165
    127166procedure TProjectNode.Load;
    128167begin
     
    143182{ TProject }
    144183
     184procedure TProject.LoadFromFile(FileName: string);
     185var
     186  Doc: TXMLDocument;
     187  NewNode: TDOMNode;
     188  NewSubNode: TDOMNode;
     189  I: Integer;
     190  Text: string;
     191begin
     192  try
     193    Clear;
     194    RootDir := ExtractFileDir(FileName) + '/';
     195    Name := ExtractFileName(FileName);
     196    Name := Copy(Name, 1, Length(Name) - Length(ExtractFileExt(FileName)));
     197
     198    ReadXMLFile(Doc, UTF8Decode(FileName));
     199
     200    NewNode := Doc.DocumentElement.FindNode('Files');
     201    if Assigned(NewNode) then
     202      LoadFromXMLNode(NewNode);
     203  finally
     204    Doc.Free;
     205  end;
     206end;
     207
     208procedure TProjectGroup.LoadFromXMLNode(Node: TDOMNode);
     209var
     210  Child: TDOMNode;
     211  ProjectNode: TProjectNode;
     212  NodeType: string;
     213begin
     214  Name := UTF8Encode(TDOMElement(Node).GetAttribute('Name'));
     215  Child := Node.FirstChild;
     216  while Assigned(Child) do begin
     217    NodeType := TDOMElement(Child).GetAttribute('Type');
     218    if NodeType = 'Folder' then
     219      ProjectNode := TProjectGroup.Create
     220    else if NodeType = 'File' then
     221      ProjectNode := TProjectFile.Create
     222    else ProjectNode := nil;
     223    if Assigned(ProjectNode) then begin
     224      ProjectNode.Parent := Self;
     225      ProjectNode.LoadFromXMLNode(Child);
     226      Items.Add(ProjectNode);
     227    end;
     228
     229    Child := Child.NextSibling;
     230  end;
     231end;
     232
     233procedure TProject.SaveToFile(FileName: string);
     234begin
     235
     236end;
     237
    145238function TProject.GetDir(IncludeRoot: Boolean): string;
    146239begin
     
    148241end;
    149242
     243procedure TProject.Load;
     244begin
     245  inherited Load;
     246end;
     247
     248procedure TProject.Save;
     249begin
     250  inherited Save;
     251end;
     252
     253procedure TProject.SaveToXMLNode(Node: TDOMNode);
     254begin
     255  inherited SaveToXMLNode(Node);
     256end;
     257
     258procedure TProject.LoadFromXMLNode(Node: TDOMNode);
     259begin
     260  inherited LoadFromXMLNode(Node);
     261end;
     262
     263procedure TProject.Clear;
     264begin
     265  Items.Clear;
     266end;
     267
    150268end.
    151269
Note: See TracChangeset for help on using the changeset viewer.