This commit is contained in:
ucrhh 2021-03-05 12:48:56 +01:00
commit b728ced2af
4 changed files with 21 additions and 9 deletions

View File

@ -12,8 +12,9 @@
#headerField {
border-bottom: 2px solid #e8e8e8;
background-color: #f8f8f8;
display: grid;
grid-template-columns: 1fr repeat(1, auto) 1fr;
align-items: center;
justify-content: center;
width: 100%;
padding: 0.5em 0em;
border-radius: 5px 5px 0 0;
@ -23,6 +24,11 @@
margin: 1px;
}
#copyButton {
margin-left: auto;
margin-right: 10%;
}
#main {
align-items: center;
justify-content: center;

View File

@ -7,6 +7,8 @@ import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.html.H4;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.i18n.LocaleChangeEvent;
@ -30,6 +32,7 @@ public class InferenceRuleField extends VerticalLayout implements LocaleChangeOb
private static final String HEADER_ID = "headerField";
private static final String MAIN_ID = "main";
private static final String RULE_NAME_ID = "ruleName";
private static final String COPY_BUTTON_ID = "copyButton";
private final String nameKey;
private final Button copyButton;
@ -48,22 +51,25 @@ public class InferenceRuleField extends VerticalLayout implements LocaleChangeOb
HorizontalLayout header = new HorizontalLayout();
header.setId(HEADER_ID);
this.ruleName = new H4(getTranslation(nameKey));
this.copyButton = new Button(new Icon(VaadinIcon.CLIPBOARD));
copyButton.addClickListener(event -> {
UI.getCurrent().getPage().executeJs("window.copyToClipboard($0)", latex);
Notification.show(getTranslation("root.copied")).addThemeVariants(NotificationVariant.LUMO_PRIMARY);
});
copyButton.setId(COPY_BUTTON_ID);
ruleName.setId(RULE_NAME_ID);
header.add(ruleName);
header.add(ruleName, copyButton);
VerticalLayout main = new VerticalLayout();
main.setId(MAIN_ID);
this.copyButton = new Button(getTranslation("root.copyLatex"), new Icon(VaadinIcon.CLIPBOARD));
MathjaxDisplay rule = new MathjaxDisplay(latex);
copyButton.addClickListener(event -> UI.getCurrent().getPage().executeJs("window.copyToClipboard($0)", latex));
main.add(rule, copyButton);
main.add(rule);
add(header, main);
setId(INFERENCE_RULE_FIELD_ID);
}
@Override
public void localeChange(LocaleChangeEvent event) {
copyButton.setText(getTranslation("root.copyLatex"));
ruleName.setText(getTranslation(nameKey));
}

View File

@ -1,6 +1,6 @@
root.close=Schließen
root.save=Speichern
root.copyLatex=Kopiere Latex-Code
root.copied=LaTeX-Code in Zwischenablage kopiert.
root.selectExample=Beispiel auswählen:
root.typeInfer=Typisieren
root.operatingHelp=Hilfe

View File

@ -1,6 +1,6 @@
root.close=Close
root.save=Save
root.copyLatex=Copy latex code
root.copied=LaTeX code copied to clipboard.
root.selectExample=Select example:
root.typeInfer=Type
root.operatingHelp=Help