use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.
the class MoveRefactoringSessionTest method testPreviewChanges.
@Test
public void testPreviewChanges() throws Exception {
IType type = fProject.findType("p.A");
ICompilationUnit unit = type.getCompilationUnit();
String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
destination.setSessionId(sessionId);
destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
destination.setDestination(p1.getPath().toOSString());
destination.setType(ReorgDestination.DestinationType.PACKAGE);
manager.setRefactoringDestination(destination);
MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
settings.setUpdateReferences(true);
settings.setSessionId(sessionId);
manager.setMoveSettings(settings);
manager.createChange(sessionId);
RefactoringPreview change = manager.getRefactoringPreview(sessionId);
RefactoringChange change1 = new DtoServerImpls.ChangeEnabledStateImpl();
change1.setSessionId(sessionId);
change1.setChangeId(change.getChildrens().get(0).getId());
ChangePreview preview = manager.getChangePreview(change1);
assertThat(preview).isNotNull();
assertThat(preview.getFileName()).isNotNull().isNotEmpty();
assertThat(preview.getOldContent()).isNotNull().isNotEmpty();
assertThat(preview.getNewContent()).isNotNull().isNotEmpty();
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.
the class MoveRefactoringSessionTest method testCtrateMoveChanges.
@Test
public void testCtrateMoveChanges() throws Exception {
IType type = fProject.findType("p.A");
ICompilationUnit unit = type.getCompilationUnit();
String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
destination.setSessionId(sessionId);
destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
destination.setDestination(p1.getPath().toOSString());
destination.setType(ReorgDestination.DestinationType.PACKAGE);
manager.setRefactoringDestination(destination);
MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
settings.setUpdateReferences(true);
settings.setSessionId(sessionId);
manager.setMoveSettings(settings);
ChangeCreationResult change = manager.createChange(sessionId);
assertThat(change).isNotNull();
assertThat(change.isCanShowPreviewPage()).isTrue();
assertThat(change.getStatus().getSeverity()).isEqualTo(RefactoringStatus.OK);
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.
the class MovePresenter method setMoveDestinationPath.
/** {@inheritDoc} */
@Override
public void setMoveDestinationPath(String path, String projectPath) {
ReorgDestination destination = dtoFactory.createDto(ReorgDestination.class);
destination.setType(ReorgDestination.DestinationType.PACKAGE);
destination.setSessionId(refactoringSessionId);
destination.setProjectPath(projectPath);
destination.setDestination(path);
Promise<RefactoringStatus> promise = refactorService.setDestination(destination);
promise.then(new Operation<RefactoringStatus>() {
@Override
public void apply(RefactoringStatus arg) throws OperationException {
view.setEnableAcceptButton(true);
view.setEnablePreviewButton(true);
switch(arg.getSeverity()) {
case INFO:
view.showStatusMessage(arg);
break;
case WARNING:
view.showStatusMessage(arg);
break;
case ERROR:
showErrorMessage(arg);
break;
case FATAL:
showErrorMessage(arg);
break;
case OK:
default:
view.clearStatusMessage();
break;
}
}
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.
the class MoveRefactoringSessionTest method testSetMoveDestination.
@Test
public void testSetMoveDestination() throws Exception {
IType type = fProject.findType("p.A");
ICompilationUnit unit = type.getCompilationUnit();
String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
destination.setSessionId(sessionId);
destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
destination.setDestination(p1.getPath().toOSString());
destination.setType(ReorgDestination.DestinationType.PACKAGE);
RefactoringStatus status = manager.setRefactoringDestination(destination);
assertThat(status).isNotNull();
assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.
the class MoveRefactoringSessionTest method testApplyMove.
@Test
public void testApplyMove() throws Exception {
IType type = fProject.findType("p.A");
ICompilationUnit unit = type.getCompilationUnit();
String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
destination.setSessionId(sessionId);
destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
destination.setDestination(p1.getPath().toOSString());
destination.setType(ReorgDestination.DestinationType.PACKAGE);
manager.setRefactoringDestination(destination);
MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
settings.setUpdateReferences(true);
settings.setSessionId(sessionId);
manager.setMoveSettings(settings);
manager.createChange(sessionId);
RefactoringStatus status = manager.applyRefactoring(sessionId);
assertThat(status).isNotNull();
assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
IType movedType = fProject.findType("p1.A");
assertThat(movedType).isNotNull();
assertThat(movedType.exists()).isTrue();
}
Aggregations