/** * Formate les colonnes en boolean : Ajoute une case a cocher a la place de O et * N * * @param propertys */ private void addBooleanColumns(String... propertys) { for (String property : propertys) { Column col = getColumn(property).setRenderer(new HtmlRenderer(), new StringToBooleanConverter( "<div style=width:100%;text-align:center>" + FontAwesome.CHECK_SQUARE_O.getHtml() + "</div>", "<div style=width:100%;text-align:center>" + FontAwesome.SQUARE_O.getHtml() + "</div>")); col.setWidth(119); } }
public ArmorTypeGrid() { super(); // withProperties("name", "proficiencyType", "baseArmorClass", "maxDexBonus", "stealthDisavantage", "minStrength"); // withColumnHeaders("Nom", "Maitrise", "Classe d'armure", "Bonus max dextérité", "Désavantage furtivité", "Force minimum"); // // getColumn("maxDexBonus").setRenderer(new ModifierRenderer()); // getColumn("baseArmorClass").setRenderer(new ModifierRenderer()); // // Grid.Column stealthDisavantage = getColumn("stealthDisavantage"); // stealthDisavantage.setRenderer(new HtmlRenderer(), // new StringToBooleanConverter( // FontAwesome.CHECK_CIRCLE_O.getHtml(), // FontAwesome.CIRCLE_O.getHtml())); StringToBooleanConverter converter = new StringToBooleanConverter("", VaadinIcons.CHECK_CIRCLE_O.getHtml(), VaadinIcons.CIRCLE_THIN.getHtml()); addColumn(ArmorType::getName).setCaption("Nom").setId("name"); addColumn(ArmorType::getProficiencyType).setCaption("Maitrise").setId("proficiencyType"); addColumn(ArmorType::getBaseArmorClass, new ModifierRenderer()).setCaption("Classe d'armure").setId("baseArmorClass"); addColumn(ArmorType::getMaxDexBonus, new ModifierRenderer()).setCaption("Bonus max dextérité").setId("maxDexBonus"); addColumn(armorType -> converter.convertToPresentation(armorType.getStealthDisavantage(), new ValueContext()), new HtmlRenderer()) .setCaption("Désavantage furtivité"); addColumn(ArmorType::getMinStrength).setCaption("Force minimum").setId("minStrength"); }
public EquipmentGrid() { super(); // withProperties("name", "type", "isPurchasable", "isSellable"); // withColumnHeaders("Nom", "Type", "Achetable", "Vendable"); // // getColumn("isPurchasable").setRenderer(new HtmlRenderer(), // new StringToBooleanConverter(FontAwesome.CHECK_CIRCLE_O.getHtml(), FontAwesome.CIRCLE_O.getHtml())); // // getColumn("isSellable").setRenderer(new HtmlRenderer(), // new StringToBooleanConverter(FontAwesome.CHECK_CIRCLE_O.getHtml(), FontAwesome.CIRCLE_O.getHtml())); StringToBooleanConverter converter = new StringToBooleanConverter("", VaadinIcons.CHECK_CIRCLE_O.getHtml(), VaadinIcons.CIRCLE_THIN.getHtml()); addColumn(Equipment::getName).setCaption("Nom").setId("name"); addColumn(Equipment::getType).setCaption("Type").setId("type"); addColumn(equipment -> converter.convertToPresentation(equipment.getIsPurchasable(), new ValueContext()), new HtmlRenderer()) .setCaption("Achetable"); addColumn(equipment -> converter.convertToPresentation(equipment.getIsSellable(), new ValueContext()), new HtmlRenderer()) .setCaption("Vendable"); }
/** * Get the default {@link Renderer} for given <code>property</code>. * @param property Property * @return The default {@link Renderer}, if available */ protected Optional<Renderer<?>> getDefaultPropertyRenderer(P property) { Class<?> type = getPropertyColumnType(property); // Images if (type != null && (ExternalResource.class.isAssignableFrom(type) || ThemeResource.class.isAssignableFrom(type))) { return Optional.of(new ImageRenderer()); } if (type != null && FontIcon.class.isAssignableFrom(type)) { return Optional.of(new HtmlRenderer("")); } return Optional.empty(); }
@Override protected Optional<Renderer<?>> getDefaultPropertyRenderer(Property property) { if (Component.class.isAssignableFrom(property.getType())) { return Optional.of(new ComponentRenderer()); } if (FontIcon.class.isAssignableFrom(property.getType())) { return Optional.of(new HtmlRenderer("")); } if (ExternalResource.class.isAssignableFrom(property.getType()) || ThemeResource.class.isAssignableFrom(property.getType())) { return Optional.of(new ImageRenderer()); } return super.getDefaultPropertyRenderer(property); }
public LanguageGrid() { super(); StringToBooleanConverter converter = new StringToBooleanConverter("", VaadinIcons.CHECK_CIRCLE_O.getHtml(), VaadinIcons.CIRCLE_THIN.getHtml()); addColumn(Language::getName).setCaption("Nom").setId("name"); addColumn(Language::getScript).setCaption("Alphabet").setId("script"); addColumn(language -> converter.convertToPresentation(language.getPlayable(), new ValueContext()), new HtmlRenderer()).setCaption("Jouable"); }
@Override protected void addColumnRenderes() { getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(), new TotalTargetGroupsConverter()); getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), new TotalTargetCountStatusConverter()); getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter()); final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class); customObjectRenderer.addClickListener(this::onClickOfRolloutName); getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer); getColumn(VIRT_PROP_RUN).setRenderer( new GridButtonRenderer(clickEvent -> startOrResumeRollout((Long) clickEvent.getItemId())), new RolloutGridButtonConverter(this::createRunButtonMetadata)); getColumn(VIRT_PROP_PAUSE).setRenderer( new GridButtonRenderer(clickEvent -> pauseRollout((Long) clickEvent.getItemId())), new RolloutGridButtonConverter(this::createPauseButtonMetadata)); getColumn(VIRT_PROP_UPDATE).setRenderer( new GridButtonRenderer(clickEvent -> updateRollout((Long) clickEvent.getItemId())), new RolloutGridButtonConverter(this::createUpdateButtonMetadata)); getColumn(VIRT_PROP_COPY).setRenderer( new GridButtonRenderer(clickEvent -> copyRollout((Long) clickEvent.getItemId())), new RolloutGridButtonConverter(this::createCopyButtonMetadata)); getColumn(VIRT_PROP_DELETE).setRenderer( new GridButtonRenderer(clickEvent -> deleteRollout((Long) clickEvent.getItemId())), new RolloutGridButtonConverter(this::createDeleteButtonMetadata)); }
@Override protected void addColumnRenderes() { getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutGroupStatusConverter()); getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), new TotalTargetCountStatusConverter()); if (permissionChecker.hasRolloutTargetsReadPermission()) { getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(new RolloutGroupClickListener())); } }
private void addGrid() { final Grid<TestFile> grid = new Grid<>("Attachment grid"); grid.addColumn(TestFile::getFileName).setCaption("File Name"); grid.addColumn(TestFile::isOpen).setHidable(true).setCaption("Is Open"); grid.addColumn(TestFile::createOpenLink, new HtmlRenderer()).setHidable(true).setCaption("Download"); grid.setColumnReorderingAllowed(true); addComponent(grid); extension = SidebarMenuExtension.create(grid); grid.setItems(Stream.of("Test file 1", "Test file 2").map(TestFile::new)); }
public HttpSourceTestsView() { super("HTTP Source Tests"); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setWidth(100, PERCENTAGE); mainLayout.setHeight(100, PERCENTAGE); mainLayout.setSpacing(true); VerticalLayout gridLayout = new VerticalLayout(); gridLayout.setSpacing(true); gridLayout.setWidth(100, PERCENTAGE); // Search field and create new button filterField.setInputPrompt("Enter URL..."); filterField.addTextChangeListener(event -> refreshGrid(event.getText())); Button testAllButton = new Button("Run All Tests"); testAllButton.addClickListener(event -> testAll()); Button addNewButton = new Button("Add New Test"); addNewButton.addClickListener(event -> showHttpSourceTestForm(new HttpSourceTest())); HorizontalLayout actionHeader = new HorizontalLayout(filterField, testAllButton, addNewButton); actionHeader.setSpacing(true); actionHeader.setWidth(100, PERCENTAGE); filterField.setWidth(100, PERCENTAGE); actionHeader.setExpandRatio(filterField, 1.0f); gridLayout.addComponent(actionHeader); // Grid itemsGrid.setWidth(100, PERCENTAGE); itemsGrid.setHeight(700, PIXELS); itemsGrid.setSelectionMode(Grid.SelectionMode.SINGLE); itemsGrid.addSelectionListener( e -> { HttpSourceTest hst = (HttpSourceTest) itemsGrid.getSelectedRow(); hst = ElasticSearch.getHttpSourceTestOperations().get(hst.getUrl()); showHttpSourceTestForm(hst); }); itemsGrid.getColumn("source").setRenderer(new HtmlRenderer(), new UrlToLinkConverter()); itemsGrid.getColumn("url").setRenderer(new HtmlRenderer(), new UrlToLinkConverter()); itemsGrid.setColumns("source", "url"); gridLayout.addComponent(itemsGrid); gridLayout.addComponent(totalCountLabel); refreshGrid(filterField.getValue()); mainLayout.addComponent(gridLayout); mainLayout.setExpandRatio(gridLayout, 1f); addComponent(mainLayout); }
@Override default HtmlRenderer getRenderer(ColumnDefinition definition) { return new HtmlRenderer(); }
public WeaponTypeGrid() { super(); // withProperties("name", "proficiencyType", "handleType", "usageType", "oneHandBaseDamage", // "twoHandBaseDamage", "damageType", "isReach", "isFinesse", "isLoading"); // withColumnHeaders("Nom", "Maitrise", "Manipulation", "Usage", "1 main", "2 mains", // "Type de dommage", "Allonge", "Finesse", "Load"); // // Grid.Column reach = getColumn("isReach"); // reach.setRenderer(new HtmlRenderer(), // new StringToBooleanConverter(FontAwesome.CHECK_CIRCLE_O.getHtml(), FontAwesome.CIRCLE_O.getHtml())); // // Grid.Column finesse = getColumn("isFinesse"); // finesse.setRenderer(new HtmlRenderer(), // new StringToBooleanConverter(FontAwesome.CHECK_CIRCLE_O.getHtml(), FontAwesome.CIRCLE_O.getHtml())); // // Grid.Column loading = getColumn("isLoading"); // loading.setRenderer(new HtmlRenderer(), // new StringToBooleanConverter(FontAwesome.CHECK_CIRCLE_O.getHtml(), FontAwesome.CIRCLE_O.getHtml())); // // Grid.HeaderRow groupingHeader = prependHeaderRow(); // Grid.HeaderCell namesCell = groupingHeader.join(groupingHeader.getCell("oneHandBaseDamage"), // groupingHeader.getCell("twoHandBaseDamage")); // namesCell.setText("Dommage"); StringToBooleanConverter converter = new StringToBooleanConverter("", VaadinIcons.CHECK_CIRCLE_O.getHtml(), VaadinIcons.CIRCLE_THIN.getHtml()); addColumn(WeaponType::getName).setCaption("Nom").setId("name"); addColumn(WeaponType::getProficiencyType).setCaption("Maitrise").setId("proficiencyType"); addColumn(WeaponType::getHandleType).setCaption("Manipulation").setId("handleType"); addColumn(WeaponType::getUsageType).setCaption("Usage").setId("usage"); addColumn(WeaponType::getOneHandBaseDamage).setCaption("1 main").setId("oneHandBaseDamage"); addColumn(WeaponType::getTwoHandBaseDamage).setCaption("2 mains").setId("twoHandBaseDamage"); addColumn(WeaponType::getDamageType).setCaption("Type de dommage").setId("damageType"); addColumn(weaponType -> converter.convertToPresentation(weaponType.getIsReach(), new ValueContext()), new HtmlRenderer()) .setCaption("Allonge"); addColumn(weaponType -> converter.convertToPresentation(weaponType.getIsFinesse(), new ValueContext()), new HtmlRenderer()) .setCaption("Finesse"); addColumn(weaponType -> converter.convertToPresentation(weaponType.getIsLoading(), new ValueContext()), new HtmlRenderer()) .setCaption("Recharge"); HeaderRow groupingHeader = prependHeaderRow(); HeaderCell namesCell = groupingHeader.join(groupingHeader.getCell("oneHandBaseDamage"), groupingHeader.getCell("twoHandBaseDamage")); namesCell.setText("Dommage"); }
@Override public HtmlRenderer getImplementation() { return (HtmlRenderer) super.getImplementation(); }
@Override protected HtmlRenderer createImplementation() { return new HtmlRenderer(getNullRepresentation()); }
@SuppressWarnings("unchecked") @Override public void enter(final ViewChangeEvent event) { eventbus.register(this); setSizeFull(); // caption caption.addStyleName("h2"); // toolbar createToolbar(); beanContainer = new BeanContainer<>(AbstractSimulatedDevice.class); beanContainer.setBeanIdProperty(ID_COL); grid.setSizeFull(); grid.setCellStyleGenerator(new CellStyleGenerator() { private static final long serialVersionUID = 1L; @Override public String getStyle(final CellReference cellReference) { return cellReference.getPropertyId().equals(STATUS_COL) ? "centeralign" : null; } }); grid.setSelectionMode(SelectionMode.NONE); grid.setContainerDataSource(beanContainer); grid.appendHeaderRow().getCell(RESPONSE_STATUS_COL).setComponent(responseComboBox); grid.setColumnOrder(ID_COL, STATUS_COL, SWVERSION_COL, PROGRESS_COL, TENANT_COL, PROTOCOL_COL, RESPONSE_STATUS_COL, NEXT_POLL_COUNTER_SEC_COL); // header widths grid.getColumn(STATUS_COL).setMaximumWidth(80); grid.getColumn(PROTOCOL_COL).setMaximumWidth(180); grid.getColumn(RESPONSE_STATUS_COL).setMaximumWidth(240); grid.getColumn(NEXT_POLL_COUNTER_SEC_COL).setMaximumWidth(210); grid.getColumn(NEXT_POLL_COUNTER_SEC_COL).setHeaderCaption("Next Poll in (sec)"); grid.getColumn(SWVERSION_COL).setHeaderCaption("SW Version"); grid.getColumn(RESPONSE_STATUS_COL).setHeaderCaption("Response Update Status"); grid.getColumn(PROGRESS_COL).setRenderer(new ProgressBarRenderer()); grid.getColumn(PROTOCOL_COL).setConverter(createProtocolConverter()); grid.getColumn(STATUS_COL).setRenderer(new HtmlRenderer(), createStatusConverter()); grid.removeColumn(TENANT_COL); // grid combobox responseComboBox.setItemIcon(ResponseStatus.SUCCESSFUL, FontAwesome.CHECK_CIRCLE); responseComboBox.setItemIcon(ResponseStatus.ERROR, FontAwesome.EXCLAMATION_CIRCLE); responseComboBox.setNullSelectionAllowed(false); responseComboBox.setValue(ResponseStatus.SUCCESSFUL); responseComboBox.addValueChangeListener( valueChangeEvent -> beanContainer.getItemIds().forEach(itemId -> beanContainer.getItem(itemId) .getItemProperty(RESPONSE_STATUS_COL).setValue(valueChangeEvent.getProperty().getValue()))); // add all components addComponent(caption); addComponent(toolbar); addComponent(grid); setExpandRatio(grid, 1.0F); // load beans repository.getAll().forEach(beanContainer::addBean); }
public CheckBoxDemo() { Random random = new Random(4837291937l); BeanItemContainer<SimplePojo> container = new BeanItemContainer<SimplePojo>(SimplePojo.class); SimplePojo bean1 = new SimplePojo(0, "Me", true, new Date(), BigDecimal.valueOf(random.nextDouble()*100), Double.valueOf(random.nextInt(5)), Integer.valueOf(random.nextInt(5))); SimplePojo bean2 = new SimplePojo(1, "You", false, new Date(), BigDecimal.valueOf(random.nextDouble()*100), Double.valueOf(random.nextInt(5)), Integer.valueOf(random.nextInt(5))); SimplePojo bean3 = new SimplePojo(2, "He", true, new Date(), BigDecimal.valueOf(random.nextDouble()*100), Double.valueOf(random.nextInt(5)), Integer.valueOf(random.nextInt(5))); container.addBean(bean1); container.addBean(bean2); container.addBean(bean3); byte[] image = Base64.decodeBase64(castle); bean1.setImage(image); bean2.setImage(image); bean3.setImage(image); Grid grid = new Grid(container); grid.setColumns("description","yes","truth","date","number","image"); grid.setSizeFull(); grid.setEditorEnabled(true); grid.setEditorBuffered(false); Grid.Column yes = grid.getColumn("yes"); yes.setRenderer(new CheckboxRenderer()); yes.setEditable(true); grid.getColumn("image").setEditable(false); grid.getColumn("image").setRenderer(new BlobImageRenderer(30,30,"image/png")); Grid.Column truth = grid.getColumn("truth"); truth.setRenderer(new HtmlRenderer(), new StringToBooleanConverter() { @Override protected String getTrueString() { return FontAwesome.CHECK_CIRCLE_O.getHtml(); } @Override protected String getFalseString() { return FontAwesome.CIRCLE_O.getHtml(); } }); truth.setEditable(false); setStyleName("demoContentLayout"); setSizeFull(); addComponent(grid); setComponentAlignment(grid , Alignment.MIDDLE_CENTER); setMargin(true); }
public ProductGrid() { setSizeFull(); setSelectionMode(SelectionMode.SINGLE); BeanItemContainer<Product> container = new BeanItemContainer<Product>( Product.class); setContainerDataSource(container); setColumnOrder("id", "productName", "price", "availability", "stockCount", "category"); // Show empty stock as "-" getColumn("stockCount").setConverter(new StringToIntegerConverter() { @Override public String convertToPresentation(Integer value, java.lang.Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { if (value == 0) { return "-"; } return super.convertToPresentation(value, targetType, locale); }; }); // Add an traffic light icon in front of availability getColumn("availability").setConverter(availabilityConverter) .setRenderer(new HtmlRenderer()); // Add " €" automatically after price getColumn("price").setConverter(new EuroConverter()); // Show categories as a comma separated list getColumn("category").setConverter(new CollectionToStringConverter()); // Align columns using a style generator and theme rule until #15438 setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(CellReference cellReference) { if (cellReference.getPropertyId().equals("price") || cellReference.getPropertyId().equals("stockCount")) { return "align-right"; } return null; } }); }