Пример #1
0
  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
   */
  @Override
  protected IContributionItem[] getContributionItems() {
    CommonNavigator navigator = (CommonNavigator) ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
    if (navigator == null) return new IContributionItem[0];

    INavigatorContentService contentService = navigator.getNavigatorContentService();
    List<IContributionItem> items = new ArrayList<IContributionItem>();
    List<String> extensionSet = new MRUList(IPreferenceKeys.PREF_CONTENT_MRU_LIST);
    CommonViewer commonViewer = navigator.getCommonViewer();
    for (int i = 0; i < extensionSet.size(); i++) {
      String extensionId = extensionSet.get(i);
      INavigatorContentDescriptor contentDescriptor =
          contentService.getContentDescriptorById(extensionId);
      if (contentDescriptor != null) {
        items.add(
            new ActionContributionItem(
                new ContentMRUAction((i + 1), contentDescriptor, contentService, commonViewer)));
      }
    }
    return items.toArray(new IContributionItem[items.size()]);
  }