Search in sources :

Example 16 with StatusNotification

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;
}
Also used : SVGResource(org.vectomatic.dom.svg.ui.SVGResource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 17 with StatusNotification

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);
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 18 with StatusNotification

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);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 19 with StatusNotification

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();
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 20 with StatusNotification

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();
}
Also used : Path(org.eclipse.che.ide.resource.Path) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)28 Operation (org.eclipse.che.api.promises.client.Operation)20 OperationException (org.eclipse.che.api.promises.client.OperationException)20 PromiseError (org.eclipse.che.api.promises.client.PromiseError)20 Project (org.eclipse.che.ide.api.resources.Project)12 Resource (org.eclipse.che.ide.api.resources.Resource)7 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)7 TestResult (org.eclipse.che.api.testing.shared.TestResult)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 Promise (org.eclipse.che.api.promises.client.Promise)4 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)3 NotificationListener (org.eclipse.che.ide.api.notification.NotificationListener)2 Credentials (org.eclipse.che.ide.api.subversion.Credentials)2 Path (org.eclipse.che.ide.resource.Path)2 Depth (org.eclipse.che.plugin.svn.shared.Depth)2 URL (com.google.gwt.http.client.URL)1 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 Label (com.google.gwt.user.client.ui.Label)1