Fixed broken renderer.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
kaizimmerm
2016-09-20 14:34:27 +02:00
parent 0ff02c8878
commit b7199bff72

View File

@@ -8,9 +8,9 @@
*/ */
package org.eclipse.hawkbit.ui.customrenderers.client.renderers; package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.google.common.collect.Maps;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.vaadin.client.renderers.WidgetRenderer; import com.vaadin.client.renderers.WidgetRenderer;
import com.vaadin.client.ui.VLabel; import com.vaadin.client.ui.VLabel;
@@ -29,11 +29,11 @@ public class HtmlLabelRenderer extends WidgetRenderer<String, VLabel> {
} }
@Override @Override
public void render(final RendererCellReference cell, final String input, final VLabel label) { public void render(RendererCellReference cell, String input, VLabel label) {
final Map<String, String> map = formatInput(input); Map<String, String> map = formatInput(input);
final String value = map.containsKey("value") ? map.get("value") : null; String value = map.containsKey("value") ? map.get("value") : null;
final String style = map.containsKey("style") ? map.get("style") : null; String style = map.containsKey("style") ? map.get("style") : null;
final String id = map.containsKey("id") ? map.get("id") : null; String id = map.containsKey("id") ? map.get("id") : null;
if (value != null) { if (value != null) {
label.setHTML("<span>&#x" + Integer.toHexString(Integer.parseInt(value)) + ";</span>"); label.setHTML("<span>&#x" + Integer.toHexString(Integer.parseInt(value)) + ";</span>");
@@ -44,7 +44,7 @@ public class HtmlLabelRenderer extends WidgetRenderer<String, VLabel> {
label.getElement().setId(id); label.getElement().setId(id);
} }
private void applyStyle(final VLabel label, final String style) { private void applyStyle(VLabel label, String style) {
label.setStyleName(VLabel.CLASSNAME); label.setStyleName(VLabel.CLASSNAME);
label.addStyleName(getStyle("small")); label.addStyleName(getStyle("small"));
label.addStyleName(getStyle("font-icon")); label.addStyleName(getStyle("font-icon"));
@@ -57,12 +57,11 @@ public class HtmlLabelRenderer extends WidgetRenderer<String, VLabel> {
return new StringBuilder(style).append(" ").append(VLabel.CLASSNAME).append("-").append(style).toString(); return new StringBuilder(style).append(" ").append(VLabel.CLASSNAME).append("-").append(style).toString();
} }
private Map<String, String> formatInput(final String input) { private Map<String, String> formatInput(String input) {
Map<String, String> details = new HashMap<>();
final String[] tempData = input.split(","); String[] tempData = input.split(",");
final Map<String, String> details = Maps.newHashMapWithExpectedSize(tempData.length); for (String statusWithCount : tempData) {
for (final String statusWithCount : tempData) { String[] statusWithCountList = statusWithCount.split(":");
final String[] statusWithCountList = statusWithCount.split(":");
details.put(statusWithCountList[0], statusWithCountList[1]); details.put(statusWithCountList[0], statusWithCountList[1]);
} }
return details; return details;