List of usage examples for com.vaadin.ui Grid setItems
@Override public default void setItems(Collection<T> items)
From source file:com.scipionyx.butterflyeffect.frontend.configuration.ui.view.AboutView.java
License:Apache License
/** * //from w w w.j a va 2s. c om * @param instancesBackend * @param justclean */ private void loadClusterInformation(List<ServiceInstance> instancesBackend, GridLayout layout, boolean justclean) { layout.removeAllComponents(); int i = 0; for (ServiceInstance instance : instancesBackend) { Grid<GridProperty<?>> tableCluster = new Grid<>("Node [" + i + "]"); tableCluster.addStyleName(ValoTheme.TABLE_COMPACT); tableCluster.setSizeFull(); tableCluster.addColumn(GridProperty::getName).setCaption("Property"); tableCluster.addColumn(GridProperty::getValue).setCaption("Value"); List<GridProperty<?>> list = new ArrayList<>(); list.add(new GridProperty<>("Host", instance.getHost())); list.add(new GridProperty<>("Service Id", instance.getServiceId())); list.add(new GridProperty<>("Port", instance.getPort())); list.add(new GridProperty<>("Uri", instance.getUri())); for (String key : instance.getMetadata().keySet()) { list.add(new GridProperty<>("Metadata[" + key + "]", instance.getMetadata().get(key))); } tableCluster.setItems(list); layout.addComponent(tableCluster); i++; } }
From source file:dhbw.clippinggorilla.userinterface.views.AboutUsView.java
public AboutUsView() { setMargin(true);/* w ww .ja v a2 s.c om*/ setWidth("55%"); Label aboutUsHeader = new Label(); Language.set(Word.ABOUT_US, aboutUsHeader); aboutUsHeader.setStyleName(ValoTheme.LABEL_H1); addComponent(aboutUsHeader); Label aboutUsGroupHeadline = new Label(); Language.set(Word.GROUP_PROJECT_OF_GROUP_4, aboutUsGroupHeadline); aboutUsGroupHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(aboutUsGroupHeadline); Label aboutUsText = new Label(); Language.set(Word.GROUP_PROJECT_BODY, aboutUsText); aboutUsText.setWidth("100%"); aboutUsText.setContentMode(com.vaadin.shared.ui.ContentMode.HTML); addComponent(aboutUsText); Label theTeamHeader = new Label(); Language.set(Word.OUR_TEAM, theTeamHeader); theTeamHeader.setStyleName(ValoTheme.LABEL_H2); addComponent(theTeamHeader); Grid<Person> theTeamGrid = new Grid<>(); List<Person> persons = Arrays.asList(new Person("Dan-Pierre", "Drehlich", Person.Function.TEAMLEADER), new Person("Stefan", "Schmid", Person.Function.RESPONSIBLE_FOR_RESEARCH), new Person("Jan", "Striegel", Person.Function.TECHNICAL_ASSISTANT), new Person("Lisa", "Hartung", Person.Function.RESPONSIBLE_FOR_MODELING_QUALITY_ASSURANCE_AND_DOCUMENTATION), new Person("Tim", "Heinzelmann", Person.Function.RESPONSIBLE_FOR_TESTS), new Person("Josua", "Frank", Person.Function.RESPONSIBLE_FOR_IMPLEMENTATION)); Grid.Column c1 = theTeamGrid.addColumn(p -> p.getFirstName()); Language.setCustom(Word.FIRST_NAME, s -> c1.setCaption(s)); Grid.Column c2 = theTeamGrid.addColumn(p -> p.getLastName()); Language.setCustom(Word.LAST_NAME, s -> c2.setCaption(s)); Grid.Column c3 = theTeamGrid.addColumn(p -> p.getResposibility()); Language.setCustom(Word.RESPONSIBILITY, s -> { c3.setCaption(s); theTeamGrid.getDataProvider().refreshAll(); }); theTeamGrid.setItems(persons); theTeamGrid.setWidth("100%"); theTeamGrid.setHeightByRows(6); addComponent(theTeamGrid); SESSIONS.put(VaadinSession.getCurrent(), this); }
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public ArchiveView() { HorizontalLayout optionsLayout = new HorizontalLayout(); optionsLayout.setWidth("100%"); Grid<Clipping> gridClippings = new Grid<>(); Set<Clipping> clippings = ClippingUtils.getUserClippings(UserUtils.getCurrent(), LocalDate.now(ZoneId.of("Europe/Berlin"))); gridClippings.setItems(clippings); InlineDateTimeField datePicker = new InlineDateTimeField(); datePicker.setValue(LocalDateTime.now(ZoneId.of("Europe/Berlin"))); datePicker.setLocale(Locale.GERMANY); datePicker.setResolution(DateTimeResolution.DAY); datePicker.addValueChangeListener(date -> { Set<Clipping> clippingsOfDate = ClippingUtils.getUserClippings(UserUtils.getCurrent(), date.getValue().toLocalDate()); gridClippings.setItems(clippingsOfDate); gridClippings.getDataProvider().refreshAll(); });//from w w w . j a v a 2s . c o m DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM); formatter.withZone(ZoneId.of("Europe/Berlin")); Column columnTime = gridClippings.addColumn(c -> { return c.getDate().format(formatter); }); Language.setCustom(Word.TIME, s -> columnTime.setCaption(s)); Column columnAmountArticles = gridClippings.addColumn(c -> { long amountArticles = c.getArticles().values().stream().flatMap(l -> l.stream()).count(); amountArticles += c.getArticlesFromGroup().values().stream().flatMap(l -> l.stream()).count(); if (amountArticles != 1) { return amountArticles + " " + Language.get(Word.ARTICLES); } else { return amountArticles + " " + Language.get(Word.ARTICLE); } }); Language.setCustom(Word.ARTICLES, s -> { columnAmountArticles.setCaption(s); gridClippings.getDataProvider().refreshAll(); }); gridClippings.setHeight("100%"); gridClippings.setSelectionMode(Grid.SelectionMode.SINGLE); gridClippings.addSelectionListener(c -> { if (c.getFirstSelectedItem().isPresent()) { currentClipping = c.getFirstSelectedItem().get(); showClippingBy(currentClipping, currentSort); } }); optionsLayout.addComponents(datePicker, gridClippings); optionsLayout.setComponentAlignment(datePicker, Alignment.BOTTOM_CENTER); optionsLayout.setComponentAlignment(gridClippings, Alignment.BOTTOM_RIGHT); optionsLayout.setExpandRatio(gridClippings, 5); VerticalLayout sortLayout = new VerticalLayout(); comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY)); Language.setCustom(Word.SORT_BY, s -> { comboBoxSortOptions.setCaption(s); comboBoxSortOptions.getDataProvider().refreshAll(); }); comboBoxSortOptions.setItems(EnumSet.allOf(ClippingView.SortOptions.class)); comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName()); comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon()); comboBoxSortOptions.setValue(currentSort); comboBoxSortOptions.setTextInputAllowed(false); comboBoxSortOptions.setEmptySelectionAllowed(false); comboBoxSortOptions.addStyleName("comboboxsort"); comboBoxSortOptions.addValueChangeListener(e -> { currentSort = e.getValue(); showClippingBy(currentClipping, currentSort); }); comboBoxSortOptions.setVisible(false); sortLayout.setMargin(false); sortLayout.setSpacing(false); sortLayout.addComponent(comboBoxSortOptions); clippingArticlesLayout = new VerticalLayout(); clippingArticlesLayout.setSpacing(true); clippingArticlesLayout.setMargin(false); clippingArticlesLayout.setSizeFull(); addComponents(optionsLayout, sortLayout, clippingArticlesLayout); }
From source file:dhbw.clippinggorilla.userinterface.views.ImpressumView.java
public ImpressumView() { setMargin(true);/*from www . j av a 2s. c o m*/ setWidth("55%"); Label impressumHeader = new Label(); Language.set(Word.IMPRESSUM, impressumHeader); impressumHeader.setStyleName(ValoTheme.LABEL_H1); addComponent(impressumHeader); Label impressumText = new Label(); Language.set(Word.IMPRESSUM_BODY, impressumText); impressumText.setWidth("100%"); impressumText.setContentMode(com.vaadin.shared.ui.ContentMode.HTML); addComponent(impressumText); Grid<Person> studentsGrid = new Grid<>(); List<Person> persons = Arrays.asList(new Person("Dan-Pierre", "Drehlich", Person.Function.TEAMLEADER), new Person("Stefan", "Schmid", Person.Function.RESPONSIBLE_FOR_RESEARCH), new Person("Jan", "Striegel", Person.Function.TECHNICAL_ASSISTANT), new Person("Lisa", "Hartung", Person.Function.RESPONSIBLE_FOR_MODELING_QUALITY_ASSURANCE_AND_DOCUMENTATION), new Person("Tim", "Heinzelmann", Person.Function.RESPONSIBLE_FOR_TESTS), new Person("Josua", "Frank", Person.Function.RESPONSIBLE_FOR_IMPLEMENTATION)); Column c1 = studentsGrid.addColumn(p -> p.getFirstName()); Language.setCustom(Word.FIRST_NAME, s -> c1.setCaption(s)); Column c2 = studentsGrid.addColumn(p -> p.getLastName()); Language.setCustom(Word.LAST_NAME, s -> c2.setCaption(s)); Column c3 = studentsGrid.addColumn(p -> p.getResposibility()); Language.setCustom(Word.RESPONSIBILITY, s -> { c3.setCaption(s); studentsGrid.getDataProvider().refreshAll(); }); studentsGrid.setItems(persons); studentsGrid.setWidth("100%"); studentsGrid.setHeightByRows(6); addComponent(studentsGrid); Label liabilityHeadline = new Label(); Language.set(Word.LIABILITY, liabilityHeadline); liabilityHeadline.setStyleName(ValoTheme.LABEL_H1); addComponent(liabilityHeadline); Label liabilityContentHeadline = new Label(); Language.set(Word.LIABILITY_CONTENT, liabilityContentHeadline); liabilityContentHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(liabilityContentHeadline); Label liabilityContentText = new Label(); Language.set(Word.LIABILITY_CONTENT_BODY, liabilityContentText); liabilityContentText.setWidth("100%"); addComponent(liabilityContentText); Label liabilityLinksHeadline = new Label(); Language.set(Word.LIABILITY_LINKS, liabilityLinksHeadline); liabilityLinksHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(liabilityLinksHeadline); Label liabilityLinksText = new Label(); Language.set(Word.LIABILITY_LINKS_BODY, liabilityLinksText); liabilityLinksText.setWidth("100%"); addComponent(liabilityLinksText); Label copyrightHeadline = new Label(); Language.set(Word.COPYRIGHT, copyrightHeadline); copyrightHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(copyrightHeadline); Label copyrightText = new Label(); Language.set(Word.COPYRIGHT_BODY, copyrightText); copyrightText.setWidth("100%"); addComponent(copyrightText); Label dataProtectionHeadline = new Label(); Language.set(Word.DATAPROTECTION, dataProtectionHeadline); dataProtectionHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(dataProtectionHeadline); Label dataProtectionText = new Label(); Language.set(Word.DATAPROTECTION_BODY, dataProtectionText); dataProtectionText.setWidth("100%"); addComponent(dataProtectionText); SESSIONS.put(VaadinSession.getCurrent(), this); }
From source file:fi.jasoft.dragdroplayouts.demo.DemoUI.java
License:Apache License
private Grid<DemoView> createViewSelection() { Grid<DemoView> select = new Grid<>(); select.addColumn(view -> view.getCaption()); select.setWidth("200px"); select.setHeight("100%"); select.addSelectionListener((change) -> { navigator.navigateTo(change.getFirstSelectedItem().get().getName()); });/* w ww .java 2 s.c o m*/ select.setItems(views); return select; }