When you right click in a folder, Eclipse pops up a context menu that allows you to create different kinds of files. I'd like to add an option to add a kind of file of my own (with some constant data I'll want to put there). Is there an easy way to do it?
To import a code template: Click Import to open the "Import Templates" browser. Select the relevant XML file containing the template information. Click Open.
The Templates Preferences page is accessed from Window | Preferences | PHP | Templates . To remove a template from the list of available options, unmark its checkbox in the list. To edit an existing template, select it from the list and click Edit.
Well, I know of two ways (one tested and of other I am not sure) in which you can extend the Default new submenu
of package explorers popup menu.
The short, working and tested way is to use org.eclipse.ui.perspectiveExtensions
.
>>Note: You will need a wizard to contribute to the Default new submenu
of package explorers popup menu. You can do this using this link eSpeed development with Eclipse wizards (the same one provided by @Ed Burnette)
Steps to follow:
testwizard.wizards.TestWizard
.org.eclipse.ui.perspectiveExtensions
. For this example I am just contributing to the Java development perspective. You can have multiple instance of it for different perspectives. Therefore, the targetId is org.eclipse.jdt.ui.JavaPerspective
.testwizard.wizards.TestWizard
in my case.>>Plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.newWizards">
<category
name="Test Wizards"
id="TestWizard">
</category>
<wizard
name="HTML Test Wizard"
icon="icons/sample.gif"
category="TestWizard"
class="testwizard.wizards.TestWizard"
id="testwizard.wizards.TestWizard">
</wizard>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaPerspective">
<newWizardShortcut
id="testwizard.wizards.TestWizard">
</newWizardShortcut>
</perspectiveExtension>
</extension>
</plugin>
>>Output
The long and untested way is to use org.eclipse.ui.navigator.navigatorContent
. And I am not sure whether it will work or not. Providing it just for reading and exploration purpose
Use these links:
In the end I will suggest you to use first approach as it is simple and elegant. Read and use second method if you are writing a new perspective, view etc.
Hope this helps.
You need to create an Eclipse plug-in and create a New File wizard. There's a great tutorial on how to do it over on developerworks:
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With