Java Code Examples for org.eclipse.core.resources.IFileState

The following are top voted examples for showing how to use org.eclipse.core.resources.IFileState. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gama   File: ShowLocalHistory.java   Source Code and License 6 votes vote down vote up
protected IFileState[] getLocalHistory() {
	final IFile file = ResourceManager.getFile(getSelection().getFirstElement());
	IFileState states[] = null;
	try {
		if (file != null)
			states = file.getHistory(null);
	} catch (final CoreException ex) {
		MessageDialog.openError(WorkbenchHelper.getShell(), getPromptTitle(), ex.getMessage());
		return null;
	}

	if (states == null || states.length <= 0) {
		MessageDialog.openInformation(WorkbenchHelper.getShell(), getPromptTitle(),
				TeamUIMessages.ShowLocalHistory_0);
		return states;
	}
	return states;
}
 
Example 2
Project: Eclipse-Postfix-Code-Completion   File: JavaTextBufferNode.java   Source Code and License 6 votes vote down vote up
static final ITypedElement[] buildEditions(ITypedElement target, IFile file) {

		// setup array of editions
		IFileState[] states= null;
		// add available editions
		try {
			states= file.getHistory(null);
		} catch (CoreException ex) {
			JavaPlugin.log(ex);
		}

		int count= 1;
		if (states != null)
			count+= states.length;

		ITypedElement[] editions= new ITypedElement[count];
		editions[0]= new ResourceNode(file);
		if (states != null)
			for (int i= 0; i < states.length; i++)
				editions[i+1]= new HistoryItem(target, states[i]);
		return editions;
	}
 
Example 3
Project: Eclipse-Postfix-Code-Completion   File: JavaHistoryActionImpl.java   Source Code and License 6 votes vote down vote up
final ITypedElement[] buildEditions(ITypedElement target, IFile file) {

		// setup array of editions
		IFileState[] states= null;
		// add available editions
		try {
			states= file.getHistory(null);
		} catch (CoreException ex) {
			JavaPlugin.log(ex);
		}

		int count= 1;
		if (states != null)
			count+= states.length;

		ITypedElement[] editions= new ITypedElement[count];
		editions[0]= new ResourceNode(file);
		if (states != null)
			for (int i= 0; i < states.length; i++)
				editions[i+1]= new HistoryItem(target, states[i]);
		return editions;
	}
 
Example 4
Project: Eclipse-Postfix-Code-Completion-Juno38   File: JavaTextBufferNode.java   Source Code and License 6 votes vote down vote up
static final ITypedElement[] buildEditions(ITypedElement target, IFile file) {

		// setup array of editions
		IFileState[] states= null;
		// add available editions
		try {
			states= file.getHistory(null);
		} catch (CoreException ex) {
			JavaPlugin.log(ex);
		}

		int count= 1;
		if (states != null)
			count+= states.length;

		ITypedElement[] editions= new ITypedElement[count];
		editions[0]= new ResourceNode(file);
		if (states != null)
			for (int i= 0; i < states.length; i++)
				editions[i+1]= new HistoryItem(target, states[i]);
		return editions;
	}
 
Example 5
Project: Eclipse-Postfix-Code-Completion-Juno38   File: JavaHistoryActionImpl.java   Source Code and License 6 votes vote down vote up
final ITypedElement[] buildEditions(ITypedElement target, IFile file) {

		// setup array of editions
		IFileState[] states= null;
		// add available editions
		try {
			states= file.getHistory(null);
		} catch (CoreException ex) {
			JavaPlugin.log(ex);
		}

		int count= 1;
		if (states != null)
			count+= states.length;

		ITypedElement[] editions= new ITypedElement[count];
		editions[0]= new ResourceNode(file);
		if (states != null)
			for (int i= 0; i < states.length; i++)
				editions[i+1]= new HistoryItem(target, states[i]);
		return editions;
	}
 
Example 6
Project: eclipse-utility   File: LocalHistoryTableProvider.java   Source Code and License 6 votes vote down vote up
protected boolean isCurrentEdition(Object element) {
	if (element instanceof IFile) {
		return true;
	}
	if (element instanceof IFileState) {
		return false;
	}
	if (element instanceof LocalFileRevision) {
		LocalFileRevision revision = (LocalFileRevision) element;
		
		// only current revision has a "real" current file
		if (revision.getFile() != null)
			return true;
	}
	
	return false;
}
 
