private DmdlParserWrapper createWrapper(IProject project) {
    IJavaProject jproject = JavaCore.create(project);
    if (jproject == null) {
      return null;
    }

    DmdlParserWrapper wrapper = null;
    try {
      IFile file = project.getFile(".classpath");
      long time = file.getLocalTimeStamp();
      Long cache = (Long) project.getSessionProperty(TIME_KEY);

      wrapper = (DmdlParserWrapper) project.getSessionProperty(PASER_KEY);
      if (wrapper == null || (cache != null && cache < time)) {
        wrapper = new DmdlParserWrapper(jproject);
        project.setSessionProperty(PASER_KEY, wrapper);
        project.setSessionProperty(TIME_KEY, time);
      }
    } catch (CoreException e) {
      if (wrapper == null) {
        wrapper = new DmdlParserWrapper(jproject);
      }
    }
    return wrapper.isValid() ? wrapper : null;
  }
  public void test000_noChangeReload() throws Exception {
    IProject p1 = createExisting("t000-p1");
    IFile pom = p1.getFile(IMavenConstants.POM_FILE_NAME);
    waitForJobsToComplete();

    IMavenProjectFacade oldFacade = manager.create(p1, monitor);

    MavenProjectChangedEvent event;
    //    assertEquals(1, events.size());
    //    event = events.get(0);
    //    assertEquals(pom, event.getSource());
    //    assertEquals(MavenProjectChangedEvent.KIND_ADDED, event.getKind());

    events.clear();

    pom.setLocalTimeStamp(pom.getLocalTimeStamp() + 1000L);
    pom.touch(monitor);
    waitForJobsToComplete();

    IMavenProjectFacade newFacade = manager.create(p1, monitor);
    assertNotSame(oldFacade.getMavenProject(monitor), newFacade.getMavenProject(monitor));

    assertEquals(1, events.size());
    event = events.get(0);
    assertEquals(pom, event.getSource());
    assertEquals(MavenProjectChangedEvent.KIND_CHANGED, event.getKind());
    assertEquals(MavenProjectChangedEvent.FLAG_NONE, event.getFlags());
    assertNotNull(event.getOldMavenProject());
    assertNotNull(event.getMavenProject());
  }
 /**
  * Find the output file and get the local time stamp.
  *
  * @return the "last modified" -timestamp of the project output file, or -1 if file does not exist
  */
 private long getOutputFileDate() {
   IFile of = getSelectedOutputFile();
   if (of != null && of.exists()) {
     return of.getLocalTimeStamp();
   } else {
     return -1;
   }
 }
 /**
  * Write the passed resource to the current archive.
  *
  * @param resource org.eclipse.core.resources.IFile
  * @param destinationPath java.lang.String
  * @exception java.io.IOException
  * @exception org.eclipse.core.runtime.CoreException
  */
 @Override
 public void write(IFile resource, String destinationPath) throws IOException, CoreException {
   if (!resolveLinks && resource.isLinked(IResource.DEPTH_INFINITE)) {
     return;
   }
   TarEntry newEntry = new TarEntry(destinationPath);
   if (resource.getLocalTimeStamp() != IResource.NULL_STAMP) {
     newEntry.setTime(resource.getLocalTimeStamp() / 1000);
   }
   ResourceAttributes attributes = resource.getResourceAttributes();
   if (attributes != null && attributes.isExecutable()) {
     newEntry.setMode(newEntry.getMode() | 0111);
   }
   if (attributes != null && attributes.isReadOnly()) {
     newEntry.setMode(newEntry.getMode() & ~0222);
   }
   write(newEntry, resource);
 }
  public void test000_eventMerge() throws Exception {
    IProject p1 = createExisting("t000-p1");
    waitForJobsToComplete();

    events.clear();

    // this emulates project refresh
    IFile pom = p1.getFile("pom.xml");
    pom.setLocalTimeStamp(pom.getLocalTimeStamp() + 1000L);
    pom.touch(monitor);
    waitForJobsToComplete();

    assertEquals(1, events.size());
    assertEquals(MavenProjectChangedEvent.KIND_CHANGED, events.get(0).getKind());
  }
  /**
   * Write the contents of the file to the tar archive.
   *
   * @param entry
   * @param contents
   * @exception java.io.IOException
   * @exception org.eclipse.core.runtime.CoreException
   */
  private void write(ZipEntry entry, IFile contents) throws IOException, CoreException {
    byte[] readBuffer = new byte[4096];

    // If the contents are being compressed then we get the below for free.
    if (!useCompression) {
      entry.setMethod(ZipEntry.STORED);
      InputStream contentStream = contents.getContents(false);
      int length = 0;
      CRC32 checksumCalculator = new CRC32();
      try {
        int n;
        while ((n = contentStream.read(readBuffer)) > 0) {
          checksumCalculator.update(readBuffer, 0, n);
          length += n;
        }
      } finally {
        if (contentStream != null) {
          contentStream.close();
        }
      }

      entry.setSize(length);
      entry.setCrc(checksumCalculator.getValue());
    }

    // set the timestamp
    long localTimeStamp = contents.getLocalTimeStamp();
    if (localTimeStamp != IResource.NULL_STAMP) entry.setTime(localTimeStamp);

    outputStream.putNextEntry(entry);
    InputStream contentStream = contents.getContents(false);
    try {
      int n;
      while ((n = contentStream.read(readBuffer)) > 0) {
        outputStream.write(readBuffer, 0, n);
      }
    } finally {
      if (contentStream != null) {
        contentStream.close();
      }
    }
    outputStream.closeEntry();
  }