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



         

  • 相关阅读:
    Arduino系列之智能家居蓝牙语音遥控灯(四)
    Arduino系列之光照传感器(三)
    address2line 定位 Android c++奔溃位置
    android UI线程安全问题
    android 后台服务定时通知
    eclipse 完全智能提示
    IOS 7 Xcode 5 免IDP证书 真机调试(转载)
    DS5 调试 android c++
    javap -s 查看java方法签名
    ndk-stack 调试 android c++ 代码崩溃位置
  • 原文地址:https://www.cnblogs.com/daition/p/6908825.html
Copyright © 2011-2022 走看看