Java 类com.vaadin.ui.Table.ColumnGenerator 实例源码

项目:hawkbit    文件:ArtifactDetailsLayout.java   
private static void addGeneratedColumn(final Table table) {
    table.addGeneratedColumn(CREATE_MODIFIED_DATE_UPLOAD, new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public String generateCell(final Table source, final Object itemId, final Object columnId) {
            final Long createdDate = (Long) table.getContainerDataSource().getItem(itemId)
                    .getItemProperty(CREATED_DATE).getValue();
            final Long modifiedDATE = (Long) table.getContainerDataSource().getItem(itemId)
                    .getItemProperty(LAST_MODIFIED_DATE).getValue();
            if (modifiedDATE != null) {
                return SPDateTimeUtil.getFormattedDate(modifiedDATE);
            }
            return SPDateTimeUtil.getFormattedDate(createdDate);
        }
    });
}
项目:hawkbit    文件:ArtifactDetailsLayout.java   
private void addGeneratedColumnButton(final Table table) {
    table.addGeneratedColumn(ACTION, new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Button generateCell(final Table source, final Object itemId, final Object columnId) {
            final String fileName = (String) table.getContainerDataSource().getItem(itemId)
                    .getItemProperty(PROVIDED_FILE_NAME).getValue();
            final Button deleteIcon = SPUIComponentProvider.getButton(
                    fileName + "-" + UIComponentIdProvider.UPLOAD_FILE_DELETE_ICON, "",
                    SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "blueicon", true,
                    FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
            deleteIcon.setData(itemId);
            deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName));
            return deleteIcon;
        }
    });

}
项目:metl    文件:EditDeduperPanel.java   
private void buildAttributeTable() {

 attributeTable.setContainerDataSource(attributeSettingsContainer);
 attributeTable.setSelectable(true);
 attributeTable.setImmediate(true);
 attributeTable.setSortEnabled(false);
 attributeTable.setSizeFull();
 attributeTable.addGeneratedColumn("attributeName", new ColumnGenerator() {
    private static final long serialVersionUID = 1L;
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
           AttributeSettings setting = (AttributeSettings) itemId;
            Model model = component.getInputModel();
            ModelAttrib attribute = model.getAttributeById(setting.getAttributeId());
            return UiUtils.getName(entityFilterField.getValue(), attribute.getName());
        }
    });
 attributeTable.setVisibleColumns(new Object[] { "attributeName", "dedupeEnabled" });
 attributeTable.setColumnWidth("attributeName", 250);
 attributeTable.setColumnHeaders(new String[] { "Attribute Name", "Dedupe Enabled" });
 attributeTable.setColumnExpandRatio("attributeName", 1);
 attributeTable.setTableFieldFactory(new EditAttributeFieldFactory());
 attributeTable.setEditable(true);
   addComponent(attributeTable, 1);

}
项目:XACML    文件:GitPushWindow.java   
protected void initializeTable(Status status) {
    //
    // Setup the table
    //
    this.tableChanges.setContainerDataSource(this.container);
    this.tableChanges.setPageLength(this.container.size());
    this.tableChanges.setImmediate(true);
    //
    // Generate column
    //
    this.tableChanges.addGeneratedColumn("Entry", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            Item item = self.container.getItem(itemId);
            assert(item != null);
            if (item instanceof StatusItem) {
                return self.generateGitEntryComponent(((StatusItem) item).getGitEntry());
            }
            assert(item instanceof StatusItem);
            return null;
        }
    });
}
项目:metl    文件:EditDeduperPanel.java   
protected void buildEntityTable() {
    entityTable.setContainerDataSource(entitySettingsContainer);
    entityTable.setSelectable(true);
    entityTable.setSortEnabled(false);
    entityTable.setImmediate(true);
    entityTable.setSizeFull();
    entityTable.addGeneratedColumn("entityName", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EntitySettings setting = (EntitySettings) itemId;
            Model model = component.getInputModel();
            ModelEntity entity = model.getEntityById(setting.getEntityId());
            return UiUtils.getName(entityFilterField.getValue(), entity.getName());
        }
    });
    entityTable.setVisibleColumns(new Object[] { "entityName" });
    entityTable.setColumnWidth("entityName", 250);
    entityTable.setColumnHeaders(new String[] { "Entity Name" });
    entityTable.setColumnExpandRatio("entityName", 1);
    entityTable.setTableFieldFactory(new EditEntityFieldFactory());
    entityTable.setEditable(true);
    entityTable.setMultiSelect(true);
    entityTable.setDragMode(TableDragMode.MULTIROW);
    entityTable.setDropHandler(new TableDropHandler());
    entityTable.setCellStyleGenerator(new TableCellStyleGenerator());
    addComponent(entityTable);        
    setExpandRatio(entityTable, 1.0f);
}
项目:metl    文件:EditDataDiffPanel.java   
protected void buildEntityTable() {
    entityTable.setContainerDataSource(entitySettingsContainer);
    entityTable.setSelectable(true);
    entityTable.setSortEnabled(false);
    entityTable.setImmediate(true);
    entityTable.setSizeFull();
    entityTable.addGeneratedColumn("entityName", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            EntitySettings setting = (EntitySettings) itemId;
            Model model = component.getInputModel();
            ModelEntity entity = model.getEntityById(setting.getEntityId());
            return UiUtils.getName(entityFilterField.getValue(), entity.getName());
        }
    });
    entityTable.setVisibleColumns(new Object[] { "entityName", "addEnabled", "updateEnabled", "deleteEnabled" });
    entityTable.setColumnWidth("entityName", 250);
    entityTable.setColumnHeaders(new String[] { "Entity Name", "Add Enabled", "Chg Enabled", "Del Enabled" });
    entityTable.setColumnExpandRatio("entityName", 1);
    entityTable.setTableFieldFactory(new EditEntityFieldFactory());
    entityTable.setEditable(true);
    entityTable.setMultiSelect(true);
    if (!readOnly) {
        entityTable.setDragMode(TableDragMode.MULTIROW);
        entityTable.setDropHandler(new TableDropHandler());
    }
    entityTable.setCellStyleGenerator(new TableCellStyleGenerator());
    addComponent(entityTable);
    setExpandRatio(entityTable, 1.0f);
}
项目:metl    文件:EditDataDiffPanel.java   
private void buildAttributeTable() {

            attributeTable.setContainerDataSource(attributeSettingsContainer);
            attributeTable.setSelectable(true);
            attributeTable.setSortEnabled(false);
            attributeTable.setImmediate(true);
            attributeTable.setSortEnabled(false);
            attributeTable.setSizeFull();
            attributeTable.addGeneratedColumn("attributeName", new ColumnGenerator() {
                private static final long serialVersionUID = 1L;

                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    AttributeSettings setting = (AttributeSettings) itemId;
                    Model model = component.getInputModel();
                    ModelAttrib attribute = model.getAttributeById(setting.getAttributeId());
                    return UiUtils.getName(entityFilterField.getValue(), attribute.getName());
                }
            });
            attributeTable.setVisibleColumns(new Object[] { "attributeName", "compareEnabled" });
            attributeTable.setColumnWidth("attributeName", 250);
            attributeTable.setColumnHeaders(new String[] { "Attribute Name", "Compare Enabled" });
            attributeTable.setColumnExpandRatio("attributeName", 1);
            attributeTable.setTableFieldFactory(new EditAttributeFieldFactory());
            attributeTable.setEditable(true);
            addComponent(attributeTable, 1);

        }
