質問

Using Netbeans 7.4, what I would like to do is create a template that is a module folder structure. This can then also contain files (not a must but would be nice)

Thus, if I click on a current folder in a project, I would like to select a Module Template, and have NetBeans create the folder structure.

As an example (coding in PHP, in a Magento project) I create lots of new magento modules daily.

I would simply like to be able to create the entire (base) folder structure via netbeans for a new module

Parent folder/Module_Name/
Parent folder/Module_Name/Block
Parent folder/Module_Name/Model
Parent folder/Module_Name/controllers
Parent folder/Module_Name/etc

and so forth. I currently have to create them one by one using New->folder which is very tedious to do so often.

Is this possible? (I would hope something akin to a new file template would exist)

役に立ちましたか?

解決

I have managed to add this functionality by creating a new plugin. I hacked together the plugin using several tutorials on the subject:

File templates https://platform.netbeans.org/tutorials/nbm-filetemplates.html

New Wizard https://platform.netbeans.org/tutorials/691/nbm-wizard.html

Basically the plugin has a global options panel, that will allow you to choose the location of a zip file.

Then you can right click a folder in your project and do New -> Other -> Directory Structure.

The wizard will ask for a name to be used as the parent folder to extract the zip into.

Using a zip is useful because it not only can setup the directory structure but it can also populate files that are used on a regular basis.

For me I build Symfony 2 applications and i am constantly creating new bundles so my zip contains:

  • Controller
    • DefaultController.php
  • Entity
    • Default.php
  • Form
    • DefaultForm.php
  • Resources
    • views
      • Default
        • index.html.twig
        • create.html.twig
        • view.html.twig
        • edit.html.twig
        • delete.html.twig

You dont have to include files in the zip it can purely be folder structure though.

I have published the source as a public repo on github: https://github.com/chasen/NBCustomDirectoryStructurePlugin

他のヒント

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top