List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder append
public SafeHtmlBuilder append(SafeHtml html)
From source file:com.googlecode.mgwt.ui.client.widget.list.celllist.BasicCell.java
License:Apache License
@Override public void render(SafeHtmlBuilder safeHtmlBuilder, final T model) { safeHtmlBuilder.append(TEMPLATE.content(styleName, getDisplayString(model))); }
From source file:com.googlecode.mgwt.ui.client.widget.list.celllist.CellList.java
License:Apache License
/** * Render a List of models in this cell list * * @param models the list of models to render *///from w ww. j a v a 2s . c om public void render(List<T> models) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); for (int i = 0; i < models.size(); i++) { T model = models.get(i); SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); String clazz = this.appearance.css().entry() + " "; if (cell.canBeSelected(model)) { clazz += this.appearance.css().canbeSelected() + " "; } if (i == 0) { clazz += this.appearance.css().first() + " "; } if (models.size() - 1 == i) { clazz += this.appearance.css().last() + " "; } cell.render(cellBuilder, model); sb.append(entryTemplate.li(i, clazz, cellBuilder.toSafeHtml())); } final String html = sb.toSafeHtml().asString(); getElement().setInnerHTML(html); if (models.size() > 0) { String innerHTML = getElement().getInnerHTML(); if ("".equals(innerHTML.trim())) { fixBug(html); } } }
From source file:com.googlecode.mgwt.ui.client.widget.list.celllist.GroupingCellList.java
License:Apache License
/** * render a given set of models/* w w w . j ava 2 s .c o m*/ * * @param groups the model to render */ public void renderGroup(List<CellGroup<G, T>> groups) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); int count = 0; map.clear(); modelMap.clear(); int groupCounter = 0; int renderedGroups = 0; for (CellGroup<G, T> cellGroup : groups) { if (cellGroup.getMember().isEmpty()) { groupCounter++; continue; } // render header of group SafeHtmlBuilder headerBuilder = new SafeHtmlBuilder(); header.render(headerBuilder, cellGroup.getGroup()); sb.append(headerTemplate.li(headerBuilder.toSafeHtml(), this.groupAppearance.css().listHeadElement())); // render members of group List<T> models = cellGroup.getMember(); for (T model : models) { SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); String clazz = this.groupAppearance.css().entry() + " "; if (cell.canBeSelected(model)) { clazz += this.groupAppearance.css().canbeSelected() + " "; } cell.render(cellBuilder, model); sb.append(entryTemplate.li(count, clazz, cellBuilder.toSafeHtml())); modelMap.put(count, model); count++; } map.put(renderedGroups, groupCounter); renderedGroups++; groupCounter++; } final String html = sb.toSafeHtml().asString(); getElement().setInnerHTML(html); if (count > 0) { String innerHTML = getElement().getInnerHTML(); if ("".equals(innerHTML.trim())) { fixBug(html); } } }
From source file:com.gwt2go.dev.client.ui.widget.celltree.CellTreeNodeSafeHtmlRenderer.java
License:Apache License
@Override public void render(GotoPlacesModel object, SafeHtmlBuilder builder) { builder.append(SafeHtmlUtils.fromString(object.getName())); }
From source file:com.gwt2go.dev.client.ui.widget.celltree.CellTreeRooterCell.java
License:Apache License
@Override public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { sb.append(value); }//from w ww . j a v a2s. c o m }
From source file:com.gwtcx.client.resources.ImageCell.java
License:Open Source License
@Override protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return;/* w ww .j a va 2 s.c o m*/ } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString("float:left; cursor:pointer;"); SafeHtml rendered = template.cell("image-1", imageStyle, PLACEHOLDER); sb.append(rendered); }
From source file:com.gwtcx.extgwt.client.desktop.view.AbstractSettingsView.java
License:Open Source License
public ColumnModel<ContextAreaModel> getContextAreaColumModel() { ColumnConfig<ContextAreaModel, String> column1IconColumnConfig = new ColumnConfig<ContextAreaModel, String>( property.column1Icon(), ContextAreaGrid.LARGE_ICON_COLUMN_WIDTH, ""); column1IconColumnConfig.setCell(new ImageCell() { @Override//w w w . j a v a 2s.c om protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString( "margin-left: 10px; width:48px; height:48px; position:relative; cursor:pointer;"); SafeHtml rendered = template.cell("column1Icon", imageStyle, getIcon(data.asString())); sb.append(rendered); } }); ColumnConfig<ContextAreaModel, String> column1DisplayNameColumnConfig = new ColumnConfig<ContextAreaModel, String>( property.column1DisplayName(), ContextAreaGrid.DISPLAY_NAME_COLUMN_WIDTH, ""); column1DisplayNameColumnConfig .setCell(new AbstractSafeHtmlCell<String>(SimpleSafeHtmlRenderer.getInstance()) { @Override protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } ContextAreaModel model = (ContextAreaModel) getGrid().getStore().get(context.getIndex()); sb.appendHtmlConstant("<span>" + "<b>" + data.asString() + "</b><br />" + model.getColumn1Description() + "</span>"); } }); ColumnConfig<ContextAreaModel, String> column2IconColumnConfig = new ColumnConfig<ContextAreaModel, String>( property.column2Icon(), ContextAreaGrid.LARGE_ICON_COLUMN_WIDTH, ""); column2IconColumnConfig.setCell(new ImageCell() { @Override protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString( "margin-left: 10px; width:48px; height:48px; position:relative; cursor:pointer;"); SafeHtml rendered = template.cell("column2Icon", imageStyle, getIcon(data.asString())); sb.append(rendered); } }); ColumnConfig<ContextAreaModel, String> column2DisplayNameColumnConfig = new ColumnConfig<ContextAreaModel, String>( property.column2DisplayName(), ContextAreaGrid.DISPLAY_NAME_COLUMN_WIDTH, ""); column2DisplayNameColumnConfig .setCell(new AbstractSafeHtmlCell<String>(SimpleSafeHtmlRenderer.getInstance()) { @Override protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } ContextAreaModel model = (ContextAreaModel) getGrid().getStore().get(context.getIndex()); sb.appendHtmlConstant("<span>" + "<b>" + data.asString() + "</b><br />" + model.getColumn2Description() + "</span>"); } }); List<ColumnConfig<ContextAreaModel, ?>> columnConfigList = new ArrayList<ColumnConfig<ContextAreaModel, ?>>(); columnConfigList.add(column1IconColumnConfig); columnConfigList.add(column1DisplayNameColumnConfig); columnConfigList.add(column2IconColumnConfig); columnConfigList.add(column2DisplayNameColumnConfig); ColumnModel<ContextAreaModel> columnModel = new ColumnModel<ContextAreaModel>(columnConfigList); return columnModel; }
From source file:com.gwtcx.extgwt.client.widgets.grid.AccountsContextAreaGrid.java
License:Open Source License
public static ColumnModel<AccountsDto> getColumConfig() { ColumnConfig<AccountsDto, String> rowIconColumnConfig = new ColumnConfig<AccountsDto, String>(property.id(), SMALL_ICON_COLUMN_WIDTH, ""); rowIconColumnConfig.setCell(new ImageCell() { @Override/* w w w . j a va2s . co m*/ protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString("float:left;cursor:hand;cursor:pointer;"); SafeHtml rendered = template.cell("row-icon", imageStyle, ROW_ICON); sb.append(rendered); } }); rowIconColumnConfig.setSortable(false); rowIconColumnConfig.setResizable(false); rowIconColumnConfig.setMenuDisabled(true); ColumnConfig<AccountsDto, String> accountIconColumnConfig = new ColumnConfig<AccountsDto, String>( property.id(), SMALL_ICON_COLUMN_WIDTH + 4, ""); // "#" accountIconColumnConfig.setCell(new ImageCell() { @Override protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString("float:left;cursor:hand;cursor:pointer;"); SafeHtml rendered = template.cell("entity-icon", imageStyle, ENTITY_ICON); sb.append(rendered); } }); accountIconColumnConfig.setSortable(false); accountIconColumnConfig.setResizable(false); accountIconColumnConfig.setMenuDisabled(true); ColumnConfig<AccountsDto, String> accountNameColumnConfig = new ColumnConfig<AccountsDto, String>( property.accountName(), ACCOUNT_NAME_COLUMN_WIDTH, I18nUtil.getConstant().accountName()); ColumnConfig<AccountsDto, String> mainPhoneColumnConfig = new ColumnConfig<AccountsDto, String>( property.mainPhone(), MAIN_PHONE_COLUMN_WIDTH, I18nUtil.getConstant().mainPhone()); ColumnConfig<AccountsDto, String> locationColumnConfig = new ColumnConfig<AccountsDto, String>( property.location(), LOCATION_COLUMN_WIDTH, I18nUtil.getConstant().location()); ColumnConfig<AccountsDto, String> primaryContactColumnConfig = new ColumnConfig<AccountsDto, String>( property.primaryContact(), PRIMARY_CONTACT_COLUMN_WIDTH, I18nUtil.getConstant().primaryContact()); ColumnConfig<AccountsDto, String> emailPrimaryContactColumnConfig = new ColumnConfig<AccountsDto, String>( property.emailPrimaryContact(), EMAIL_PRIMARY_CONTACT_COLUMN_WIDTH, I18nUtil.getConstant().emailPrimaryContact()); List<ColumnConfig<AccountsDto, ?>> columnConfigList = new ArrayList<ColumnConfig<AccountsDto, ?>>(); columnConfigList.add(rowIconColumnConfig); columnConfigList.add(accountIconColumnConfig); columnConfigList.add(accountNameColumnConfig); columnConfigList.add(mainPhoneColumnConfig); columnConfigList.add(locationColumnConfig); columnConfigList.add(primaryContactColumnConfig); columnConfigList.add(emailPrimaryContactColumnConfig); ColumnModel<AccountsDto> columnModel = new ColumnModel<AccountsDto>(columnConfigList); return columnModel; }
From source file:com.gwtcx.extgwt.client.widgets.grid.ContactsContextAreaGrid.java
License:Open Source License
public static ColumnModel<ContactsDto> getColumnConfig() { ColumnConfig<ContactsDto, String> rowIconColumnConfig = new ColumnConfig<ContactsDto, String>(property.id(), SMALL_ICON_COLUMN_WIDTH, ""); rowIconColumnConfig.setCell(new ImageCell() { @Override/* w w w . j a va2s. com*/ protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString("float:left;cursor:hand;cursor:pointer;"); SafeHtml rendered = template.cell("row-icon", imageStyle, ROW_ICON); sb.append(rendered); } }); rowIconColumnConfig.setSortable(false); rowIconColumnConfig.setResizable(false); rowIconColumnConfig.setMenuDisabled(true); ColumnConfig<ContactsDto, String> entityIconColumnConfig = new ColumnConfig<ContactsDto, String>( property.id(), SMALL_ICON_COLUMN_WIDTH + 4, ""); entityIconColumnConfig.setCell(new ImageCell() { @Override protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString("float:left;cursor:hand;cursor:pointer;"); SafeHtml rendered = template.cell("entity-icon", imageStyle, ENTITY_ICON); sb.append(rendered); } }); entityIconColumnConfig.setSortable(false); entityIconColumnConfig.setResizable(false); entityIconColumnConfig.setMenuDisabled(true); ColumnConfig<ContactsDto, String> fullNameColumnConfig = new ColumnConfig<ContactsDto, String>( property.fullName(), FULL_NAME_COLUMN_WIDTH, I18nUtil.getConstant().fullName()); ColumnConfig<ContactsDto, String> parentCustomerColumnConfig = new ColumnConfig<ContactsDto, String>( property.parentCustomer(), PARENT_CUSTOMER_COLUMN_WIDTH, I18nUtil.getConstant().parentCustomer()); ColumnConfig<ContactsDto, String> cityColumnConfig = new ColumnConfig<ContactsDto, String>(property.city(), CITY_COLUMN_WIDTH, I18nUtil.getConstant().city()); // ColumnConfig<ContactsDto, String> locationColumnConfig = new ColumnConfig<ContactsDto, String>(property.location(), // LOCATION_COLUMN_WIDTH, I18nUtil.getConstant().location()); ColumnConfig<ContactsDto, String> phoneColumnConfig = new ColumnConfig<ContactsDto, String>( property.phone(), PHONE_COLUMN_WIDTH, I18nUtil.getConstant().phone()); ColumnConfig<ContactsDto, String> businessPhoneColumnConfig = new ColumnConfig<ContactsDto, String>( property.businessPhone(), BUSINESS_PHONE_COLUMN_WIDTH, I18nUtil.getConstant().businessPhone()); ColumnConfig<ContactsDto, String> emailColumnConfig = new ColumnConfig<ContactsDto, String>( property.email(), EMAIL_COLUMN_WIDTH, I18nUtil.getConstant().email()); List<ColumnConfig<ContactsDto, ?>> columnConfigList = new ArrayList<ColumnConfig<ContactsDto, ?>>(); columnConfigList.add(rowIconColumnConfig); columnConfigList.add(entityIconColumnConfig); columnConfigList.add(fullNameColumnConfig); columnConfigList.add(parentCustomerColumnConfig); columnConfigList.add(cityColumnConfig); columnConfigList.add(phoneColumnConfig); columnConfigList.add(businessPhoneColumnConfig); columnConfigList.add(emailColumnConfig); ColumnModel<ContactsDto> columnModel = new ColumnModel<ContactsDto>(columnConfigList); return columnModel; }
From source file:com.gwtcx.extgwt.client.widgets.NavigationPaneSection.java
License:Open Source License
public ColumnModel<NavigationPaneSectionModel> getColumModel() { ColumnConfig<NavigationPaneSectionModel, String> iconColumnConfig = new ColumnConfig<NavigationPaneSectionModel, String>( property.icon(), NavigationPaneSectionGrid.SMALL_ICON_COLUMN_WIDTH + 4, ""); iconColumnConfig.setCell(new ImageCell() { @Override/* w w w . ja v a 2 s . com*/ protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data == null) { return; } SafeStyles imageStyle = SafeStylesUtils.fromTrustedString("float:left;cursor:hand;cursor:pointer;"); SafeHtml rendered = template.cell("image-1", imageStyle, getIcon(data.asString())); sb.append(rendered); } }); ColumnConfig<NavigationPaneSectionModel, String> displayNameColumnConfig = new ColumnConfig<NavigationPaneSectionModel, String>( property.displayName(), NavigationPaneSectionGrid.DISPLAY_NAME_COLUMN_WIDTH, ""); List<ColumnConfig<NavigationPaneSectionModel, ?>> columnConfigList = new ArrayList<ColumnConfig<NavigationPaneSectionModel, ?>>(); columnConfigList.add(iconColumnConfig); columnConfigList.add(displayNameColumnConfig); ColumnModel<NavigationPaneSectionModel> columnModel = new ColumnModel<NavigationPaneSectionModel>( columnConfigList); return columnModel; }