use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult 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.ChangeCreationResult in project che by eclipse.
the class RenamePresenter method applyChanges.
private void applyChanges() {
final RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
session.setSessionId(renameRefactoringSession.getSessionId());
prepareRenameChanges(session).then(new Operation<ChangeCreationResult>() {
@Override
public void apply(ChangeCreationResult arg) throws OperationException {
int severityCode = arg.getStatus().getSeverity();
switch(severityCode) {
case WARNING:
case ERROR:
showWarningDialog(session, arg);
break;
case FATAL:
if (!arg.isCanShowPreviewPage()) {
view.showErrorMessage(arg.getStatus());
}
break;
default:
applyRefactoring(session);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify(locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
}
});
}
Aggregations