List of usage examples for com.vaadin.ui Grid Grid
public Grid(DataProvider<T, ?> dataProvider)
From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java
License:Apache License
private Component displayRequirementTypes() { VerticalLayout vl = new VerticalLayout(); Grid grid = new Grid(TRANSLATOR.translate(REQUIREMENT_TYPE)); BeanItemContainer<RequirementType> types = new BeanItemContainer<>(RequirementType.class); types.addAll(new RequirementTypeJpaController(DataBaseManager.getEntityManagerFactory()) .findRequirementTypeEntities()); grid.setContainerDataSource(types);// w ww . j a v a 2 s.c o m grid.setSelectionMode(SelectionMode.SINGLE); grid.setColumns(NAME, DESC); Grid.Column name = grid.getColumn(NAME); name.setHeaderCaption(TRANSLATOR.translate("general.name")); name.setConverter(new TranslationConverter()); Grid.Column desc = grid.getColumn(DESC); desc.setHeaderCaption(TRANSLATOR.translate("general.description")); desc.setConverter(new TranslationConverter()); grid.setSizeFull(); vl.addComponent(grid); grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(types.size() > 5 ? 5 : types.size()); //Menu HorizontalLayout hl = new HorizontalLayout(); Button add = new Button(TRANSLATOR.translate("general.create")); add.addClickListener(listener -> { VMWindow w = new VMWindow(); w.setContent(new RequirementTypeComponent(new RequirementType(), true)); ((VMUI) UI.getCurrent()).addWindow(w); w.addCloseListener(l -> { ((VMUI) UI.getCurrent()).updateScreen(); }); }); hl.addComponent(add); Button delete = new Button(TRANSLATOR.translate("general.delete")); delete.setEnabled(false); delete.addClickListener(listener -> { RequirementType selected = (RequirementType) ((SingleSelectionModel) grid.getSelectionModel()) .getSelectedRow(); if (selected != null && selected.getId() >= 1000) { try { new RequirementTypeJpaController(DataBaseManager.getEntityManagerFactory()) .destroy(selected.getId()); ((VMUI) UI.getCurrent()).updateScreen(); } catch (IllegalOrphanException | NonexistentEntityException ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate(DELETE_ERROR), TRANSLATOR.translate(DELETE_ERROR), Notification.Type.ERROR_MESSAGE); } } }); hl.addComponent(delete); vl.addComponent(hl); grid.addSelectionListener(event -> { // Java 8 // Get selection from the selection model RequirementType selected = (RequirementType) ((SingleSelectionModel) grid.getSelectionModel()) .getSelectedRow(); //Only delete custom ones. delete.setEnabled(selected != null && selected.getId() >= 1000); }); return vl; }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadProgressInfoWindow.java
License:Open Source License
private Grid createGrid() { final Grid statusGrid = new Grid(uploads); statusGrid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID); statusGrid.setId(UIComponentIdProvider.UPLOAD_STATUS_POPUP_GRID); statusGrid.setSelectionMode(SelectionMode.NONE); statusGrid.setHeaderVisible(true);/*from www . j a v a 2 s. co m*/ statusGrid.setImmediate(true); statusGrid.setSizeFull(); return statusGrid; }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadStatusInfoWindow.java
License:Open Source License
private Grid createGrid() { final Grid statusGrid = new Grid(uploads); statusGrid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID); statusGrid.setSelectionMode(SelectionMode.NONE); statusGrid.setHeaderVisible(true);//from w w w . j ava 2 s . c o m statusGrid.setImmediate(true); statusGrid.setSizeFull(); return statusGrid; }
From source file:org.esn.esobase.view.tab.QuestTranslateTab.java
public QuestTranslateTab(DBService service_) { this.setSizeFull(); this.setSpacing(false); this.setMargin(false); this.service = service_; QuestChangeListener questChangeListener = new QuestChangeListener(); FilterChangeListener filterChangeListener = new FilterChangeListener(); questListlayout = new HorizontalLayout(); questListlayout.setWidth(100f, Unit.PERCENTAGE); questListlayout.setSpacing(false);//from w ww. ja v a 2 s .co m questListlayout.setMargin(false); locationTable = new ComboBox("?"); locationTable.setPageLength(30); locationTable.setScrollToSelectedItem(true); locationTable.setWidth(100f, Unit.PERCENTAGE); locationTable.addValueChangeListener(filterChangeListener); locationTable.setDataProvider(new ListDataProvider<>(locations)); questTable = new ComboBox("?"); questTable.setWidth(100f, Unit.PERCENTAGE); questTable.setPageLength(15); questTable.setScrollToSelectedItem(true); questTable.setWidth(100f, Unit.PERCENTAGE); questTable.addValueChangeListener(questChangeListener); questTable.setDataProvider(new ListDataProvider<>(questList)); questListlayout.addComponent(questTable); FormLayout locationAndQuestLayout = new FormLayout(locationTable, questTable); locationAndQuestLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); locationAndQuestLayout.setSizeFull(); questListlayout.addComponent(locationAndQuestLayout); translateStatus = new ComboBoxMultiselect("? ", Arrays.asList(TRANSLATE_STATUS.values())); translateStatus.setClearButtonCaption("?"); translateStatus.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { LoadFilters(); LoadContent(); } }); noTranslations = new CheckBox("? ?"); noTranslations.setValue(Boolean.FALSE); noTranslations.addValueChangeListener(filterChangeListener); emptyTranslations = new CheckBox("? "); emptyTranslations.setValue(Boolean.FALSE); emptyTranslations.addValueChangeListener(filterChangeListener); HorizontalLayout checkBoxlayout = new HorizontalLayout(noTranslations, emptyTranslations); checkBoxlayout.setSpacing(false); checkBoxlayout.setMargin(false); translatorBox = new ComboBox(""); translatorBox.setPageLength(15); translatorBox.setScrollToSelectedItem(true); translatorBox.setDataProvider(new ListDataProvider<SysAccount>(service.getSysAccounts())); translatorBox.addValueChangeListener(filterChangeListener); refreshButton = new Button(""); refreshButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LoadFilters(); LoadContent(); } }); countLabel = new Label(); searchField = new TextField("?? ?"); searchField.setSizeFull(); searchField.addValueChangeListener(filterChangeListener); FormLayout filtersLayout = new FormLayout(translateStatus, translatorBox, checkBoxlayout, searchField); filtersLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); filtersLayout.setSizeFull(); questListlayout.addComponent(filtersLayout); questListlayout.addComponent(refreshButton); questListlayout.addComponent(countLabel); questListlayout.setExpandRatio(locationAndQuestLayout, 0.4f); questListlayout.setExpandRatio(filtersLayout, 0.4f); questListlayout.setExpandRatio(refreshButton, 0.1f); questListlayout.setExpandRatio(countLabel, 0.1f); questListlayout.setHeight(105f, Unit.PIXELS); this.addComponent(questListlayout); infoLayout = new VerticalLayout(); infoLayout.setSizeFull(); infoLayout.setSpacing(false); infoLayout.setMargin(false); tabSheet = new TabSheet(); tabSheet.setSizeFull(); nameLayout = new VerticalLayout(); nameLayout.setSizeFull(); nameHLayout = new HorizontalLayout(); nameHLayout.setSizeFull(); nameHLayout.setSpacing(false); nameHLayout.setMargin(false); nameLayout = new VerticalLayout(); nameLayout.setSizeFull(); nameLayout.setSpacing(false); nameLayout.setMargin(false); questNameEnArea = new TextArea("?"); questNameEnArea.setSizeFull(); questNameEnArea.setRows(1); questNameEnArea.setReadOnly(true); questNameRuArea = new TextArea("? Ru"); questNameRuArea.setSizeFull(); questNameRuArea.setRows(1); questNameRuArea.setReadOnly(true); questNameRawEnArea = new TextArea("? "); questNameRawEnArea.setSizeFull(); questNameRawEnArea.setRows(1); questNameRawEnArea.setReadOnly(true); questNameRawRuArea = new TextArea("? Ru"); questNameRawRuArea.setSizeFull(); questNameRawRuArea.setRows(1); questNameRawRuArea.setReadOnly(true); nameLayout.addComponents(questNameEnArea, questNameRuArea, questNameRawEnArea, questNameRawRuArea); nameHLayout.addComponent(nameLayout); nameTranslateLayout = new VerticalLayout(); nameTranslateLayout.setSizeFull(); nameTranslateLayout.setSpacing(false); nameTranslateLayout.setMargin(false); nameHLayout.addComponent(nameTranslateLayout); infoLayout.addComponent(nameHLayout); descriptionLayout = new VerticalLayout(); descriptionLayout.setSizeFull(); descriptionHLayout = new HorizontalLayout(); descriptionHLayout.setSizeFull(); descriptionHLayout.setSpacing(false); descriptionHLayout.setMargin(false); descriptionLayout = new VerticalLayout(); descriptionLayout.setSizeFull(); descriptionLayout.setSpacing(false); descriptionLayout.setMargin(false); questDescriptionEnArea = new TextArea("?"); questDescriptionEnArea.setSizeFull(); questDescriptionEnArea.setRows(4); questDescriptionEnArea.setReadOnly(true); questDescriptionRuArea = new TextArea("? Ru"); questDescriptionRuArea.setSizeFull(); questDescriptionRuArea.setRows(4); questDescriptionRuArea.setReadOnly(true); questDescriptionRawEnArea = new TextArea("? "); questDescriptionRawEnArea.setSizeFull(); questDescriptionRawEnArea.setRows(4); questDescriptionRawEnArea.setReadOnly(true); questDescriptionRawRuArea = new TextArea("? Ru"); questDescriptionRawRuArea.setSizeFull(); questDescriptionRawRuArea.setRows(4); questDescriptionRawRuArea.setReadOnly(true); descriptionLayout.addComponents(questDescriptionEnArea, questDescriptionRuArea, questDescriptionRawEnArea, questDescriptionRawRuArea); descriptionHLayout.addComponent(descriptionLayout); descriptionTranslateLayout = new VerticalLayout(); descriptionTranslateLayout.setSizeFull(); descriptionTranslateLayout.setSpacing(false); descriptionTranslateLayout.setMargin(false); descriptionHLayout.addComponent(descriptionTranslateLayout); infoLayout.addComponent(descriptionHLayout); tabSheet.addTab(infoLayout, "?"); stepsLayout = new VerticalLayout(); stepsLayout.setSizeFull(); stepsLayout.setSpacing(false); stepsLayout.setMargin(false); stepsData = new TreeData(); stepsGrid = new TreeGrid(new TreeDataProvider(stepsData)); stepsGrid.setSelectionMode(Grid.SelectionMode.NONE); stepsGrid.setRowHeight(250); stepsGrid.setHeaderVisible(false); stepsGrid.setSizeFull(); stepsGrid.setItemCollapseAllowedProvider(new ItemCollapseAllowedProvider() { @Override public boolean test(Object item) { return false; } }); stepsGrid.addColumn(new ValueProvider() { @Override public Object apply(Object source) { if (source instanceof QuestStep) { return "?"; } if (source instanceof QuestDirection) { return " - " + ((QuestDirection) source).getDirectionType().name(); } return null; } }).setId("rowType").setCaption("").setWidth(132).setStyleGenerator(rowStyleGenerator); stepsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestStep) { QuestStep step = (QuestStep) source; if (step.getTextEn() != null && !step.getTextEn().isEmpty()) { TextArea textEnArea = new TextArea("? "); textEnArea.setValue(step.getTextEn()); textEnArea.setReadOnly(true); textEnArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnArea); } if (step.getTextRu() != null && !step.getTextRu().isEmpty()) { TextArea textRuArea = new TextArea(" "); textRuArea.setValue(step.getTextRu()); textRuArea.setReadOnly(true); textRuArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuArea); } } else if (source instanceof QuestDirection) { QuestDirection d = (QuestDirection) source; if (d.getTextEn() != null && !d.getTextEn().isEmpty()) { TextArea textEnArea = new TextArea("? "); textEnArea.setValue(d.getTextEn()); textEnArea.setRows(2); textEnArea.setReadOnly(true); textEnArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnArea); } if (d.getTextRu() != null && !d.getTextRu().isEmpty()) { TextArea textRuArea = new TextArea(" "); textRuArea.setValue(d.getTextRu()); textRuArea.setRows(2); textRuArea.setReadOnly(true); textRuArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuArea); } } return result; } }).setId("ingameText").setStyleGenerator(rowStyleGenerator); stepsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestStep) { QuestStep step = (QuestStep) source; if (step.getSheetsJournalEntry() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(step.getSheetsJournalEntry().getTextEn()); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (step.getSheetsJournalEntry().getTextRu() != null && !step.getSheetsJournalEntry() .getTextRu().equals(step.getSheetsJournalEntry().getTextEn())) { TextArea textRuRawArea = new TextArea(" " + step.getSheetsJournalEntry().getTranslator()); textRuRawArea.setValue(step.getSheetsJournalEntry().getTextRu()); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea);//, " " } } } else if (source instanceof QuestDirection) { QuestDirection d = (QuestDirection) source; if (d.getSheetsQuestDirection() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(d.getSheetsQuestDirection().getTextEn()); textEnRawArea.setRows(2); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (d.getSheetsQuestDirection().getTextRu() != null && !d.getSheetsQuestDirection() .getTextRu().equals(d.getSheetsQuestDirection().getTextEn())) { TextArea textRuRawArea = new TextArea(" " + d.getSheetsQuestDirection().getTranslator()); textRuRawArea.setValue(d.getSheetsQuestDirection().getTextRu()); textRuRawArea.setRows(2); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea); } } } return result; } }).setId("rawText").setStyleGenerator(rowStyleGenerator); stepsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { Panel panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setWidth(100f, Unit.PERCENTAGE); panel.setHeight(245f, Unit.PIXELS); final VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestStep) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestStep step = (QuestStep) source; list.addAll(step.getSheetsJournalEntry().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && step.getSheetsJournalEntry() != null && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsJournalEntry(step.getSheetsJournalEntry()); Button addTranslation = new Button(" ", FontAwesome.PLUS_SQUARE); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsJournalEntry() != null) { translatedText.getSpreadSheetsJournalEntry().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } else if (source instanceof QuestDirection) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestDirection d = (QuestDirection) source; list.addAll(d.getSheetsQuestDirection().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && d.getSheetsQuestDirection() != null && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsQuestDirection(d.getSheetsQuestDirection()); Button addTranslation = new Button(" "); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsQuestDirection() != null) { translatedText.getSpreadSheetsQuestDirection().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } panel.setContent(result); return panel; } }).setId("translation").setStyleGenerator(rowStyleGenerator); stepsGrid.setColumns("rowType", "ingameText", "rawText", "translation"); stepsLayout.addComponent(stepsGrid); tabSheet.addTab(stepsLayout, ""); itemsGrid = new Grid(new ListDataProvider(itemList)); itemsGrid.setSelectionMode(Grid.SelectionMode.NONE); itemsGrid.setRowHeight(250); itemsGrid.setHeaderVisible(false); itemsGrid.setSizeFull(); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { QuestItem item = (QuestItem) source; if (item.getName() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(item.getName().getTextEn()); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (item.getName().getTextRu() != null && !item.getName().getTextRu().equals(item.getName().getTextEn())) { TextArea textRuRawArea = new TextArea( " ? " + item.getName().getTranslator()); textRuRawArea.setValue(item.getName().getTextRu()); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea);//, " " } } } return result; } }).setId("rawName"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { QuestItem item = (QuestItem) source; if (item.getDescription() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(item.getDescription().getTextEn()); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (item.getDescription().getTextRu() != null && !item.getDescription().getTextRu().equals(item.getDescription().getTextEn())) { TextArea textRuRawArea = new TextArea( " ?? " + item.getDescription().getTranslator()); textRuRawArea.setValue(item.getDescription().getTextRu()); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea);//, " " } } } return result; } }).setId("rawDescription"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { Panel panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setWidth(100f, Unit.PERCENTAGE); panel.setHeight(245f, Unit.PIXELS); final VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestItem item = (QuestItem) source; if (item.getName() != null) { String text = item.getName().getTextEn(); list.addAll(item.getName().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsItemName(item.getName()); Button addTranslation = new Button(" ", FontAwesome.PLUS_SQUARE); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsItemName() != null) { translatedText.getSpreadSheetsItemName().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } } panel.setContent(result); return panel; } }).setId("nameTranslation"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { Panel panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setWidth(100f, Unit.PERCENTAGE); panel.setHeight(245f, Unit.PIXELS); final VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestItem item = (QuestItem) source; if (item.getDescription() != null) { String text = item.getDescription().getTextEn(); list.addAll(item.getDescription().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsItemDescription(item.getDescription()); Button addTranslation = new Button(" ", FontAwesome.PLUS_SQUARE); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsItemDescription() != null) { translatedText.getSpreadSheetsItemDescription().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } } panel.setContent(result); return panel; } }).setId("descriptionTranslation"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setMargin(new MarginInfo(true, false, false, false)); result.setSpacing(false); if (source instanceof QuestItem) { GSpreadSheetsItemName name = ((QuestItem) source).getName(); if (name.getIcon() != null) { Image image = new Image(null, new ExternalResource( "https://elderscrolls.net" + name.getIcon().replaceAll(".dds", ".png"))); result.addComponent(image); return result; } } return result; } }).setId("icon").setWidth(95); itemsGrid.setColumns("icon", "rawName", "nameTranslation", "rawDescription", "descriptionTranslation"); tabSheet.addTab(itemsGrid, ""); this.addComponent(tabSheet); this.setExpandRatio(tabSheet, 1f); GridScrollExtension stepsScrollExtension = new GridScrollExtension(stepsGrid); GridScrollExtension itemsScrollExtension = new GridScrollExtension(itemsGrid); new NoAutcompleteComboBoxExtension(locationTable); new NoAutcompleteComboBoxExtension(questTable); new NoAutcompleteComboBoxExtension(translatorBox); LoadFilters(); }
From source file:org.vaadin.gridfiledownloadertest.GridFileDownloaderUI.java
License:Apache License
@SuppressWarnings("unchecked") @Override/*w ww .ja va 2 s .c om*/ protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); final Grid grid = new Grid("Attachment grid"); grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(5); grid.setSelectionMode(SelectionMode.NONE); Column column = grid.addColumn("filename"); column.setHeaderCaption("File name"); column.setExpandRatio(1); Indexed dataSource = grid.getContainerDataSource(); for (int i = 1; i <= 5; ++i) { DownloadPojo cp = new DownloadPojo(i); Item item = dataSource.addItem(cp); item.getItemProperty("filename").setValue(cp.getName()); } layout.addComponent(grid); addGridFileDownloader(grid); // set tooltip for the default download column grid.setCellDescriptionGenerator(new CellDescriptionGenerator() { @Override public String getDescription(CellReference cell) { if (FontAwesome.DOWNLOAD.equals(cell.getPropertyId())) { return "download"; } return null; } }); // clear the header HeaderCell downloadHeader = grid.getHeaderRow(0).getCell(FontAwesome.DOWNLOAD); downloadHeader.setHtml(""); }
From source file:org.vaadin.peholmst.samples.dddwebinar.ui.admin.LicenseTypeMapField.java
License:Open Source License
@Override protected Component initContent() { HorizontalLayout layout = new HorizontalLayout(); layout.setSizeUndefined();/*from ww w .jav a2 s. c o m*/ layout.setSpacing(true); selectable = new Grid(selectableContainer); selectable.setWidth("300px"); selectable.setHeight("200px"); layout.addComponent(selectable); VerticalLayout buttons = new VerticalLayout(); buttons.setSpacing(true); add = new Button("Add", this::add); buttons.addComponent(add); remove = new Button("Remove", this::remove); buttons.addComponent(remove); layout.addComponent(buttons); selected = new Grid(selectedContainer); selected.setWidth("330px"); selected.setHeight("200px"); selected.getColumn("name").setEditable(false); selected.setEditorEnabled(true); selected.setEditorBuffered(false); layout.addComponent(selected); return layout; }
From source file:org.vaadin.peholmst.samples.dddwebinar.ui.admin.ProcedureCategoryAdminView.java
@PostConstruct void init() {/*from ww w .j a v a2 s . c om*/ setSpacing(true); setMargin(true); setSizeFull(); Label label = new Label("Procedure Categories"); label.addStyleName(ValoTheme.LABEL_H1); addComponent(label); procedureCategoryContainer = new BeanItemContainer<>(ProcedureCategory.class); procedureCategoryGrid = new Grid(procedureCategoryContainer); procedureCategoryGrid.setColumns("name", "licenseTypes"); procedureCategoryGrid.getColumn("licenseTypes").setConverter(new LicenseTypeMapConverter()); procedureCategoryGrid.setSizeFull(); procedureCategoryGrid.addSelectionListener(this::select); addComponent(procedureCategoryGrid); setExpandRatio(procedureCategoryGrid, 1.0f); formLayout = new HorizontalLayout(); formLayout.setSpacing(true); formLayout.setVisible(false); addComponent(formLayout); name = new TextField("Category Name"); formLayout.addComponent(name); formLayout.setComponentAlignment(name, Alignment.TOP_LEFT); licenseTypes = new LicenseTypeMapField("License Types"); licenseTypes.setSelectable(licenseTypeRepository.findAll()); formLayout.addComponent(licenseTypes); Button save = new Button("Save", this::save); formLayout.addComponent(save); formLayout.setComponentAlignment(save, Alignment.BOTTOM_LEFT); binder.bindMemberFields(this); refresh(); }
From source file:org.vaadin.spring.samples.push.PushUI.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { measurements = new IndexedContainer(); measurements.addContainerProperty("Timestamp", Date.class, null); measurements.addContainerProperty("Measurement", Integer.class, null); grid = new Grid(measurements); grid.setSizeFull();/*from w w w . j a v a 2s . co m*/ setContent(grid); LOGGER.info("Scheduling background job"); jobHandle = executorService.scheduleWithFixedDelay(updateGraphJob, 500, 3000, TimeUnit.MILLISECONDS); }
From source file:probe.com.view.core.MultiSelectionTable.java
/** * *//* w ww . j a v a 2 s. co m*/ public MultiSelectionTable() { setSpacing(true); // Set up combo boxes with possible values setWidth(100, Unit.PERCENTAGE); // Editor is not enabled when setEnabled(false); Indexed datares = new BeanContainer(null); // Create new Grid with BeanItemContainer filled with BugEntries Grid grid = new Grid(datares); grid.setSizeFull(); // Hide the "changed" property grid.removeColumn("changed"); // Activate multi selection mode grid.setSelectionMode(SelectionMode.MULTI); // Add a rowstyle generator to display recently changed items. // Also uses another style for closed entries grid.setRowStyleGenerator(new RowStyleGenerator() { @Override public String getStyle(RowReference rowReference) { Item item = rowReference.getItem(); boolean closed = item.getItemProperty("status").getValue() == Status.CLOSED; boolean changed = (Boolean) item.getItemProperty("changed").getValue(); if (closed) { if (changed) { // Combined style return "changed closed"; } // Closed style return "closed"; } else if (changed) { // Modified style return "changed"; } // No style return null; } }); // Make Editor listen to changes in the selection of this Grid grid.addSelectionListener(this); }
From source file:qbic.vaadincomponents.InputFilesComponent.java
License:Open Source License
/** * DAVID// ww w.j a v a 2s. c o m * * @param wfparameters * @param datasets */ public void buildLayout(Map<String, Parameter> wfparameters, BeanItemContainer<DatasetBean> datasets) { wfmap = wfparameters; for (Map.Entry<String, Parameter> entry : wfmap.entrySet()) { GeneratedPropertyContainer gpcontainer = null; Grid newGrid = new Grid(gpcontainer); if (entry.getValue() instanceof FileParameter || entry.getValue() instanceof FileListParameter) { // TODO also do filtering on filetype level List<String> range = getRange(entry.getValue()); if (range.contains("fasta") || range.contains("gtf")) { gpcontainer = fastaContainer(); // show only bwaIndex references for bwa } else if (range.contains("bwaIndex")) { gpcontainer = fastaContainerFiltered("bwa"); } else if (range.contains("barcodes")) { gpcontainer = fastaContainerFiltered("barcodes"); } else if (range.contains("shRNAlibrary")) { gpcontainer = fastaContainerFiltered("shRNAlibrary"); } else { gpcontainer = filter(datasets, range); } newGrid.setContainerDataSource(gpcontainer); newGrid.setSelectionMode(getSelectionMode(entry.getValue())); } else { // showError(String.format("Invalid Inputfile Parameter!", entry.getKey())); helpers.Utils.Notification("Invalid Inputfile Parameter", "Invalid value for inputfile parameter has been provided." + entry.getKey(), "error"); } HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(new MarginInfo(true, true, true, true)); layout.setSizeFull(); newGrid.setWidth("100%"); layout.addComponent(newGrid); // if (newGrid.getContainerDataSource().size() == 0) { // Notification.show( // String.format("No dataset of type %s available in this project!", entry.getKey()), // Type.WARNING_MESSAGE); // helpers.Utils // .Notification( // "Missing Dataset Type", // String // .format( // "Workflow submission might not be possible because no dataset of type %s is available in // this project", // entry.getKey()), "warning"); layout.addComponent(newGrid); // } helpers.GridFunctions.addColumnFilters(newGrid, gpcontainer); inputFileForm.addTab(layout, entry.getKey()); } }