From 36f27a7d7598ece946e52340c280e2e0b808c726 Mon Sep 17 00:00:00 2001 From: f43nd1r Date: Fri, 30 Nov 2018 03:04:34 +0100 Subject: [PATCH] fix layouts & nullpointer --- .../java/com/faendir/acra/ui/base/ConfigurationLabel.java | 6 +++--- src/main/java/com/faendir/acra/ui/base/popup/Popup.java | 8 ++++---- .../com/faendir/acra/ui/base/statistics/Property.java | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/faendir/acra/ui/base/ConfigurationLabel.java b/src/main/java/com/faendir/acra/ui/base/ConfigurationLabel.java index a97a75a..ad8aff1 100644 --- a/src/main/java/com/faendir/acra/ui/base/ConfigurationLabel.java +++ b/src/main/java/com/faendir/acra/ui/base/ConfigurationLabel.java @@ -18,9 +18,9 @@ package com.faendir.acra.ui.base; import com.faendir.acra.i18n.Messages; import com.faendir.acra.rest.RestReportInterface; +import com.faendir.acra.ui.component.Label; import com.faendir.acra.ui.view.Overview; import com.faendir.acra.util.PlainTextUser; -import com.vaadin.flow.component.Text; import com.vaadin.flow.component.UI; import com.vaadin.flow.i18n.LocaleChangeEvent; import com.vaadin.flow.i18n.LocaleChangeObserver; @@ -30,7 +30,7 @@ import org.springframework.lang.NonNull; * @author lukas * @since 09.11.18 */ -public class ConfigurationLabel extends Text implements LocaleChangeObserver { +public class ConfigurationLabel extends Label implements LocaleChangeObserver { private final PlainTextUser user; public ConfigurationLabel(@NonNull PlainTextUser user) { @@ -40,6 +40,6 @@ public class ConfigurationLabel extends Text implements LocaleChangeObserver { @Override public void localeChange(LocaleChangeEvent event) { - setText(getTranslation(Messages.CONFIGURATION_LABEL, UI.getCurrent().getRouter().getUrl(Overview.class), RestReportInterface.REPORT_PATH, user.getUsername(), user.getPlaintextPassword())); + getElement().setProperty("innerHTML", getTranslation(Messages.CONFIGURATION_LABEL, UI.getCurrent().getRouter().getUrl(Overview.class), RestReportInterface.REPORT_PATH, user.getUsername(), user.getPlaintextPassword())); } } diff --git a/src/main/java/com/faendir/acra/ui/base/popup/Popup.java b/src/main/java/com/faendir/acra/ui/base/popup/Popup.java index 4d689d6..a992b32 100644 --- a/src/main/java/com/faendir/acra/ui/base/popup/Popup.java +++ b/src/main/java/com/faendir/acra/ui/base/popup/Popup.java @@ -17,12 +17,12 @@ package com.faendir.acra.ui.base.popup; import com.faendir.acra.i18n.Messages; +import com.faendir.acra.ui.component.FlexLayout; import com.faendir.acra.ui.component.Translatable; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.HasSize; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.dialog.Dialog; -import com.vaadin.flow.component.formlayout.FormLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import org.springframework.data.util.Pair; import org.springframework.lang.NonNull; @@ -140,9 +140,9 @@ public class Popup extends Dialog { } } }); - FormLayout layout = new FormLayout(); - layout.setResponsiveSteps(new FormLayout.ResponsiveStep("0px", 1)); - components.forEach(c -> layout.addFormItem(c, "")); + FlexLayout layout = new FlexLayout(); + layout.setFlexDirection(FlexLayout.FlexDirection.COLUMN); + components.forEach(layout::add); checkValid(); removeAll(); add(layout); diff --git a/src/main/java/com/faendir/acra/ui/base/statistics/Property.java b/src/main/java/com/faendir/acra/ui/base/statistics/Property.java index ae9a6cb..0ac7a23 100644 --- a/src/main/java/com/faendir/acra/ui/base/statistics/Property.java +++ b/src/main/java/com/faendir/acra/ui/base/statistics/Property.java @@ -99,7 +99,9 @@ class Property & HasEnabled & HasSize & ComboBox comboBox = new ComboBox<>(null, list); comboBox.setAllowCustomValue(false); comboBox.setRequired(true); - comboBox.setValue(list.get(0)); + if(!list.isEmpty()) { + comboBox.setValue(list.get(0)); + } return new Property<>(app, comboBox, stringExpression::eq, new PieChart(chartTitleId), dataService, stringExpression, filterTextId); }