RCP自定义扩展点的应用

         打开plugin.xml文件中Extension Points添加自定义扩展点的,定义相关元素的属性。此处仅仅定义一个可可扩展的Tab也实现一个自定义扩展。

         操作完成之后,在项目中自动添加一个目录schema的目录。里面放着自定义的扩展点的schema描述。同时在plugin.xml中添加一句自定义扩展点的导入。

例如:

<extension-point id="com.easyway.tbs.commons.ext.tabs" name="tabPoint" schema="schema/com.easyway.tbs.commons.ext.tabs.exsd"/>
 

 

自定义的扩展点的xml如下:

 <extension
         point="com.easyway.tbs.commons.ext.tabs">
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.GridExampleTab"
            name="Grid"/>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.PGroupExampleTab"
            name="PGroup"/>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.CDateTimeExampleTab"
            name="CDateTime"/>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.GalleryExampleTab"
            name="Gallery"/>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.AnimationExampleTab"
            name="Animation"/>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.CollapsibleButtonsExampleTab"
            name="CollapsibleButtons"/>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.DateChooserExampleTab"
            name="DateChooser">
      </tab>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.DateChooserComboExampleTab"
            name="DateChooserCombo">
      </tab>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.RadioGroupExampleTab"
            name="RadioGroup">
      </tab>
      <tab
            class="com.easyway.tbs.commons.ext.nebula.part.TableComboExampleTab"
            name="TableCombo">
      </tab>
   </extension>
  

 

获取之后设置为:

 

  public void createPartControl(Composite parent)
    {
       TabFolder  tabFolder = new TabFolder(parent, 128);
        IConfigurationElement elements[] = Platform.getExtensionRegistry().getConfigurationElementsFor("com.easyway.tbs.commons.ext.tabs");
        for(int i = 0; i < elements.length; i++)
        {
            IConfigurationElement element = elements[i];
            TabItem item = new TabItem(tabFolder, 0);
            item.setText(element.getAttribute("name"));
            try
            {
                AbstractExampleTab part = (AbstractExampleTab)element.createExecutableExtension("class");
                Composite client = new Composite(tabFolder, 0);
                part.create(client);
                item.setControl(client);
            }
            catch(CoreException e)
            {
                e.printStackTrace();
            }
        }
        tabFolder.setSelection(tabFolder.getItem(0));
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值