use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class UploadFilePresenter method onSubmitComplete.
/** {@inheritDoc} */
@Override
public void onSubmitComplete(String result) {
if (!isNullOrEmpty(result)) {
view.closeDialog();
notificationManager.notify(locale.failedToUploadFiles(), parseMessage(result), StatusNotification.Status.FAIL, FLOAT_MODE);
return;
}
container.getFile(Path.valueOf(view.getFileName())).then(new Operation<Optional<File>>() {
@Override
public void apply(final Optional<File> file) throws OperationException {
if (file.isPresent()) {
eventBus.fireEvent(new RevealResourceEvent(file.get()));
final NotificationListener notificationListener = new NotificationListener() {
boolean clicked = false;
@Override
public void onClick(Notification notification) {
if (!clicked) {
eventBus.fireEvent(FileEvent.createOpenFileEvent(file.get()));
clicked = true;
notification.setListener(null);
notification.setContent("");
}
}
@Override
public void onDoubleClick(Notification notification) {
//stub
}
@Override
public void onClose(Notification notification) {
//stub
}
};
notificationManager.notify("File '" + view.getFileName() + "' has uploaded successfully", "Click here to open it", StatusNotification.Status.SUCCESS, FLOAT_MODE, notificationListener);
view.closeDialog();
}
}
});
//TODO this should process editor agent
// if (view.isOverwriteFileSelected()) {
// String path = ((HasStorablePath)getResourceBasedNode()).getStorablePath() + "/" + view.getFileName();
// eventBus.fireEvent(new FileContentUpdateEvent(path));
// }
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class JavaRefactoringRename method createLinkedRenameSession.
private void createLinkedRenameSession() {
final CreateRenameRefactoring refactoringSession = createRenameRefactoringDto(textEditor, true);
Promise<RenameRefactoringSession> createRenamePromise = refactoringServiceClient.createRenameRefactoring(refactoringSession);
createRenamePromise.then(new Operation<RenameRefactoringSession>() {
@Override
public void apply(RenameRefactoringSession session) throws OperationException {
activateLinkedModeIntoEditor(session, textEditor.getDocument());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
isActiveLinkedEditor = false;
showError();
}
});
}
use of org.eclipse.che.api.promises.client.OperationException 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);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class JavaRefactoringRename method createRenameSession.
private void createRenameSession() {
final CreateRenameRefactoring refactoringSession = createRenameRefactoringDto(textEditor, false);
Promise<RenameRefactoringSession> createRenamePromise = refactoringServiceClient.createRenameRefactoring(refactoringSession);
createRenamePromise.then(new Operation<RenameRefactoringSession>() {
@Override
public void apply(RenameRefactoringSession session) throws OperationException {
renamePresenter.show(session);
if (mode != null) {
mode.exitLinkedMode(false);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
showError();
}
});
}
use of org.eclipse.che.api.promises.client.OperationException 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