Search in sources :

Example 1 with Notification

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

the class NotificationManagerImpl method onValueChanged.

/** {@inheritDoc} */
@Override
public void onValueChanged() {
    unread = 0;
    for (Notification notification : notifications) {
        if (!notification.isRead()) {
            unread++;
        }
    }
    firePropertyChange(TITLE_PROPERTY);
}
Also used : Notification(org.eclipse.che.ide.api.notification.Notification) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification)

Example 2 with Notification

use of org.eclipse.che.ide.api.notification.Notification 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));
//        }
}
Also used : Optional(com.google.common.base.Optional) RevealResourceEvent(org.eclipse.che.ide.resources.reveal.RevealResourceEvent) File(org.eclipse.che.ide.api.resources.File) OperationException(org.eclipse.che.api.promises.client.OperationException) Notification(org.eclipse.che.ide.api.notification.Notification) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) NotificationListener(org.eclipse.che.ide.api.notification.NotificationListener)

Example 3 with Notification

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

the class NotificationManagerImplTest method testOnValueChanged.

@Test
public void testOnValueChanged() throws Exception {
    Notification notification = new Notification("Title");
    manager.notify(notification);
    reset(view);
    manager.onValueChanged();
    reset(view);
    notification.setState(ReadState.READ);
}
Also used : Notification(org.eclipse.che.ide.api.notification.Notification) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Test(org.junit.Test)

Example 4 with Notification

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

the class NotificationManagerImplTest method testShowSimpleNotification.

@Test
public void testShowSimpleNotification() throws Exception {
    Notification notification = new Notification("Title");
    manager.notify(notification);
    verify(notificationContainer).addNotification(eq(notification));
    verify(notificationMessageStack, never()).push(any(StatusNotification.class));
}
Also used : StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Notification(org.eclipse.che.ide.api.notification.Notification) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Test(org.junit.Test)

Aggregations

Notification (org.eclipse.che.ide.api.notification.Notification)4 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)4 Test (org.junit.Test)2 Optional (com.google.common.base.Optional)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 NotificationListener (org.eclipse.che.ide.api.notification.NotificationListener)1 File (org.eclipse.che.ide.api.resources.File)1 RevealResourceEvent (org.eclipse.che.ide.resources.reveal.RevealResourceEvent)1