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; }
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; }
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; }
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; }
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; }
/** * 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(); } }
@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); }
private IFileState getMatchingFileState(IFileState[] states) { for (int i = 0; i < states.length; i++) { if (localTimeStamp == states[i].getModificationTime()) { return states[i]; } } return states[0]; }
/** * 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]; }
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; }
@Override public IFileState[] getHistory(IProgressMonitor iProgressMonitor) throws CoreException { throw new UnsupportedOperationException(); }
@Override public void setContents(IFileState content, int updateFlags, IProgressMonitor monitor) throws CoreException { setContents(content.getContents(), updateFlags, monitor); }
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(); } }; } }
/** * {@inheritDoc} */ @Override public IFileState[] getHistory(final IProgressMonitor monitor) throws CoreException { return resource().getHistory(monitor); }
/** * {@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); }
/** * {@inheritDoc} */ @Override public void setContents(final IFileState source, final int updateFlags, final IProgressMonitor monitor) throws CoreException { resource().setContents(source, updateFlags, monitor); }
public IFileState[] getHistory(IProgressMonitor arg0) throws CoreException { throw new RuntimeException("not implemented"); //$NON-NLS-1$ // return null; }
public void setContents(IFileState arg0, int arg1, IProgressMonitor arg2) throws CoreException { throw new RuntimeException("not implemented"); //$NON-NLS-1$ }
public void setContents(IFileState arg0, boolean arg1, boolean arg2, IProgressMonitor arg3) throws CoreException { throw new RuntimeException("not implemented"); //$NON-NLS-1$ }
@Override public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException { throw new RuntimeException("Not implemented"); }
@Override public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { throw new RuntimeException("Not implemented"); }
@Override public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor) throws CoreException { throw new RuntimeException("Not implemented"); }