use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult in project che by eclipse.
the class MovePresenter method onAcceptButtonClicked.
/** {@inheritDoc} */
@Override
public void onAcceptButtonClicked() {
final RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
session.setSessionId(refactoringSessionId);
prepareMovingChanges(session).then(new Operation<ChangeCreationResult>() {
@Override
public void apply(ChangeCreationResult arg) throws OperationException {
if (arg.isCanShowPreviewPage()) {
eventBus.fireEvent(newFileTrackingSuspendEvent());
refactorService.applyRefactoring(session).then(new Operation<RefactoringResult>() {
@Override
public void apply(RefactoringResult arg) throws OperationException {
if (arg.getSeverity() == OK) {
view.hide();
refactoringUpdater.updateAfterRefactoring(arg.getChanges());
final Resource[] resources = refactorInfo.getResources();
if (resources != null && resources.length == 1) {
refactorService.reindexProject(resources[0].getRelatedProject().get().getLocation().toString());
}
} else {
view.showErrorMessage(arg);
}
for (ChangeInfo change : arg.getChanges()) {
final String path = change.getPath();
final String oldPath = change.getOldPath();
eventBus.fireEvent(newFileTrackingMoveEvent(path, oldPath));
}
eventBus.fireEvent(newFileTrackingResumeEvent());
}
});
} else {
view.showErrorMessage(arg.getStatus());
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(locale.applyMoveError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult in project che by eclipse.
the class JavaRefactoringRename method performRename.
private void performRename(RenameRefactoringSession session) {
final LinkedRenameRefactoringApply dto = createLinkedRenameRefactoringApplyDto(newName, session.getSessionId());
Promise<RefactoringResult> applyModelPromise = refactoringServiceClient.applyLinkedModeRename(dto);
applyModelPromise.then(new Operation<RefactoringResult>() {
@Override
public void apply(RefactoringResult result) throws OperationException {
switch(result.getSeverity()) {
case OK:
case INFO:
final VirtualFile file = textEditor.getDocument().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
refactoringServiceClient.reindexProject(project.get().getLocation().toString());
}
refactoringUpdater.updateAfterRefactoring(result.getChanges());
break;
case WARNING:
case ERROR:
enableAutoSave();
undoChanges();
showWarningDialog();
break;
case FATAL:
undoChanges();
notificationManager.notify(locale.failedToRename(), result.getEntries().get(0).getMessage(), FAIL, FLOAT_MODE);
break;
default:
break;
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
enableAutoSave();
undoChanges();
notificationManager.notify(locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
}
});
}
Aggregations