Search in sources :

Example 6 with IStorage

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());
        }
    }
}
Also used : IStorage(org.eclipse.core.resources.IStorage) IDocument(org.eclipse.jface.text.IDocument)

Example 7 with IStorage

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);
}
Also used : ToBeBuilt(org.eclipse.xtext.builder.impl.ToBeBuilt) IResourceDeltaVisitor(org.eclipse.core.resources.IResourceDeltaVisitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) IStorage(org.eclipse.core.resources.IStorage) IProject(org.eclipse.core.resources.IProject) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 8 with IStorage

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);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) IStorage(org.eclipse.core.resources.IStorage) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 9 with IStorage

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);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) IStorage(org.eclipse.core.resources.IStorage) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 10 with IStorage

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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IFileState(org.eclipse.core.resources.IFileState) IStorage(org.eclipse.core.resources.IStorage)

Aggregations

IStorage (org.eclipse.core.resources.IStorage)96 URI (org.eclipse.emf.common.util.URI)32 IFile (org.eclipse.core.resources.IFile)31 IProject (org.eclipse.core.resources.IProject)27 CoreException (org.eclipse.core.runtime.CoreException)25 IResource (org.eclipse.core.resources.IResource)20 Pair (org.eclipse.xtext.util.Pair)16 Test (org.junit.Test)15 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)13 IStorageEditorInput (org.eclipse.ui.IStorageEditorInput)12 IPath (org.eclipse.core.runtime.IPath)11 IJavaProject (org.eclipse.jdt.core.IJavaProject)10 IOException (java.io.IOException)7 WrappedException (org.eclipse.emf.common.util.WrappedException)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 InputStream (java.io.InputStream)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)6 GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)6 Storage2UriMapperJavaImpl (org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl)6