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

The following examples show how to use org.eclipse.core.resources.IFile#isSynchronized() . 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: ERFluteMultiPageEditor.java    From erflute with Apache License 2.0 6 votes vote down vote up
private void prepareDiagram() {
    try {
        final IFile file = ((IFileEditorInput) getEditorInput()).getFile();
        setPartName(file.getName());
        final Persistent persistent = Persistent.getInstance();
        if (!file.isSynchronized(IResource.DEPTH_ONE)) {
            file.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
        }
        final InputStream in = file.getContents();
        diagram = persistent.read(in);
    } catch (final Exception e) {
        Activator.showExceptionDialog(e);
    }
    if (diagram == null) {
        diagram = new ERDiagram(DBManagerFactory.getAllDBList().get(0));
        diagram.init();
    }
    diagram.setEditor(this);
}
 
Example 2
Source File: AbstractRepositoryStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public T getChild(final String fileName, boolean force) {
    Assert.isNotNull(fileName);
    final IFile file = getResource().getFile(fileName);
    if (force && !file.isSynchronized(IResource.DEPTH_ONE) && file.isAccessible()) {
        try {
            file.refreshLocal(IResource.DEPTH_ONE, Repository.NULL_PROGRESS_MONITOR);
        } catch (final CoreException e) {
            BonitaStudioLog.error(e);
        }
    }
    if (file.exists()) {
        return createRepositoryFileStore(fileName);
    }

    return null;
}
 
Example 3
Source File: AvoidRefreshDocumentProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void refreshFile(IFile file, IProgressMonitor monitor) throws CoreException {
	// Note that file.isSynchronized does not require a scheduling rule and thus helps to identify a no-op attempt
	// to refresh the file. The no-op will otherwise be blocked by a running build or cancel a running build
	if (!file.isSynchronized(IResource.DEPTH_ZERO)) {
		super.refreshFile(file, monitor);
	}
}
 
Example 4
Source File: ImportedResourceCache.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Refresh local file to avoid deadlock with scheduling rule XtextBuilder ->
 * Editing Domain runexclusive
 */
protected void refreshFile(final URI uri) {
	String platformString = uri.toPlatformString(true);
	if (platformString == null)
		return;
	IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformString));
	if (file.isAccessible() && !file.isSynchronized(IResource.DEPTH_INFINITE)) {
		try {
			file.refreshLocal(IResource.DEPTH_INFINITE, null);
		} catch (CoreException e) {
			e.printStackTrace();
		}
	}
}