Search in sources :

Example 1 with NotificationListener

use of org.eclipse.che.ide.api.notification.NotificationListener 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)

Example 2 with NotificationListener

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

the class NotificationManagerImpl method onClose.

/** {@inheritDoc} */
@Override
public void onClose(Notification notification) {
    removeNotification(notification);
    NotificationListener listener = notification.getListener();
    if (listener != null) {
        listener.onClose(notification);
    }
}
Also used : StatusNotificationListener(org.eclipse.che.ide.api.notification.StatusNotificationListener) NotificationListener(org.eclipse.che.ide.api.notification.NotificationListener)

Example 3 with NotificationListener

use of org.eclipse.che.ide.api.notification.NotificationListener 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 4 with NotificationListener

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

the class NotificationManagerImplTest method testOnMessageClicked.

@Test
public void testOnMessageClicked() throws Exception {
    NotificationListener listener = mock(NotificationListener.class);
    StatusNotification notification = new StatusNotification("Title", "Message", SUCCESS, NOT_EMERGE_MODE, null, listener);
    manager.onClick(notification);
    verify(listener).onClick(eq(notification));
    verify(listener, never()).onClose(eq(notification));
    verify(listener, never()).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)

Example 5 with NotificationListener

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

the class NotificationManagerImplTest method testOnCloseMessageClicked.

@Test
public void testOnCloseMessageClicked() throws Exception {
    NotificationListener listener = mock(NotificationListener.class);
    StatusNotification notification = new StatusNotification("Title", "Message", SUCCESS, NOT_EMERGE_MODE, null, listener);
    manager.onClose(notification);
    verify(listener, never()).onClick(eq(notification));
    verify(listener).onClose(eq(notification));
    verify(listener, never()).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

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