如何从文件>中删除默认向导RCP应用程序中的新菜单? [英] How to remove default wizards from File > New Menu in RCP application?

查看:95
本文介绍了如何从文件>中删除默认向导RCP应用程序中的新菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过将org.eclipse.ui.newWizards扩展点添加到plugin.xml文件中,在RCP应用程序的文件>新建菜单中添加一些向导。



< pre class = lang-xml prettyprint-override> < extension point = org.eclipse.ui.newWizards>
<类别
id = com.my.testapp.ui.objects
name = Objects />
<向导
category = com.my.testapp.ui.objects
class = com.my.testapp.ui.wizard.create.COWizard
图标= icons / co.gif
id = com.my.testapp.ui.wizard.co
name =配置对象
preferredPerspectives = com.my.testapp。 ui.perspective />
< / wizard>
< / extension>

默认情况下,文件>新建>其他菜单除外,但带有配置对象向导的我的对象文件夹也包含常规文件夹使用以下向导:文件,文件夹,项目和无标题文本文件。正如在我的应用程序中一样,这些向导没有意义,我想摆脱它们。

解决方案

提供的解决方案此处(感谢@bananeweizen和@stracka),用于删除默认导入向导也可以应用于此问题。
因此,解决方案是将以下代码添加到 ApplicationWorkbenchWindowAdvisor 类的 postWindowOpen()方法中,以便删除

  AbstractExtensionWizardRegistry wizardRegistry =(AbstractExtensionWizardRegistry) PlatformUI.getWorkbench()。getNewWizardRegistry(); 
IWizardCategory [] category = PlatformUI.getWorkbench()。getNewWizardRegistry()。getRootCategory()。getCategories();
for(IWizardDescriptor向导:getAllWizards(类别)){
if(wizard.getCategory()。getId()。matches( org.eclipse.ui.Basic)){
WorkbenchWizardElement向导元素=(WorkbenchWizardElement)向导;
wizardRegistry.removeExtension(wizardElement.getConfigurationElement()。getDeclaringExtension(),new Object [] {wizardElement});
}
}


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?

解决方案

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});
    }
}

这篇关于如何从文件&gt;中删除默认向导RCP应用程序中的新菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