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();
}
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();
}
}
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());
}
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();
}
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();
}
Aggregations