com.vaadin.data.Container Java Examples

The following examples show how to use com.vaadin.data.Container. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WinLogView.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
private Container getServiceList(Container container) {
    ComponentService componentService = BeanContext.getBean(ComponentService.class);

    if (cmbMyCloud.getValue() != null) {
        Long farmNo = (Long) cmbMyCloud.getValue();
        List<ComponentDto> componentDtos;
        componentDtos = componentService.getComponents(farmNo);

        for (ComponentDto componentDto : componentDtos) {
            Item item;
            item = container.addItem(componentDto.getComponent().getComponentNo());
            item.getItemProperty("serviceName").setValue(componentDto.getComponent().getComponentName());
        }
    }
    return container;
}
 
Example #2
Source File: TargetBulkUpdateWindowLayout.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return
 */
private Container createContainer() {

    final Map<String, Object> queryConfiguration = Maps.newHashMapWithExpectedSize(2);

    queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG,
            managementUIState.getDistributionTableFilters().isNoTagSelected());

    queryConfiguration.put(SPUIDefinitions.FILTER_BY_TAG,
            managementUIState.getDistributionTableFilters().getClickedDistSetTags());

    final BeanQueryFactory<DistributionBeanQuery> distributionQF = new BeanQueryFactory<>(
            DistributionBeanQuery.class);
    distributionQF.setQueryConfiguration(queryConfiguration);
    return new LazyQueryContainer(
            new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), distributionQF);
}
 
Example #3
Source File: WinLogView.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
private Container getServerList(Container container) {
    InstanceService instanceService = BeanContext.getBean(InstanceService.class);

    if (cmbMyCloud.getValue() != null) {
        Long farmNo = (Long) cmbMyCloud.getValue();
        List<InstanceDto> instanceDtos;
        instanceDtos = instanceService.getInstances(farmNo);

        for (InstanceDto instanceDto : instanceDtos) {
            Item item;
            item = container.addItem(instanceDto.getInstance().getInstanceNo());
            item.getItemProperty("serverName").setValue(instanceDto.getInstance().getInstanceName());
        }
    }

    return container;
}
 
Example #4
Source File: TableEditor.java    From jdal with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
	if (getContainer() == null) {
		Container c = createBeanContainer(getEntityClass(), null);
		setContainer(c);
	}
	
	getTable().setContainerDataSource(getContainer());
	getTable().addItemClickListener(this);
	VerticalLayout vl = getVerticalLayout();
	vl.setSpacing(true);
	vl.addComponent(this.buttonBar);
	vl.addComponent(getTable());
	vl.setExpandRatio(getTable(), 1);
	this.buttonBar.setSpacing(true);
}
 
Example #5
Source File: PageableTable.java    From jdal with Apache License 2.0 6 votes vote down vote up
/**
 * Load models from page and add to internal bean item container
 */
@SuppressWarnings("unchecked")
protected void loadPage() {
	Container container = getContainer();
	Class<T> entityClass = getEntityClass();
	
	if (this.page.getData() != null && this.page.getData().size() > 0) {
		
		if (container == null) {
			Class<T> beanClass = (Class<T>) (entityClass != null ? entityClass : this.page.getData().get(0).getClass());
			container = createBeanContainer(beanClass, this.page.getData());
			getTable().setContainerDataSource(container);
			setContainer(container);
		}
		else {
			container.removeAllItems();
			addBeansFromPage(container);
		}
	}
	else {
		if (container != null)
			container.removeAllItems();
	}
	
	paginator.refresh();
}
 
Example #6
Source File: ConfigurableTable.java    From jdal with Apache License 2.0 6 votes vote down vote up
@Override
public void setContainerDataSource(Container newDataSource,
           Collection<?> visibleIds) {
	if (visibleIds != null && visibleIds.size() > 0) {
		for (String id : properties) {
			if (PropertyUtils.isNested(id)) {
				addNestedPropertyIfPossible(newDataSource, id);
			}
			
			if (!visibleIds.contains(id) && !PropertyUtils.isNested(id)) {
				throw new IllegalStateException("Unknown property [" + id + "]");
			}
		}
	}
	super.setContainerDataSource(newDataSource, properties);
}
 
