Java Code Examples for org.eclipse.core.resources.IFile#getModificationStamp()

The following examples show how to use org.eclipse.core.resources.IFile#getModificationStamp() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileMetaDataProvider.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private ImageInfo createImageFileMetaData(final IFile file) {
	ImageInfo imageInfo = null;
	ImageData imageData = null;

	int type = -1, width = -1, height = -1;
	imageData = ImageDataLoader.getImageData(file);
	if (imageData != null) {
		width = imageData.width;
		height = imageData.height;
		type = imageData.type;
	} else {
		width = -1;
		height = -1;
		type = -1;
	}
	imageInfo = new ImageInfo(file.getModificationStamp(), type, width, height);
	return imageInfo;

}
 
Example 2
Source File: ProcessDocumentProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
private long computeModificationStamp(ResourceSetInfo info) {
	int result = 0;
	for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
		Resource nextResource = it.next();
		IFile file = WorkspaceSynchronizer.getFile(nextResource);
		if (file != null) {
			if (file.getLocation() != null) {
				result += file.getLocation().toFile().lastModified();
			} else {
				result += file.getModificationStamp();
			}
		}
	}
	return result;
}
 
Example 3
Source File: CleanUpPostSaveListener.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private long getDocumentStamp(IFile file, IProgressMonitor monitor) throws CoreException {
 final ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
 final IPath path= file.getFullPath();

 monitor.beginTask("", 2); //$NON-NLS-1$

 ITextFileBuffer buffer= null;
 try {
 	manager.connect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
  buffer= manager.getTextFileBuffer(path, LocationKind.IFILE);
	    IDocument document= buffer.getDocument();

	    if (document instanceof IDocumentExtension4) {
			return ((IDocumentExtension4)document).getModificationStamp();
		} else {
			return file.getModificationStamp();
		}
 } finally {
 	if (buffer != null)
 		manager.disconnect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
 	monitor.done();
 }
}
 
Example 4
Source File: CrossflowDocumentProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private long computeModificationStamp(ResourceSetInfo info) {
	int result = 0;
	for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
		Resource nextResource = it.next();
		IFile file = WorkspaceSynchronizer.getFile(nextResource);
		if (file != null) {
			if (file.getLocation() != null) {
				result += file.getLocation().toFile().lastModified();
			} else {
				result += file.getModificationStamp();
			}
		}
	}
	return result;
}
 
Example 5
Source File: BusinessObjectModelFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public BusinessObjectModel getContent() {
    final IFile resource = getResource();
    if (!resource.exists()) {
        cachedBusinessObjectModel.clear();
        return null;
    }
    final long modificationStamp = resource.getModificationStamp();
    if (cachedBusinessObjectModel.containsKey(modificationStamp)) {
        return cachedBusinessObjectModel.get(modificationStamp);
    }
    try (InputStream contents = resource.getContents()) {
        final BusinessObjectModel bom = getConverter().unmarshall(ByteStreams.toByteArray(contents));
        cachedBusinessObjectModel.clear();
        cachedBusinessObjectModel.put(modificationStamp, bom);
        return bom;
    } catch (final Exception e) {
        BonitaStudioLog.error(e);
    }
    return null;
}
 
Example 6
Source File: PyChange.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void initializeFile(IFile file) {
    fTextFileBuffer = getBuffer(file);
    if (fTextFileBuffer == null) {
        initializeResource(file);
    } else {
        IDocument document = fTextFileBuffer.getDocument();
        fDirty = fTextFileBuffer.isDirty();
        fReadOnly = isReadOnly(file);
        if (document instanceof IDocumentExtension4) {
            fKind = DOCUMENT;
            fModificationStamp = ((IDocumentExtension4) document).getModificationStamp();
        } else {
            fKind = RESOURCE;
            fModificationStamp = file.getModificationStamp();
        }
    }

}
 
Example 7
Source File: PyChange.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public long getModificationStamp(IResource resource) {
    if (!(resource instanceof IFile)) {
        return resource.getModificationStamp();
    }
    IFile file = (IFile) resource;
    ITextFileBuffer buffer = getBuffer(file);
    if (buffer == null) {
        return file.getModificationStamp();
    } else {
        IDocument document = buffer.getDocument();
        if (document instanceof IDocumentExtension4) {
            return ((IDocumentExtension4) document).getModificationStamp();
        } else {
            return file.getModificationStamp();
        }
    }
}
 
Example 8
Source File: FileMetaDataProvider.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param file
 * @return
 */
private GamaShapeFile.ShapeInfo createShapeFileMetaData(final IFile file) {
	ShapeInfo info = null;
	try {
		info = new ShapeInfo(null, file.getLocationURI().toURL(), file.getModificationStamp());
	} catch (final MalformedURLException e) {
		e.printStackTrace();
	}
	return info;

}
 
Example 9
Source File: FileMetaDataProvider.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private GamaOsmFile.OSMInfo createOSMMetaData(final IFile file) {
	OSMInfo info = null;
	try {
		info = new OSMInfo(file.getLocationURI().toURL(), file.getModificationStamp());
	} catch (final MalformedURLException e) {
		e.printStackTrace();
	}
	return info;

}
 
