Java Code Examples for org.eclipse.core.resources.IResource#getLocalTimeStamp()

The following examples show how to use org.eclipse.core.resources.IResource#getLocalTimeStamp() . 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: TexlipseProperties.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Check if the project properties should be read from disk.
 * 
 * @param project current project
 * @return true, if the project properties should be read from disk
 */
public static boolean isProjectPropertiesFileChanged(IProject project) {
    
    IResource settingsFile = project.findMember(LATEX_PROJECT_SETTINGS_FILE);
    if (settingsFile == null) {
        return false;
    }
    
    Long lastLoadTime = (Long) getSessionProperty(project, SESSION_PROPERTIES_LOAD);
    if (lastLoadTime == null) {
        return true;
    }
    
    long timeStamp = settingsFile.getLocalTimeStamp();
    return timeStamp > lastLoadTime.longValue();
}
 
Example 2
Source File: TexBuilder.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find a handle to the index file of this project.
 * @param project the current project
 * @param source buildable resource inside project 
 * @return handle to index file or null if not found.
 *         Returns null also if the index file is older than the current output file
 */
private IResource findIndex(IProject project, IResource source) {
    
    IContainer srcDir = TexlipseProperties.getProjectSourceDir(project);
    if (srcDir == null) {
        srcDir = project;
    }
    
    String name = source.getName();
    String idxName = name.substring(0, name.length() - source.getFileExtension().length()) + TexlipseProperties.INPUT_FORMAT_IDX;
    IResource idxFile = srcDir.findMember(idxName);
    if (idxFile == null) {
        return null;
    }
    
    IResource outFile = TexlipseProperties.getProjectOutputFile(project);
    if (outFile.getLocalTimeStamp() > idxFile.getLocalTimeStamp()) {
        return null;
    }
    
    return idxFile;
}
 
Example 3
Source File: TexBuilder.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find a handle to the index file of this project.
 * @param project the current project
 * @param source buildable resource inside project 
 * @return handle to index file or null if not found.
 *         Returns null also if the index file is older than the current output file
 */
private IResource findNomencl(IProject project, IResource source) {
    
    IContainer srcDir = TexlipseProperties.getProjectSourceDir(project);
    if (srcDir == null) {
        srcDir = project;
    }

    String name = source.getName();
    String nomenclName = name.substring(0, name.length() - source.getFileExtension().length()) + TexlipseProperties.INPUT_FORMAT_NOMENCL;
    IResource idxFile = srcDir.findMember(nomenclName);

    if (idxFile == null) {
        return null;
    }
    
    IResource outFile = TexlipseProperties.getProjectOutputFile(project);
    if (outFile.getLocalTimeStamp() > idxFile.getLocalTimeStamp()) {
        return null;
    }
    
    return idxFile;
}
 
Example 4
Source File: Storage2UriMapperJavaImpl.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.9
 */
protected Object getLastModified(IResource resource) throws CoreException {
	IPath location = resource.getLocation();
	if (location != null) {
		return location.toFile().lastModified();
	}
	long timestamp = resource.getLocalTimeStamp();
	if (timestamp == IResource.NULL_STAMP) {
		return null;
	}
	return timestamp;
}
 
Example 5
Source File: FileFolderSorter.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private Long getDate(final Object e) {
	final IResource r = ResourceManager.getResource(e);
	if (r != null) {
		return r.getLocalTimeStamp();
	} else {
		return Long.MAX_VALUE;
	}
}
 
Example 6
Source File: NavigatorDateLighweightDecorator.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void decorate(final Object element, final IDecoration decoration) {
	final IResource r = ResourceManager.getResource(element);
	if (r != null) {
		final long date = r.getLocalTimeStamp();
		final DateFormat df = DateFormat.getInstance();
		final String dateStr = df.format(new Date(date));
		decoration.addSuffix(" - " + dateStr);
	}
}
 
Example 7
Source File: TLAParsingBuilder.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
 */
public boolean visit(IResourceDelta delta) throws CoreException
{
    IResource resource = delta.getResource();
    if (resource.exists() && IResource.FILE == resource.getType())
    {
        // a file found
        if (ResourceHelper.isModule(resource))
        {
            // if the spec is null, this means that we are unable to get
            // access to the spec manager
            // because it has not yet been instantiatec. Instantiating
            // it would trigger a resource change
            // event which is not allowed
            if (spec == null)
            {
                modules.add(resource);

            } else if (spec.getRootFile().getParent().equals(resource.getParent()))
            {
                // we are only concerned with modules in the same
                // directory as the root module because those are the
                // only ones allowed to be a part of the spec
                if (resource.getPersistentProperty(TLAParsingBuilderConstants.LAST_BUILT) == null)
                {
                    if (spec.getStatus() < IParseConstants.PARSED && spec.getStatus() > IParseConstants.UNKNOWN)
                    {
                        // If the property has never been set, the
                        // resource has never been built. If the
                        // current status is parsed, then it cannot be
                        // relevant because it would have been built
                        // if it were relevant. If the status is
                        // unknown, it should remain unknown. In all
                        // other cases, it is possible that the resource
                        // is relevant but it is not known because there
                        // was not a successful parse. Conservatively we
                        // should consider it relevant.
                        modules.add(resource);
                    }
                }
                // If there current spec status is a problem status (see
                // AdaptorFactory.isProblemStatus),
                // then it is not known whether a given resource is
                // relevant so all resources are considered
                // relevant. Relevant resources are not necessarily in
                // dependancy storage. Any resource that is
                // out of build when the parse status is error is added to
                // the list of modules.
                else if (Long.parseLong(resource.getPersistentProperty(TLAParsingBuilderConstants.LAST_BUILT)) < resource
                        .getLocalTimeStamp()
                        && (dependancyTable.containsKey(resource.getName()) || (spec.getStatus() < IParseConstants.PARSED && spec
                                .getStatus() > IParseConstants.UNPARSED)))
                {
                    modules.add(resource);
                }
            }
        }
    }
    // we want the visitor to visit the whole tree
    return true;
}