Example #7
Source File: DistributionSetSelectComboBox.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private static Container createContainer() {
    final Map<String, Object> queryConfig = new HashMap<>();
    queryConfig.put(SPUIDefinitions.FILTER_BY_DS_COMPLETE, Boolean.TRUE);

    final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<>(ManageDistBeanQuery.class);
    distributionQF.setQueryConfiguration(queryConfig);

    final LazyQueryDefinition distribtuinQD = new LazyQueryDefinition(false, SPUIDefinitions.PAGE_SIZE,
            SPUILabelDefinitions.VAR_ID);

    final QueryView distributionSetFilterLazyQueryView = new DistributionSetFilterQueryView(
            new LazyQueryView(distribtuinQD, distributionQF));
    distributionSetFilterLazyQueryView.sort(
            new Object[] { SPUILabelDefinitions.VAR_NAME, SPUILabelDefinitions.VAR_VERSION },
            new boolean[] { true, true });

    return new LazyQueryContainer(distributionSetFilterLazyQueryView);
}
 
Example #8
Source File: TargetFilterQueryDetailsTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Populate software module metadata.
 *
 * @param distributionSet
 *            the selected distribution set
 */
public void populateTableByDistributionSet(final DistributionSet distributionSet) {
    removeAllItems();
    if (distributionSet == null) {
        return;
    }

    final Container dataSource = getContainerDataSource();
    final List<TargetFilterQuery> filters = distributionSet.getAutoAssignFilters();
    filters.forEach(query -> {
        final Object itemId = dataSource.addItem();
        final Item item = dataSource.getItem(itemId);
        item.getItemProperty(TFQ_NAME).setValue(query.getName());
        item.getItemProperty(TFQ_QUERY).setValue(query.getQuery());
    });

}
 
Example #9
Source File: SwModuleTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void addContainerProperties(final Container container) {
    final LazyQueryContainer lazyContainer = (LazyQueryContainer) container;
    lazyContainer.addContainerProperty(SPUILabelDefinitions.NAME_VERSION, String.class, null, false, false);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_ID, Long.class, null, false, false);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_VERSION, String.class, null, false, false);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, null, false, true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_VENDOR, String.class, null, false, true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false,
            true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_COLOR, String.class, null, false, true);
    lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_SOFT_TYPE_ID, Long.class, null, false, true);
}
 
Example #10
Source File: TargetBulkUpdateWindowLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private ComboBox getDsComboField() {
    final Container container = createContainer();
    final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("bulkupload.ds.name"), "", null,
            null, false, "", i18n.getMessage("bulkupload.ds.name"));
    dsComboBox.setSizeUndefined();
    dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE);
    dsComboBox.setImmediate(true);
    dsComboBox.setFilteringMode(FilteringMode.STARTSWITH);
    dsComboBox.setPageLength(7);
    dsComboBox.setContainerDataSource(container);
    dsComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME_VERSION);
    dsComboBox.setId(UIComponentIdProvider.BULK_UPLOAD_DS_COMBO);
    dsComboBox.setWidth("100%");
    return dsComboBox;
}
 
Example #11
Source File: AbstractTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void refreshContainer() {
    final Container container = getContainerDataSource();
    if (!(container instanceof LazyQueryContainer)) {
        return;
    }
    ((LazyQueryContainer) getContainerDataSource()).refresh();
}
 
Example #12
Source File: AbstractTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
protected void addNewContainerDS() {
    final Container container = createContainer();
    addContainerProperties(container);
    setContainerDataSource(container);
    final int size = container.size();
    if (size == 0) {
        setData(i18n.getMessage(UIMessageIdProvider.MESSAGE_NO_DATA));
    }
}
 
Example #13
Source File: DistributionSetSelectComboBox.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void initDataSource() {
    final Container container = createContainer();
    container.addContainerProperty(SPUILabelDefinitions.VAR_NAME_VERSION, String.class, null);

    setItemCaptionMode(ItemCaptionMode.PROPERTY);
    setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME_VERSION);
    setFilteringMode(FilteringMode.CONTAINS);

    setContainerDataSource(container);
}
 
Example #14
Source File: TargetTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Container createContainer() {
    // ADD all the filters to the query config
    final Map<String, Object> queryConfig = prepareQueryConfigFilters();
    // Create TargetBeanQuery factory with the query config.
    final BeanQueryFactory<TargetBeanQuery> targetQF = new BeanQueryFactory<>(TargetBeanQuery.class);
    targetQF.setQueryConfiguration(queryConfig);
    // create lazy query container with lazy defination and query
    final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
            new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
    targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
    return targetTableContainer;
}
 
