Refactor HawkbitNotificationMessage
Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import com.vaadin.ui.Notification;
|
||||
/**
|
||||
* Notification message component.
|
||||
*/
|
||||
public class HawkbitNotificationMessage extends Notification {
|
||||
public class HawkbitErrorNotificationMessage extends Notification {
|
||||
|
||||
/**
|
||||
* ID.
|
||||
@@ -26,34 +26,18 @@ public class HawkbitNotificationMessage extends Notification {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public HawkbitNotificationMessage() {
|
||||
super("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate.
|
||||
*
|
||||
* @param styleName
|
||||
* style name of message
|
||||
* @param caption
|
||||
* message caption
|
||||
* @param description
|
||||
* message description
|
||||
* @param autoClose
|
||||
* flag to indicate enable close option
|
||||
*/
|
||||
public void decorateWith(final String styleName, final String caption, final String description,
|
||||
final Boolean autoClose) {
|
||||
setCaption(caption);
|
||||
setDescription(description);
|
||||
setStyleName(styleName);
|
||||
setHtmlContentAllowed(true);
|
||||
setPosition(Position.BOTTOM_RIGHT);
|
||||
public HawkbitErrorNotificationMessage(final String style, final String caption, final String description,
|
||||
final boolean autoClose) {
|
||||
super(caption);
|
||||
setStyleName(style);
|
||||
if (autoClose) {
|
||||
setDelayMsec(SPUILabelDefinitions.SP_DELAY);
|
||||
} else {
|
||||
setDelayMsec(-1);
|
||||
}
|
||||
setHtmlContentAllowed(true);
|
||||
setPosition(Position.BOTTOM_RIGHT);
|
||||
setDescription(description);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
final Optional<Page> originError = getPageOriginError(event);
|
||||
|
||||
if (originError.isPresent()) {
|
||||
final HawkbitNotificationMessage message = buildNotification(getRootExceptionFrom(event));
|
||||
final HawkbitErrorNotificationMessage message = buildNotification(getRootExceptionFrom(event));
|
||||
message.show(originError.get());
|
||||
}
|
||||
}
|
||||
@@ -71,14 +71,11 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
protected HawkbitNotificationMessage buildNotification(final Throwable exception) {
|
||||
protected HawkbitErrorNotificationMessage buildNotification(final Throwable exception) {
|
||||
|
||||
final HawkbitNotificationMessage notification = new HawkbitNotificationMessage();
|
||||
final I18N i18n = SpringContextHelper.getBean(I18N.class);
|
||||
notification.decorateWith(STYLE, i18n.get("caption.error"),
|
||||
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
|
||||
i18n.get("message.error.temp", exception.getClass().getSimpleName()), false);
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ import com.vaadin.ui.Notification;
|
||||
|
||||
/**
|
||||
* Show notification messages.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@UIScope
|
||||
@SpringComponent
|
||||
@@ -27,8 +25,6 @@ public class NotificationMessage extends Notification {
|
||||
|
||||
/**
|
||||
* Default constructor of notification message.
|
||||
*
|
||||
* @param caption
|
||||
*/
|
||||
public NotificationMessage() {
|
||||
super("");
|
||||
|
||||
Reference in New Issue
Block a user