Java 类com.vaadin.ui.CustomTable 实例源码

项目:osc-core    文件:DistributedApplianceView.java   
@Override
public void initChildTable() {
    this.childContainer = new BeanContainer<Long, VirtualSystemDto>(VirtualSystemDto.class);
    this.childTable.setContainerDataSource(this.childContainer);
    // Creating table
    this.childTable.setVisibleColumns("name", "virtualizationConnectorName", "virtualizationType", "domainName",
            "markForDeletion");

    this.childTable.addGeneratedColumn("virtualizationConnectorName", new ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, Object itemId, Object columnId) {
            VirtualSystemDto vsDto = DistributedApplianceView.this.childContainer.getItem(itemId).getBean();
            return ViewUtil.generateObjectLink(
                    new LockObjectDto(vsDto.getVcId(), vsDto.getVirtualizationConnectorName(),
                            ObjectTypeDto.VIRTUALIZATION_CONNECTOR), DistributedApplianceView.this.server);
        }
    });

    // re-naming table header columns
    this.childTable.setColumnHeader("name", "VSS Name");
    this.childTable.setColumnHeader("virtualizationConnectorName", "Virtualization Connector");
    this.childTable.setColumnHeader("virtualizationType", "Virtualization Type");
    this.childTable.setColumnHeader("domainName", "Domain");
    this.childTable.setColumnHeader("markForDeletion", "Deleted");
}
项目:osc-core    文件:DeploymentSpecSubView.java   
@SuppressWarnings("serial")
@Override
public void initTable() {
    this.tableContainer = new BeanContainer<Long, DeploymentSpecDto>(DeploymentSpecDto.class);
    this.table.setContainerDataSource(this.tableContainer);
    this.table.setVisibleColumns("name", "projectName", "managementNetworkName", "markForDeletion",
            "lastJobStatus");

    // Customizing column header names
    this.table.setColumnHeader("name", "Name");
    this.table.setColumnHeader("projectName", "Project");
    this.table.setColumnHeader("managementNetworkName", "Network");
    this.table.setColumnHeader("markForDeletion", "Deleted");
    this.table.addGeneratedColumn("lastJobStatus", new ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, Object itemId, Object columnId) {
            DeploymentSpecDto dsDto = DeploymentSpecSubView.this.tableContainer.getItem(itemId).getBean();
            return ViewUtil.generateJobLink(dsDto.getLastJobStatus(), dsDto.getLastJobState(),
                    dsDto.getLastJobId(), DeploymentSpecSubView.this.server);
        }

    });
    this.table.setColumnHeader("lastJobStatus", "Last Job Status");
}
项目:osc-core    文件:BaseSecurityGroupWindow.java   
protected void populateToList() {
    this.selectedItemsContainer.removeAllItems();
    this.selectedItemsTable.removeAllItems();
    if (this.protectionTypeOption.getValue() != TYPE_ALL && this.currentSecurityGroup.getId() != null) {
        try {
            SetResponse<SecurityGroupMemberItemDto> response = this.listSecurityGroupMembersBySgService.dispatch(new BaseIdRequest(
                    this.currentSecurityGroup.getId()));
            CustomTable toTable = this.selectedItemsTable;
            for (SecurityGroupMemberItemDto memberItem : response.getSet()) {
                this.selectedItemsContainer.addBean(memberItem);
                handleProtectExternal(toTable, memberItem.getOpenstackId(), memberItem);
            }
            updateCountFooter(this.selectedItemsTable, this.selectedItemsTable.getItemIds().size());
        } catch (Exception e) {
            ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
            log.error("Error getting to Servers List", e);
        }
    }

}
项目:extacrm    文件:SalesGrid.java   
/**
 * {@inheritDoc}
 */