Example #15
Source File: WinLogView.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void setMyCloudList(Container container) {
    List<FarmDto> farms;

    // ユーザ番号
    Long userNo = ViewContext.getUserNo();

    if (userNo != null) {
        // クラウド情報を取得
        FarmService farmService = BeanContext.getBean(FarmService.class);
        farms = farmService.getFarms(userNo);

        List<Long> farmNos = new ArrayList<Long>();
        for (int i = 0; i < farms.size(); i++) {
            FarmDto farm = farms.get(i);
            Item item = container.addItem(farm.getFarm().getFarmNo());
            item.getItemProperty("FarmName").setValue(farm.getFarm().getFarmName());
            farmNos.add(farm.getFarm().getFarmNo());
        }
        if (!farmNos.contains(cmbMyCloud.getValue())) {
            cmbMyCloud.setValue(null);
        }
        cmbMyCloud.setContainerDataSource(container);

        if (cmbService != null && cmbServer != null) {
            Container serviceContainer = cmbService.getContainerDataSource();
            serviceContainer.removeAllItems();
            cmbService.setContainerDataSource(getServiceList(serviceContainer));
            cmbService.select(null);

            Container serverContainer = cmbServer.getContainerDataSource();
            serverContainer.removeAllItems();
            cmbServer.setContainerDataSource(getServerList(serverContainer));
            cmbServer.select(null);

        }
    }
}
 
Example #16
Source File: TargetFilterQueryButtons.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/** 
 * {@inheritDoc}
 */
@Override
public void refreshContainer() {
  final Container container = getContainerDataSource();
  if (!(container instanceof LazyQueryContainer)) {
      return;
  }
  ((LazyQueryContainer) getContainerDataSource()).refresh();
}
 
Example #17
Source File: HawkbitCommonUtil.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set distribution table column properties.
 *
 * @param container
 *            table container
 */
public static void getDsTableColumnProperties(final Container container) {
    final LazyQueryContainer lqc = (LazyQueryContainer) container;
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_ID, Long.class, null, false, false);
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_VERSION, String.class, null, false, false);
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, null, false, true);
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true);
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true);
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, true);
    lqc.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true);
}
 
Example #18
Source File: DefineGroupsLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Container createTargetFilterComboContainer() {
    final BeanQueryFactory<TargetFilterBeanQuery> targetFilterQF = new BeanQueryFactory<>(
            TargetFilterBeanQuery.class);
    return new LazyQueryContainer(
            new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_NAME),
            targetFilterQF);
}
 
Example #19
Source File: SoftwareModuleTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Container createContainer() {
    final Map<String, Object> queryConfiguration = prepareQueryConfigFilters();

    final BeanQueryFactory<BaseSwModuleBeanQuery> swQF = new BeanQueryFactory<>(BaseSwModuleBeanQuery.class);
    swQF.setQueryConfiguration(queryConfiguration);

    return new LazyQueryContainer(
            new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_SWM_ID), swQF);
}
 
Example #20
Source File: AddUpdateRolloutWindowLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private static Container createTargetFilterComboContainer() {
    final BeanQueryFactory<TargetFilterBeanQuery> targetFilterQF = new BeanQueryFactory<>(
            TargetFilterBeanQuery.class);
    return new LazyQueryContainer(
            new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_NAME),
            targetFilterQF);
}
 
Example #21
Source File: WinLogView.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
void fillContainer(Container container, List<EventLog> eventLogs) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
    int i = 0;
    for (EventLog eventLog : eventLogs) {
        String id = String.valueOf(i++);
        Item item = container.addItem(id);
        item.getItemProperty("DateTime").setValue(simpleDateFormat.format(eventLog.getLogDate()));
        item.getItemProperty("LogLevel").setValue(transformLogLevel(eventLog.getLogLevel()));
        item.getItemProperty("myCloud").setValue(eventLog.getFarmName());
        item.getItemProperty("Service").setValue(eventLog.getComponentName());
        item.getItemProperty("Server").setValue(eventLog.getInstanceName());
        item.getItemProperty("Message").setValue(eventLog.getMessage());
    }
}
 
