Changeset 48


Ignore:
Timestamp:
Mar 4, 2012, 4:28:12 PM (12 years ago)
Author:
chronos
Message:
  • Added: New project and files templates.
Location:
trunk/IDE
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/IDE/Forms/UFormMain.lfm

    r45 r48  
    629629    object AProjectNew: TAction
    630630      Category = 'Project'
    631       Caption = 'New'
     631      Caption = 'New...'
    632632      Hint = 'Create new project'
    633633      ImageIndex = 10
  • trunk/IDE/Forms/UFormMain.lrt

    r45 r48  
    1616TFORMMAIN.MENUITEM22.CAPTION=-
    1717TFORMMAIN.MENUITEM9.CAPTION=Help
    18 TFORMMAIN.APROJECTNEW.CAPTION=New
     18TFORMMAIN.APROJECTNEW.CAPTION=New...
    1919TFORMMAIN.APROJECTNEW.HINT=Create new project
    2020TFORMMAIN.APROJECTOPEN.CAPTION=Open...
  • trunk/IDE/Forms/UFormMain.pas

    r47 r48  
    141141  private
    142142    LastOpenedFiles: TLastOpenedList;
     143    procedure ProjectTemplatesInit;
    143144    procedure CompilerDebugLog(Text: string);
    144145    procedure MenuItemTargetClick(Sender: TObject);
     
    153154    LogParsing: Boolean;
    154155    Project: TProject;
     156    ProjectTemplates: TProjectTemplateList;
    155157    TargetProject: TProject;
    156158    Compiler: TCustomCompiler;
     
    169171uses
    170172  UFormMessages, UFormSourceCode, UFormProject, UCommon, UFormAbout, UFormOptions,
    171   UFormTargets, UTarget, UAnalyzer, UProducer, UExecutor;
     173  UFormTargets, UTarget, UAnalyzer, UProducer, UExecutor, UFormProjectNew,
     174  UProjectTemplates;
    172175
    173176resourcestring
     
    239242      Compiler.Compile;
    240243    end;
    241     //FormProject.TreeViewProjectChange(Self, FormProject.TreeViewProject.Selected);
     244    FormProject.TreeViewProjectChange(Self, FormProject.TreeViewProject.Selected);
    242245    FormMessages.Reload;
    243246end;
     
    483486  Compiler := TCustomCompiler.Create;
    484487  Project := TProject.Create;
     488  ProjectTemplates := TProjectTemplateList.Create;
    485489  TargetProject := TProject.Create;
    486490  LastOpenedFiles := TLastOpenedList.Create;
     
    491495procedure TFormMain.FormDestroy(Sender: TObject);
    492496begin
     497  ProjectTemplates.Free;
    493498  LastOpenedFiles.Free;
    494499  TargetProject.Free;
     
    497502end;
    498503
     504procedure TFormMain.ProjectTemplatesInit;
     505begin
     506  ProjectTemplates.AddTemplate(TProjectTemplateConsoleApp.Create);
     507  ProjectTemplates.AddTemplate(TProjectTemplateGUIApp.Create);
     508  ProjectTemplates.AddTemplate(TProjectTemplatePackage.Create);
     509  ProjectTemplates.AddTemplate(TProjectTemplateUnit.Create);
     510end;
     511
    499512procedure TFormMain.CompilerDebugLog(Text: string);
    500513begin
     
    514527  LoadFromRegistry(RegistryRootKey, ApplicationInfo.RegistryKey);
    515528  DockInit;
     529  ProjectTemplatesInit;
    516530
    517531  if ReopenLastOpenedFile and (LastOpenedFiles.Count > 0) then begin
     
    560574  NewFile: TProjectFile;
    561575begin
    562   AProjectClose.Execute;
    563   Project.Active := True;
    564   Project.FileName := SNewProject;
    565   Project.Files.AddFile('Unit1.pas');
     576  if FormProjectNew.ShowModal = mrOk then begin
     577    if Assigned(FormProjectNew.ListView1.Selected) then
     578      TProjectTemplate(FormProjectNew.ListView1.Selected.Data).InitProject(Project);
     579  end;
    566580  UpdateInterface;
    567581end;
  • trunk/IDE/Languages/Transpascal.cs.po

    r45 r48  
    139139
    140140#: tformmain.aprojectnew.caption
     141#| msgid "New"
    141142msgctxt "tformmain.aprojectnew.caption"
    142 msgid "New"
    143 msgstr "Nový"
     143msgid "New..."
     144msgstr "Nový..."
    144145
    145146#: tformmain.aprojectnew.hint
     
    400401msgid "Project manager"
    401402msgstr "Správce projektu"
     403
     404#: tformprojectnew.buttoncancel.caption
     405msgctxt "tformprojectnew.buttoncancel.caption"
     406msgid "Cancel"
     407msgstr "Zrušit"
     408
     409#: tformprojectnew.buttonok.caption
     410msgctxt "tformprojectnew.buttonok.caption"
     411msgid "Ok"
     412msgstr "Ok"
     413
     414#: tformprojectnew.caption
     415msgid "New item"
     416msgstr "Nová položka"
    402417
    403418#: tformsourcecode.caption
     
    762777msgstr "Nový projekt"
    763778
     779#: uproject.snewproject
     780msgctxt "uproject.snewproject"
     781msgid "New project"
     782msgstr "Nový projekt"
     783
  • trunk/IDE/Languages/Transpascal.po

    r45 r48  
    132132#: tformmain.aprojectnew.caption
    133133msgctxt "TFORMMAIN.APROJECTNEW.CAPTION"
    134 msgid "New"
     134msgid "New..."
    135135msgstr ""
    136136
     
    393393msgstr ""
    394394
     395#: tformprojectnew.buttoncancel.caption
     396msgctxt "TFORMPROJECTNEW.BUTTONCANCEL.CAPTION"
     397msgid "Cancel"
     398msgstr ""
     399
     400#: tformprojectnew.buttonok.caption
     401msgctxt "TFORMPROJECTNEW.BUTTONOK.CAPTION"
     402msgid "Ok"
     403msgstr ""
     404
     405#: tformprojectnew.caption
     406msgid "New item"
     407msgstr ""
     408
    395409#: tformsourcecode.caption
    396410msgctxt "TFORMSOURCECODE.CAPTION"
     
    753767msgstr ""
    754768
     769#: uproject.snewproject
     770msgctxt "uproject.snewproject"
     771msgid "New project"
     772msgstr ""
     773
  • trunk/IDE/Transpascal.lpi

    r46 r48  
    106106      </Item7>
    107107    </RequiredPackages>
    108     <Units Count="14">
     108    <Units Count="16">
    109109      <Unit0>
    110110        <Filename Value="Transpascal.lpr"/>
     
    201201        <UnitName Value="UFormCompilerSettings"/>
    202202      </Unit13>
     203      <Unit14>
     204        <Filename Value="Forms\UFormProjectNew.pas"/>
     205        <IsPartOfProject Value="True"/>
     206        <ComponentName Value="FormProjectNew"/>
     207        <ResourceBaseClass Value="Form"/>
     208        <UnitName Value="UFormProjectNew"/>
     209      </Unit14>
     210      <Unit15>
     211        <Filename Value="UProjectTemplates.pas"/>
     212        <IsPartOfProject Value="True"/>
     213        <UnitName Value="UProjectTemplates"/>
     214      </Unit15>
    203215    </Units>
    204216  </ProjectOptions>
  • trunk/IDE/Transpascal.lpr

    r45 r48  
    1212UFormSourceCode, UFormMessages,
    1313  UFormTargetCode, UFormCodeTree, TemplateGenerics, CoolTranslator, Common,
    14   UFormAbout, UFormOptions, UFormTargets, UFormCompilerSettings;
     14  UFormAbout, UFormOptions, UFormTargets, UFormCompilerSettings,
     15UFormProjectNew, UProjectTemplates;
    1516
    1617{$R *.res}
     
    4041  Application.CreateForm(TFormCompilerSettings, FormCompilerSettings);
    4142  Application.CreateForm(TFormTargets, FormTargets);
     43  Application.CreateForm(TFormProjectNew, FormProjectNew);
    4244  Application.Run;
    4345end.
  • trunk/IDE/UProject.pas

    r47 r48  
    6565    procedure LoadFromXMLNode(Node: TDOMNode);
    6666    function SearchFile(FileName: string): TProjectFile;
    67     procedure AddFile(FileName: string);
     67    function AddFile(FileName: string): TProjectFile;
    6868  end;
    6969
     
    9191  end;
    9292
     93  { TProjectTemplate }
     94
     95  TProjectTemplate = class
     96    Name: string;
     97    Description: TStringList;
     98    procedure InitProject(Project: TProject); virtual;
     99    constructor Create; virtual;
     100    destructor Destroy; override;
     101  end;
     102
     103  { TProjectTemplateList }
     104
     105  TProjectTemplateList = class(TListObject)
     106    procedure AddTemplate(Template: TProjectTemplate);
     107  end;
     108
     109
    93110implementation
    94111
     112resourcestring
     113  SNewProject = 'New project';
     114
     115{ TProjectTemplateList }
     116
     117procedure TProjectTemplateList.AddTemplate(Template: TProjectTemplate);
     118begin
     119  Add(Template);
     120end;
     121
     122{ TProjectTemplate }
     123
     124procedure TProjectTemplate.InitProject(Project: TProject);
     125begin
     126  Project.Active := False;
     127  Project.Active := True;
     128  Project.FileName := SNewProject;
     129end;
     130
     131constructor TProjectTemplate.Create;
     132begin
     133  Description := TStringList.Create;
     134end;
     135
     136destructor TProjectTemplate.Destroy;
     137begin
     138  Description.Free;
     139  inherited Destroy;
     140end;
     141
    95142{ TProjectPackageList }
    96143
     
    114161
    115162end;
    116 
    117 
    118163
    119164{ TProjectGroup }
     
    184229end;
    185230
    186 procedure TProjectFileList.AddFile(FileName: string);
    187 var
    188   NewFile: TProjectFile;
    189 begin
    190   NewFile := TProjectFile(AddNew(TProjectFile.Create));
    191   NewFile.Parent := Parent;
    192   NewFile.FileName := FileName;
     231function TProjectFileList.AddFile(FileName: string): TProjectFile;
     232begin
     233  Result := TProjectFile(AddNew(TProjectFile.Create));
     234  Result.Parent := Parent;
     235  Result.FileName := FileName;
    193236end;
    194237
     
    234277      FileName := UTF8Encode(NewNode.TextContent);
    235278  end;
    236   if FileExistsUTF8(FileName) then Load;
     279  if FileExistsUTF8(ExtractFileDir(Parent.FileName) + DirectorySeparator + FileName) then Load;
    237280end;
    238281
Note: See TracChangeset for help on using the changeset viewer.