use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.
the class NotificationContainerItem method getIconBaseOnStatus.
/**
* Return an icon based on {@link org.eclipse.che.ide.api.notification.StatusNotification.Status}.
*
* @return SVG image that represents icon status
*/
private SVGImage getIconBaseOnStatus() {
final SVGResource icon;
final String status;
switch(((StatusNotification) notification).getStatus()) {
case PROGRESS:
icon = resources.progress();
status = "progress";
break;
case SUCCESS:
icon = resources.success();
status = "success";
break;
case FAIL:
icon = resources.fail();
status = "fail";
break;
case WARNING:
icon = resources.warning();
status = "warning";
break;
default:
throw new IllegalArgumentException("Can't determine notification icon");
}
SVGImage image = new SVGImage(icon);
image.getElement().setAttribute("name", status);
return image;
}
use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.
the class CopyPresenter method onCopyClicked.
/** {@inheritDoc} */
@Override
public void onCopyClicked() {
final Project project = appContext.getRootProject();
Preconditions.checkState(project != null);
final Path src = view.isSourceCheckBoxSelected() ? Path.valueOf(view.getSourcePath()) : toRelative(project, sourceNode);
final Path target = view.isTargetCheckBoxSelected() ? Path.valueOf(view.getTargetUrl()) : toRelative(project, this.target);
final String comment = view.isTargetCheckBoxSelected() ? view.getComment() : null;
final StatusNotification notification = new StatusNotification(constants.copyNotificationStarted(src.toString()), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
view.hide();
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
notification.setStatus(PROGRESS);
notification.setTitle(constants.copyNotificationStarted(src.toString()));
return service.copy(project.getLocation(), src, target, comment, credentials);
}
}, notification).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandCopy());
notification.setTitle(constants.copyNotificationSuccessful());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.copyNotificationFailed());
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.
the class AddPresenter method showAdd.
public void showAdd() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
final StatusNotification notification = new StatusNotification(constants.addStarted(resources.length), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
service.add(project.getLocation(), toRelative(project, resources), null, false, true, false, false).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandAdd());
if (response.getErrOutput() == null || response.getErrOutput().size() == 0) {
notification.setTitle(constants.addSuccessful());
notification.setStatus(SUCCESS);
} else {
notification.setTitle(constants.addWarning());
notification.setStatus(FAIL);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.addFailed() + ": " + error.getMessage());
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.
the class CommitPresenter method doCommit.
private void doCommit(String message, Path[] paths, boolean keepLocks) {
final Project project = appContext.getRootProject();
checkState(project != null);
service.commit(project.getLocation(), paths, message, false, keepLocks).then(new Operation<CLIOutputWithRevisionResponse>() {
@Override
public void apply(CLIOutputWithRevisionResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandCommit());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
final StatusNotification notification = new StatusNotification(error.getMessage(), FAIL, FLOAT_MODE);
notificationManager.notify(notification);
}
});
view.onClose();
}
use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.
the class MovePresenter method onMoveClicked.
/** {@inheritDoc} */
@Override
public void onMoveClicked() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Path source = getSource();
final String comment = view.isURLSelected() ? view.getComment() : null;
final StatusNotification notification = new StatusNotification(locale.moveNotificationStarted(source.toString()), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
notification.setStatus(PROGRESS);
notification.setTitle(locale.moveNotificationStarted(source.toString()));
return service.move(project.getLocation(), source, getTarget(), comment, credentials);
}
}, notification).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
notification.setTitle(locale.moveNotificationSuccessful());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notification.setTitle(locale.moveNotificationFailed());
notification.setStatus(FAIL);
}
});
view.onClose();
}
Aggregations