From 24d5fa4968482cf0168349bf85e78ba80d8f83db Mon Sep 17 00:00:00 2001 From: f43nd1r Date: Sat, 2 Nov 2019 00:20:44 +0100 Subject: [PATCH] nicer text breaks in path --- .../main/java/com/faendir/acra/ui/base/Path.java | 6 ++++++ .../com/faendir/acra/ui/component/Translatable.java | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/acrarium/src/main/java/com/faendir/acra/ui/base/Path.java b/acrarium/src/main/java/com/faendir/acra/ui/base/Path.java index 4d1887e..4f20bb5 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/base/Path.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/base/Path.java @@ -95,6 +95,12 @@ public class Path extends SubTabs implements AfterNavigationListener, HasStyle, public Tab toTab() { Translatable
div = Translatable.createDiv(getId(), getParams()); + div.addTranslatedListener(e -> { + String text = div.getContent().getText(); + if(text != null) { + div.getContent().getElement().setProperty("innerHTML", text.replace(".", ".")); + } + }); div.getStyle().set("overflow-wrap", "break-word"); div.getStyle().set("width", "100%"); return new Tab(div); diff --git a/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java b/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java index 62b9cc7..53c2984 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java @@ -19,6 +19,7 @@ package com.faendir.acra.ui.component; import com.vaadin.flow.component.AbstractField; import com.vaadin.flow.component.ClickEvent; import com.vaadin.flow.component.Component; +import com.vaadin.flow.component.ComponentEvent; import com.vaadin.flow.component.ComponentEventListener; import com.vaadin.flow.component.Composite; import com.vaadin.flow.component.HasText; @@ -67,6 +68,7 @@ public class Translatable extends Composite implements L @Override public void localeChange(LocaleChangeEvent event) { setter.accept(getContent()); + fireEvent(new TranslatedEvent(this, false)); } public Translatable with(Consumer consumer) { @@ -74,6 +76,10 @@ public class Translatable extends Composite implements L return this; } + public Registration addTranslatedListener(ComponentEventListener listener) { + return addListener(TranslatedEvent.class, listener); + } + @NonNull public static Translatable createText(@NonNull String captionId, @NonNull Object... params) { return create(new Text(""), captionId, params); @@ -233,4 +239,11 @@ public class Translatable extends Composite implements L return (Value) super.with(consumer); } } + + public static class TranslatedEvent extends ComponentEvent> { + + public TranslatedEvent(Translatable source, boolean fromClient) { + super(source, fromClient); + } + } }