コード例 #1
0
 public void run(IAction action) {
   if (project == null) {
     return;
   }
   if (cpEntry != null) {
     // update the restrictions on this classpath element
     // although the element probably already is on the aspect/in path, we can ensure it's on, just
     // in case
     IClasspathEntry newEntry = cpEntry;
     if (shouldAskForClasspathRestrictions(cpEntry)) {
       String currRestriction =
           AspectJCorePreferences.getRestriction(
               cpEntry, AspectJCorePreferences.INPATH_RESTRICTION_ATTRIBUTE_NAME);
       String restriction = askForClasspathRestrictions(newEntry, currRestriction, "In path");
       if (restriction != null) {
         newEntry =
             AspectJCorePreferences.updatePathRestrictions(
                 newEntry, restriction, AspectJCorePreferences.INPATH_RESTRICTION_ATTRIBUTE_NAME);
       } else {
         newEntry =
             AspectJCorePreferences.ensureHasAttribute(
                 newEntry, AspectJCorePreferences.INPATH_RESTRICTION_ATTRIBUTE_NAME, "");
       }
     }
     newEntry =
         AspectJCorePreferences.ensureHasAttribute(
             newEntry,
             AspectJCorePreferences.INPATH_ATTRIBUTE_NAME,
             AspectJCorePreferences.INPATH_ATTRIBUTE_NAME);
     AspectJCorePreferences.updateClasspathEntry(project, newEntry);
   }
   AJDTUtils.refreshPackageExplorer();
 }
コード例 #2
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);
   }
 }
  protected void setUp() throws Exception {
    super.setUp();
    origFactory = AspectJPlugin.getDefault().getCompilerFactory();
    AspectJPlugin.getDefault().setCompilerFactory(new MockCompilerFactory());

    Utils.setAutobuilding(true);

    proj2 = createPredefinedProject("ExportAsJar");
    AspectJCorePreferences.setProjectOutJar(proj2, "export.jar");
    proj2.build(IncrementalProjectBuilder.FULL_BUILD, null);
    proj1 = createPredefinedProject("JarOnInpath");
    waitForAutoBuild();
  }
  /** should cause location manager to be refreshed */
  public void testOutjarChangedChanged() {
    // first build of proj1 is full build, so should have been flushed, but is a noop since started
    // out as null
    assertTrue(proj1 + "'s OutputLocationManager should have been flushed", hasBeenFlushed());
    assertFalse(
        proj1 + "'s OutputLocationManager's binToProject map should not have been zapped",
        hasBeenZapped());
    unflush();
    AspectJCorePreferences.setProjectOutJar(proj1, "out.jar");
    waitForAutoBuild();

    assertTrue(
        proj1 + "'s OutputLocationManager should not have been flushed after change to out jar",
        hasBeenFlushed());
  }
  /** should cause location manager to be refreshed */
  public void testInpathChanged() throws Exception {
    // first build of proj1 is full build, so should have been flushed, but is a noop since started
    // out as null
    assertTrue(proj1 + "'s OutputLocationManager should have been flushed", hasBeenFlushed());
    assertFalse(
        proj1 + "'s OutputLocationManager's binToProject map should not have been zapped",
        hasBeenZapped());
    unflush();
    AspectJCorePreferences.removeFromInPath(proj1, getClasspathEntry());
    waitForAutoBuild();

    assertTrue(
        proj1 + "'s OutputLocationManager should not have been flushed after change to in path",
        hasBeenFlushed());
  }