Example 10
Source File: FileMetaDataProvider.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private GenericFileInfo createShapeFileSupportMetaData(final IFile file) {
	GenericFileInfo info = null;
	final IResource r = shapeFileSupportedBy(file);
	if (r == null) { return null; }
	final String ext = file.getFileExtension();
	final String type = longNames.containsKey(ext) ? longNames.get(ext) : "Data";
	info = new GenericFileInfo(file.getModificationStamp(), "" + type + " for '" + r.getName() + "'");
	return info;

}
 
Example 11
Source File: PyModuleMatch.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public PyModuleMatch(IFile element, int offset, int length, PyModuleLineElement lineEntry, ModulesKey modulesKey) {
    super(element, offset, length);
    Assert.isLegal(lineEntry != null);
    this.modulesKey = modulesKey;
    fLineElement = lineEntry;
    fCreationTimeStamp = element.getModificationStamp();
}
 
Example 12
Source File: BuildPathsBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public boolean hasChangesInClasspathFile() {
	IFile file= fCurrJProject.getProject().getFile(".classpath"); //$NON-NLS-1$
	return fFileTimeStamp != file.getModificationStamp();
}
 
Example 13
Source File: JCasGenM2ETest.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
public void testTypeSystemReferences() throws Exception {
  ResolverConfiguration configuration = new ResolverConfiguration();
  IProject project = importProject("target/projects/jcasgen/classpath/pom.xml", configuration);
  waitForJobsToComplete();
  assertNoErrors(project);

  project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  String prefix = "target/generated-sources/jcasgen/type/";
  IFile sentenceFile = project.getFile(prefix + "span/Sentence.java");
  IFile tokenFile = project.getFile(prefix + "span/Token.java");
  IFile dependencyFile = project.getFile(prefix + "relation/Dependency.java");

  // make sure the Java sources were generated
  assertTrue(sentenceFile.isAccessible());
  assertTrue(tokenFile.isAccessible());
  assertTrue(dependencyFile.isAccessible());

  // record the modification times
  long sentenceTime = sentenceFile.getModificationStamp();
  long tokenTime = tokenFile.getModificationStamp();
  long dependencyTime = dependencyFile.getModificationStamp();

  // build incrementally
  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  // modify something unrelated to the type system
  project.getFile("pom.xml").touch(monitor);
  Thread.sleep(1000);

  // re-run the build
  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  // make sure no type system files were changed
  assertEquals(sentenceTime, sentenceFile.getModificationStamp(), 1e-10);
  assertEquals(tokenTime, tokenFile.getModificationStamp(), 1e-10);
  assertEquals(dependencyTime, dependencyFile.getModificationStamp(), 1e-10);

  // modify the type system file
  project.getFile("src/main/resources/TypeSystem.xml").touch(monitor);
  Thread.sleep(1000);

  // re-run the build
  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  // make sure all generated files were re-generated
  assertTrue(sentenceFile.getModificationStamp() > sentenceTime);
  assertTrue(tokenFile.getModificationStamp() > tokenTime);
  assertTrue(dependencyFile.getModificationStamp() > dependencyTime);

  // update the modification times
  sentenceTime = sentenceFile.getModificationStamp();
  tokenTime = tokenFile.getModificationStamp();
  dependencyTime = dependencyFile.getModificationStamp();

  // now modify the token descriptor which is indirectly referenced from TypeSystem.xml
  project.getFile("src/main/resources/type/Token.xml").touch(monitor);
  Thread.sleep(1000);

  // re-run the build
  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  // make sure all generated files were re-generated
  assertTrue(sentenceFile.getModificationStamp() > sentenceTime);
  assertTrue(tokenFile.getModificationStamp() > tokenTime);
  assertTrue(dependencyFile.getModificationStamp() > dependencyTime);
}
 
Example 14
Source File: FileMatch.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public FileMatch(IFile element, int offset, int length, LineElement lineEntry) {
    super(element, offset, length);
    Assert.isLegal(lineEntry != null);
    fLineElement = lineEntry;
    fCreationTimeStamp = element.getModificationStamp();
}
 
Example 15
Source File: BuildPathsBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void initializeTimeStamps() {
	IFile file= fCurrJProject.getProject().getFile(".classpath"); //$NON-NLS-1$
	fFileTimeStamp= file.getModificationStamp();
	fUserSettingsTimeStamp= getEncodedSettings();
}
 
Example 16
Source File: FileMetaDataProvider.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
private GenericFileInfo createGenericFileMetaData(final IFile file) {
	String ext = file.getFileExtension();
	if (ext == null) { return new GenericFileInfo(file.getModificationStamp(), "Generic file"); }
	ext = ext.toUpperCase();
	return new GenericFileInfo(file.getModificationStamp(), "Generic " + ext + " file");
}
 
Example 17
Source File: FileMetaDataProvider.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
private GamaCSVFile.CSVInfo createCSVFileMetaData(final IFile file) {
	return new CSVInfo(file.getLocation().toOSString(), file.getModificationStamp(), null);
}