当前位置: 首页>>代码示例>>Java>>正文


Java ColumnGenerator类代码示例

本文整理汇总了Java中com.vaadin.ui.Table.ColumnGenerator的典型用法代码示例。如果您正苦于以下问题:Java ColumnGenerator类的具体用法?Java ColumnGenerator怎么用?Java ColumnGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ColumnGenerator类属于com.vaadin.ui.Table包,在下文中一共展示了ColumnGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addGeneratedColumn

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:18,代码来源:ArtifactDetailsLayout.java

示例2: addGeneratedColumnButton

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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;
        }
    });

}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:20,代码来源:ArtifactDetailsLayout.java

示例3: buildAttributeTable

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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);
    
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:27,代码来源:EditDeduperPanel.java

示例4: initializeTable

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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;
		}
	});
}
 
开发者ID:att,项目名称:XACML,代码行数:26,代码来源:GitPushWindow.java

示例5: buildEntityTable

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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);
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:30,代码来源:EditDeduperPanel.java

示例6: buildEntityTable

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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);
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:33,代码来源:EditDataDiffPanel.java

示例7: buildAttributeTable

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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);

        }
 
开发者ID:JumpMind,项目名称:metl,代码行数:29,代码来源:EditDataDiffPanel.java

示例8: generateIdColumn

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
/**
 * 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;
		}
	});
}
 
开发者ID:alejandro-du,项目名称:enterprise-app,代码行数:14,代码来源:CrudComponent.java

示例9: addGeneratedColumn

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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);
}
 
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:8,代码来源:HeadingPropertySet.java

示例10: addGeneratedColumn

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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);
}
 
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:11,代码来源:BaseCrudView.java

示例11: getStatusColumnGenerator

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
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;

		}
	};
}
 
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:36,代码来源:JasperReportScheduleLayout.java

示例12: init

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:75,代码来源:ScolTypeTraitementView.java

示例13: init

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:76,代码来源:ScolTypeStatutPieceView.java

示例14: AdminBatchHistoWindow

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:78,代码来源:AdminBatchHistoWindow.java

示例15: init

import com.vaadin.ui.Table.ColumnGenerator; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:76,代码来源:ScolMessageView.java


注:本文中的com.vaadin.ui.Table.ColumnGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。