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);
}
}
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());
}
}
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));
}
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));
}
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));
}
Aggregations