Package com.smartgwt.client.widgets.grid

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


        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

        }

        @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

     */
    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

            BundleDestinationDataSource.FIELD_LATEST_DEPLOY_STATUS, MSG.view_bundle_dest_lastDeploymentStatus());

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

        nameField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
                Integer bundleId = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_BUNDLE_ID);
                Integer bundleDestId = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_ID);
                return "<a href=\"" + LinkManager.getBundleDestinationLink(bundleId, bundleDestId) + "\">"
                    + StringUtility.escapeHtml(value.toString()) + "</a>";
            }
        });

        groupNameField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
                Integer groupId = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_GROUP_ID);
                return "<a href=\"" + LinkManager.getResourceGroupLink(groupId) + "\">"
                    + StringUtility.escapeHtml(value.toString()) + "</a>";
            }
        });

        bundleNameField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
                Integer bid = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_BUNDLE_ID);
                return "<a href=\"" + LinkManager.getBundleLink(bid) + "\">"
                    + StringUtility.escapeHtml(value.toString()) + "</a>";
            }
View Full Code Here

        idField.setType(ListGridFieldType.INTEGER);
        idField.setWidth("50");

        ListGridField nameField = new ListGridField(BundleGroupsDataSource.FIELD_NAME, MSG.common_title_name());
        nameField.setWidth("33%");
        nameField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int i, int i1) {
                return "<a href=\"" + record.getAttribute(BundleGroupsDataSource.FIELD_NAMELINK) + "\">"
                    + StringUtility.escapeHtml(String.valueOf(value)) + "</a>";
            }
        });

        ListGridField descField = new ListGridField(BundleGroupsDataSource.FIELD_DESCRIPTION,
            MSG.common_title_description());
        descField.setWidth("*");
        descField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int i, int i1) {
                return StringUtility.escapeHtml(String.valueOf(value));
            }
        });

View Full Code Here

        }

        @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

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

        // only users that are authorized can see deployments
        if (canDeploy) {
            nameField.setCellFormatter(new CellFormatter() {
                public String format(Object value, ListGridRecord record, int i, int i1) {
                    return "<a href=\""
                        + LinkManager.getBundleDeploymentLink(
                            record.getAttributeAsInt(BundleDeploymentDataSource.FIELD_BUNDLE_ID),
                            record.getAttributeAsInt(BundleDeploymentDataSource.FIELD_ID)) + "\">"
                        + StringUtility.escapeHtml(String.valueOf(value)) + "</a>";
                }
            });
        } else {
            nameField.setCellFormatter(new EscapedHtmlCellFormatter());
        }

        descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());

        bundleVersionField.setCellFormatter(new CellFormatter() {
            public String format(Object o, ListGridRecord record, int i, int i1) {
                return "<a href=\""
                    + LinkManager.getBundleVersionLink(
                        record.getAttributeAsInt(BundleDeploymentDataSource.FIELD_BUNDLE_ID),
                        record.getAttributeAsInt(BundleDeploymentDataSource.FIELD_BUNDLE_VERSION_ID)) + "\">"
View Full Code Here

        ListGridField pathField = new ListGridField(ATTR_PATH, MSG.common_title_path());
        fields.add(pathField);

        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) {
                    String url = LinkManager
                        .getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
                    return LinkManager.getHref(url, o.toString());
                }
View Full Code Here

    /**
     * Override if you don't want the detailsLinkColumn to have the default link wrapper.
     * @return the desired CellFormatter.
     */
    protected CellFormatter getDetailsLinkColumnCellFormatter() {
        return new CellFormatter() {
            public String format(Object value, ListGridRecord record, int i, int i1) {
                if (value == null) {
                    return "";
                }
                ID recordId = getId(record);
View Full Code Here

TOP

Related Classes of com.smartgwt.client.widgets.grid.CellFormatter

Copyright © 2018 www.massapicom. 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.