zoukankan      html  css  js  c++  java
  • eclipse中如何获得feature与plugin的list

    eclipse中如何获得feature与plugin的list

          做一些基于eclipse的开发,如RCP,经常需要查找当前platform中所有已经安装的feature和plug-in。其实,eclipse的“about eclipse platform”对话框就需要使用这个功能。通过阅读该对话框的代码,作者发现了以下方法。约定本文中Plugin与Bundle概念相同。
          1.获得所有feature的list
             首先,通过Platform,得到一个IBundleGroupProvider数组;
             然后,通过IBundleGroupProvider,获得相应的IBundleGroup数组;
             最后,通过IBundleGroup,得到Bundle数组。
             代码如下:
           

    for (int i=0;i<providers.length;i++){
          IBundleGroupProvider provider = providers[i];
          System.out.println("Provider name: "+ provider.getName());
          IBundleGroup[] groups=provider.getBundleGroups();
          
          for (int j=0;j<groups.length;j++){
            IBundleGroup group = groups[j];
            System.out.println("  Feature name: "+group.getName());      
          }
        }


          2. 获得plug-in的list
          原本可以通过上例的IBundleGroup列出,每个BundleGroup下的Bundle。但是,考虑到有的Plugin不属于任何一个feature,所以上述方法得到的bundle list可能不完全。通过BundleContext的getBundles()方法,可以达到这个目的。但是,如果某些class没有继承Bundle,Plugin或者BundleActivator,就无法获得BundleContext参数。因此,需要采用另一种方式得到所有bundle list。不通过BundleContext获得bundle list的代码如下:

    BundleDescription[] descriptions = Platform.getPlatformAdmin().getState().getBundles();
        for (int i=0;i<descriptions.length;i++){
          System.out.println("Bundle name:"+descriptions[i].getSymbolicName());
        }



         

  • 相关阅读:
    发现另一种简便的完全居中css写法 element.style { width: 500px; height: 200px; background: #eee; position: absolute; margin: auto; top: 0; left: 0; bottom: 0; right: 0; }
    子网掩码随笔
    C# MVC网站自动由HTTP转为HTTPS
    c++中的void*
    权利的游戏
    字符串
    字符串
    权利的游戏 S0803
    加权有向图
    加权无向图
  • 原文地址:https://www.cnblogs.com/daition/p/6908825.html
Copyright © 2011-2022 走看看