Examples of CellFormatter


Examples of com.smartgwt.client.widgets.grid.CellFormatter

            public ArrayList<ListGridField> getListGridFields() {
                ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);

                ListGridField nameField = new ListGridField(DriftDefinitionDataSource.ATTR_NAME,
                    MSG.common_title_name());
                nameField.setCellFormatter(new CellFormatter() {
                    public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                        Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
                        Integer driftDefId = listGridRecord.getAttributeAsInt("id");
                        String url = LinkManager.getDriftDefinitionCarouselLink(resourceId, driftDefId);
                        return LinkManager.getHref(url, o.toString());
                    }
                });
                fields.add(nameField);

                ListGridField descriptionField = new ListGridField(DriftDefinitionDataSource.ATTR_DESCRIPTION,
                    MSG.common_title_description());
                fields.add(descriptionField);

                ListGridField attachedField = new ListGridField(DriftDefinitionDataSource.ATTR_ATTACHED,
                    MSG.view_drift_table_attached());
                fields.add(attachedField);

                ListGridField enabledField = new ListGridField(DriftDefinitionDataSource.ATTR_IS_ENABLED_ICON,
                    MSG.common_title_enabled());
                enabledField.setType(ListGridFieldType.IMAGE);
                enabledField.setAlign(Alignment.CENTER);
                fields.add(enabledField);

                ListGridField inComplianceField = new ListGridField(DriftDefinitionDataSource.ATTR_COMPLIANCE_ICON,
                    MSG.common_title_in_compliance());
                inComplianceField.setType(ListGridFieldType.IMAGE);
                inComplianceField.setAlign(Alignment.CENTER);
                inComplianceField.setShowHover(true);
                inComplianceField.setHoverCustomizer(new HoverCustomizer() {
                    @Override
                    public String hoverHTML(Object o, ListGridRecord record, int row, int column) {
                        int complianceCode = record.getAttributeAsInt(DriftDefinitionDataSource.ATTR_COMPLIANCE);
                        DriftComplianceStatus complianceStatus = DriftComplianceStatus.fromCode(complianceCode);
                        switch (complianceStatus) {
                        case OUT_OF_COMPLIANCE_NO_BASEDIR:
                            return MSG.view_drift_table_hover_outOfCompliance_noBaseDir();
                        case OUT_OF_COMPLIANCE_DRIFT:
                            return MSG.view_drift_table_hover_outOfCompliance_drift();
                        default:
                            return "";
                        }
                    }
                });
                fields.add(inComplianceField);

                ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME,
                    MSG.common_title_resource());
                resourceNameField.setCellFormatter(new CellFormatter() {
                    public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                        Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
                        String url = LinkManager.getResourceLink(resourceId);
                        return LinkManager.getHref(url, o.toString());
                    }
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

        ctimeField.setShowHover(true);
        ctimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(AlertCriteria.SORT_FIELD_CTIME));
        fields.add(ctimeField);

        ListGridField nameField = new ListGridField("name", MSG.common_title_name());
        nameField.setCellFormatter(new CellFormatter() {
            public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
                Integer defId = listGridRecord.getAttributeAsInt("definitionId");
                String url = LinkManager.getSubsystemAlertDefinitionLink(resourceId, defId);
                return LinkManager.getHref(url, o.toString());
            }
        });
        fields.add(nameField);

        ListGridField conditionField = new ListGridField("conditionText", MSG.view_alerts_field_condition_text());
        conditionField.setCanSortClientOnly(true);
        fields.add(conditionField);

        ListGridField conditionLogField = new ListGridField("conditionValue", MSG.view_alerts_field_condition_value());
        conditionLogField.setCanSortClientOnly(true);
        fields.add(conditionLogField);

        ListGridField priorityField = new ListGridField("priority", MSG.view_alerts_field_priority());
        priorityField.setType(ListGridFieldType.IMAGE);
        priorityField.setAlign(Alignment.CENTER);
        priorityField.setShowHover(true);
        priorityField.setHoverCustomizer(new HoverCustomizer() {
            @Override
            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                String prio = record.getAttribute("priority");
                if (PRIORITY_ICON_HIGH.equals(prio)) {
                    return MSG.common_alert_high();
                } else if (PRIORITY_ICON_MEDIUM.equals(prio)) {
                    return MSG.common_alert_medium();
                } else if (PRIORITY_ICON_LOW.equals(prio)) {
                    return MSG.common_alert_low();
                } else {
                    return ""; // will never get here
                }
            }
        });
        fields.add(priorityField);

        ListGridField statusField = new ListGridField("acknowledgingSubject", MSG.common_title_acknowledged());
        statusField.setCellFormatter(new CellFormatter() {
            public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                String ackSubject = listGridRecord.getAttribute("acknowledgingSubject");
                if (ackSubject == null) {
                    return "&nbsp;";
                } else {
                    Img checkedImg = new Img(ImageManager.getAlertStatusCheckedIcon(),80,16);
                    checkedImg.setImageType(ImageStyle.CENTER);
                    return checkedImg.getInnerHTML();
                }
            }
        });
        statusField.setShowHover(true);
        statusField.setHoverCustomizer(new HoverCustomizer() {
            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                String ackSubject = record.getAttribute("acknowledgingSubject");
                StringBuilder sb = new StringBuilder("<p");
                if (ackSubject == null) {
                    sb.append(" style='width:150px'>");
                    sb.append(MSG.view_alerts_field_ack_status_noAckHover());
                } else {
                    sb.append(" style='width:500px'>");
                    Date ackDateTime = record.getAttributeAsDate("acknowledgeTime");
                    String ackDateTimeString = TimestampCellFormatter.format(ackDateTime,
                        TimestampCellFormatter.DATE_TIME_FORMAT_FULL);
                    sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackDateTimeString));
                }
                sb.append("</p>");
                return sb.toString();
            }
        });
        fields.add(statusField);

        ListGridField recoveredField = new ListGridField("recovered", MSG.common_title_recovered());
        recoveredField.setCellFormatter(new CellFormatter() {
            public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                Long recovered = listGridRecord.getAttributeAsLong("recovered");
                if(recovered.longValue() > 0) {
                    Img checkedImg = new Img(ImageManager.getAlertStatusCheckedIcon(),80,16);
                    checkedImg.setImageType(ImageStyle.CENTER);
                    return checkedImg.getInnerHTML();
                } else {
                    return "&nbsp;";
                }
            }
        });
        recoveredField.setHoverCustomizer(new HoverCustomizer() {
            @Override
            public String hoverHTML(Object o, ListGridRecord listGridRecord, int i, int i2) {
                Long recovered = listGridRecord.getAttributeAsLong("recovered");
                if(recovered.longValue() > 0) {
                    Date recoveredTime = listGridRecord.getAttributeAsDate("recoveredTime");
                    String recoveredTimeString = TimestampCellFormatter.format(recoveredTime,
                            TimestampCellFormatter.DATE_TIME_FORMAT_FULL);
                    return new StringBuilder()
                            .append("<p style='width:500px'>")
                            .append(MSG.view_alerts_field_recovered_status_hover(recoveredTimeString))
                            .append("</p>").toString();
                }
                return "";
            }
        });
        recoveredField.setShowHover(true);
        fields.add(recoveredField);

        if (this.entityContext.type != EntityContext.Type.Resource) {
            ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
            resourceNameField.setCellFormatter(new CellFormatter() {
                public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                    String url = LinkManager.getResourceLink(record.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
                    return LinkManager.getHref(url, value.toString());
                }
            });
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

            }
        });
        fields.add(iconField);

        ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
        nameField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                String invStatus = record.getAttribute(INVENTORY_STATUS.propertyName());
                if (InventoryStatus.COMMITTED == InventoryStatus.valueOf(invStatus)) {
                    String url = LinkManager.getResourceLink(record.getAttributeAsInt("id"));
                    String name = StringUtility.escapeHtml(value.toString());
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

            ListGridField status = new ListGridField("status", MSG.view_alert_common_tab_notifications_status());
            status.setWidth("50");
            status.setAlign(Alignment.CENTER);
            status.setType(ListGridFieldType.IMAGE);
            status.setCellFormatter(new CellFormatter() {
                public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                    String statusStr = record.getAttribute("status");
                    ResultState statusEnum = (statusStr == null) ? ResultState.UNKNOWN : ResultState.valueOf(statusStr);
                    return imgHTML(ImageManager.getAlertNotificationResultIcon(statusEnum));
                }
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

        ListGridField endRow = new ListGridField(FIELD_END_ROW, "End Row");

        timestamp.setType(ListGridFieldType.DATE);
        TimestampCellFormatter.prepareDateField(timestamp);

        status.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (value == null) {
                    return "?";
                }
                int statusNum = ((Integer) value).intValue();
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

    protected void configureTable() {
        ListGridField idField = new ListGridField("id", MSG.common_title_id());
        idField.setWidth(50);

        IconField categoryField = new IconField(CATEGORY.propertyName());
        categoryField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                String categoryName = (String) value;
                GroupCategory category = GroupCategory.valueOf(categoryName);
                String icon = ImageManager.getGroupIcon(category);
                return "<img class='tableImage' src=\"" + ImageManager.getFullImagePath(icon) + "\" />";
            }
        });
        categoryField.setShowHover(true);
        categoryField.setHoverCustomizer(new HoverCustomizer() {
            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                String categoryName = record.getAttribute(CATEGORY.propertyName());
                GroupCategory category = GroupCategory.valueOf(categoryName);
                String displayName;
                switch (category) {
                case COMPATIBLE:
                    displayName = MSG.view_group_summary_compatible();
                    break;
                case MIXED:
                    displayName = MSG.view_group_summary_mixed();
                    break;
                default:
                    throw new IllegalStateException("Unknown group category: " + category);
                }
                return displayName;
            }
        });

        ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title());
        nameField.setWidth("40%");

        nameField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int i, int i1) {
                String groupId = record.getAttribute("id");
                String groupUrl = LinkManager.getResourceGroupLink(Integer.valueOf(groupId));
                return LinkManager.getHref(groupUrl, value.toString());
            }
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

        ListGridField attachedField = new ListGridField(ATTR_ATTACHED, MSG.view_drift_table_attached());
        fields.add(attachedField);

        ListGridField templateField = new ListGridField(ATTR_TEMPLATE, MSG.view_drift_table_template());
        templateField.setCellFormatter(new CellFormatter() {
            public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                DriftDefinition def = (DriftDefinition) listGridRecord.getAttributeAsObject(ATTR_ENTITY);
                if (null == def.getTemplate()) {
                    return MSG.common_val_none();
                }
                if (null != globalPermissions && globalPermissions.contains(Permission.MANAGE_SETTINGS)) {
                    int typeId = def.getResource().getResourceType().getId();
                    int templateId = def.getTemplate().getId();
                    String link = LinkManager.getDriftTemplateLink(typeId, templateId);
                    return LinkManager.getHref(link, o.toString());

                } else {
                    return o.toString();
                }
            }
        });
        templateField.setCanSortClientOnly(true);
        fields.add(templateField);

        ListGridField editField = new ListGridField(ATTR_EDIT, hasWriteAccess ? MSG.common_title_edit() : MSG.common_title_view_mode());
        editField.setType(ListGridFieldType.IMAGE);
        editField.setAlign(Alignment.CENTER);
        editField.setShowHover(true);
        editField.setCanSort(false);
        editField.addRecordClickHandler(new RecordClickHandler() {

            public void onRecordClick(RecordClickEvent event) {
                switch (entityContext.getType()) {
                case Resource:
                    CoreGUI.goToView(LinkManager.getDriftDefinitionEditLink(entityContext.getResourceId(), event
                        .getRecord().getAttributeAsInt(ATTR_ID)));
                    break;
                default:
                    throw new IllegalArgumentException("Entity Type not supported");
                }
            }
        });
        editField.setHoverCustomizer(new HoverCustomizer() {

            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {

                return MSG.view_drift_table_hover_edit();
            }
        });
        fields.add(editField);

        if (this.entityContext.type != EntityContext.Type.Resource) {
            ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
            resourceNameField.setCellFormatter(new CellFormatter() {
                public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                    Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
                    String url = LinkManager.getResourceLink(resourceId);
                    return LinkManager.getHref(url, o.toString());
                }
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

        idField.setWidth(38);
        fields.add(idField);

        ListGridField resourceField = createResourceField();
        resourceField.setWidth("25%");
        resourceField.setCellFormatter(new CellFormatter() {
            public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
                return LinkManager.getHref(url, o.toString());
            }
        });
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

        }

        @Override
        protected void configureTable() {
            ListGridField fieldResource = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
            fieldResource.setCellFormatter(new CellFormatter() {
                public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                    String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
                    return LinkManager.getHref(url, o.toString());
                }
            });
View Full Code Here

Examples of com.smartgwt.client.widgets.grid.CellFormatter

     */
    public ArrayList<ListGridField> getListGridFields() {
        ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);

        ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, "chart");
        sparklineField.setCellFormatter(new CellFormatter() {
            @Override
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (value == null) {
                    return "";
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.