use of com.vaadin.flow.component.Text in project flow by vaadin.
the class BootstrapHandlerTest method no_body_size_or_page_configurator_still_adds_margin_for_body.
// 2344
@Test
public void no_body_size_or_page_configurator_still_adds_margin_for_body() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(RootNavigationTarget.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
Optional<Element> styleTag = allElements.stream().filter(element -> element.tagName().equals("style")).findFirst();
Assert.assertTrue("Expected a style element in head.", styleTag.isPresent());
Assert.assertTrue("The first style tag should start with body style containing margin", styleTag.get().toString().startsWith("<style type=\"text/css\">body {margin:0;}"));
}
use of com.vaadin.flow.component.Text in project flow by vaadin.
the class AnchorTest method createWithComponent.
@Test
public void createWithComponent() {
Anchor anchor = new Anchor("#", new Text("Home"));
Assert.assertEquals(anchor.getElement().getAttribute("href"), "#");
Assert.assertEquals(anchor.getHref(), "#");
Assert.assertEquals(anchor.getElement().getText(), "Home");
Assert.assertEquals(anchor.getText(), "Home");
}
use of com.vaadin.flow.component.Text in project flow by vaadin.
the class DependencyView method onShow.
@Override
protected void onShow() {
add(new Text("This test initially loads a stylesheet which makes all text red, a JavaScript for logging window messages, a JavaScript for handling body click events and an HTML which sends a window message"), new Hr(), new Hr());
Div clickBody = new Div();
clickBody.setText("Hello, click the body please");
clickBody.setId("hello");
add(clickBody);
NativeButton jsOrder = new NativeButton("Test JS order", e -> {
getPage().addJavaScript("/test-files/js/set-global-var.js");
getPage().addJavaScript("/test-files/js/read-global-var.js", LoadMode.LAZY);
});
jsOrder.setId("loadJs");
NativeButton allBlue = new NativeButton("Load 'everything blue' stylesheet", e -> {
getPage().addStyleSheet("/test-files/css/allblueimportant.css");
});
allBlue.setId("loadBlue");
NativeButton loadUnavailableResources = new NativeButton("Load unavailable resources", e -> {
getPage().addStyleSheet("/not-found.css");
getPage().addJavaScript("/not-found.js");
});
loadUnavailableResources.setId("loadUnavailableResources");
Div log = new Div();
log.setId("log");
add(jsOrder, allBlue, loadUnavailableResources, new Hr(), log);
}
use of com.vaadin.flow.component.Text in project flow by vaadin.
the class SynchronizedPropertyView method addSyncMultipleProperties.
private void addSyncMultipleProperties() {
add(new Text("Synchronize 'value' on 'input' event and 'valueAsNumber' on 'blur'"));
Div valueLabel = new Div();
valueLabel.setId("multiSyncValueLabel");
Div valueAsNumberLabel = new Div();
valueAsNumberLabel.setId("multiSyncValueAsNumberLabel");
Element multiSync = ElementFactory.createInput("number");
multiSync.setAttribute("id", "multiSyncValue");
multiSync.addPropertyChangeListener("valueAsNumber", "blur", event -> {
});
multiSync.addPropertyChangeListener("value", "input", event -> {
});
multiSync.addEventListener("input", e -> {
valueLabel.setText("Server value: " + multiSync.getProperty("value"));
});
multiSync.addEventListener("blur", e -> {
valueAsNumberLabel.setText("Server valueAsNumber: " + multiSync.getProperty("valueAsNumber"));
});
getElement().appendChild(multiSync);
add(valueLabel, valueAsNumberLabel);
}
use of com.vaadin.flow.component.Text in project flow by vaadin.
the class SynchronizedPropertyView method addSyncWithInitialValue.
private void addSyncWithInitialValue() {
add(new Text("Synchronized on 'change' event with initial value"));
final Div syncOnChangeInitialValueLabel = new Div();
syncOnChangeInitialValueLabel.setId("syncOnChangeInitialValueLabel");
Element syncOnChangeInitialValue = ElementFactory.createInput();
syncOnChangeInitialValueLabel.setText("Server value on create: " + syncOnChangeInitialValue.getProperty("value"));
syncOnChangeInitialValue.setAttribute("id", "syncOnChangeInitialValue");
syncOnChangeInitialValue.addPropertyChangeListener("value", "change", event -> {
});
syncOnChangeInitialValue.addEventListener("change", e -> {
syncOnChangeInitialValueLabel.setText("Server value in change listener: " + syncOnChangeInitialValue.getProperty("value"));
});
syncOnChangeInitialValue.setProperty("value", "initial");
getElement().appendChild(syncOnChangeInitialValue);
add(syncOnChangeInitialValueLabel);
}
Aggregations