Example #22
Source File: AddressSelectViewImplEx.java    From vaadinator with Apache License 2.0 5 votes vote down vote up
@Override
protected Container initContainer() {
	AddressLazyQueryFactory factory = new AddressLazyQueryFactory(observer);
	// quite small batch size, for debugging. Don't use that in production.
	container = new AddressLazyQueryContainer(new LazyQueryDefinition(false, 2, null), factory);
	return container;
}
 
Example #23
Source File: PDPGroupContainer.java    From XACML with MIT License 5 votes vote down vote up
@Override
public void addItemSetChangeListener(ItemSetChangeListener listener) {
       if (getItemSetChangeListeners() == null) {
           setItemSetChangeListeners(new LinkedList<Container.ItemSetChangeListener>());
       }
       getItemSetChangeListeners().add(listener);	
}
 
Example #24
Source File: ItemSetChangeNotifier.java    From XACML with MIT License 5 votes vote down vote up
/**
 * Sends an Item set change event to all registered interested listeners.
 * 
 * @param event
 *            the item set change event to send, optionally with additional
 *            information
 */
protected void fireItemSetChange(ItemSetChangeEvent event) {
    if (getItemSetChangeListeners() != null) {
        final Object[] l = getItemSetChangeListeners().toArray();
        for (int i = 0; i < l.length; i++) {
            ((Container.ItemSetChangeListener) l[i])
                    .containerItemSetChange(event);
        }
    }
}
 
Example #25
Source File: SchemaSelectorComponent.java    From RDFUnit with Apache License 2.0 5 votes vote down vote up
private static Container generateTestContainer() {
    BeanItemContainer<SchemaSource> container = new BeanItemContainer<>(
            SchemaSource.class);

    java.util.Collection<SchemaSource> sources;
    try {
        sources = SchemaService.getSourceListAll(false, null);
    } catch (UndefinedSchemaException e) {
        LOGGER.error("Undefined schema", e);
        sources = new ArrayList<>();
    }

    sources.forEach(container::addBean);
    return container;
}
 
Example #26
Source File: ContainerDataSource.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Notity listeners that the item set change
 */
private void fireItemSetChange() {
	ItemSetChangeEvent isce = new ItemSetChangeEvent() {

		public Container getContainer() {
			return ContainerDataSource.this;
		}
	};
	// must be first 
	itemIdStrategy.containerItemSetChange(isce);
	
	for (ItemSetChangeListener listener : listeners) {
		listener.containerItemSetChange(isce);
	}
}
 
Example #27
Source File: ConfigurableTable.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Add nested property to datasource if is possilbe. 
 * @param name of nested property 
 */
private void addNestedPropertyIfPossible(Container cds, String name) {
	if (cds instanceof AbstractBeanContainer<?,?>) {
		((AbstractBeanContainer<?,?>) cds).addNestedContainerProperty(name);
	}
	else if (cds instanceof ListBeanContainer)
		((ListBeanContainer) cds).addProperty(name);
}
 
Example #28
Source File: TableComponent.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Create the BeanContainer to use.
 * @param beanClass bean type in container
 * @param data intial data.
 * @return a new BeanContainer
 */
protected Container createBeanContainer(Class<T> beanClass, List<T> data) {
	Constructor<?extends Container> ctor = 
			ClassUtils.getConstructorIfAvailable(this.containerClass, Class.class, Collection.class);
	
	if (ctor != null)
		return BeanUtils.instantiateClass(ctor, beanClass, data);
	
	return new BeanItemContainer<T>(beanClass, data);
}
 
Example #29
Source File: TableAccessor.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Collection<?> getControlValue() {
	Container container = getControl().getContainerDataSource();
	if (container instanceof Filterable) 
		((Filterable) container).removeAllContainerFilters();
	
	ArrayList<Object> list = new ArrayList<Object>();
	
	for (Object id : container.getItemIds())
		list.add(ItemUtils.getBean(container.getItem(id)));
	
	return list;
}
 
Example #30
Source File: TableAccessor.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setControlValue(Object value) {
	if (!(value instanceof Collection))
		throw new IllegalArgumentException("Value must implements Collection");
	
	Collection<?> collection = (Collection<?>) value;
	Container container = getControl().getContainerDataSource();
	container.removeAllItems();
	
	for (Object itemId : collection)
		container.addItem(itemId);
}