This commit is contained in:
ucrhh 2021-02-19 18:38:19 +01:00
commit 383802bc59
5 changed files with 24 additions and 24 deletions

View File

@ -21,22 +21,18 @@ public class ImageSlide extends Slide implements LocaleChangeObserver {
private static final String SLIDE_LAYOUT_ID = "slideLayout";
private static final String EXPLANATION_ID = "explanation";
private final VerticalLayout slideLayout;
private final Span explanation;
private final String explanationKey;
private Image image;
private final String imagePathKey;
/**
* Create a new ImageSlide with a key for the path of the image and a key for the text.
* Create a new ImageSlide with the path of the image and a key for the text.
*
* @param imgPathKey key for the path of the image
* @param imgPath the path of the image
* @param textKey key for the text
*/
public ImageSlide(String imgPathKey, String textKey) {
slideLayout = new VerticalLayout();
this.imagePathKey = imgPathKey;
image = new Image(getTranslation(imgPathKey), StringUtils.EMPTY);
public ImageSlide(String imgPath, String textKey) {
VerticalLayout slideLayout = new VerticalLayout();
Image image = new Image(imgPath, StringUtils.EMPTY);
explanationKey = textKey;
explanation = new Span(getTranslation(explanationKey));
explanation.setId(EXPLANATION_ID);
@ -48,9 +44,6 @@ public class ImageSlide extends Slide implements LocaleChangeObserver {
@Override
public void localeChange(LocaleChangeEvent event) {
explanation.setText(getTranslation(explanationKey));
slideLayout.remove(image, explanation);
image = new Image(getTranslation(imagePathKey), StringUtils.EMPTY);
slideLayout.add(image, explanation);
}
}

View File

@ -70,6 +70,7 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L
linkText = new Text(getTranslation("root.linkText"));
link = new Anchor(getTranslation("root.link"), getTranslation("root.here"));
link.setTarget("_blank"); // opens new tab
Span linkContainer = new Span(linkText, link, new Text(DOT));
linkContainer.setId(LINK_CONTAINER_ID);
@ -81,14 +82,14 @@ public class StartPageView extends VerticalLayout implements ControlPanelView, L
}
private Carousel createSzenarioCarousel() {
Slide slide1 = new ImageSlide("root.image1", "root.text1");
Slide slide2 = new ImageSlide("root.image2", "root.text2");
Slide slide3 = new ImageSlide("root.image3", "root.text3");
Slide slide4 = new ImageSlide("root.image4", "root.text4");
Slide slide5 = new ImageSlide("root.image5", "root.text5");
Slide slide6 = new ImageSlide("root.image6", "root.text6");
Slide slide7 = new ImageSlide("root.image7", "root.text7");
Slide slide8 = new ImageSlide("root.image8", "root.text8");
Slide slide1 = new ImageSlide(getTranslation("root.image1"), "root.text1");
Slide slide2 = new ImageSlide(getTranslation("root.image2"), "root.text2");
Slide slide3 = new ImageSlide(getTranslation("root.image3"), "root.text3");
Slide slide4 = new ImageSlide(getTranslation("root.image4"), "root.text4");
Slide slide5 = new ImageSlide(getTranslation("root.image5"), "root.text5");
Slide slide6 = new ImageSlide(getTranslation("root.image6"), "root.text6");
Slide slide7 = new ImageSlide(getTranslation("root.image7"), "root.text7");
Slide slide8 = new ImageSlide(getTranslation("root.image8"), "root.text8");
return new Carousel(slide1, slide2, slide3, slide4, slide5, slide6, slide7, slide8).withoutNavigation()
.withoutSwipe();

View File

@ -54,12 +54,13 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
infoIcon.addClickListener(event -> onInfoIconClick());
inputField = new TextField();
inputField.setPlaceholder(getTranslation("root.inputFieldPlaceholder"));
inputField.setId(INPUT_FIELD_ID);
inputField.setClearButtonVisible(true);
inputField.setMaxLength(MAX_INPUT_LENGTH);
// attach a listener that replaces \ with λ
// JavaScript is used because Vaadin does not have APIs for selectionStart/selectionEnd
// and this will be much faster than a bunch of network round trips per character entered!
UI.getCurrent().getPage().executeJs(
"document.getElementById('" + INPUT_FIELD_ID + "').addEventListener('keyup', e => {"
+ "var area = e.target.shadowRoot.querySelector('input');"
@ -132,6 +133,7 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
@Override
public void localeChange(LocaleChangeEvent event) {
inputField.setPlaceholder(getTranslation("root.inputFieldPlaceholder"));
inferTypeButton.setText(getTranslation("root.typeInfer"));
typeAssumptions.setText(getTranslation("root.typeAssumptions"));
}

View File

@ -11,6 +11,7 @@ root.appRule=App-Regel
root.varRule=Var-Regel
root.constRule=Const-Regel
root.letRule=Let-Regel
root.inputFieldPlaceholder=Term hier eingeben. Ein '\\' wird zu '\u03BB' umgewandelt.
root.absRuleLet=Abs-Regel mit Let
root.varRuleLet=Var-Regel mit Let
root.selectLanguage=Sprache
@ -78,7 +79,7 @@ root.slideExp=Typicalc ist eine Anwendung zur Visualisierung von Typinferenz. In
Beispielszenario mit den wichtigsten Funktionen der Website vorgeführt. Das relevante Bedienelement ist jeweils mit \
einem roten Rahmen hervorgehoben. Zwischen einzelnen Slides kann mithilfe der Knöpfe am unteren Ende der Seite \
navigiert werden.
root.linkText=Weitere Informationen zur Typinferenz finden sie \u0020
root.linkText=Weitere Informationen zur Typinferenz finden Sie \u0020
root.link=https://de.wikipedia.org/wiki/Typinferenz_nach_Hindley-Milner
root.here=hier
root.image1=/carousel/EnterTerm.png

View File

@ -13,6 +13,7 @@ root.constRule=Const rule
root.letRule=Let rule
root.absRuleLet=Abs rule with Let
root.varRuleLet=Var rule with Let
root.inputFieldPlaceholder=Enter term here. A '\\' is converted to '\u03BB'.
root.selectLanguage=Language
root.termExplanation=The following grammar specifies the structure of a valid term:
root.assExplanation=The following grammar specifies the syntax of a valid type:
@ -69,8 +70,10 @@ root.UNEXPECTED_TOKEN=The input does not match the syntax specified in the info
root.UNEXPECTED_CHARACTER=The input contains a characters which is not allowed at this position.
root.wrongCharacter=Wrong character: \u0020
root.position=At Position: \u0020
root.slideExp=TODO
root.linkText=Further information can be found \u0020
root.slideExp=Typicalc is an application for the visualisation of type inference. The slideshow below the text \
demonstrates the most important features of the website. In each slide the relevant operating element is surrounded \
by a red border. The buttons at the bottom of the website can be used to navigate through the slides.
root.linkText=Further information on the type inference algorithm can be found \u0020
root.link=https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system
root.here=here
root.image1=/carousel/EnterTerm.png