List of usage examples for org.apache.wicket.feedback FeedbackMessage isError
public final boolean isError()
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.home.page.ApplicationPageBase.java
License:Apache License
@SuppressWarnings({ "serial" })
private void commonInit() {
// getSession().setLocale(Locale.ENGLISH);
logoutPanel = new LogoutPanel("logoutPanel");
feedbackPanel = new FeedbackPanel("feedbackPanel");
feedbackPanel.setOutputMarkupId(true);
feedbackPanel.add(new AttributeModifier("class", "error"));
feedbackPanel.setFilter(new IFeedbackMessageFilter() {
@Override// w w w . j a va 2s . c o m
public boolean accept(FeedbackMessage aMessage) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth != null ? auth.getName() : "SYSTEM";
if (aMessage.isFatal()) {
LOG.fatal(username + ": " + aMessage.getMessage());
} else if (aMessage.isError()) {
LOG.error(username + ": " + aMessage.getMessage());
} else if (aMessage.isWarning()) {
LOG.warn(username + ": " + aMessage.getMessage());
} else if (aMessage.isInfo()) {
LOG.info(username + ": " + aMessage.getMessage());
} else if (aMessage.isDebug()) {
LOG.debug(username + ": " + aMessage.getMessage());
}
return true;
}
});
versionLabel = new Label("version", SettingsUtil.getVersionString());
embeddedDbWarning = new Label("embeddedDbWarning", "USE THIS INSTALLATION FOR TESTING ONLY -- "
+ "AN EMBEDDED DATABASE IS NOT RECOMMENDED FOR PRODUCTION USE");
embeddedDbWarning.setVisible(false);
try {
String driver = repository.getDatabaseDriverName();
embeddedDbWarning.setVisible(StringUtils.contains(driver.toLowerCase(Locale.US), "hsql"));
} catch (Throwable e) {
LOG.warn("Unable to determine which database is being used", e);
}
// Override warning about embedded database.
Properties settings = SettingsUtil.getSettings();
if ("false".equalsIgnoreCase(settings.getProperty("warnings.embeddedDatabase"))) {
embeddedDbWarning.setVisible(false);
}
// Display a warning when using an unsupported browser
RequestCycle requestCycle = RequestCycle.get();
WebClientInfo clientInfo;
if (Session.exists()) {
WebSession session = WebSession.get();
clientInfo = session.getClientInfo();
} else {
clientInfo = new WebClientInfo(requestCycle);
}
ClientProperties clientProperties = clientInfo.getProperties();
browserWarning = new Label("browserWarning",
"THIS BROWSER IS NOT SUPPORTED -- " + "PLEASE USE CHROME OR SAFARI");
browserWarning.setVisible(!clientProperties.isBrowserSafari() && !clientProperties.isBrowserChrome());
// Override warning about browser.
if ("false".equalsIgnoreCase(settings.getProperty("warnings.unsupportedBrowser"))) {
browserWarning.setVisible(false);
}
boolean helpAvailable;
try {
Application.get().getResourceSettings().getLocalizer().getString("page.help.link", this);
Application.get().getResourceSettings().getLocalizer().getString("page.help", this);
helpAvailable = true;
} catch (MissingResourceException e) {
helpAvailable = false;
}
add(helpLink = new ExternalLink("helpLink", new ResourceModel("page.help.link", ""),
new ResourceModel("page.help", "")));
helpLink.setPopupSettings(new PopupSettings("_blank"));
helpLink.setVisible(helpAvailable);
add(logoutPanel);
add(feedbackPanel);
add(versionLabel);
add(embeddedDbWarning);
add(browserWarning);
}
From source file:de.tudarmstadt.ukp.csniper.webapp.page.ApplicationPageBase.java
License:Apache License
@SuppressWarnings({ "serial" })
private void commonInit() {
getSession().setLocale(Locale.ENGLISH);
logInOutPanel = new LogInOutPanel("logInOutPanel");
helpPanel = new InfoPanel("helpPanel", "page.help");
macroPanel = new InfoPanel("macroPanel", "page.macros") {
@Override//from w w w . j a v a2 s . co m
protected void initialize() {
super.initialize();
Map<String, String> macros = new HashMap<String, String>();
for (CqpMacro macro : CqpEngine.getMacros()) {
macros.put(macro.getName(), macro.getBodyAsHtml());
}
infoPanel.replaceWith(new ExpandableList("infoPanel", macros));
}
};
openHelp = new AjaxLink<Void>("openHelp") {
@Override
public void onClick(AjaxRequestTarget aTarget) {
helpPanel.setVisible(!helpPanel.isVisible());
aTarget.add(helpPanel);
}
};
openMacros = new AjaxLink<Void>("openMacros") {
@Override
public void onClick(AjaxRequestTarget aTarget) {
macroPanel.setVisible(!macroPanel.isVisible());
aTarget.add(macroPanel);
}
};
feedbackPanel = new FeedbackPanel("feedbackPanel");
feedbackPanel.setOutputMarkupId(true);
feedbackPanel.setFilter(new IFeedbackMessageFilter() {
@Override
public boolean accept(FeedbackMessage aMessage) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth != null ? auth.getName() : "UNKNOWN";
if (aMessage.isFatal()) {
LOG.fatal(username + ": " + aMessage.getMessage());
} else if (aMessage.isError()) {
LOG.error(username + ": " + aMessage.getMessage());
} else if (aMessage.isWarning()) {
LOG.warn(username + ": " + aMessage.getMessage());
} else if (aMessage.isInfo()) {
LOG.info(username + ": " + aMessage.getMessage());
} else if (aMessage.isDebug()) {
LOG.debug(username + ": " + aMessage.getMessage());
}
return true;
}
});
Properties props = getVersionProperties();
versionLabel = new Label("version",
props.getProperty("version") + " (" + props.getProperty("timestamp") + ")");
add(openHelp);
add(openMacros);
add(helpPanel);
add(macroPanel);
add(logInOutPanel);
add(feedbackPanel);
add(versionLabel);
}
From source file:guru.mmp.application.web.template.components.Alerts.java
License:Apache License
/** * Render the alerts./* w w w. j a v a 2s . co m*/ */ @Override protected void onRender() { MarkupStream markupStream = findMarkupStream(); MarkupElement element = markupStream.get(); Response response = getResponse(); if (element instanceof ComponentTag) { List<FeedbackMessage> messages = getFilteredMessages(); if (messages.size() == 0) { response.write("<div id=\"" + getMarkupId() + "\" class=\"alerts\"></div>"); return; } StringBuilder errorBuffer = null; StringBuilder infoBuffer = null; StringBuilder warningBuffer = null; StringBuilder debugBuffer = null; int numberOfErrorMessages = 0; int numberOfInfoMessages = 0; int numberOfWarningMessages = 0; int numberOfDebugMessages = 0; for (FeedbackMessage message : messages) { if (message.isError()) { if (errorBuffer == null) { errorBuffer = new StringBuilder(); } numberOfErrorMessages++; } else if (message.isWarning()) { if (warningBuffer == null) { warningBuffer = new StringBuilder(); } numberOfWarningMessages++; } else if (message.isInfo()) { if (infoBuffer == null) { infoBuffer = new StringBuilder(); } numberOfInfoMessages++; } else if (message.isFatal()) { if (errorBuffer == null) { errorBuffer = new StringBuilder(); } numberOfErrorMessages++; } else if (message.isDebug()) { if (debugBuffer == null) { debugBuffer = new StringBuilder(); } numberOfDebugMessages++; } } for (FeedbackMessage message : messages) { if (message.isError()) { if (numberOfErrorMessages == 1) { errorBuffer.append(message.getMessage().toString()); } else { errorBuffer.append("<li>"); errorBuffer.append(message.getMessage().toString()); errorBuffer.append("</li>"); } } else if (message.isWarning()) { if (numberOfWarningMessages == 1) { warningBuffer.append(message.getMessage().toString()); } else { warningBuffer.append("<li>"); warningBuffer.append(message.getMessage().toString()); warningBuffer.append("</li>"); } } else if (message.isInfo()) { if (numberOfInfoMessages == 1) { infoBuffer.append(message.getMessage().toString()); } else { infoBuffer.append("<li>"); infoBuffer.append(message.getMessage().toString()); infoBuffer.append("</li>"); } } else if (message.isFatal()) { if (numberOfErrorMessages == 1) { errorBuffer.append(message.getMessage().toString()); } else { errorBuffer.append("<li>"); errorBuffer.append(message.getMessage().toString()); errorBuffer.append("</li>"); } } else if (message.isDebug()) { if (numberOfDebugMessages == 1) { debugBuffer.append(message.getMessage().toString()); } else { debugBuffer.append("<li>"); debugBuffer.append(message.getMessage().toString()); debugBuffer.append("</li>"); } } message.markRendered(); } response.write("<div id=\""); response.write(getMarkupId()); response.write("\" class=\"alerts\">"); // Display error messages first if (numberOfErrorMessages > 0) { response.write("<div class=\"errorHandler alert alert-danger\">"); response.write("<button data-dismiss=\"alert\" class=\"close\">×</button>"); response.write("<i class=\"fa fa-times-circle\"></i> "); if (numberOfErrorMessages == 1) { response.write(errorBuffer.toString()); response.write("</div>"); } else { response.write("The following errors occurred while processing your request:"); response.write("<ul style=\"padding: 5px 0px 0px 19px;\">"); response.write(errorBuffer.toString()); response.write("</ul></div>"); } } // Display warning messages second if (numberOfWarningMessages > 0) { response.write("<div class=\"alert alert-warning\">"); response.write("<button data-dismiss=\"alert\" class=\"close\">×</button>"); response.write("<i class=\"fa fa-exclamation-triangle\"></i> "); if (numberOfWarningMessages == 1) { response.write(warningBuffer.toString()); response.write("</div>"); } else { response.write("The following warnings were raised while processing your request:"); response.write("<ul style=\"padding: 5px 0px 0px 19px;\">"); response.write(warningBuffer.toString()); response.write("</ul></div>"); } } // Display informational messages third if (numberOfInfoMessages > 0) { response.write("<div class=\"alert alert-success\">"); response.write("<button data-dismiss=\"alert\" class=\"close\">×</button>"); response.write("<i class=\"fa fa-check-circle\"></i> "); if (numberOfInfoMessages == 1) { response.write(infoBuffer.toString()); response.write("</div>"); } else { response.write("Please take note of the following:"); response.write("<ul style=\"padding: 5px 0px 0px 19px;\">"); response.write(infoBuffer.toString()); response.write("</ul></div>"); } } // Display debug messages fourth if (numberOfDebugMessages > 0) { response.write("<div class=\"alert alert-info\">"); response.write("<button data-dismiss=\"alert\" class=\"close\">×</button>"); response.write("<i class=\"fa fa-info-circle\"></i> "); if (numberOfDebugMessages == 1) { response.write(debugBuffer.toString()); response.write("</div>"); } else { response.write("Please take note of the following:"); response.write("<ul style=\"padding: 5px 0px 0px 19px;\">"); response.write(debugBuffer.toString()); response.write("</ul></div>"); } } response.write("</div>"); } }
From source file:guru.mmp.application.web.template.util.FeedbackUtil.java
License:Apache License
/** * Generate the Javascript to display the feedback for the specified component. * * @param id the id of the component to provide the feedback for * @param component the component to generate the feedback JavaScript for * @param isAjaxRequest is feedback being generated as part of an Ajax request * @param feedbackMessageClasses the additional CSS classes to apply to the feedback message * * @return the JavaScript to display the feedback message or <code>null</code> * if there is no feedback for the specified component *///from w ww. java2 s. co m public static String generateFeedbackJavaScript(String id, Component component, boolean isAjaxRequest, String feedbackMessageClasses) { if (component.hasFeedbackMessage()) { FeedbackMessages feedbackMessages = component.getFeedbackMessages(); FeedbackMessage feedbackMessage = feedbackMessages.first(); String feedbackClass = null; if (feedbackMessage.isError()) { feedbackClass = "has-error"; } else if (feedbackMessage.isFatal()) { feedbackClass = "has-error"; } else if (feedbackMessage.isWarning()) { feedbackClass = "has-warning"; } else if (feedbackMessage.isInfo()) { feedbackClass = "has-info"; } else if (feedbackMessage.isDebug()) { feedbackClass = "has-success"; } String javaScript = String.format( isAjaxRequest ? SHOW_FORM_COMPONENT_FEEDBACK_JAVA_SCRIPT : DOM_READY_SHOW_FORM_COMPONENT_FEEDBACK_JAVA_SCRIPT, id, feedbackClass, StringUtil.notNull(feedbackMessageClasses), JavaScriptUtils.escapeQuotes(feedbackMessage.getMessage().toString())); // Clear the feedback messages for the component for (FeedbackMessage componentFeedbackMessage : feedbackMessages) { componentFeedbackMessage.markRendered(); } return javaScript; } else { if (isAjaxRequest) { return String.format(CLEAR_FORM_COMPONENT_FEEDBACK_JAVA_SCRIPT, id); } return null; } }
From source file:org.apache.syncope.client.console.panels.NotificationPanel.java
License:Apache License
public final void refresh(final IPartialPageRequestHandler handler) { for (FeedbackMessage message : this.getModelObject()) { if (message.isError()) { this.notification.error(handler, message.getMessage()); } else if (message.isSuccess() || message.isInfo()) { this.notification.success(handler, message.getMessage()); } else {// w w w. j a v a 2 s.c o m this.notification.warn(handler, message.getMessage()); } message.markRendered(); } }