项目:enterprise-app    文件:CrudComponent.java   
/**
 * Generates the ID column
 */
protected void generateIdColumn() {
    table.addGeneratedColumn("id", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;
        @Override
        public Component generateCell(Table source, Object itemId, Object columnId) {
            Label label = new Label(itemId.toString());
            return label;
        }
    });
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public <T extends Object> Builder<E> addGeneratedColumn(final String heading,
        final SingularAttribute<E, T> headingPropertyId, final ColumnGenerator columnGenerator,
        final boolean defaultVisibleState, final boolean lockedState, int width)
{
    return addGeneratedColumn(heading, headingPropertyId.getName(), columnGenerator, defaultVisibleState,
            lockedState, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedColumn(final String heading, final String headingPropertyId,
        final ColumnGenerator columnGenerator, final boolean defaultVisibleState, final boolean lockedState)
{
    cols.add(new HeadingToPropertyId(heading, headingPropertyId, columnGenerator, defaultVisibleState,
            lockedState, null));
    return this;
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public <T extends Object> Builder<E> addGeneratedColumn(final String heading,
        final SingularAttribute<E, T> headingPropertyId, final ColumnGenerator columnGenerator,
        final boolean defaultVisibleState, final boolean lockedState)
{
    return addGeneratedColumn(heading, headingPropertyId.getName(), columnGenerator, defaultVisibleState,
            lockedState);
}
项目:VaadinUtils    文件:BaseCrudView.java   
public void addGeneratedColumn(final Object id, ColumnGenerator generator)
{
    Preconditions.checkState(entityTable != null, "call BaseCrudView.init() first");
    Object idName = id;
    if (id instanceof SingularAttribute)
    {
        idName = ((SingularAttribute<?, ?>) id).getName();
    }
    entityTable.addGeneratedColumn(idName, generator);
}
项目:VaadinUtils    文件:JasperReportScheduleLayout.java   
private ColumnGenerator getStatusColumnGenerator()
{
    return new ColumnGenerator()
    {

        private static final long serialVersionUID = -1873561613938103218L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId)
        {
            @SuppressWarnings("unchecked")
            EntityItem<ReportEmailScheduleEntity> item = (EntityItem<ReportEmailScheduleEntity>) source
                    .getItem(itemId);
            ReportEmailScheduleEntity schedule = item.getEntity();

            final Label label = new Label("<font color='green'>Scheduled</font>");
            label.setContentMode(ContentMode.HTML);
            if (schedule.getReportLog() != null && schedule.getReportLog().length() > 0
                    && !schedule.getReportLog().equals(Scheduler.REPORT_SUCCESSFULLY_RUN))
            {
                label.setValue("<font color='red'><b>Error</b></font>");
            }
            else
            {
                if (!schedule.isEnabled())
                {
                    label.setValue("<font color='orange'><b>Disabled</b></font>");
                }
            }

            return label;

        }
    };
}
项目:esup-ecandidat    文件:ScolTypeTraitementView.java   
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    /* Titre */
    Label titleParam = new Label(applicationContext.getMessage("typeTraitement.title", null, UI.getCurrent().getLocale()));
    titleParam.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleParam);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    addComponent(buttonsLayout);


    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.setEnabled(false);
    btnEdit.addClickListener(e -> {
        if (typeTraitementTable.getValue() instanceof TypeTraitement) {
            nomenclatureTypeController.editTypeTraitement((TypeTraitement) typeTraitementTable.getValue());
        }
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);


    /* Table des typeTraitements */     
    typeTraitementTable.setContainerDataSource(new BeanItemContainer<TypeTraitement>(TypeTraitement.class, nomenclatureTypeController.getTypeTraitements()));
    typeTraitementTable.addGeneratedColumn(TypeTraitement_.i18nLibTypTrait.getName(), new ColumnGenerator() {

        /*** serialVersionUID*/
        private static final long serialVersionUID = 2101119091378513475L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final TypeTraitement typeTraitement = (TypeTraitement) itemId;
            return i18nController.getI18nTraductionLibelle(typeTraitement.getI18nLibTypTrait());
        }
    });
    typeTraitementTable.setSizeFull();
    typeTraitementTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (String fieldName : FIELDS_ORDER) {
        typeTraitementTable.setColumnHeader(fieldName, applicationContext.getMessage("typeTraitement.table." + fieldName, null, UI.getCurrent().getLocale()));
    }
    typeTraitementTable.setSortContainerPropertyId(TypeTraitement_.codTypTrait.getName());
    typeTraitementTable.setColumnCollapsingAllowed(true);
    typeTraitementTable.setColumnReorderingAllowed(true);
    typeTraitementTable.setSelectable(true);
    typeTraitementTable.setImmediate(true);
    typeTraitementTable.addItemSetChangeListener(e -> typeTraitementTable.sanitizeSelection());
    typeTraitementTable.addValueChangeListener(e -> {
        /* Les boutons d'édition et de suppression de typeTraitement sont actifs seulement si une typeTraitement est sélectionnée. */
        boolean typeTraitementIsSelected = typeTraitementTable.getValue() instanceof TypeTraitement;
        btnEdit.setEnabled(typeTraitementIsSelected);
    });
    typeTraitementTable.addItemClickListener(e -> {
        if (e.isDoubleClick()) {
            typeTraitementTable.select(e.getItemId());
            btnEdit.click();
        }
    });
    addComponent(typeTraitementTable);
    setExpandRatio(typeTraitementTable, 1);

    /* Inscrit la vue aux mises à jour de typeTraitement */
    typeTraitementEntityPusher.registerEntityPushListener(this);
}
项目:esup-ecandidat    文件:ScolTypeStatutPieceView.java   
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    /* Titre */
    Label titleParam = new Label(applicationContext.getMessage("typeStatutPiece.title", null, UI.getCurrent().getLocale()));
    titleParam.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleParam);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    addComponent(buttonsLayout);


    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.setEnabled(false);
    btnEdit.addClickListener(e -> {
        if (typeStatutPieceTable.getValue() instanceof TypeStatutPiece) {
            typeStatutController.editTypeStatutPiece((TypeStatutPiece) typeStatutPieceTable.getValue());
        }
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);


    /* Table des typeStatutPieces */
    BeanItemContainer<TypeStatutPiece> container = new BeanItemContainer<TypeStatutPiece>(TypeStatutPiece.class, typeStatutController.getTypeStatutPieces());       
    typeStatutPieceTable.setContainerDataSource(container);
    typeStatutPieceTable.addGeneratedColumn(TypeStatutPiece_.i18nLibTypStatutPiece.getName(), new ColumnGenerator() {

        /*** serialVersionUID*/
        private static final long serialVersionUID = 2101119091378513475L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final TypeStatutPiece type = (TypeStatutPiece) itemId;
            return i18nController.getI18nTraductionLibelle(type.getI18nLibTypStatutPiece());
        }
    });
    typeStatutPieceTable.setSizeFull();
    typeStatutPieceTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (String fieldName : FIELDS_ORDER) {
        typeStatutPieceTable.setColumnHeader(fieldName, applicationContext.getMessage("typeStatutPiece.table." + fieldName, null, UI.getCurrent().getLocale()));
    }
    typeStatutPieceTable.setSortContainerPropertyId(TypeStatutPiece_.codTypStatutPiece.getName());
    typeStatutPieceTable.setColumnCollapsingAllowed(true);
    typeStatutPieceTable.setColumnReorderingAllowed(true);
    typeStatutPieceTable.setSelectable(true);
    typeStatutPieceTable.setImmediate(true);
    typeStatutPieceTable.addItemSetChangeListener(e -> typeStatutPieceTable.sanitizeSelection());
    typeStatutPieceTable.addValueChangeListener(e -> {
        /* Les boutons d'édition et de suppression de typeStatutPiece sont actifs seulement si une typeStatutPiece est sélectionnée. */
        boolean typeStatutPieceIsSelected = typeStatutPieceTable.getValue() instanceof TypeStatutPiece;
        btnEdit.setEnabled(typeStatutPieceIsSelected);
    });
    typeStatutPieceTable.addItemClickListener(e -> {
        if (e.isDoubleClick()) {
            typeStatutPieceTable.select(e.getItemId());
            btnEdit.click();
        }
    });
    addComponent(typeStatutPieceTable);
    setExpandRatio(typeStatutPieceTable, 1);

    /* Inscrit la vue aux mises à jour de typeStatutPiece */
    typeStatutPieceEntityPusher.registerEntityPushListener(this);
}
项目:esup-ecandidat    文件:AdminBatchHistoWindow.java   
/**
 * Crée une fenêtre de visu de l'histo d'un batch
 * @param batch le batch à visualiser
 */
