1

I wanted to add some of my wizards in File > New menu of my RCP application by adding org.eclipse.ui.newWizards extension point into plugin.xml file.

<extension point="org.eclipse.ui.newWizards">
<category
    id="com.my.testapp.ui.objects"
    name="Objects"/>
<wizard
    category="com.my.testapp.ui.objects"
    class="com.my.testapp.ui.wizard.create.COWizard"
    icon="icons/co.gif"
    id="com.my.testapp.ui.wizard.co"
    name="Configure Object"
    preferredPerspectives="com.my.testapp.ui.perspective"/>
</wizard>
</extension>

By default File > New > Other menu except my Objects folder with Configure Object Wizard, also contains General folder with following wizards: File, Folder, Project and Untitled Text File. As in my application these wizards does not make sense I would like to get rid of them. How to do that?

Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
franz
  • 312
  • 3
  • 15

3 Answers3

7

Solution provided here (thanks @bananeweizen and @stracka) for removing default import wizards can also be applied to this issue. So, solution is to add following code to postWindowOpen() method of ApplicationWorkbenchWindowAdvisor class in order to remove default "General" category from File > New > Other menu.

AbstractExtensionWizardRegistry wizardRegistry = (AbstractExtensionWizardRegistry)PlatformUI.getWorkbench().getNewWizardRegistry();
IWizardCategory[] categories = PlatformUI.getWorkbench().getNewWizardRegistry().getRootCategory().getCategories();
for(IWizardDescriptor wizard : getAllWizards(categories)){
    if(wizard.getCategory().getId().matches("org.eclipse.ui.Basic")){
        WorkbenchWizardElement wizardElement = (WorkbenchWizardElement) wizard;
        wizardRegistry.removeExtension(wizardElement.getConfigurationElement().getDeclaringExtension(), new Object[]{wizardElement});
    }
}
Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
franz
  • 312
  • 3
  • 15
1

While this question asks about hiding some of the "Import" wizards (instead of the "New" wizards), the solution should apply to your problem also.

If you are googling around for further details, please be aware that the extension point for that mechanism is called activities, but the Eclipse terminology referring to it is capabilities.

Community
  • 1
  • 1
Bananeweizen
  • 21,797
  • 8
  • 68
  • 88
  • [link](http://www.eclipse.org/forums/index.php/t/261462/) mentioned in that question helped me! Thanks a lot! – franz Jul 04 '12 at 07:25
0

Have you tried removing related action sets? I've never removed the items you're referring to, but I have removed things like the default 'Search' action, the 'Annotation' actions, and the 'Navigation' actions, as I usually don't support those functions in my applications.

Once you puzzle out what packages those actions live in, which often takes a bit of research and digging around, you can hide them in the postWindowOpen() method of your ApplicationWorkbenchWindowAdvisor class, like this:

public void postWindowOpen() { 
    // remove unwanted UI contributions that eclipse makes by default
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    for (int i = 0; i < windows.length; ++i) {
        IWorkbenchPage page = windows[i].getActivePage();
        if (page != null) {
            // hide 'Search' commands
            page.hideActionSet("org.eclipse.search.searchActionSet");

            // hide 'Annotation' commands
            page.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");

            // hide 'Forward/Back' type navigation commands
            page.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
        }
    }
}
Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
stracka
  • 1,023
  • 6
  • 13
  • 1
    Thanks for your answer, unfortunately it didn't help me, but you give me a hint. Actually those 4 things (File, Folder, Project and Untitled Text File) are wizards so they don't belong to any ActionSet. In postWindowsOpen() method I've succeeded to get those wizards from File>New menu by calling PlatformUI.getWorkbench().getNewWizardRegistry().findCategory("org.eclipse.ui.Basic") but I haven't found a way to delete or hide that Category. – franz Jul 03 '12 at 15:37
  • Have you seen ? It looks like *maybe* it would have some more clues that could help you. – stracka Jul 03 '12 at 16:28
  • 1
    [link](http://www.eclipse.org/forums/index.php/t/261462/) mentioned in that question helped me! Thanks a lot! – franz Jul 04 '12 at 07:24