move buttons to accordion sumamry

This commit is contained in:
ucrhh 2021-03-05 13:55:31 +01:00
parent a7e8a24d77
commit 24f898d64a
2 changed files with 17 additions and 17 deletions

View File

@ -4,6 +4,7 @@ import com.vaadin.flow.component.accordion.AccordionPanel;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.details.DetailsVariant;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.i18n.LocaleChangeEvent;
import com.vaadin.flow.i18n.LocaleChangeObserver;
@ -19,6 +20,8 @@ public class HelpContentField extends AccordionPanel implements LocaleChangeObse
private final String summaryKey;
private final String contentKey;
private final HorizontalLayout summary;
private final Paragraph summaryText;
private final Paragraph content;
/**
@ -30,8 +33,11 @@ public class HelpContentField extends AccordionPanel implements LocaleChangeObse
protected HelpContentField(String summaryKey, String contentKey) {
this.summaryKey = summaryKey;
this.contentKey = contentKey;
this.content = new Paragraph(getTranslation(contentKey));
setSummaryText(getTranslation(summaryKey));
this.content = new Paragraph();
this.summaryText = new Paragraph();
this.summary = new HorizontalLayout(summaryText);
summary.setAlignItems(FlexComponent.Alignment.BASELINE);
setSummary(summary);
setContent(content);
addThemeVariants(DetailsVariant.FILLED);
}
@ -46,14 +52,14 @@ public class HelpContentField extends AccordionPanel implements LocaleChangeObse
*/
protected HelpContentField(String summaryKey, Button button, String contentKey) {
this(summaryKey, contentKey);
HorizontalLayout layout = new HorizontalLayout(button, content);
layout.setClassName(CLASSNAME);
setContent(layout);
summary.removeAll();
summary.add(button, summaryText);
setContent(content);
}
@Override
public void localeChange(LocaleChangeEvent event) {
setSummaryText(getTranslation(summaryKey));
summaryText.setText(getTranslation(summaryKey));
content.setText(getTranslation(contentKey));
}

View File

@ -3,9 +3,7 @@ package edu.kit.typicalc.view.main;
import com.vaadin.flow.component.ItemLabelGenerator;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.accordion.Accordion;
import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.html.H3;
@ -38,7 +36,6 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
private final H3 heading;
private final Select<Locale> languageSelect;
private final ItemLabelGenerator<Locale> renderer;
private final Button typeButtonCopy;
/**
* Create a new HelpDialog.
@ -56,9 +53,6 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
headingLayout.add(heading, languageSelect);
VerticalLayout contentLayout = new VerticalLayout();
typeButtonCopy = new Button(getTranslation("root.typeInfer"));
typeButtonCopy.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
typeButtonCopy.setId(TYPE_BUTTON_COPY_ID);
Accordion content = createHelpContent();
content.setId(ACCORDION_ID);
contentLayout.add(content);
@ -68,12 +62,13 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
private Accordion createHelpContent() {
Accordion acc = new Accordion();
acc.add(new HelpContentField("root.drawer", new DrawerToggle(), "root.helpDrawer"));
acc.add(new HelpContentField("root.example",
new Button(getTranslation("root.examplebutton")), "root.helpExample"));
acc.add(new HelpContentField("root.typeInferButton", "root.helpTypeInferButton"));
acc.add(new HelpContentField("root.inputField", "root.helpInputField"));
acc.add(new HelpContentField("root.typeAssumptions", "root.helpTypeAssumptions"));
acc.add(new HelpContentField("root.typeInferButton", typeButtonCopy, "root.helpTypeInferButton"));
acc.add(new HelpContentField("root.drawer",
new Button(new Icon(VaadinIcon.MENU)), "root.helpDrawer"));
acc.add(new HelpContentField("root.example",
new Button(new Icon(VaadinIcon.PAPERCLIP)), "root.helpExample"));
acc.add(new HelpContentField("root.firstStepButton",
new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT)), "root.helpFirstStepButton"));
acc.add(new HelpContentField("root.previousStepButton",
@ -91,7 +86,6 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
public void localeChange(LocaleChangeEvent event) {
heading.setText(getTranslation("root.operatingHelp"));
languageSelect.setLabel(getTranslation("root.selectLanguage"));
typeButtonCopy.setText(getTranslation("root.typeInfer"));
languageSelect.setTextRenderer(renderer);
}
}