use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ValidateNewName in project che by eclipse.
the class RenameRefactoringTest method testRenamePackage.
@Test
public void testRenamePackage() throws Exception {
final IPackageFragment packageFragment = getRoot().createPackageFragment("p.a.b.c", true, null);
RenameRefactoringSession refactoring = manager.createRenameRefactoring(packageFragment, null, -1, false);
assertThat(refactoring).isNotNull();
assertThat(refactoring.getSessionId()).isNotNull().isNotEmpty();
final ValidateNewName validateNewName = new DtoServerImpls.ValidateNewNameImpl().withNewName("p.x.s.z");
validateNewName.setSessionId(refactoring.getSessionId());
final RefactoringStatus status = manager.renameValidateNewName(validateNewName);
assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ValidateNewName in project che by eclipse.
the class RenamePresenter method validateName.
/** {@inheritDoc} */
@Override
public void validateName() {
ValidateNewName validateNewName = dtoFactory.createDto(ValidateNewName.class);
validateNewName.setSessionId(renameRefactoringSession.getSessionId());
validateNewName.setNewName(view.getNewName());
refactorService.validateNewName(validateNewName).then(new Operation<RefactoringStatus>() {
@Override
public void apply(RefactoringStatus arg) throws OperationException {
switch(arg.getSeverity()) {
case OK:
view.setEnableAcceptButton(true);
view.setEnablePreviewButton(true);
view.clearErrorLabel();
break;
case INFO:
view.setEnableAcceptButton(true);
view.setEnablePreviewButton(true);
view.showStatusMessage(arg);
break;
default:
view.setEnableAcceptButton(false);
view.setEnablePreviewButton(false);
view.showErrorMessage(arg);
break;
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify(locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
}
});
}
Aggregations