@Override
protected void initTable(final Mode mode) {
    super.initTable(mode);

    // Раскрашиваем "протухшие" продажи
    if (domain == ExtaDomain.SALES_OPENED) {
        final CustomTable.CellStyleGenerator defGen = table.getCellStyleGenerator();
        table.setCellStyleGenerator((source, itemId, propertyId) -> {
            String style = null;
            if (defGen != null) // Если уже есть генератор
                style = defGen.getStyle(source, itemId, propertyId);
            if (style == null) {
                final Sale sale = getEntity(itemId);
                final DateTime curDate = DateTime.now(DateTimeZone.UTC);
                final DateTime modifiedDate = sale.getLastModifiedDate();
                if (modifiedDate.plus(Days.days(2)).isBeforeNow())
                    style = "highlight-red"; // Красненькие
                else if (modifiedDate.plus(Days.days(1)).isBeforeNow())
                    style = "highlight-yellow"; // Желтенькие
            }
            return style;
        });
    }
}
项目:osc-core    文件:AlertView.java   
@SuppressWarnings("serial")
@Override
public void initParentTable() {
    this.parentContainer = new BeanContainer<Long, AlertDto>(AlertDto.class);

    this.parentTable.setContainerDataSource(this.parentContainer);
    this.parentTable.setVisibleColumns(ALERT_ID_COLUMN, ALERT_NAME_COLUMN_ID, ALERT_OBJECTS_COLUMN_ID,
            ALERT_SEVERITY_COLUMN_ID, ALERT_MESSAGE_COLUMN, ALERT_TIME_CREATED_COLUMN_ID, ALERT_STATUS_COLUMN_ID,
            ALERT_TIME_ACKNOWLEDGED_COLUMN_ID, ALERT_USER_ACKNOWLEDGED_COLUMN_ID);

    this.parentTable.addGeneratedColumn(ALERT_OBJECTS_COLUMN_ID, new ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, Object itemId, Object columnId) {
            AlertDto alertDto = AlertView.this.parentContainer.getItem(itemId).getBean();
            if (alertDto.getObject() != null) {
                return ViewUtil.generateObjectLink(alertDto.getObject(), AlertView.this.server);
            }
            return null;
        }
    });

    this.parentTable.setColumnHeader(ALERT_ID_COLUMN, "Id");
    this.parentTable.setColumnHeader(ALERT_NAME_COLUMN_ID, "Name");
    this.parentTable.setColumnHeader(ALERT_OBJECTS_COLUMN_ID, "Objects");
    this.parentTable.setColumnHeader(ALERT_SEVERITY_COLUMN_ID, "Severity");
    this.parentTable.setColumnHeader(ALERT_MESSAGE_COLUMN, "Message");
    this.parentTable.setColumnHeader(ALERT_TIME_CREATED_COLUMN_ID, "Created");
    this.parentTable.setColumnHeader(ALERT_STATUS_COLUMN_ID, "Status");
    this.parentTable.setColumnHeader(ALERT_TIME_ACKNOWLEDGED_COLUMN_ID, "Acknowledged");
    this.parentTable.setColumnHeader(ALERT_USER_ACKNOWLEDGED_COLUMN_ID, "Acknowledged By");
}
项目:osc-core    文件:BaseSecurityGroupWindow.java   
@SuppressWarnings("unchecked")
private void moveItems(CustomTable fromTable, CustomTable toTable) {
    if (fromTable.equals(toTable)) {
        return;
    }
    BeanContainer<String, SecurityGroupMemberItemDto> fromContainer = (BeanContainer<String, SecurityGroupMemberItemDto>) fromTable
            .getContainerDataSource();
    BeanContainer<String, SecurityGroupMemberItemDto> toContainer = (BeanContainer<String, SecurityGroupMemberItemDto>) toTable
            .getContainerDataSource();

    boolean isMovingToSelectedItemList = toTable == this.selectedItemsTable;

    String memberType = (String) this.protectionEntityType.getValue();
    Set<String> itemIdsSelected = (Set<String>) fromTable.getValue();
    for (String itemId : itemIdsSelected) {
        if (fromContainer.getItem(itemId) != null) {
            SecurityGroupMemberItemDto memberItem = fromContainer.getItem(itemId).getBean();
            // Add the item to the 'to' container, if the 'to' container is the selected items table
            if (isMovingToSelectedItemList) {
                toContainer.addBean(memberItem);
                handleProtectExternal(toTable, itemId, memberItem);
            } else if (memberItem.getType().equals(memberType)) {
                // If the 'to' container is not the selected list, we need to check the current selected type
                // from the UI and add the member only if it matches the selected type
                toContainer.addBean(memberItem);
            }
        }
        fromContainer.removeItem(itemId);
        fromTable.removeItem(itemId);
    }

    toTable.setValue(itemIdsSelected);
    updateCountFooter(fromTable, fromTable.getItemIds().size());
    updateCountFooter(toTable, toTable.getItemIds().size());

    toTable.sort(new Object[] { toTable.getSortContainerPropertyId() }, new boolean[] { toTable.isSortAscending() });
}
项目:extacrm    文件:TasksGrid.java   
@Override
protected CustomTable.ColumnGenerator createDetailColumnGenerator(final UIAction defAction) {
    return new CustomTable.ColumnGenerator() {

        private StringToDateTimeConverter dtConverter;
        {
            dtConverter = lookup(StringToDateTimeConverter.class);
            dtConverter.setPattern("EEE, dd MMM, HH:mm");
        }

        @Override
        public Object generateCell(final CustomTable source, final Object itemId, final Object columnId) {
            final Item item = getItem(itemId);
            final Task task = GridItem.extractBean(item);

            final Button titleLink = new Button();
            titleLink.addStyleName(ExtaTheme.BUTTON_LINK);
            titleLink.setCaption(task.getName());
            titleLink.setDescription(defAction.getDescription());
            titleLink.setClickShortcut(ShortcutAction.KeyCode.ENTER);
            titleLink.addClickListener(event -> defAction.fire(newHashSet(itemId)));

            final VerticalLayout panel = new VerticalLayout();
            panel.addComponent(titleLink);

            final Label desc = new Label(task.getDescription());
            panel.addComponent(desc);

            final Label dueTime = new Label(item.getItemProperty("dueDate"));
            dueTime.setConverter(dtConverter);
            panel.addComponent(dueTime);

            return panel;
        }
    };
}
项目:osc-core    文件:BaseSecurityGroupWindow.java   
protected void updateCountFooter(CustomTable table, int count) {
    table.setColumnFooter("name", VmidcMessages.getString(VmidcMessages_.SELECTOR_COUNT, count));
}
项目:osc-core    文件:BaseSecurityGroupWindow.java   
private void handleProtectExternal(CustomTable toTable, String itemId, SecurityGroupMemberItemDto memberItem) {
    boolean enableProtectExternalFlag = !SECURITY_GROUP_MEMBER_SUBNET.equals(memberItem.getType());
    toTable.getContainerProperty(itemId, PROTECT_EXTERNAL).setReadOnly(enableProtectExternalFlag);
}
项目:osc-core    文件:BaseSecurityGroupWindow.java   
@Override
public Object generateCell(CustomTable source, Object itemId, Object columnId) {
    Property<?> prop = source.getItem(itemId).getItemProperty(columnId);
    return new CheckBox(null, prop);
}
项目:konekti    文件:JobView.java   
@Override
public Object generateCell(CustomTable source, Object itemId, Object columnId) {

    Label jobNameLabel = new Label();

    Job job = (Job) itemId;

    if(job.getArea() != null)
        jobNameLabel.setValue(job.getArea().getName());

    return jobNameLabel;
}
项目:konekti    文件:JobView.java   
@Override
public Object generateCell(CustomTable source, Object itemId, Object columnId) {

    Label jobTriggerType = new Label();

    Job job = (Job) itemId;

    if(job.getJobTriggerType() != null)
        jobTriggerType.setValue(job.getJobTriggerType().getDescription());

    return jobTriggerType;
}