Beispiel #1
0
  private static void processContentExtensions(
      final CommonViewer commonViewer, boolean activeFilter, boolean activedPerspectiveFilter) {
    final INavigatorContentService contentService = commonViewer.getNavigatorContentService();

    String[] visibleExtensionIds = contentService.getVisibleExtensionIds();

    List<String> visibleIDsForPecpective = new ArrayList<String>();
    List<String> visibleIdsForActiveFilter = new ArrayList<String>();

    if (visibleExtensionIds != null) {
      visibleIdsForActiveFilter.addAll(Arrays.asList(visibleExtensionIds));
    }

    if (activedPerspectiveFilter) {
      String perspectiveId =
          PlatformUI.getWorkbench()
              .getActiveWorkbenchWindow()
              .getActivePage()
              .getPerspective()
              .getId();
      PerspectiveFilterHelper helper = new PerspectiveFilterHelper();
      helper.setTreeViewer(commonViewer);
      helper.setNavigatorContentService(contentService);
      helper.setActionProviderId(PerspectiveFilterActionProvider.ID);
      String[] pvExtensions = helper.getExtensionIdsToActivate(perspectiveId);

      if (pvExtensions != null && pvExtensions.length > 0) {
        visibleIDsForPecpective = Arrays.asList(pvExtensions);
      }
      visibleIdsForActiveFilter.retainAll(visibleIDsForPecpective);
    }

    String[] filteredContents = RepositoryNodeFilterHelper.getFilterByNodeValues();
    List<String> filteredContentsList = new ArrayList<String>();
    if (filteredContents != null) {
      filteredContentsList = Arrays.asList(filteredContents);
    }

    List<String> checkedExtensions = new ArrayList<String>();
    if (activeFilter) {
      for (String id : visibleIdsForActiveFilter) {
        if (!filteredContentsList.contains(id)) {
          checkedExtensions.add(id);
        }
      }
    } else {
      checkedExtensions.addAll(visibleIdsForActiveFilter);
    }
    String[] contentExtensionIdsToActivate =
        (String[]) checkedExtensions.toArray(new String[checkedExtensions.size()]);
    UpdateActiveExtensionsOperation updateExtensions =
        new UpdateActiveExtensionsOperation(commonViewer, contentExtensionIdsToActivate);
    updateExtensions.execute(null, null);
  }
 /*
  * (non-Javadoc)
  * @see org.eclipse.jface.action.Action#run()
  */
 @Override
 public void run() {
   Set<String> activeIds = new HashSet<String>();
   String[] visibleIds = contentService.getVisibleExtensionIds();
   if (visibleIds != null) {
     for (String visibleId : visibleIds) {
       if (contentService.isActive(visibleId)) activeIds.add(visibleId);
     }
   }
   if (isChecked()) activeIds.add(contentDescriptor.getId());
   else activeIds.remove(contentDescriptor.getId());
   String[] idsToActivate = activeIds.toArray(new String[activeIds.size()]);
   UpdateActiveExtensionsOperation updateExtensions =
       new UpdateActiveExtensionsOperation(commonViewer, idsToActivate);
   updateExtensions.execute(null, null);
 }