2020国产成人精品视频,性做久久久久久久久,亚洲国产成人久久综合一区,亚洲影院天堂中文av色

分享

在Eclipse RCP中屏蔽Eclipse擴展點自帶的General功能

 小不點的書房齋 2011-06-20
 在自己的Eclipse的RCP產(chǎn)品中,可能經(jīng)常要集成第三方的插件,來滿足特定的功能需要,但是對于一些不需要的功能,通常的做法是該插件修改源代碼,如果出于許可或非開源的原因,無法修改,或刪除其源代碼,就要考慮如何在RCP中控制其擴展點的加載。
       可以在RCP的WorkbenchWindowAdvisor.preWindowOpen中,取到所有加載的擴展點,然后進行相應的過濾處理首先使用WorkbenchPlugin.getDefault()得到WorkbenchPlugin;。通過WorkbenchPlugin可以獲取各種類型的擴展點的注冊表WorkbenchPlugin 。getActionSetRegistry()得到的注冊表中存有所有的ActionSet擴展點; WorkbenchPlugin.getViewRegistry()得到了所有的意見,擴展點通過注冊表的removeExtension()可以去掉相應的擴展點,使其不被加載到RCP中。
     具體使用方法如下:
1、(移除wizard中的General)// 移除文件菜單下導入功能中自帶的General
AbstractExtensionWizardRegistry importWizardRegistry = (AbstractExtensionWizardRegistry) WorkbenchPlugin
   .getDefault().getImportWizardRegistry();
IWizardCategory[] categories = wizardRegistry.getRootCategory().getCategories();
for (int i = 0; i < categories.length; i++){
if(categories[i].getId().equals("org.eclipse.ui.Basic")){
IWizardDescriptor[] wizard = categories[i].getWizards();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint("org.eclipse.ui.importWizards");
IExtension[] extensions = point.getExtensions();
for (int j = 0; j < wizard.length; j++){
wizardRegistry.removeExtension(extensions[i],
   new Object[] {wizard[j] });
}
}
}

2、(移除wizard中的General)// 移除文件菜單下導出功能中自帶的General
AbstractExtensionWizardRegistry exportWizardRegistry = (AbstractExtensionWizardRegistry) WorkbenchPlugin
   .getDefault().getExportWizardRegistry();
IWizardCategory[] categories = wizardRegistry.getRootCategory().getCategories();
for (int i = 0; i < categories.length; i++){
if(categories[i].getId().equals("org.eclipse.ui.Basic")){
IWizardDescriptor[] wizard = categories[i].getWizards();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint("org.eclipse.ui.exportWizards");
IExtension[] extensions = point.getExtensions();
for (int j = 0; j < wizard.length; j++){
wizardRegistry.removeExtension(extensions[i],
   new Object[] {wizard[j] });
}
}
}

3、(移除view中的General)// 移除窗口菜單下顯示視圖中自帶的General
ViewRegistry viewRegistry = (ViewRegistry) WorkbenchPlugin.getDefault().getViewRegistry();
IViewCategory[] viewCat = viewRegistry.getCategories();
for (int i = 0; i < viewCat.length; i++){
if(viewCat[i].getId().equals("org.eclipse.ui")){
IViewDescriptor[] viewDes = viewCat[i].getViews();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint("org.eclipse.ui.views");
IExtension[] extensions = point.getExtensions();
for (int j = 0; j < viewDes.length; j++){
if(!viewDes[j].getId().equals("org.eclipse.ui.console.ConsoleView")){
viewRegistry.removeExtension(extensions[i],
   new Object[] {viewDes[j] });
}

}
}
}
4、(移除ActionSet中的General)

ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
IActionSetDescriptor[] actionSets = reg.getActionSets();
// removing annoying gotoLastPosition Message.
String actionSetId = "org.eclipse.ui.edit.text.actionSet.navigation"; //$NON-NLS-1$
for (int i = 0; i <actionSets.length; i++)
{
    if (!actionSets[i].getId().equals(actionSetId))
        continue;
        IExtension ext = actionSets[i].getConfigurationElement()
            .getDeclaringExtension();
        reg.removeExtension(ext, new Object[] { actionSets[i] });
}
// Removing convert line delimiters menu.
actionSetId = "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo"; //$NON-NLS-1$
for (int i = 0; i <actionSets.length; i++)
{
    if (!actionSets[i].getId().equals(actionSetId))
        continue;
    IExtension ext = actionSets[i].getConfigurationElement()
            .getDeclaringExtension();
   reg.removeExtension(ext, new Object[] { actionSets[i] });
}


    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多