use of org.eclipse.core.resources.IStorage in project jbosstools-hibernate by jbosstools.
the class CriteriaEditor method showEditorInput.
public void showEditorInput(IEditorInput editorInput) {
if (!(getEditorInput() instanceof CriteriaEditorInput)) {
super.showEditorInput(editorInput);
return;
}
CriteriaEditorInput hei = (CriteriaEditorInput) getEditorInput();
super.showEditorInput(editorInput);
IStorage storage = ((CriteriaEditorInput) editorInput).getStorage();
if (storage instanceof CriteriaEditorStorage) {
CriteriaEditorStorage sqlEditorStorage = (CriteriaEditorStorage) storage;
IDocument document = getDocumentProvider().getDocument(hei);
if (document.get().compareTo(sqlEditorStorage.getContentsString()) != 0) {
document.set(sqlEditorStorage.getContentsString());
}
}
}
use of org.eclipse.core.resources.IStorage in project dsl-devkit by dsldevkit.
the class RebuildingXtextBuilder method incrementalBuild.
@Override
protected void incrementalBuild(final IResourceDelta delta, final IProgressMonitor monitor) throws CoreException {
final SubMonitor progress = SubMonitor.convert(monitor, Messages.XtextBuilder_CollectingResources, 2);
progress.subTask(Messages.XtextBuilder_CollectingResources);
final ToBeBuilt toBeBuilt = new ToBeBuilt();
IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
@Override
public boolean visit(final IResourceDelta delta) throws CoreException {
if (progress.isCanceled()) {
throw new OperationCanceledException();
}
if (delta.getResource() instanceof IProject) {
return delta.getResource() == getProject();
}
if (delta.getResource() instanceof IStorage) {
if (delta.getKind() == IResourceDelta.REMOVED) {
return getToBeBuiltComputer().removeStorage(null, toBeBuilt, (IStorage) delta.getResource());
} else if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {
return getToBeBuiltComputer().updateStorage(null, toBeBuilt, (IStorage) delta.getResource());
}
}
return true;
}
};
delta.accept(visitor);
if (progress.isCanceled()) {
throw new OperationCanceledException();
}
progress.worked(1);
doBuild(toBeBuilt, progress.newChild(1), BuildType.INCREMENTAL);
}
use of org.eclipse.core.resources.IStorage in project egit by eclipse.
the class HistoryTest method testIndexRevisionSecondCommit.
@Test
public void testIndexRevisionSecondCommit() throws Exception {
GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
assertNotNull(provider);
IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/B.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
IFileRevision fileRevision = fileHistory.getFileRevision(GitFileRevision.INDEX);
assertEquals(GitFileRevision.INDEX, fileRevision.getContentIdentifier());
IStorage storage = fileRevision.getStorage(null);
String content = testUtils.slurpAndClose(storage.getContents());
assertEquals("B.txt - second version\n", content);
}
use of org.eclipse.core.resources.IStorage in project egit by eclipse.
the class HistoryTest method testIndexRevision.
@Test
public void testIndexRevision() throws Exception {
GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
assertNotNull(provider);
IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/A.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
IFileRevision fileRevision = fileHistory.getFileRevision(GitFileRevision.INDEX);
assertEquals(GitFileRevision.INDEX, fileRevision.getContentIdentifier());
IStorage storage = fileRevision.getStorage(null);
String content = testUtils.slurpAndClose(storage.getContents());
assertEquals("A.txt - first version\n", content);
}
use of org.eclipse.core.resources.IStorage in project egit by eclipse.
the class GitCompareFileRevisionEditorInput method getContentIdentifier.
private String getContentIdentifier(ITypedElement element) {
if (element instanceof FileRevisionTypedElement) {
FileRevisionTypedElement fileRevisionElement = (FileRevisionTypedElement) element;
Object fileObject = fileRevisionElement.getFileRevision();
if (fileObject instanceof LocalFileRevision) {
try {
IStorage storage = ((LocalFileRevision) fileObject).getStorage(new NullProgressMonitor());
if (AdapterUtils.adapt(storage, IFileState.class) != null) {
// local revision
return UIText.GitCompareFileRevisionEditorInput_LocalRevision;
} else if (AdapterUtils.adapt(storage, IFile.class) != null) {
// current revision
return UIText.GitCompareFileRevisionEditorInput_CurrentRevision;
}
} catch (CoreException e) {
Activator.logError(UIText.GitCompareFileRevisionEditorInput_contentIdentifier, e);
}
} else {
return fileRevisionElement.getContentIdentifier();
}
}
return UIText.GitCompareFileRevisionEditorInput_CurrentTitle;
}
Aggregations