fix layouts & nullpointer

This commit is contained in:
f43nd1r 2018-11-30 03:04:34 +01:00
parent 2899a37c84
commit 36f27a7d75
3 changed files with 10 additions and 8 deletions

View file

@ -18,9 +18,9 @@ package com.faendir.acra.ui.base;
import com.faendir.acra.i18n.Messages; import com.faendir.acra.i18n.Messages;
import com.faendir.acra.rest.RestReportInterface; import com.faendir.acra.rest.RestReportInterface;
import com.faendir.acra.ui.component.Label;
import com.faendir.acra.ui.view.Overview; import com.faendir.acra.ui.view.Overview;
import com.faendir.acra.util.PlainTextUser; import com.faendir.acra.util.PlainTextUser;
import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.UI; import com.vaadin.flow.component.UI;
import com.vaadin.flow.i18n.LocaleChangeEvent; import com.vaadin.flow.i18n.LocaleChangeEvent;
import com.vaadin.flow.i18n.LocaleChangeObserver; import com.vaadin.flow.i18n.LocaleChangeObserver;
@ -30,7 +30,7 @@ import org.springframework.lang.NonNull;
* @author lukas * @author lukas
* @since 09.11.18 * @since 09.11.18
*/ */
public class ConfigurationLabel extends Text implements LocaleChangeObserver { public class ConfigurationLabel extends Label implements LocaleChangeObserver {
private final PlainTextUser user; private final PlainTextUser user;
public ConfigurationLabel(@NonNull PlainTextUser user) { public ConfigurationLabel(@NonNull PlainTextUser user) {
@ -40,6 +40,6 @@ public class ConfigurationLabel extends Text implements LocaleChangeObserver {
@Override @Override
public void localeChange(LocaleChangeEvent event) { 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()));
} }
} }

View file

@ -17,12 +17,12 @@
package com.faendir.acra.ui.base.popup; package com.faendir.acra.ui.base.popup;
import com.faendir.acra.i18n.Messages; import com.faendir.acra.i18n.Messages;
import com.faendir.acra.ui.component.FlexLayout;
import com.faendir.acra.ui.component.Translatable; import com.faendir.acra.ui.component.Translatable;
import com.vaadin.flow.component.Component; import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasSize; import com.vaadin.flow.component.HasSize;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dialog.Dialog; import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import org.springframework.data.util.Pair; import org.springframework.data.util.Pair;
import org.springframework.lang.NonNull; import org.springframework.lang.NonNull;
@ -140,9 +140,9 @@ public class Popup extends Dialog {
} }
} }
}); });
FormLayout layout = new FormLayout(); FlexLayout layout = new FlexLayout();
layout.setResponsiveSteps(new FormLayout.ResponsiveStep("0px", 1)); layout.setFlexDirection(FlexLayout.FlexDirection.COLUMN);
components.forEach(c -> layout.addFormItem(c, "")); components.forEach(layout::add);
checkValid(); checkValid();
removeAll(); removeAll();
add(layout); add(layout);

View file

@ -99,7 +99,9 @@ class Property<F, C extends Component & HasValue<?, F> & HasEnabled & HasSize &
ComboBox<String> comboBox = new ComboBox<>(null, list); ComboBox<String> comboBox = new ComboBox<>(null, list);
comboBox.setAllowCustomValue(false); comboBox.setAllowCustomValue(false);
comboBox.setRequired(true); 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); return new Property<>(app, comboBox, stringExpression::eq, new PieChart(chartTitleId), dataService, stringExpression, filterTextId);
} }