Example 7
Project: uefi_edk2_wizards_plugin   File: Edk2ModuleObservablesManager.java   Source Code and License 5 votes vote down vote up
private static Edk2Module getOldEdk2Module(IResource resource, String workspacePath)
		throws CoreException, FileNotFoundException, IOException {
	Edk2Module oldModule = null;
	IFile infFile = (IFile) resource;
	IFileState[] states = infFile.getHistory(null);
	
	if(states != null && states.length > 0) {
		IFileState lastState = states[0];
		oldModule = new Edk2Module(resource.getLocation().toString(), workspacePath, lastState.getContents());
	}
	
	return oldModule;
}
 
Example 8
Project: VariantSync   File: ChangeHandler.java   Source Code and License 5 votes vote down vote up
/**
 * Creates patch for changed resource.
 * 
 * @param res
 *            changed resource
 * @param delta
 *            resource delta
 */
private void handleChangedResource(IResource res, IResourceDelta delta) {
	if (res.getType() == IResource.FILE
			&& (delta.getFlags() & IResourceDelta.CONTENT) != 0) {
		IFile file = (IFile) res;
		IFileState[] states = null;
		try {
			states = file.getHistory(null);
			if (states.length > 0) {
				long t = states[0].getModificationTime();
				Date d = new Date(t);
				LogOperations.logInfo(DateFormat.getDateTimeInstance(
						DateFormat.SHORT, DateFormat.SHORT).format(d)
						+ "");
				deltaOperations.createPatch(res);
				update();
			}
		} catch (CoreException e) {
			LogOperations
					.logError("File states could not be retrieved.", e);
		}
		VariantSyncPlugin.getDefault().logMessage(
				RESOURCE + res.getFullPath() + " has changed "
						+ getFlagTxt(delta.getFlags()));
		update();
	}
}
 
Example 9
Project: che   File: File.java   Source Code and License 5 votes vote down vote up
@Override
public void setContents(
    IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor)
    throws CoreException {
  // funnel all operations to central method
  int updateFlags = force ? IResource.FORCE : IResource.NONE;
  updateFlags |= keepHistory ? IResource.KEEP_HISTORY : IResource.NONE;
  setContents(source.getContents(), updateFlags, monitor);
}
 
Example 10
Project: che   File: FileDescription.java   Source Code and License 5 votes vote down vote up
private IFileState getMatchingFileState(IFileState[] states) {
  for (int i = 0; i < states.length; i++) {
    if (localTimeStamp == states[i].getModificationTime()) {
      return states[i];
    }
  }
  return states[0];
}
 
Example 11
Project: che   File: FileUndoState.java   Source Code and License 5 votes vote down vote up
/**
 * Get the file state that matches this file description. The local time stamp is used to try to
 * find a matching file state. If none can be found, the most recent copy of the file state is
 * used.
 *
 * @param states file states
 * @return best guess state
 */
private IFileState getMatchingFileState(IFileState[] states) {
  for (int i = 0; i < states.length; i++) {
    if (localTimeStamp == states[i].getModificationTime()) {
      return states[i];
    }
  }
  return states[0];
}
 
Example 12
Project: eclipse-utility   File: LocalHistoryTableProvider.java   Source Code and License 5 votes vote down vote up
protected long getModificationDate(Object element) {
	IModificationDate md = (IModificationDate)Utils.getAdapter(element, IModificationDate.class);
	if (md != null)
		return md.getModificationDate();
	if (element instanceof IFileState) {
		IFileState fs = (IFileState) element;
		return fs.getModificationTime();
	}
	if (element instanceof IFile) {
		IFile f = (IFile) element;
		return f.getLocalTimeStamp();
	}
	return -1;
}
 
Example 13
Project: che   File: File.java   Source Code and License 4 votes vote down vote up
@Override
public IFileState[] getHistory(IProgressMonitor iProgressMonitor) throws CoreException {
  throw new UnsupportedOperationException();
}
 
Example 14
Project: che   File: File.java   Source Code and License 4 votes vote down vote up
@Override
public void setContents(IFileState content, int updateFlags, IProgressMonitor monitor)
    throws CoreException {
  setContents(content.getContents(), updateFlags, monitor);
}
 
