use of com.vaadin.v7.ui.HorizontalLayout 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.HorizontalLayout in project charts by vaadin.
the class ServerSideEvents method createControls.
private Layout createControls() {
visibilityToggling = new CheckBox("Disable series visibility toggling");
visibilityToggling.addValueChangeListener(e -> {
chart.setSeriesVisibilityTogglingDisabled(visibilityToggling.getValue());
});
final Button firstSeriesVisible = new Button("Hide first series");
firstSeriesVisible.setId("hideFirstSeries");
firstSeriesVisible.addClickListener(new Button.ClickListener() {
boolean hideSeries = true;
@Override
public void buttonClick(Button.ClickEvent event) {
Series firstSeries = chart.getConfiguration().getSeries().get(0);
((AbstractSeries) firstSeries).setVisible(!hideSeries);
hideSeries = !hideSeries;
String caption = hideSeries ? "Hide first series" : "Show first series";
firstSeriesVisible.setCaption(caption);
}
});
Button setExtremes = new Button("Toggle extremes");
setExtremes.setId("setExtremes");
setExtremes.addClickListener(new Button.ClickListener() {
public boolean extremesSet;
@Override
public void buttonClick(Button.ClickEvent event) {
if (extremesSet) {
chart.getConfiguration().getxAxis().setExtremes(10, 90);
} else {
chart.getConfiguration().getxAxis().setExtremes(20, 80);
}
extremesSet = !extremesSet;
}
});
final OptionGroup zoomLevels = new OptionGroup("Zoom Type");
zoomLevels.addItem(ZoomType.XY);
zoomLevels.addItem(ZoomType.X);
zoomLevels.addItem(ZoomType.Y);
zoomLevels.setValue(ZoomType.XY);
zoomLevels.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
ZoomType zoom = (ZoomType) zoomLevels.getValue();
chart.getConfiguration().getChart().setZoomType(zoom);
chart.drawChart();
}
});
Button resetHistory = new Button("Reset history");
resetHistory.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
lastEvent.setValue(null);
eventDetails.setValue(null);
historyLayout.removeAllComponents();
}
});
HorizontalLayout controls = new HorizontalLayout();
controls.setId("controls");
controls.setSpacing(true);
controls.addComponent(visibilityToggling);
controls.addComponent(firstSeriesVisible);
controls.addComponent(setExtremes);
controls.addComponent(zoomLevels);
controls.addComponent(resetHistory);
return controls;
}
use of com.vaadin.v7.ui.HorizontalLayout in project charts by vaadin.
the class ChartWithExternalContainer method getChart.
@Override
protected Component getChart() {
HorizontalLayout lo = new HorizontalLayout();
lo.setSpacing(true);
Container vaadinContainer = ExampleUtil.getOrderContainer();
ContainerDataSeries container1 = createContainerView1(vaadinContainer);
ContainerDataSeries container2 = createContainerView2(vaadinContainer);
Component table = createTable(vaadinContainer);
Component chart1 = createChart1(container1);
Component chart2 = createChart2(container2);
table.setSizeFull();
chart1.setSizeFull();
chart2.setSizeFull();
lo.setWidth("100%");
lo.setHeight("450px");
lo.addComponents(table);
lo.addComponent(chart1);
lo.addComponent(chart2);
lo.setExpandRatio(table, 0.2f);
lo.setExpandRatio(chart1, 0.4f);
lo.setExpandRatio(chart2, 0.4f);
return lo;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class CommunitiesView method createFilterBar.
private HorizontalLayout createFilterBar() {
filterLayout = new HorizontalLayout();
filterLayout.setMargin(false);
filterLayout.setSpacing(true);
filterLayout.setWidth(100, Unit.PERCENTAGE);
searchField = new SearchField();
searchField.addTextChangeListener(e -> {
criteria.nameLike(e.getText());
grid.reload();
});
filterLayout.addComponent(searchField);
countryFilter = addCountryFilter(filterLayout, country -> {
criteria.country(country);
grid.reload();
}, regionFilter);
countryFilter.addValueChangeListener(country -> {
CountryReferenceDto countryReferenceDto = (CountryReferenceDto) country.getProperty().getValue();
criteria.country(countryReferenceDto);
navigateTo(criteria);
FieldHelper.updateItems(regionFilter, countryReferenceDto != null ? FacadeProvider.getRegionFacade().getAllActiveByCountry(countryReferenceDto.getUuid()) : null);
});
regionFilter = ComboBoxHelper.createComboBoxV7();
regionFilter.setId(DistrictDto.REGION);
regionFilter.setWidth(140, Unit.PIXELS);
regionFilter.setCaption(I18nProperties.getPrefixCaption(DistrictDto.I18N_PREFIX, DistrictDto.REGION));
regionFilter.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
regionFilter.addValueChangeListener(e -> {
RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
criteria.region(region);
navigateTo(criteria);
FieldHelper.updateItems(districtFilter, region != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()) : null);
});
filterLayout.addComponent(regionFilter);
districtFilter = ComboBoxHelper.createComboBoxV7();
districtFilter.setId(CommunityDto.DISTRICT);
districtFilter.setWidth(140, Unit.PIXELS);
districtFilter.setCaption(I18nProperties.getPrefixCaption(CommunityDto.I18N_PREFIX, CommunityDto.DISTRICT));
districtFilter.addValueChangeListener(e -> {
criteria.district((DistrictReferenceDto) e.getProperty().getValue());
navigateTo(criteria);
});
filterLayout.addComponent(districtFilter);
resetButton = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
ViewModelProviders.of(CommunitiesView.class).remove(CommunityCriteria.class);
navigateTo(null);
}, CssStyles.FORCE_CAPTION);
resetButton.setVisible(false);
filterLayout.addComponent(resetButton);
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Show active/archived/all dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
relevanceStatusFilter.setId("relevanceStatus");
relevanceStatusFilter.setWidth(220, Unit.PERCENTAGE);
relevanceStatusFilter.setNullSelectionAllowed(false);
relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.communityActiveCommunities));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.communityArchivedCommunities));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.communityAllCommunities));
relevanceStatusFilter.addValueChangeListener(e -> {
criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(criteria);
});
actionButtonsLayout.addComponent(relevanceStatusFilter);
// Bulk operation dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.COMMUNITY, new Runnable() {
public void run() {
navigateTo(criteria);
}
});
}, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.COMMUNITY, new Runnable() {
public void run() {
navigateTo(criteria);
}
});
}, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
bulkOperationsDropdown.setVisible(isBulkOperationsDropdownVisible());
actionButtonsLayout.addComponent(bulkOperationsDropdown);
}
}
}
filterLayout.addComponent(actionButtonsLayout);
filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
filterLayout.setExpandRatio(actionButtonsLayout, 1);
return filterLayout;
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class DistrictsView method createFilterBar.
private HorizontalLayout createFilterBar() {
filterLayout = new HorizontalLayout();
filterLayout.setMargin(false);
filterLayout.setSpacing(true);
filterLayout.setWidth(100, Unit.PERCENTAGE);
searchField = new SearchField();
searchField.addTextChangeListener(e -> {
criteria.nameEpidLike(e.getText());
grid.reload();
});
filterLayout.addComponent(searchField);
countryFilter = addCountryFilter(filterLayout, country -> {
criteria.country(country);
grid.reload();
}, regionFilter);
countryFilter.addValueChangeListener(country -> {
CountryReferenceDto countryReferenceDto = (CountryReferenceDto) country.getProperty().getValue();
criteria.country(countryReferenceDto);
navigateTo(criteria);
FieldHelper.updateItems(regionFilter, countryReferenceDto != null ? FacadeProvider.getRegionFacade().getAllActiveByCountry(countryReferenceDto.getUuid()) : null);
});
regionFilter = ComboBoxHelper.createComboBoxV7();
regionFilter.setId(DistrictDto.REGION);
regionFilter.setWidth(140, Unit.PIXELS);
regionFilter.setCaption(I18nProperties.getPrefixCaption(DistrictDto.I18N_PREFIX, DistrictDto.REGION));
regionFilter.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
regionFilter.addValueChangeListener(e -> {
criteria.region((RegionReferenceDto) e.getProperty().getValue());
navigateTo(criteria);
});
filterLayout.addComponent(regionFilter);
resetButton = ButtonHelper.createButton(Captions.actionResetFilters, event -> {
ViewModelProviders.of(DistrictsView.class).remove(DistrictCriteria.class);
navigateTo(null);
}, CssStyles.FORCE_CAPTION);
resetButton.setVisible(false);
filterLayout.addComponent(resetButton);
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Show active/archived/all dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
relevanceStatusFilter.setId("relevanceStatus");
relevanceStatusFilter.setWidth(220, Unit.PERCENTAGE);
relevanceStatusFilter.setNullSelectionAllowed(false);
relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.districtActiveDistricts));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.districtArchivedDistricts));
relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.districtAllDistricts));
relevanceStatusFilter.addValueChangeListener(e -> {
criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(criteria);
});
actionButtonsLayout.addComponent(relevanceStatusFilter);
// Bulk operation dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(true, grid.asMultiSelect().getSelectedItems(), InfrastructureType.DISTRICT, new Runnable() {
public void run() {
navigateTo(criteria);
}
});
}, EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())), new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchiveInfrastructure), VaadinIcons.ARCHIVE, selectedItem -> {
ControllerProvider.getInfrastructureController().archiveOrDearchiveAllSelectedItems(false, grid.asMultiSelect().getSelectedItems(), InfrastructureType.DISTRICT, new Runnable() {
public void run() {
navigateTo(criteria);
}
});
}, EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
bulkOperationsDropdown.setVisible(isBulkOperationsDropdownVisible());
actionButtonsLayout.addComponent(bulkOperationsDropdown);
}
}
}
filterLayout.addComponent(actionButtonsLayout);
filterLayout.setComponentAlignment(actionButtonsLayout, Alignment.BOTTOM_RIGHT);
filterLayout.setExpandRatio(actionButtonsLayout, 1);
return filterLayout;
}
Aggregations