コード例 #1
0
 public void selectionChanged(IAction action, ISelection sel) {
   boolean enable = false;
   if (sel instanceof IStructuredSelection) {
     IStructuredSelection selection = (IStructuredSelection) sel;
     Object element = selection.getFirstElement();
     try {
       if (element instanceof IPackageFragmentRoot) {
         IPackageFragmentRoot root = (IPackageFragmentRoot) element;
         project = root.getJavaProject().getProject();
         cpEntry = root.getRawClasspathEntry();
         if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
           fileName = root.getElementName();
           enable = AspectJCorePreferences.isOnInpath(cpEntry);
         } else {
           fileName = null;
           cpEntry = null;
           project = null;
           enable = false;
         }
       } else {
         enable = false;
       }
     } catch (JavaModelException e) {
     }
     action.setEnabled(enable);
   }
 }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator#
   * isSelectedValid(java.lang.Object)
   */
  @Override
  public boolean isSelectedValid(Object element) {
    boolean isValid = false;
    try {
      if (element instanceof IJavaProject) {
        IJavaProject jproject = (IJavaProject) element;
        IPath path = jproject.getProject().getFullPath();
        isValid = (jproject.findPackageFragmentRoot(path) != null);
      } else if (element instanceof IPackageFragmentRoot) {
        IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element;

        boolean isSrc = (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE);
        boolean isGen =
            packageFragmentRoot.getElementName().equals(IAndroidConstants.GEN_SRC_FOLDER)
                && (packageFragmentRoot.getParent() instanceof IJavaProject);

        isValid = isSrc && !isGen;
      } else {
        isValid = true;
      }
    } catch (JavaModelException e) {
      AndmoreLogger.error(ElementTreeValidator.class, e.getLocalizedMessage(), e);
    }
    return isValid;
  }
 private void initializeContainerText(Text targetText) {
   String text = ""; // $NON-NLS-1$
   if (project != null && project.isAccessible()) {
     IJavaProject javaProject = JavaCore.create(project);
     if (javaProject != null) {
       try {
         IPackageFragmentRoot srcPackage = JavaUtils.getSourcePackageFragmentRoot(javaProject);
         if (srcPackage != null) {
           text = javaProject.getElementName() + "/" + srcPackage.getElementName(); // $NON-NLS-1$
         }
       } catch (JavaModelException e) {
         AppEngineRPCPlugin.log(e);
       }
     }
   }
   targetText.setText(text);
 }
コード例 #4
0
 private TableTreeItem createNewRow(MetricDescriptor md, IPackageFragmentRoot[] roots) {
   TableTreeItem item = new TableTreeItem(this, SWT.NONE);
   item.setText(0, md.getName() + " (" + md.getId() + ")");
   item.setData("id", md.getId());
   item.setData("md", md);
   item.setChecked(isEnabled(md.getId()));
   String[] patterns = getExclusionPatterns(md.getId());
   item.setData("patterns", patterns);
   item.setText(1, concat(patterns));
   rowLookup.put(md.getId(), item);
   for (IPackageFragmentRoot root : roots) {
     TableTreeItem next = new TableTreeItem(item, SWT.NONE);
     next.setText(0, root.getElementName());
     next.setData("id", md.getId());
     next.setData("element", root);
     next.setData("md", md);
     patterns = getExclusionPatterns(md.getId(), root);
     next.setData("patterns", patterns);
     next.setText(1, concat(patterns));
     next.setChecked(isEnabled(md.getId(), root));
     next.setGrayed(!item.getChecked());
   }
   return item;
 }
コード例 #5
0
 @Override
 public Object visit(final IPackageFragmentRoot packageFragmentRoot) {
   return packageFragmentRoot.getElementName();
 }