private static boolean isValidWorkingSet(IWorkingSet workingSet) {
    String id = workingSet.getId();
    if (!IWorkingSetIDs_JAVA.equals(id) && !IWorkingSetIDs_RESOURCE.equals(id)) return false;

    if (workingSet.isAggregateWorkingSet()) return false;

    return true;
  }
  private boolean isValidWorkingSet(IWorkingSet workingSet) {
    String id = workingSet.getId();
    if (!JavaWorkingSetUpdater.ID.equals(id)
        && !"org.eclipse.ui.resourceWorkingSetPage".equals(id)) // $NON-NLS-1$
    return false;

    if (workingSet.isAggregateWorkingSet()) return false;

    return true;
  }
Пример #3
0
 private boolean isEnabled(IStructuredSelection selection) {
   Object[] selected = selection.toArray();
   for (int i = 0; i < selected.length; i++) {
     try {
       if (selected[i] instanceof IJavaElement) {
         IJavaElement elem = (IJavaElement) selected[i];
         if (elem.exists()) {
           switch (elem.getElementType()) {
             case IJavaElement.TYPE:
               return elem.getParent().getElementType()
                   == IJavaElement.COMPILATION_UNIT; // for browsing perspective
             case IJavaElement.COMPILATION_UNIT:
               return true;
             case IJavaElement.IMPORT_CONTAINER:
               return true;
             case IJavaElement.PACKAGE_FRAGMENT:
             case IJavaElement.PACKAGE_FRAGMENT_ROOT:
               IPackageFragmentRoot root =
                   (IPackageFragmentRoot) elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
               return (root.getKind() == IPackageFragmentRoot.K_SOURCE);
             case IJavaElement.JAVA_PROJECT:
               // https://bugs.eclipse.org/bugs/show_bug.cgi?id=65638
               return true;
           }
         }
       } else if (selected[i] instanceof LogicalPackage) {
         return true;
       } else if (selected[i] instanceof IWorkingSet) {
         IWorkingSet workingSet = (IWorkingSet) selected[i];
         return IWorkingSetIDs.JAVA.equals(workingSet.getId());
       }
     } catch (JavaModelException e) {
       if (!e.isDoesNotExist()) {
         JavaPlugin.log(e);
       }
     }
   }
   return false;
 }