Search in sources :

Example 1 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class ExportPresenter method onExportClicked.

/** {@inheritDoc} */
@Override
public void onExportClicked() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    final String givenRevision = view.isRevisionSpecified() ? view.getRevision() : null;
    final StatusNotification notification = new StatusNotification(constants.exportStarted(resources[0].getLocation().toString()), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    view.onClose();
    if (!isNullOrEmpty(givenRevision)) {
        service.getRevisions(project.getLocation(), toRelative(project, resources[0]), "1:HEAD").then(new Operation<GetRevisionsResponse>() {

            @Override
            public void apply(GetRevisionsResponse response) throws OperationException {
                final List<String> pathRevisions = response.getRevisions();
                if (pathRevisions.size() > 0) {
                    final String pathFirstRevision = pathRevisions.get(0);
                    final String pathLastRevision = pathRevisions.get(pathRevisions.size() - 1);
                    final int givenRevisionNb = Integer.valueOf(givenRevision);
                    final int pathFirstRevisionNb = Integer.valueOf(pathFirstRevision.substring(1));
                    final int pathLastRevisionNb = Integer.valueOf(pathLastRevision.substring(1));
                    final List<String> errOutput = response.getErrOutput();
                    if (errOutput != null && !errOutput.isEmpty()) {
                        printErrors(errOutput, constants.commandInfo());
                        notification.setTitle(constants.exportCommandExecutionError());
                        notification.setStatus(FAIL);
                    } else if (givenRevisionNb < pathFirstRevisionNb || givenRevisionNb > pathLastRevisionNb) {
                        notification.setTitle(constants.exportRevisionDoNotExistForPath(givenRevision, toRelative(project, resources[0]).toString()));
                        notification.setStatus(FAIL);
                    } else {
                        openExportPopup(project.getLocation(), toRelative(project, resources[0]), givenRevision, notification);
                    }
                } else {
                    notification.setTitle(constants.exportNoRevisionForPath(toRelative(project, resources[0]).toString()));
                    notification.setStatus(FAIL);
                }
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                notification.setTitle(constants.exportCommandExecutionError() + "\n" + error.getMessage());
                notification.setStatus(FAIL);
            }
        });
    } else {
        openExportPopup(project.getLocation(), toRelative(project, resources[0]), null, notification);
    }
}
Also used : GetRevisionsResponse(org.eclipse.che.plugin.svn.shared.GetRevisionsResponse) Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class NotificationContainerItem method update.

/**
     * Update notification's widget values.
     * <p/>
     * Widget consumes:
     * <ul>
     * <li>{@link Notification#title}</li>
     * <li>{@link Notification#content}</li>
     * <li>Icon and background color based on {@link StatusNotification.Status}</li>
     * </ul>
     */
private void update() {
    Widget titleWidget = titlePanel.getWidget();
    if (titleWidget != null && titleWidget instanceof Label) {
        ((Label) titleWidget).setText(notification.getTitle());
        StringBuilder infoBuilder = new StringBuilder();
        if (notification.getProject() != null) {
            infoBuilder.append("Project: ").append(notification.getProject().getName()).append(". ");
        }
        infoBuilder.append(DATA_FORMAT.format(new Date(notification.getTime())));
        titlePanel.getElement().setAttribute("info", infoBuilder.toString());
    }
    Widget messageWidget = messagePanel.getWidget();
    if (messageWidget != null && messageWidget instanceof Label) {
        ((Label) messageWidget).setText(notification.getContent());
    }
    if (notification instanceof StatusNotification) {
        iconPanel.setWidget(getIconBaseOnStatus());
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) Label(com.google.gwt.user.client.ui.Label) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Date(java.util.Date)

Example 3 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class NotificationManagerImplTest method testShowStatusNotification.

@Test
public void testShowStatusNotification() throws Exception {
    StatusNotification notification = new StatusNotification("Title", "Message", SUCCESS, FLOAT_MODE, null, null);
    manager.notify(notification);
    verify(notificationContainer).addNotification(eq(notification));
    verify(notificationMessageStack).push(eq(notification));
}
Also used : StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Test(org.junit.Test)

Example 4 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class NotificationManagerImplTest method testRemoveNotification.

@Test
public void testRemoveNotification() throws Exception {
    StatusNotification notification = new StatusNotification("Title", "Message", SUCCESS, NOT_EMERGE_MODE, null, null);
    manager.removeNotification(notification);
    verify(notificationContainer).removeNotification(eq(notification));
}
Also used : StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Test(org.junit.Test)

Example 5 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class NotificationManagerImplTest method testOnMessageDoubleClicked.

@Test
public void testOnMessageDoubleClicked() throws Exception {
    NotificationListener listener = mock(NotificationListener.class);
    StatusNotification notification = new StatusNotification("Title", "Message", SUCCESS, NOT_EMERGE_MODE, null, listener);
    manager.onDoubleClick(notification);
    verify(listener, never()).onClick(eq(notification));
    verify(listener, never()).onClose(eq(notification));
    verify(listener).onDoubleClick(eq(notification));
}
Also used : StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) NotificationListener(org.eclipse.che.ide.api.notification.NotificationListener) Test(org.junit.Test)

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