use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.
the class ResizableTextAreaWrapper method wrap.
@Override
public ComponentContainer wrap(T textField, String caption, boolean withMargin) {
this.textField = textField;
this.caption = caption;
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(false);
layout.setMargin(false);
layout.setWidth(100, Sizeable.Unit.PERCENTAGE);
if (withMargin) {
layout.addStyleName(CssStyles.FIELD_WRAPPER);
}
textField.setWidth(100, Sizeable.Unit.PERCENTAGE);
textField.addStyleName(CssStyles.RESIZABLE);
textField.setNullRepresentation("");
textField.setTextChangeTimeout(200);
Stream<Validator> maxLengthValidatorStream = textField.getValidators().stream().filter(v -> v instanceof MaxLengthValidator);
if (withMaxLength) {
maxLengthValidatorStream.findFirst().map(v -> ((MaxLengthValidator) v).getMaxLength()).ifPresent(textField::setMaxLength);
labelField = new Label(buildLabelMessage(textField.getValue(), textField, caption));
labelField.setId(textField.getId() + "_label");
labelField.setWidth(100, Sizeable.Unit.PERCENTAGE);
labelField.addStyleNames(CssStyles.ALIGN_RIGHT, CssStyles.FIELD_EXTRA_INFO, CssStyles.LABEL_ITALIC);
layout.addComponents(labelField);
} else {
maxLengthValidatorStream.iterator().forEachRemaining(v -> textField.removeValidator(v));
}
textField.addTextChangeListener(e -> {
updateTextfieldAppearance();
});
textField.addValueChangeListener(e -> {
updateTextfieldAppearance();
});
layout.addComponents(textField);
if (withMaxLength) {
layout.addComponents(labelField);
}
return layout;
}
use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.
the class MultiSelect method initContent.
@Override
protected Component initContent() {
VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setMargin(new MarginInfo(false, false, true, false));
selectComponent.setWidth("100%");
selectComponent.addValueChangeListener((ValueChangeListener) event -> {
T item = (T) selectComponent.getValue();
if (item == null) {
return;
}
String caption = selectComponent.getItemCaption(item);
selectedItemsWithCaption.put(item, caption);
setValue(new HashSet<>(selectedItemsWithCaption.keySet()));
selectComponent.setValue(null);
listSelectedItems();
});
verticalLayout.addComponent(selectComponent);
if (isReadOnly()) {
selectComponent.setVisible(false);
selectComponent.setReadOnly(true);
}
labelLayout.setMargin(false);
verticalLayout.addComponent(labelLayout);
initFromCurrentValue();
listSelectedItems();
return verticalLayout;
}
use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.
the class ExposuresField method showMultipleInfectionEnvironmentsPopup.
private void showMultipleInfectionEnvironmentsPopup(ExposureDto entry) {
VerticalLayout warningLayout = VaadinUiUtil.createWarningLayout();
Window popupWindow = VaadinUiUtil.showPopupWindow(warningLayout);
com.vaadin.ui.Label infoLabel = new com.vaadin.ui.Label(I18nProperties.getValidationError(Validations.caseMultipleInfectionEnvironments));
CssStyles.style(infoLabel, CssStyles.LABEL_LARGE, CssStyles.LABEL_WHITE_SPACE_NORMAL);
warningLayout.addComponent(infoLabel);
ConfirmationComponent yesNo = VaadinUiUtil.buildYesNoConfirmationComponent();
yesNo.getConfirmButton().addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(Button.ClickEvent event) {
popupWindow.close();
for (ExposureDto exposure : getValue()) {
if (exposure.isProbableInfectionEnvironment() && !exposure.getUuid().equals(entry.getUuid())) {
exposure.setProbableInfectionEnvironment(false);
}
}
getTable().refreshRowCache();
}
});
yesNo.getCancelButton().addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(Button.ClickEvent event) {
popupWindow.close();
entry.setProbableInfectionEnvironment(false);
getTable().refreshRowCache();
}
});
warningLayout.addComponent(yesNo);
popupWindow.setWidth(800, Sizeable.Unit.PIXELS);
popupWindow.setClosable(false);
}
use of com.vaadin.v7.ui.VerticalLayout in project charts by vaadin.
the class ChartsDemoUI method init.
@Override
protected void init(VaadinRequest request) {
initGATracker();
tabSheet = new TabSheet();
tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {
@Override
public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
com.vaadin.ui.JavaScript.eval("setTimeout(function(){prettyPrint();},300);");
}
});
tabSheet.setSizeFull();
tabSheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
Link homepage = new Link("Home Page", new ExternalResource("https://vaadin.com/components/vaadin-charts"));
Link javadoc = new Link("JavaDoc", new ExternalResource("https://vaadin.com/api/com.vaadin/vaadin-charts/" + getVersion() + "/"));
Link manual = new Link("Manual", new ExternalResource("https://vaadin.com/docs/v8/charts/charts-overview.html"));
Link pricing = new Link("Pricing", new ExternalResource("https://vaadin.com/pricing"));
Label version = new Label("Version " + getVersion());
version.addStyleName("version");
HorizontalLayout links = new HorizontalLayout(homepage, pricing, javadoc, manual);
links.setSpacing(true);
links.addStyleName("links");
final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
horizontalSplitPanel.setSecondComponent(tabSheet);
horizontalSplitPanel.setSplitPosition(300, Unit.PIXELS);
horizontalSplitPanel.addStyleName("main-layout");
ChartOptions.get().setTheme(new ValoLightTheme());
themeSelector = new ComboBox("Charts Theme:");
themeSelector.addStyleName("theme-selector");
themeSelector.addStyleName(ValoTheme.COMBOBOX_SMALL);
themeSelector.setTextInputAllowed(false);
com.vaadin.addon.charts.model.style.Theme defaultTheme = new ValoLightTheme();
Map<com.vaadin.addon.charts.model.style.Theme, String> mapThemes = new HashMap<>();
com.vaadin.addon.charts.model.style.Theme[] themes = new com.vaadin.addon.charts.model.style.Theme[] { defaultTheme, new ValoDarkTheme(), new VaadinTheme(), new HighChartsDefaultTheme(), new GridTheme(), new GrayTheme(), new SkiesTheme() };
mapThemes.put(themes[0], "Valo Light");
mapThemes.put(themes[1], "Valo Dark");
mapThemes.put(themes[2], "Vaadin");
mapThemes.put(themes[3], "HighCharts");
mapThemes.put(themes[4], "Grid");
mapThemes.put(themes[5], "Gray");
mapThemes.put(themes[6], "Skies");
themeSelector.setEmptySelectionAllowed(false);
themeSelector.setItems(themes);
themeSelector.setSelectedItem(defaultTheme);
themeSelector.setItemCaptionGenerator(mapThemes::get);
themeSelector.addSelectionListener(e -> {
ChartOptions.get().setTheme(e.getValue());
});
final HierarchicalContainer container = getContainer();
VerticalLayout content = new VerticalLayout();
content.setSpacing(true);
content.setMargin(false);
Label logo = new Label("Vaadin Charts for Vaadin 8");
logo.setWidth("100%");
logo.addStyleName("h3");
logo.addStyleName("logo");
TextField filterField = new TextField();
filterField.setPlaceholder("Filter examples");
filterField.setIcon(FontAwesome.SEARCH);
filterField.addStyleName("filter");
filterField.setWidth("100%");
filterField.addValueChangeListener(e -> {
container.removeAllContainerFilters();
String text = e.getValue();
if (text != null && !text.isEmpty()) {
expandForFiltering();
container.addContainerFilter("searchName", text, true, false);
} else {
restoreExpandedStates();
}
});
tree = new Tree();
tree.setImmediate(true);
tree.setContainerDataSource(container);
tree.setItemCaptionPropertyId("displayName");
tree.setNullSelectionAllowed(false);
tree.setWidth("100%");
tree.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
Object value = event.getProperty().getValue();
if (value instanceof Class) {
updateTabSheet((Class) value);
} else {
tree.expandItemsRecursively(value);
}
}
});
Button trial = new Button("Start Free Trial");
trial.addStyleName(ValoTheme.BUTTON_PRIMARY);
trial.addStyleName(ValoTheme.BUTTON_TINY);
trial.addClickListener(e -> {
getUI().getPage().open("https://vaadin.com/trial", "_blank");
});
content.addComponents(logo, links, trial, filterField, tree, version);
content.setComponentAlignment(trial, Alignment.MIDDLE_CENTER);
horizontalSplitPanel.setFirstComponent(content);
selectItem();
Page.getCurrent().addUriFragmentChangedListener(new Page.UriFragmentChangedListener() {
@Override
public void uriFragmentChanged(Page.UriFragmentChangedEvent event) {
selectItem();
}
});
setContent(new CssLayout() {
{
setSizeFull();
addComponent(horizontalSplitPanel);
addComponent(themeSelector);
}
});
if (tracker != null) {
tracker.trackPageview("/charts");
}
}
use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.
the class CampaignDashboardView method refreshDashboard.
@SuppressWarnings("deprecation")
@Override
public void refreshDashboard() {
final Page page = Page.getCurrent();
cleanupDashboard(page);
final VerticalLayout tabLayout = new VerticalLayout();
tabLayout.setSizeFull();
tabLayout.setMargin(new MarginInfo(false, false, false, false));
tabLayout.setSpacing(false);
campaignDashboardTabComponents.add(tabLayout);
dashboardLayout.addComponent(tabLayout);
dashboardLayout.setExpandRatio(tabLayout, 1);
final OptionGroup tabSwitcher = new OptionGroup();
tabSwitcher.setWidthFull();
final VerticalLayout tabSwitcherLayout = new VerticalLayout(tabSwitcher);
tabSwitcherLayout.setWidthFull();
tabSwitcherLayout.setMargin(new MarginInfo(false, false, false, true));
tabSwitcherLayout.setSpacing(false);
tabLayout.addComponent(tabSwitcherLayout);
tabLayout.setExpandRatio(tabSwitcherLayout, 0);
final List<String> tabs = new ArrayList<>(dataProvider.getTabIds());
tabs.forEach(tabId -> {
tabSwitcher.addItem(tabId);
tabSwitcher.setItemCaption(tabId, tabId);
});
if (!(tabs.size() > 1)) {
tabSwitcherLayout.setVisible(false);
}
final String lastTabId = lastTabIdForCampaign.get(dataProvider.getCampaign());
tabSwitcher.setValue(tabs.isEmpty() ? StringUtils.EMPTY : lastTabId != null ? lastTabId : tabs.get(0));
CssStyles.style(tabSwitcher, CssStyles.FORCE_CAPTION, ValoTheme.OPTIONGROUP_HORIZONTAL, CssStyles.OPTIONGROUP_HORIZONTAL_PRIMARY);
final VerticalLayout subTabLayout = new VerticalLayout();
subTabLayout.setSizeFull();
subTabLayout.setMargin(new MarginInfo(false, false, false, false));
subTabLayout.setSpacing(false);
campaignDashboardTabComponents.add(subTabLayout);
tabLayout.addComponent(subTabLayout);
tabLayout.setExpandRatio(subTabLayout, 1);
tabSwitcher.addValueChangeListener(e -> {
final String tabId = (String) e.getProperty().getValue();
subTabLayout.removeComponent(currentDiagramsWrapper);
subTabLayout.removeComponent(currentSubTabsWrapper);
lastTabIdForCampaign.put(dataProvider.getCampaign(), tabId);
refreshSubTabs(page, tabId, subTabLayout);
});
refreshSubTabs(page, (String) tabSwitcher.getValue(), subTabLayout);
}
Aggregations