public AdminBatchHistoWindow(Batch batch) {
    /* Style */
    setModal(true);
    setWidth(700,Unit.PIXELS);
    setResizable(false);
    setClosable(false);

    /* Layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    /* Titre */
    setCaption(applicationContext.getMessage("batchHisto.window", new Object[]{batch.getCodBatch()}, UI.getCurrent().getLocale()));

    /* Table */
    container = new BeanItemContainer<BatchHisto>(BatchHisto.class, batchController.getBatchHisto(batch));
    batchHistoTable = new TableFormating(null,container);
    batchHistoTable.addGeneratedColumn("duree", new ColumnGenerator() {

        /*** serialVersionUID*/
        private static final long serialVersionUID = 7461290324017459118L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final BatchHisto batchHisto = (BatchHisto) itemId;
            if (batchHisto.getDateFinBatchHisto()!=null)
            {
                LocalDateTime dateDeb = LocalDateTime.from(batchHisto.getDateDebBatchHisto());
                Long minutes = dateDeb.until(batchHisto.getDateFinBatchHisto(), ChronoUnit.MINUTES);
                dateDeb = dateDeb.plusMinutes(minutes);
                Long secondes = dateDeb.until(batchHisto.getDateFinBatchHisto(), ChronoUnit.SECONDS);
                return new Label(applicationContext.getMessage("batch.histo.duree", new Object[]{minutes,secondes}, UI.getCurrent().getLocale()));
            }
            return null;
        }
    });
    batchHistoTable.setSizeFull();
    batchHistoTable.setVisibleColumns((Object[]) BATCH_HISTO_FIELDS_ORDER);
    for (String fieldName : BATCH_HISTO_FIELDS_ORDER) {
        batchHistoTable.setColumnHeader(fieldName, applicationContext.getMessage("batchHisto.table." + fieldName, null, UI.getCurrent().getLocale()));
    }
    batchHistoTable.setSortContainerPropertyId(Batch_.codBatch.getName());
    batchHistoTable.setColumnCollapsingAllowed(true);
    batchHistoTable.setColumnReorderingAllowed(true);
    batchHistoTable.setSelectable(true);

    layout.addComponent(batchHistoTable);


    /* Ajoute les boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    btnFermer = new OneClickButton(applicationContext.getMessage("btnClose", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
    btnFermer.addClickListener(e -> close());
    buttonsLayout.addComponent(btnFermer);
    buttonsLayout.setComponentAlignment(btnFermer, Alignment.MIDDLE_LEFT);

    btnRefresh = new OneClickButton(applicationContext.getMessage("btnRefresh", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
    btnRefresh.addClickListener(e -> {
        container.removeAllItems();
        container.addAll(batchController.getBatchHisto(batch));
    });
    buttonsLayout.addComponent(btnRefresh);
    buttonsLayout.setComponentAlignment(btnRefresh, Alignment.MIDDLE_RIGHT);

    /* Centre la fenêtre */
    center();
}
项目:esup-ecandidat    文件:ScolMessageView.java   
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    /* Titre */
    Label titleParam = new Label(applicationContext.getMessage("message.title", null, UI.getCurrent().getLocale()));
    titleParam.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleParam);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    addComponent(buttonsLayout);


    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.setEnabled(false);
    btnEdit.addClickListener(e -> {
        if (messageTable.getValue() instanceof Message) {
            messageController.editMessage((Message) messageTable.getValue());
        }
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);


    /* Table des messages */
    BeanItemContainer<Message> container = new BeanItemContainer<Message>(Message.class, cacheController.getMessages());
    messageTable.setContainerDataSource(container);     
    messageTable.setSizeFull();
    messageTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (String fieldName : FIELDS_ORDER) {
        messageTable.setColumnHeader(fieldName, applicationContext.getMessage("message.table." + fieldName, null, UI.getCurrent().getLocale()));
    }
    messageTable.addGeneratedColumn(Message_.i18nValMessage.getName(), new ColumnGenerator() {
        /*** serialVersionUID*/
        private static final long serialVersionUID = -8469925144843229389L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final Message message = (Message) itemId;
            return i18nController.getI18nTraductionLibelle(message.getI18nValMessage());
        }
    });
    messageTable.setSortContainerPropertyId(Message_.codMsg.getName());
    messageTable.addBooleanColumn(Message_.tesMsg.getName(), true);
    messageTable.setColumnCollapsingAllowed(true);
    messageTable.setColumnReorderingAllowed(true);
    messageTable.setSelectable(true);
    messageTable.setImmediate(true);
    messageTable.addItemSetChangeListener(e -> messageTable.sanitizeSelection());
    messageTable.addValueChangeListener(e -> {
        /* Les boutons d'édition et de suppression de message sont actifs seulement si une message est sélectionnée. */
        boolean messageIsSelected = messageTable.getValue() instanceof Message;
        btnEdit.setEnabled(messageIsSelected);
    });
    messageTable.addItemClickListener(e -> {
        if (e.isDoubleClick()) {
            messageTable.select(e.getItemId());
            btnEdit.click();
        }
    });
    addComponent(messageTable);
    setExpandRatio(messageTable, 1);

    /* Inscrit la vue aux mises à jour de message */
    messageEntityPusher.registerEntityPushListener(this);
}
项目:esup-ecandidat    文件:AdminVersionView.java   
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    /* Titre */
    Label titleNom = new Label(applicationContext.getMessage("adminVersionView.title", null, UI.getCurrent().getLocale()));
    titleNom.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleNom);

    versionTable.addGeneratedColumn(SimpleTablePresentation.CHAMPS_ACTION, new ColumnGenerator() {
        private static final long serialVersionUID = 7461290324017459118L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleTablePresentation bean = (SimpleTablePresentation)itemId;
            OneClickButton btnCheck = new OneClickButton(applicationContext.getMessage("btnCheck", null, UI.getCurrent().getLocale()), FontAwesome.ROTATE_RIGHT);
            switch (bean.getCode()){
                case NomenclatureUtils.VERSION_DEMAT:
                    btnCheck.addClickListener(e -> {
                        fileController.testDemat(true);
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_SI_SCOL_COD:
                    btnCheck.addClickListener(e -> {
                        siScolController.testSiScolConnnexion();
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_WS:
                    btnCheck.addClickListener(e -> {
                        siScolController.testWSSiScolConnnexion();
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_WS_PJ:
                    btnCheck.addClickListener(e -> {
                        AdminWsPjWindow window = new AdminWsPjWindow();
                        UI.getCurrent().addWindow(window);
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_LS:
                    btnCheck.addClickListener(e -> {
                        formulaireController.testConnexionLS();
                    });
                    return btnCheck;
                default : return null;
            }
        }
    });
    versionTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (String fieldName : FIELDS_ORDER) {
        versionTable.setColumnHeader(fieldName, applicationContext.getMessage("version." + fieldName, null, UI.getCurrent().getLocale()));
    }
    versionTable.setSortContainerPropertyId(SimpleTablePresentation.CHAMPS_ORDER);
    versionTable.setColumnCollapsingAllowed(false);
    versionTable.setColumnReorderingAllowed(false);
    versionTable.setSelectable(false);
    versionTable.setImmediate(true);

    versionTable.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 300);
    versionTable.setCellStyleGenerator((components, itemId, columnId)->{
        if (columnId!=null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)){
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });     
    addComponent(versionTable);
    setExpandRatio(versionTable, 1);

    /* Inscrit la vue aux mises à jour de version */
    versionEntityPusher.registerEntityPushListener(this);
}
项目:esup-ecandidat    文件:ScolTypeStatutView.java   
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    /* Titre */
    Label titleParam = new Label(applicationContext.getMessage("typeStatut.title", null, UI.getCurrent().getLocale()));
    titleParam.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleParam);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    addComponent(buttonsLayout);


    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.setEnabled(false);
    btnEdit.addClickListener(e -> {
        if (typeStatutTable.getValue() instanceof TypeStatut) {
            nomenclatureTypeController.editTypeStatut((TypeStatut) typeStatutTable.getValue());
        }
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);


    /* Table des typeStatuts */     
    typeStatutTable.setContainerDataSource(new BeanItemContainer<TypeStatut>(TypeStatut.class, nomenclatureTypeController.getTypeStatuts()));
    typeStatutTable.addGeneratedColumn(TypeStatut_.i18nLibTypStatut.getName(), new ColumnGenerator() {

        /*** serialVersionUID*/
        private static final long serialVersionUID = 2101119091378513475L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final TypeStatut type = (TypeStatut) itemId;
            return i18nController.getI18nTraductionLibelle(type.getI18nLibTypStatut());
        }
    });
    typeStatutTable.setSizeFull();
    typeStatutTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (String fieldName : FIELDS_ORDER) {
        typeStatutTable.setColumnHeader(fieldName, applicationContext.getMessage("typeStatut.table." + fieldName, null, UI.getCurrent().getLocale()));
    }
    typeStatutTable.setSortContainerPropertyId(TypeStatut_.codTypStatut.getName());
    typeStatutTable.setColumnCollapsingAllowed(true);
    typeStatutTable.setColumnReorderingAllowed(true);
    typeStatutTable.setSelectable(true);
    typeStatutTable.setImmediate(true);
    typeStatutTable.addBooleanColumn(TypeStatut_.temCommVisible.getName());
    typeStatutTable.setColumnWidth(TypeStatut_.temCommVisible, 250);
    typeStatutTable.addItemSetChangeListener(e -> typeStatutTable.sanitizeSelection());
    typeStatutTable.addValueChangeListener(e -> {
        /* Les boutons d'édition et de suppression de typeStatut sont actifs seulement si une typeStatut est sélectionnée. */
        boolean typeStatutIsSelected = typeStatutTable.getValue() instanceof TypeStatut;
        btnEdit.setEnabled(typeStatutIsSelected);
    });
    typeStatutTable.addItemClickListener(e -> {
        if (e.isDoubleClick()) {
            typeStatutTable.select(e.getItemId());
            btnEdit.click();
        }
    });
    addComponent(typeStatutTable);
    setExpandRatio(typeStatutTable, 1);

    /* Inscrit la vue aux mises à jour de typeStatut */
    typeStatutEntityPusher.registerEntityPushListener(this);
}
项目:mycollab    文件:AbstractPagedBeanTable.java   
@Override
public void addGeneratedColumn(Object id, ColumnGenerator generatedColumn) {
    this.columnGenerators.put(id, generatedColumn);
}
项目:mycollab    文件:AbstractPagedBeanTable.java   
private void createTable() {
    tableItem = new Table();
    tableItem.setWidth("100%");
    tableItem.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
    tableItem.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
    tableItem.setSortEnabled(false);

    // set column generator
    for (Map.Entry<Object, ColumnGenerator> entry : columnGenerators.entrySet()) {
        tableItem.addGeneratedColumn(entry.getKey(), entry.getValue());
    }

    if (StringUtils.isNotBlank((String) sortColumnId)) {
        tableItem.setColumnIcon(sortColumnId, isAscending ? FontAwesome.CARET_DOWN : FontAwesome.CARET_UP);
    }

    tableItem.addHeaderClickListener(headerClickEvent -> {
        String propertyId = (String) headerClickEvent.getPropertyId();

        if (propertyId.equals("selected")) {
            return;
        }

        if (searchRequest != null) {
            S searchCriteria = searchRequest.getSearchCriteria();
            if (sortColumnId == null) {
                sortColumnId = propertyId;
                searchCriteria.setOrderFields(Collections.singletonList(new SearchCriteria.OrderField(propertyId, SearchCriteria.DESC)));
                isAscending = false;
            } else if (propertyId.equals(sortColumnId)) {
                isAscending = !isAscending;
                String direction = (isAscending) ? SearchCriteria.ASC : SearchCriteria.DESC;
                searchCriteria.setOrderFields(Collections.singletonList(new SearchCriteria.OrderField(propertyId, direction)));
            } else {
                sortColumnId = propertyId;
                searchCriteria.setOrderFields(Collections.singletonList(new SearchCriteria.OrderField(propertyId, SearchCriteria.DESC)));
                isAscending = false;
            }

            setSearchCriteria(searchCriteria);
        }
    });

    BeanItemContainer<B> container = new BeanItemContainer<>(type, currentListData);
    tableItem.setPageLength(0);
    tableItem.setContainerDataSource(container);
    displayTableColumns();

    if (this.getComponentCount() > 0) {
        final Component component0 = this.getComponent(0);
        if (component0 instanceof Table) {
            this.replaceComponent(component0, tableItem);
        } else {
            this.addComponent(tableItem, 0);
        }
    } else {
        this.addComponent(tableItem, 0);
    }
    this.setExpandRatio(tableItem, 1);
}
项目:opennmszh    文件:NodeSelectionLinkGenerator.java   
public NodeSelectionLinkGenerator(String nodeIdProperty, ColumnGenerator generator) {
    m_nodeIdProperty = nodeIdProperty;
    m_generator = generator;
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
@Override
public AddingColumn<E> setColumnGenerator(ColumnGenerator columnGenerator)
{
    columnBuilder.setColumnGenerator(columnGenerator);
    return this;
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedColumn(final String heading, final ColumnGenerator columnGenerator,
        final boolean defaultVisibleState, final boolean lockedState, int width)
{
    return addGeneratedColumn(heading, heading + "-generated", columnGenerator, defaultVisibleState,
            lockedState, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedColumn(final String heading, final ColumnGenerator columnGenerator,
        final boolean defaultVisibleState, final boolean lockedState)
{
    return addGeneratedColumn(heading, heading + "-generated", columnGenerator, defaultVisibleState,
            lockedState);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedColumn(final String heading, final String headingPropertyId,
        final ColumnGenerator columnGenerator, final int width)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, true, false, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public <T extends Object> Builder<E> addGeneratedColumn(final String heading,
        final SingularAttribute<E, T> headingPropertyId, final ColumnGenerator columnGenerator, final int width)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, true, false, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedColumn(final String heading, final String headingPropertyId,
        final ColumnGenerator columnGenerator)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, true, false);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public <T extends Object> Builder<E> addGeneratedColumn(final String heading,
        final SingularAttribute<E, T> headingPropertyId, final ColumnGenerator columnGenerator)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, true, false);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedColumn(final String heading, final ColumnGenerator columnGenerator,
        final int width)
{
    return addGeneratedColumn(heading, heading + "-generated", columnGenerator, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedColumn(final String heading, final ColumnGenerator columnGenerator)
{
    return addGeneratedColumn(heading, heading + "-generated", columnGenerator);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addHiddenGeneratedColumn(final String heading, final String headingPropertyId,
        final ColumnGenerator columnGenerator, final int width)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, false, false, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public <T extends Object> Builder<E> addHiddenGeneratedColumn(final String heading,
        final SingularAttribute<E, T> headingPropertyId, final ColumnGenerator columnGenerator, final int width)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, false, false, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addHiddenGeneratedColumn(final String heading, final String headingPropertyId,
        final ColumnGenerator columnGenerator)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, false, false);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public <T extends Object> Builder<E> addHiddenGeneratedColumn(final String heading,
        final SingularAttribute<E, T> headingPropertyId, final ColumnGenerator columnGenerator)
{
    return addGeneratedColumn(heading, headingPropertyId, columnGenerator, false, false);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addHiddenGeneratedColumn(final String heading, final ColumnGenerator columnGenerator,
        final int width)
{
    return addGeneratedColumn(heading, columnGenerator, false, false, width);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addHiddenGeneratedColumn(final String heading, final ColumnGenerator columnGenerator)
{
    return addGeneratedColumn(heading, columnGenerator, false, false);
}
项目:VaadinUtils    文件:HeadingPropertySet.java   
public Builder<E> addGeneratedBooleanIconColumn(String heading, final SingularAttribute<E, Boolean> attribute,
        final FontAwesome trueIcon, final FontAwesome falseIcon)
{

    ColumnGenerator generator = new ColumnGenerator()
    {

        private static final long serialVersionUID = -7730752061513328598L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId)
        {
            Boolean checked = (Boolean) source.getItem(itemId).getItemProperty(attribute.getName()).getValue();

            final Label label = new Label();
            if (checked != null)
            {
                label.setContentMode(ContentMode.HTML);
                if (checked)
                {
                    if (trueIcon != null)
                    {
                        label.setValue(trueIcon.getHtml());
                    }
                }
                else
                {
                    if (falseIcon != null)
                    {
                        label.setValue(falseIcon.getHtml());
                    }
                }
            }

            return label;

        }
    };

    addGeneratedColumn(heading, attribute, generator);

    return this;

}
项目:VaadinUtils    文件:SearchableGrid.java   
public void addGeneratedColumn(Object id, ColumnGenerator generatedColumn)
{
    // grid.addGeneratedColumn(id, generatedColumn);
}
项目:VaadinUtils    文件:HeadingToPropertyId.java   
public Builder setColumnGenerator(ColumnGenerator columnGenerator)
{
    this.columnGenerator = columnGenerator;
    return this;
}