use of org.eclipse.che.jdt.core.resources.ResourceChangedEvent in project che by eclipse.
the class BaseTest method createTestProject.
protected FolderEntry createTestProject() throws ServerException, NotFoundException, ConflictException, ForbiddenException {
String classpath = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<classpath>\n" + "\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n" + "</classpath>";
FolderEntry parent = projectManager.getProjectsRoot().createFolder("project");
parent.createFolder("bin");
parent.createFolder("src");
FolderEntry codenvyFolder = parent.createFolder(".che");
FolderEntry libFolder = parent.createFolder("lib");
libFolder.createFile("a.jar", "text".getBytes());
codenvyFolder.createFile("classpath", classpath.getBytes());
projectRegistry.setProjectType(parent.getPath().toString(), PlainJavaProjectConstants.JAVAC_PROJECT_ID, false);
//inform DeltaProcessingStat about new project
JavaModelManager.getJavaModelManager().deltaState.resourceChanged(new ResourceChangedEvent(root, new ProjectCreatedEvent("", parent.getPath().toString())));
return parent;
}
use of org.eclipse.che.jdt.core.resources.ResourceChangedEvent in project che by eclipse.
the class ProjectListeners method handleEvent.
public void handleEvent(ProjectItemModifiedEvent event) {
final String eventPath = event.getPath();
if (!isJavaProject(event.getProject())) {
return;
}
try {
JavaModelManager.getJavaModelManager().deltaState.resourceChanged(new ResourceChangedEvent(workspace, event));
} catch (Throwable t) {
//catch all exceptions that may be happened
LOG.error("Can't update java model in " + eventPath, t);
}
if (event.getType() == ProjectItemModifiedEvent.EventType.UPDATED) {
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
ITextFileBuffer fileBuffer = manager.getTextFileBuffer(new Path(eventPath), LocationKind.IFILE);
if (fileBuffer != null) {
try {
fileBuffer.revert(new NullProgressMonitor());
} catch (CoreException e) {
LOG.error("Can't read file content: " + eventPath, e);
}
}
}
}
use of org.eclipse.che.jdt.core.resources.ResourceChangedEvent in project che by eclipse.
the class DeltaProcessingTest method testAddClass.
@Test
public void testAddClass() throws Exception {
File workspace = new File(BaseTest.class.getResource("/projects").getFile());
ResourceChangedEvent event = new ResourceChangedEvent(workspace, new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.CREATED, "projects", "test", "/test/src/main/java/org/eclipse/che/test/NewClass.java", false));
NameEnvironmentAnswer answer = project.newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY).findType(CharOperation.splitOn('.', "org.eclipse.che.test.NewClass".toCharArray()));
assertThat(answer).isNull();
FileOutputStream outputStream = new FileOutputStream(new File(workspace, "/test/src/main/java/org/eclipse/che/test/NewClass.java"));
outputStream.write("package org.eclipse.che.test;\n public class NewClass{}\n".getBytes());
outputStream.close();
JavaModelManager.getJavaModelManager().deltaState.resourceChanged(event);
answer = project.newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY).findType(CharOperation.splitOn('.', "org.eclipse.che.test.NewClass".toCharArray()));
assertThat(answer).isNotNull();
}
use of org.eclipse.che.jdt.core.resources.ResourceChangedEvent in project che by eclipse.
the class DeltaProcessingTest method testRemoveClass.
@Test
public void testRemoveClass() throws Exception {
ResourceChangedEvent event = new ResourceChangedEvent(new File(BaseTest.class.getResource("/projects").getFile()), new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.DELETED, "projects", "test", "/test/src/main/java/org/eclipse/che/test/MyClass.java", false));
NameEnvironmentAnswer answer = project.newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY).findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));
assertThat(answer).isNotNull();
JavaModelManager.getJavaModelManager().deltaState.resourceChanged(event);
answer = project.newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY).findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));
assertThat(answer).isNull();
}
use of org.eclipse.che.jdt.core.resources.ResourceChangedEvent in project che by eclipse.
the class DeltaProcessingTest method testRemoveFolder.
@Test
public void testRemoveFolder() throws Exception {
ResourceChangedEvent event = new ResourceChangedEvent(new File(BaseTest.class.getResource("/projects").getFile()), new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.DELETED, "projects", "test", "/test/src/main/java/org/eclipse/che/test", true));
NameEnvironmentAnswer answer = project.newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY).findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));
assertThat(answer).isNotNull();
JavaModelManager.getJavaModelManager().deltaState.resourceChanged(event);
answer = project.newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY).findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));
assertThat(answer).isNull();
}
Aggregations