Example 15
Project: che   File: FileDescription.java   Source Code and License 4 votes vote down vote up
public void recordStateFromHistory(IResource resource, IProgressMonitor monitor)
    throws CoreException {
  Assert.isLegal(resource.getType() == IResource.FILE);

  if (location != null) {
    // file is linked, no need to record any history
    return;
  }
  IFileState[] states = ((IFile) resource).getHistory(monitor);
  if (states.length > 0) {
    final IFileState state = getMatchingFileState(states);
    this.fileContentDescription =
        new IFileContentDescription() {
          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#exists()
           */
          public boolean exists() {
            return state.exists();
          }

          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#getContents()
           */
          public InputStream getContents() throws CoreException {
            return state.getContents();
          }

          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#getCharset()
           */
          public String getCharset() throws CoreException {
            return state.getCharset();
          }
        };
  }
}
 
Example 16
Project: che   File: FileUndoState.java   Source Code and License 4 votes vote down vote up
public void recordStateFromHistory(IResource resource, IProgressMonitor monitor)
    throws CoreException {
  Assert.isLegal(resource.getType() == IResource.FILE);

  if (location != null) {
    // file is linked, no need to record any history
    return;
  }
  IFileState[] states = ((IFile) resource).getHistory(monitor);
  if (states.length > 0) {
    final IFileState state = getMatchingFileState(states);
    this.fileContentDescription =
        new IFileContentDescription() {
          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#exists()
           */
          public boolean exists() {
            return state.exists();
          }

          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#getContents()
           */
          public InputStream getContents() throws CoreException {
            return state.getContents();
          }

          /*
           * (non-Javadoc)
           *
           * @see org.eclipse.ui.internal.ide.undo.IFileContentDescription#getCharset()
           */
          public String getCharset() throws CoreException {
            return state.getCharset();
          }
        };
  }
}
 
Example 17
Project: PerformanceHat   File: AbstractFileDecorator.java   Source Code and License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public IFileState[] getHistory(final IProgressMonitor monitor) throws CoreException {
  return resource().getHistory(monitor);
}
 
Example 18
Project: PerformanceHat   File: AbstractFileDecorator.java   Source Code and License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setContents(final IFileState source, final boolean force, final boolean keepHistory, final IProgressMonitor monitor) throws CoreException {
  resource().setContents(source, force, keepHistory, monitor);
}
 
Example 19
Project: PerformanceHat   File: AbstractFileDecorator.java   Source Code and License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setContents(final IFileState source, final int updateFlags, final IProgressMonitor monitor) throws CoreException {
  resource().setContents(source, updateFlags, monitor);
}
 
Example 20
Project: XPagesExtensionLibrary   File: TestFile.java   Source Code and License 4 votes vote down vote up
public IFileState[] getHistory(IProgressMonitor arg0) throws CoreException {
        throw new RuntimeException("not implemented"); //$NON-NLS-1$
//        return null;
    }
 
Example 21
Project: XPagesExtensionLibrary   File: TestFile.java   Source Code and License 4 votes vote down vote up
public void setContents(IFileState arg0, int arg1, IProgressMonitor arg2) throws CoreException {
    throw new RuntimeException("not implemented"); //$NON-NLS-1$
}
 
Example 22
Project: XPagesExtensionLibrary   File: TestFile.java   Source Code and License 4 votes vote down vote up
public void setContents(IFileState arg0, boolean arg1, boolean arg2, IProgressMonitor arg3) throws CoreException {
    throw new RuntimeException("not implemented"); //$NON-NLS-1$
}
 
Example 23
Project: Pydev   File: AbstractIFileStub.java   Source Code and License 4 votes vote down vote up
@Override
public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {
    throw new RuntimeException("Not implemented");
}
 
Example 24
Project: Pydev   File: AbstractIFileStub.java   Source Code and License 4 votes vote down vote up
@Override
public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor)
        throws CoreException {
    throw new RuntimeException("Not implemented");
}
 
Example 25
Project: Pydev   File: AbstractIFileStub.java   Source Code and License 4 votes vote down vote up
@Override
public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor) throws CoreException {
    throw new RuntimeException("Not implemented");
}