nicer text breaks in path
This commit is contained in:
parent
c6c6d2fc58
commit
24d5fa4968
2 changed files with 19 additions and 0 deletions
|
@ -95,6 +95,12 @@ public class Path extends SubTabs implements AfterNavigationListener, HasStyle,
|
|||
|
||||
public Tab toTab() {
|
||||
Translatable<Div> div = Translatable.createDiv(getId(), getParams());
|
||||
div.addTranslatedListener(e -> {
|
||||
String text = div.getContent().getText();
|
||||
if(text != null) {
|
||||
div.getContent().getElement().setProperty("innerHTML", text.replace(".", ".<wbr>"));
|
||||
}
|
||||
});
|
||||
div.getStyle().set("overflow-wrap", "break-word");
|
||||
div.getStyle().set("width", "100%");
|
||||
return new Tab(div);
|
||||
|
|
|
@ -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<T extends Component> extends Composite<T> implements L
|
|||
@Override
|
||||
public void localeChange(LocaleChangeEvent event) {
|
||||
setter.accept(getContent());
|
||||
fireEvent(new TranslatedEvent(this, false));
|
||||
}
|
||||
|
||||
public Translatable<T> with(Consumer<T> consumer) {
|
||||
|
@ -74,6 +76,10 @@ public class Translatable<T extends Component> extends Composite<T> implements L
|
|||
return this;
|
||||
}
|
||||
|
||||
public Registration addTranslatedListener(ComponentEventListener<TranslatedEvent> listener) {
|
||||
return addListener(TranslatedEvent.class, listener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Translatable<Text> createText(@NonNull String captionId, @NonNull Object... params) {
|
||||
return create(new Text(""), captionId, params);
|
||||
|
@ -233,4 +239,11 @@ public class Translatable<T extends Component> extends Composite<T> implements L
|
|||
return (Value<T, V>) super.with(consumer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TranslatedEvent extends ComponentEvent<Translatable<?>> {
|
||||
|
||||
public TranslatedEvent(Translatable<?> source, boolean fromClient) {
|
||||
super(source, fromClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue