Java 类com.vaadin.ui.renderers.ProgressBarRenderer 实例源码

项目:dungeonstory-java    文件:CharacterGrid.java   
public CharacterGrid() {
    super();

    addColumn(Character::getName).setCaption("Nom").setId("name");
    addColumn(character -> {
        Level previousLevel = Services.getLevelService().read(character.getLevel().getId() - 1);
        double progress = (double) (character.getExperience() - previousLevel.getMaxExperience())
                / (double) (character.getLevel().getMaxExperience() - previousLevel.getMaxExperience());
        return progress;
    }, new ProgressBarRenderer()).setCaption("Progrès").setId("progress");

}
项目:hawkbit    文件:UploadStatusInfoWindow.java   
private void setGridColumnProperties() {
    grid.getColumn(STATUS).setRenderer(new StatusRenderer());
    grid.getColumn(PROGRESS).setRenderer(new ProgressBarRenderer());
    grid.setColumnOrder(STATUS, PROGRESS, FILE_NAME, SPUILabelDefinitions.NAME_VERSION, REASON);
    setColumnWidth();
    grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setHeaderCaption(i18n.getMessage("upload.swModuleTable.header"));
    grid.setFrozenColumnCount(5);
}
项目:hawkbit-examples    文件:SimulatorView.java   
@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);
}
项目:KrishnasSpace    文件:GeneratedColumns.java   
/**
 * 
 */
private void addGeneratedColumn() {

    // Get the container if you have already set it to grid and wrap it in
    // GeneratedPropertyContainer
    GeneratedPropertyContainer container = new GeneratedPropertyContainer(
            grid.getContainerDataSource());
    grid.setContainerDataSource(container);

    // Add a generated Column to the table
    container.addGeneratedProperty("totalSalesTillDate",
            new PropertyValueGenerator<Double>() {

                /**
                 * 
                 */
                private static final long serialVersionUID = -7625273505835964597L;

                @Override
                public Double getValue(Item item, Object itemId,
                        Object propertyId) {
                    return getSalesPercentage((VehicleInfo) itemId);
                }

                @Override
                public Class<Double> getType() {
                    return Double.class;
                }
            });
    grid.getColumn("totalSalesTillDate").setRenderer(
            new ProgressBarRenderer());
    grid.getColumn("totalSalesTillDate")
            .setHeaderCaption("Sales Till Date");
    /*
     * Remove the properties you wish to hide. Have done it already in
     * native container? even then you have do it as this is a new container
     */
    container.removeContainerProperty("id");
    // A new getter called Total Sales was added for YearlySales
    container.removeContainerProperty("sales2012.totalSales");
    container.removeContainerProperty("sales2013.totalSales");
    container.removeContainerProperty("sales2014.totalSales");
}