use of org.eclipse.core.resources.IWorkspace in project che by eclipse.
the class RefactoringTest method performRefactoring.
protected final RefactoringStatus performRefactoring(Refactoring ref, boolean providesUndo) throws Exception {
performDummySearch();
IUndoManager undoManager = getUndoManager();
if (DESCRIPTOR_TEST) {
final CreateChangeOperation create = new CreateChangeOperation(new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS), RefactoringStatus.FATAL);
create.run(new NullProgressMonitor());
RefactoringStatus checkingStatus = create.getConditionCheckingStatus();
if (!checkingStatus.isOK())
return checkingStatus;
Change change = create.getChange();
ChangeDescriptor descriptor = change.getDescriptor();
if (descriptor instanceof RefactoringChangeDescriptor) {
RefactoringChangeDescriptor rcd = (RefactoringChangeDescriptor) descriptor;
RefactoringDescriptor refactoringDescriptor = rcd.getRefactoringDescriptor();
if (refactoringDescriptor instanceof JavaRefactoringDescriptor) {
JavaRefactoringDescriptor jrd = (JavaRefactoringDescriptor) refactoringDescriptor;
RefactoringStatus validation = jrd.validateDescriptor();
if (!validation.isOK())
return validation;
RefactoringStatus refactoringStatus = new RefactoringStatus();
Class expected = jrd.getClass();
RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(jrd.getID());
jrd = (JavaRefactoringDescriptor) contribution.createDescriptor(jrd.getID(), jrd.getProject(), jrd.getDescription(), jrd.getComment(), contribution.retrieveArgumentMap(jrd), jrd.getFlags());
assertEquals(expected, jrd.getClass());
ref = jrd.createRefactoring(refactoringStatus);
if (!refactoringStatus.isOK())
return refactoringStatus;
TestRenameParticipantSingle.reset();
TestCreateParticipantSingle.reset();
TestMoveParticipantSingle.reset();
TestDeleteParticipantSingle.reset();
}
}
}
final CreateChangeOperation create = new CreateChangeOperation(new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS), RefactoringStatus.FATAL);
final PerformChangeOperation perform = new PerformChangeOperation(create);
perform.setUndoManager(undoManager, ref.getName());
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (fIsPreDeltaTest) {
IResourceChangeListener listener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
if (create.getConditionCheckingStatus().isOK() && perform.changeExecuted()) {
TestModelProvider.assertTrue(event.getDelta());
}
}
};
try {
TestModelProvider.clearDelta();
workspace.checkpoint(false);
workspace.addResourceChangeListener(listener);
executePerformOperation(perform, workspace);
} finally {
workspace.removeResourceChangeListener(listener);
}
} else {
executePerformOperation(perform, workspace);
}
RefactoringStatus status = create.getConditionCheckingStatus();
if (!status.isOK())
return status;
assertTrue("Change wasn't executed", perform.changeExecuted());
Change undo = perform.getUndoChange();
if (providesUndo) {
assertNotNull("Undo doesn't exist", undo);
assertTrue("Undo manager is empty", undoManager.anythingToUndo());
} else {
assertNull("Undo manager contains undo but shouldn't", undo);
}
return null;
}
use of org.eclipse.core.resources.IWorkspace in project che by eclipse.
the class PomChangeListener method updateProms.
// @ScheduleDelay(initialDelay = 30, delay = 3)
protected void updateProms() {
try {
if (projectToUpdate.size() == 0) {
return;
}
Set<String> projects = new HashSet<>(projectToUpdate);
projectToUpdate.clear();
IWorkspace workspace = eclipseWorkspaceProvider.get();
List<IProject> projectsList = projects.stream().map(project -> workspace.getRoot().getProject(project)).collect(Collectors.toList());
mavenWorkspace.update(projectsList);
} catch (Throwable t) {
JavaPlugin.log(t);
}
}
use of org.eclipse.core.resources.IWorkspace in project che by eclipse.
the class MavenServerService method reimportDependencies.
@POST
@Path("reimport")
@ApiOperation(value = "Re-import maven model")
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Internal Server Error") })
public Response reimportDependencies(@ApiParam(value = "The paths to projects which need to be reimported") @QueryParam("projectPath") List<String> paths) throws ServerException {
IWorkspace workspace = eclipseWorkspaceProvider.get();
List<IProject> projectsList = paths.stream().map(projectPath -> workspace.getRoot().getProject(projectPath)).collect(Collectors.toList());
mavenWorkspace.update(projectsList);
return Response.ok().build();
}
use of org.eclipse.core.resources.IWorkspace in project che by eclipse.
the class ResourceChangeDescriptionFactory method getDelta.
private ProposedResourceDelta getDelta(IResource resource) {
ProposedResourceDelta delta = (ProposedResourceDelta) root.findMember(resource.getFullPath());
if (delta != null) {
return delta;
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResource iResource = resource.getParent();
if (iResource == null) {
iResource = ((Workspace) workspace).newResource(resource.getFullPath().removeLastSegments(1), IResource.FOLDER);
}
ProposedResourceDelta parent = getDelta(iResource);
delta = new ProposedResourceDelta(resource);
parent.add(delta);
return delta;
}
use of org.eclipse.core.resources.IWorkspace in project flux by eclipse.
the class Activator method initCoreService.
private void initCoreService(String userChannel) throws CoreException {
repository = new Repository(messageConnector, userChannel);
liveEditCoordinator = new LiveEditCoordinator(messageConnector);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
resourceListener = new CloudSyncResourceListener(repository);
workspace.addResourceChangeListener(resourceListener, IResourceChangeEvent.POST_CHANGE);
metadataListener = new CloudSyncMetadataListener(repository);
workspace.addResourceChangeListener(metadataListener, IResourceChangeEvent.POST_BUILD);
this.repositoryListener = new IRepositoryListener() {
@Override
public void projectDisconnected(IProject project) {
removeConnectedProjectPreference(project.getName());
}
@Override
public void projectConnected(IProject project) {
addConnectedProjectPreference(project.getName());
}
@Override
public void resourceChanged(IResource resource) {
// nothing
}
};
getRepository().addRepositoryListener(repositoryListener);
workspaceListener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
if (event.getResource() instanceof IProject) {
IResourceDelta delta = event.getDelta();
if (delta == null) {
return;
}
if (delta.getKind() == IResourceDelta.REMOVED) {
IProject project = (IProject) event.getResource();
removeConnectedProjectPreference(project.getName());
} else if (delta.getKind() == IResourceDelta.CHANGED) {
// TODO, we aren't handling project renaming yet
// IProject project = (IProject) event.getResource();
// String oldName =
// delta.getMovedFromPath().lastSegment();
// removeConnectedProjectPreference(oldName);
// addConnectedProjectPreference(project.getName());
}
}
}
};
workspace.addResourceChangeListener(workspaceListener);
updateProjectConnections();
}
Aggregations