I am making a sample by exploring nopcommerce 1.9. I saw two things which i cannot understand First, I am not seeing "NopModel.Designer.cs" file in NopCommerce project and second t4 templates, how to generate these files?
You usually don't see the designer file associated with the EDMX file. If you want to view the XML code that is contained in the EDMX you can right click on it in the solution explorer and choose "Open With..." and then choose "Automatic Editor Selector (XML)" and it will let you view the XML code that is generated by VS when you add/create the EDMX file.
I don't believe that editing this code is suggested, as it is generated by VS and can be re-generated again for certain reasons which will wipe out any code that you may put there. Also if you change some code there it may break something.
I don't know why you're wanting T4 templates, but you can start here:
How to create a simple T4 template
Related
I have deveoped a custom file type, together with a custom editor (basically a tree with several data pages attached and a few extra buttons). OK, I can run it stand alone and that is fine, and even add it to the tools menu, but I would like to integrate it into the Delphi IDE so that my custom editor (or a similar new version) appears in the IDE, rather like a DFM file has a custom editor. I can find references to most extensions in the Delphi IDE, but not this one. Any guiding hands? Note that this is not a property or component editor (the file type has nothing to do with either of these) nor is it simply syntax highlighting of a text file.
AFAIK it currently isn't possible to reliably integrate a custom editor into the Delphi IDE. The required API simply isn't there. See QC89028 Custom Module support.
During the Delphi 2010 and XE betas I spent most my spare time trying to get a resource editor integrated. Although the effort had the official blessing of Embarcadero and got some, half hearted, support from the IDE engineer, I was never able to get them to deliver on their promises and surface the module API. I eventually abandoned the project.
Update: I've now checked my old correspondence regarding this and it turns out part of the problem was that IOTAModuleCreator (used to implement File|New for custom file types) and IOTAEditorContent (used to transfer data to/from the custom module) only supports text data. Binary data gets mangled.
You can probably do this via an IDE plugin that uses the ToolsAPI (see ToolsAPI.pas in the IDE's source folder (e.g. Program Files (x86)\Embarcadero\Studio\source\ToolsAPI\ToolsAPI.pas.)
For information on writing a plugin in general, see David G Hoyle's excellent blog. Once you know the basics - i.e., write a 'wizard' and get it to do something - you will need to work on integrating your editor.
I have never done this, and so I can't guarantee it is possible. However, some interfaces that look worth investigating and implementing are INTACustomEditorView, which represents a 'view' (file tab when that file is open - think the code editor, Welcome view, type library editor, etc) and IOTAEditorViewServices, to register your custom view. I do not know how you associate a view type with a file type, sorry - possibly something to do with the personality interfaces. You might also be interested in INTACustomEditorSubView which is what creates a tab on the bottom of a file.
Good luck, and if you find a solution please write here so that other people can learn too!
Different Delphi versions (in my case 2007, XE and XE2) seem to use the same code-template repository, such as ..\Documents\RAD Studio\code_templates. Since XE2 uses namespaced units, this causes problems when one have to use a unit name in a template.
For instance I have a template when I write winbeep which completes to windows.Beep(300, 100); and selects and stops on frequency etc.. This does not compile on XE2 unless I remove the Winapi. part of the Windows unit in the uses clause (or of course add the prefix manually). I have to have the unit name because otherwise SysUtils.Beep gets referred.
I couldn't find an option entry or a registry key or an environment variable specifying the place of the templates. It is not even related to BDSUSERDIR, in fact I don't even have a directory in my computer having the path of BDSUSERDIR (which is ..\Documents\RAD Studio\9.0). Is this my oversight and in fact there's an option to relocate code templates? If not, is it possible to make the IDE use unit aliases in uses clause for new forms?
edit:
Here it is stated that (emphasis by me) "Templates that you create (and templates provided by third party add-ins) are saved by default in the \My Documents\RAD Studio\code templates\ directory." That would imply there should be way to save them in a non-default place. But the article does not mention how.
You can put your templates in "Delphi installation folder"\ObjRepos\en\Code_Templates to make them visible only on one Delphi version.
Edit
As Sertac points out in the comments, Template libraries are related to project templates, not code templates. Leaving this answer in place because it may help people looking for ways to structure / share / split their project template repositories.
In Delphi XE2 you have a "Template libraries" option under the "Tools" menu. When you open that, you get this dialog:
The "Add" button allows you to add a folder, the "Properties" button allows you to view and manage the contents of that repository.
So it would seem to me that you can simply copy the template library, change it XE2 specific stuff, and then point XE2 to its own repository. Or you could do that only for the templates that require specific XE2 unit handling.
While I was using D2007 I've really got used to Project > Project Page Options feature to keep and view some free-form project notes, external references (these almost never being comfortably viewable in built-in HTML designer) etc. Now I have Delphi XE and Project Page Options is missing from Project menu, moreover, projpageide150.bpl mentioned in the documentation is not present in bin directory. How do i fix it? I'm really finding ability to view (not edit!) HTML documents in the IDE a very convenient feature.
It looks like it was dropped but has been re-instated. In my XE2 installation the projpageide160.bpl file is there, as is the Project | Project Page options menu. Neither are present in my D2010 installation.
Are there examples and resources (source code and documentation) available which show how a 'New xyz Application' or 'New xyz Document' wizard can be created with Delphi which then will appear in the new project / new file dialog of the Delphi IDE?
What I want to do: for some of my libraries I would like to add a new project type and a new file type to the IDE dialogs, which will guide the developer through a wizard and then create some customized auto-generated source code.
So far I found this short overview:
Experts and Wizards in Delphi
And this article
OTA: Visual design of Wizards
Note that this question is not about wizard or GUI creation in general but on how the Delphi IDE can be extended to include my own new project / file type dialogs. The new project and file types should appear in the new file or new project type dialog in the matching category (or even a new one).
The source code for the "Visual design of Wizards" article is here.
That code in itself is an example of what you're asking for, but it can also be used to create your "creators" by writing less code and designing more in the IDE object inspector.
Basically, to have a new source file item for Delphi's "New Items" dialog you need to implement IOTAModuleCreator ; for a new project item you need to implement IOTAProjectCreator. You can even implement IOTAProjectGroupCreator to add an item which will create a whole project group with several projects at once.
Your implementors of these interfaces should generate the source code and return it to the IDE via an implementation of IOTAFile interface. ToolsAPI already contains TOTAFile class which you can easily use by passing it a string of the whole contents of the new file. This will create an unnamed file in memory which the user can then save to hard disk and give it a file name.
You can also find more information by following the links in Zarko's article.
Also see the ToolsAPI unit where the interfaces are declared. There are also some explanations in the comments.
You can try the JvWizard from the JVCL Components.
you can check an example of use here (translated page)
alt text http://vingrad.ru/blogs/bose/files/2008/12/image26.png
Bye.
Is there a rule of thumb that .pas, .dfm and .dpr files should not be removed?
While opening/working with concerned project files ,Unit1.pas,Form1,Unit1.dpr etc are automatically created by the IDE in the same project-folder.As they were not related to my proj,I inadvertently deleted them.Will that cause any issue?
Further should the same project be saved with a new name every time one saves it?
Like PfojDel.dpr
edit then save as PfojDel1.dpr
edit then save as PfojDel2.dpr etc
Kindly help
Thanks and Regards
Vas
Your first question's pretty straightforward. Any file that you need to compile into your project needs to be present on the disc. Anything else can go.
As for changing your project file name, that's a big hassle. Sounds like you're trying to keep a history of your changes. If so, I'd look into version control if I were you. TortoiseSVN makes it pretty easy to create a simple source code repository, either on your own hard drive or a networked system, that you can check changes into to keep a history.
See http://delphi.about.com/od/beginners/a/aa032800a.htm for an explanation on all most file extensions you come across when developing a Delphi application.
The dfm file contains the component information for the form (or data module). The dpr is the basic pascal program file. It is also the base of the project (normally contains the list of files in the project).
Deleting them is not a disaster, but you need some time to recreate them (specially if the form is big). But if you have the choice, do not delete them.
The dfm files are created because they contain the information you provide with the form designer (position of controls and the value of their published properties).
If you have renamed your project, you can delete the other files without problem. This is also true for units that are not used anymore.
You don't have to use a different name every time you save the project. If you want to keep track of changes, use source control. (Every wise programmer should use source control and backup the files frequently).
Under normal circumstances you shouldn't have any Unit1/Form1 files on your system. The first time you save/compile/run a project with a new file the IDE will prompt you for the filename and location.
If you have a file named Unit1/Form1 then it would indicate that you have a unit or form which hasn't been given a name, but it may still be used as part of your project. If it is used as part of your project then it is not safe to delete it. The only way to know if is used is to go through each of the uses clauses in your project, or to use an automated tool to do this for you.