Search in sources :

Example 6 with IFolder

use of org.eclipse.core.resources.IFolder in project che by eclipse.

the class ContainerDescription method recordStateFromHistory.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#recordStateFromHistory(org.eclipse.core.resources.IResource,
	 *      org.eclipse.core.runtime.IProgressMonitor)
	 */
public void recordStateFromHistory(IResource resource, IProgressMonitor monitor) throws CoreException {
    monitor.beginTask(UndoMessages.FolderDescription_SavingUndoInfoProgress, 100);
    if (members != null) {
        for (int i = 0; i < members.length; i++) {
            if (members[i] instanceof FileDescription) {
                IPath path = resource.getFullPath().append(((FileDescription) members[i]).name);
                IFile fileHandle = resource.getWorkspace().getRoot().getFile(path);
                members[i].recordStateFromHistory(fileHandle, new SubProgressMonitor(monitor, 100 / members.length));
            } else if (members[i] instanceof FolderDescription) {
                IPath path = resource.getFullPath().append(((FolderDescription) members[i]).name);
                IFolder folderHandle = resource.getWorkspace().getRoot().getFolder(path);
                members[i].recordStateFromHistory(folderHandle, new SubProgressMonitor(monitor, 100 / members.length));
            }
        }
    }
    monitor.done();
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IFolder(org.eclipse.core.resources.IFolder)

Example 7 with IFolder

use of org.eclipse.core.resources.IFolder in project che by eclipse.

the class FolderUndoState method createExistentResourceFromHandle.

public void createExistentResourceFromHandle(IResource resource, IProgressMonitor monitor) throws CoreException {
    Assert.isLegal(resource instanceof IFolder);
    if (resource.exists()) {
        return;
    }
    IFolder folderHandle = (IFolder) resource;
    try {
        //$NON-NLS-1$
        monitor.beginTask("", 200);
        monitor.setTaskName(RefactoringCoreMessages.FolderDescription_NewFolderProgress);
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        if (location != null) {
            folderHandle.createLink(location, IResource.ALLOW_MISSING_LOCAL, new SubProgressMonitor(monitor, 100));
        } else {
            folderHandle.create(false, true, new SubProgressMonitor(monitor, 100));
        }
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        createChildResources(folderHandle, monitor, 100);
    } finally {
        monitor.done();
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IFolder(org.eclipse.core.resources.IFolder)

Example 8 with IFolder

use of org.eclipse.core.resources.IFolder in project che by eclipse.

the class ClasspathBuilderTest method elementShouldBeAddedAsLibToClasspathFromLibFolder.

@Test
public void elementShouldBeAddedAsLibToClasspathFromLibFolder() throws Exception {
    Path jarPath = new Path(LIBRARY + "/a.jar");
    library.add(LIBRARY);
    IFolder libraryFolder1 = mock(IFolder.class);
    IResourceProxy iResourceProxy = mock(IResourceProxy.class);
    IResource iResource = mock(IResource.class);
    when(iProject.getFolder(LIBRARY)).thenReturn(libraryFolder1);
    when(libraryFolder1.exists()).thenReturn(true);
    when(iResourceProxy.getType()).thenReturn(IResource.FILE);
    when(iResourceProxy.requestFullPath()).thenReturn(jarPath);
    when(iResourceProxy.requestResource()).thenReturn(iResource);
    when(iResource.getLocation()).thenReturn(jarPath);
    classpathBuilder.generateClasspath(iJavaProject, sourceFolders, library);
    ArgumentCaptor<IResourceProxyVisitor> resourceProxyVisitorArgumentCaptor = ArgumentCaptor.forClass(IResourceProxyVisitor.class);
    verify(libraryFolder1).accept(resourceProxyVisitorArgumentCaptor.capture(), eq(IContainer.INCLUDE_PHANTOMS));
    resourceProxyVisitorArgumentCaptor.getValue().visit(iResourceProxy);
    verify(iResourceProxy).getType();
    assertEquals(jarPath, iResource.getLocation());
}
Also used : Path(org.eclipse.core.runtime.Path) IResourceProxyVisitor(org.eclipse.core.resources.IResourceProxyVisitor) IResourceProxy(org.eclipse.core.resources.IResourceProxy) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder) Test(org.testng.annotations.Test) BaseTest(org.eclipse.che.plugin.java.plain.server.BaseTest)

Example 9 with IFolder

use of org.eclipse.core.resources.IFolder in project che by eclipse.

the class ClasspathBuilderTest method libraryFolderShouldNotBeAddedIfItIsNotExist.

@Test
public void libraryFolderShouldNotBeAddedIfItIsNotExist() throws Exception {
    library.add(LIBRARY);
    IFolder libraryFolder1 = mock(IFolder.class);
    when(iProject.getFolder(LIBRARY)).thenReturn(libraryFolder1);
    when(libraryFolder1.exists()).thenReturn(false);
    classpathBuilder.generateClasspath(iJavaProject, sourceFolders, library);
    verifyIfOnlyJREContainerInClasspath();
}
Also used : IFolder(org.eclipse.core.resources.IFolder) Test(org.testng.annotations.Test) BaseTest(org.eclipse.che.plugin.java.plain.server.BaseTest)

Example 10 with IFolder

use of org.eclipse.core.resources.IFolder in project che by eclipse.

the class ClasspathBuilderTest method folderShouldNotBeAddedToClasspathIfItNotExist.

@Test
public void folderShouldNotBeAddedToClasspathIfItNotExist() throws Exception {
    IFolder sourceFolder1 = mock(IFolder.class);
    when(iProject.getFolder(SOURCE_FOLDER1)).thenReturn(sourceFolder1);
    when(sourceFolder1.exists()).thenReturn(false);
    sourceFolders.add(SOURCE_FOLDER1);
    classpathBuilder.generateClasspath(iJavaProject, sourceFolders, library);
    verify(iProject).getFolder(anyString());
    verifyIfOnlyJREContainerInClasspath();
}
Also used : IFolder(org.eclipse.core.resources.IFolder) Test(org.testng.annotations.Test) BaseTest(org.eclipse.che.plugin.java.plain.server.BaseTest)

Aggregations

IFolder (org.eclipse.core.resources.IFolder)237 IFile (org.eclipse.core.resources.IFile)95 IPath (org.eclipse.core.runtime.IPath)70 CoreException (org.eclipse.core.runtime.CoreException)65 IProject (org.eclipse.core.resources.IProject)64 IResource (org.eclipse.core.resources.IResource)56 File (java.io.File)35 IContainer (org.eclipse.core.resources.IContainer)33 ArrayList (java.util.ArrayList)31 Path (org.eclipse.core.runtime.Path)31 IOException (java.io.IOException)26 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)26 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)18 Test (org.junit.Test)18 IRunProcessService (org.talend.designer.runprocess.IRunProcessService)17 PersistenceException (org.talend.commons.exception.PersistenceException)16 InputStream (java.io.InputStream)15 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)13 IJavaProject (org.eclipse.jdt.core.IJavaProject)13 URL (java.net.URL)12