use of org.ovirt.engine.ui.frontend.Message in project ovirt-engine by oVirt.
the class ErrorMessageFormatter method getDescription2MsgMap.
private static Map<String, Set<String>> getDescription2MsgMap(List<Message> msgList) {
Map<String, Set<String>> desc2Msgs = new HashMap<>();
for (Message msg : msgList) {
String desc = msg.getDescription();
if (desc == null) {
// $NON-NLS-1$
desc = "";
}
desc = desc.trim();
Set<String> msgs = desc2Msgs.get(desc);
if (msgs == null) {
msgs = new HashSet<>();
desc2Msgs.put(desc, msgs);
}
msgs.add(msg.getText());
}
return desc2Msgs;
}
use of org.ovirt.engine.ui.frontend.Message in project ovirt-engine by oVirt.
the class ErrorMessageFormatter method formatMessages.
public static String formatMessages(List<Message> values) {
// If one error message without description no need to format
if (values.size() == 1) {
Message msg = values.get(0);
if (msg.getDescription() == null || "".equals(msg.getDescription())) {
// $NON-NLS-1$
return msg.getText();
}
}
SafeHtmlBuilder allSb = new SafeHtmlBuilder();
// $NON-NLS-1$
allSb.append(SafeHtmlUtils.fromTrustedString("<br/><br/>"));
Map<String, Set<String>> desc2msgs = getDescription2MsgMap(values);
for (Map.Entry<String, Set<String>> entry : desc2msgs.entrySet()) {
String desc = entry.getKey();
SafeHtml sh = buildItemList(entry.getValue());
if (!"".equals(desc)) {
// $NON-NLS-1$
// $NON-NLS-1$
allSb.append(SafeHtmlUtils.fromString(desc + ":"));
}
allSb.append(sh);
}
return allSb.toSafeHtml().asString();
}
use of org.ovirt.engine.ui.frontend.Message in project ovirt-engine by oVirt.
the class FrontendEventsHandlerImpl method runMultipleActionsFailed.
public void runMultipleActionsFailed(List<ActionType> actions, List<ActionReturnValue> returnValues, MessageFormatter messageFormatter) {
List<Message> errors = new ArrayList<>();
int actionNum = 0;
for (ActionReturnValue v : returnValues) {
if (isRaiseErrorModalPanel(actions.get(actionNum++), v.getFault())) {
String description = // $NON-NLS-1$ //$NON-NLS-2$
(v.getDescription() != null && !"".equals(v.getDescription().trim())) || returnValues.size() == 1 ? v.getDescription() : ConstantsManager.getInstance().getConstants().action() + " " + actionNum;
if (!v.isValid()) {
for (String validateMessage : v.getValidationMessages()) {
errors.add(new Message(description, validateMessage));
}
} else {
errors.add(new Message(description, v.getFault().getMessage()));
}
}
}
errorPopupManager.show(messageFormatter.format(ErrorMessageFormatter.formatMessages(errors)));
}
Aggregations