List of usage examples for com.google.gwt.safecss.shared SafeStylesUtils fromTrustedString
public static SafeStyles fromTrustedString(String s)
Returns a SafeStyles constructed from a trusted string, i.e., without escaping the string.
From source file:com.arcbees.chosen.client.ChosenImpl.java
License:Apache License
private SafeHtml resultAddOption(OptionItem option) { if (!option.isDisabled()) { option.domId = containerId + "_o_" + option.getArrayIndex(); StringBuilder classes = buildOptionStyleClass(option); classes.append(" ").append(css.activeResult()); SafeStyles safeStyles = SafeStylesUtils.fromTrustedString(option.getStyle()); if (option.getHtml() != null && !option.getHtml().trim().isEmpty()) { SafeHtml html = fromTrustedString(option.getHtml()); return ChosenTemplate.templates.option(option.getDomId(), classes.toString().trim(), safeStyles, html);/* ww w. j ava 2 s . com*/ } else { return ChosenTemplate.templates.option(option.getDomId(), classes.toString().trim(), safeStyles, option.getText()); } } return null; }
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;/*from w w w . j av a2s . c om*/ } 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//from w w w . j ava 2s .com 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/*from w w w . j ava 2s . c o 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/*from www. j a v a2 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("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/*from w ww. j a va 2 s . c o 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("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; }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.grid.CellGridExample.java
License:sencha.com license
@Override public Widget asWidget() { // reduce the padding on text element as we have widgets in the cells SafeStyles textStyles = SafeStylesUtils.fromTrustedString("padding: 1px 3px;"); ColumnConfig<Plant, String> nameColumn = new ColumnConfig<Plant, String>(properties.name(), 100, "Name"); // IMPORTANT we want the text element (cell parent) to only be as wide as // the cell and not fill the cell nameColumn.setColumnTextClassName(CommonStyles.get().inlineBlock()); nameColumn.setColumnTextStyle(textStyles); TextButtonCell button = new TextButtonCell(); button.addSelectHandler(new SelectHandler() { @Override//www .j av a 2 s .com public void onSelect(SelectEvent event) { Context c = event.getContext(); int row = c.getIndex(); Plant p = store.get(row); Info.display("Event", "The " + p.getName() + " was clicked."); } }); nameColumn.setCell(button); DateCell dateCell = new DateCell(); dateCell.getDatePicker().addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { Info.display("Date Selected", "You selected " + DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(event.getValue())); } }); dateCell.setPropertyEditor( new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT))); ColumnConfig<Plant, Date> availableColumn = new ColumnConfig<Plant, Date>(properties.available(), 170, "Date"); availableColumn.setColumnTextStyle(SafeStylesUtils.fromTrustedString("padding: 2px 3px;")); availableColumn.setCell(dateCell); ListStore<String> lights = new ListStore<String>(new ModelKeyProvider<String>() { @Override public String getKey(String item) { return item; } }); lights.add("Mostly Shady"); lights.add("Mostly Sunny"); lights.add("Shade"); lights.add("Sunny"); lights.add("Sun or Shade"); ColumnConfig<Plant, String> lightColumn = new ColumnConfig<Plant, String>(properties.light(), 130, "Light"); lightColumn.setColumnTextStyle(SafeStylesUtils.fromTrustedString("padding: 2px 3px;")); ComboBoxCell<String> lightCombo = new ComboBoxCell<String>(lights, new LabelProvider<String>() { @Override public String getLabel(String item) { return item; } }); lightCombo.addSelectionHandler(new SelectionHandler<String>() { @Override public void onSelection(SelectionEvent<String> event) { CellSelectionEvent<String> sel = (CellSelectionEvent<String>) event; Plant p = store.get(sel.getContext().getIndex()); Info.display("Lightness Selected", p.getName() + " selected " + event.getSelectedItem()); } }); lightCombo.setTriggerAction(TriggerAction.ALL); lightCombo.setForceSelection(true); lightColumn.setCell(lightCombo); lightCombo.setWidth(110); ColumnConfig<Plant, String> colorColumn = new ColumnConfig<Plant, String>(properties.color(), 140, "Color"); colorColumn.setColumnTextStyle(SafeStylesUtils.fromTrustedString("padding: 2px 3px;")); // This next line only works with any appearance that extends from Base ColorPaletteBaseAppearance appearance = GWT.create(ColorPaletteAppearance.class); appearance.setColumnCount(6); ColorPaletteCell colorPalette = new ColorPaletteCell(appearance, COLORS, COLORS) { @Override public boolean handlesSelection() { return true; } }; colorPalette.addSelectionHandler(new SelectionHandler<String>() { @Override public void onSelection(SelectionEvent<String> event) { Info.display("Color Selected", "You selected " + event.getSelectedItem()); } }); colorColumn.setCell(colorPalette); ColumnConfig<Plant, Integer> difficultyColumn = new ColumnConfig<Plant, Integer>(properties.difficulty(), 150, "Durability"); SliderCell slider = new SliderCell() { @Override public boolean handlesSelection() { return true; } }; slider.setWidth(140); difficultyColumn.setCell(slider); final ColumnConfig<Plant, Double> progressColumn = new ColumnConfig<Plant, Double>(properties.progress(), 150, "Progress"); final ProgressBarCell progress = new ProgressBarCell() { @Override public boolean handlesSelection() { return true; } }; progress.setProgressText("{0}% Complete"); progress.setWidth(140); progressColumn.setCell(progress); List<ColumnConfig<Plant, ?>> l = new ArrayList<ColumnConfig<Plant, ?>>(); l.add(nameColumn); l.add(availableColumn); l.add(lightColumn); l.add(colorColumn); l.add(difficultyColumn); l.add(progressColumn); ColumnModel<Plant> cm = new ColumnModel<Plant>(l); store = new ListStore<Plant>(properties.key()); List<Plant> plants = new ArrayList<Plant>(TestData.getPlants()); for (Plant p : plants) { p.setColor(COLORS[Random.nextInt(4)]); } store.addAll(plants); final Grid<Plant> grid = new Grid<Plant>(store, cm); grid.setBorders(true); grid.getView().setAutoExpandColumn(nameColumn); grid.getView().setTrackMouseOver(false); grid.getColumnModel() .addColumnWidthChangeHandler(new CellColumnResizer<Plant, Double>(grid, progressColumn, progress)); FramedPanel cp = new FramedPanel(); cp.setHeadingText("Cell Grid Example"); cp.setWidget(grid); cp.setPixelSize(920, 410); cp.addStyleName("margin-10"); cp.setButtonAlign(BoxLayoutPack.CENTER); cp.addButton(new TextButton("Reset", new SelectHandler() { @Override public void onSelect(SelectEvent event) { store.rejectChanges(); } })); cp.addButton(new TextButton("Save", new SelectHandler() { @Override public void onSelect(SelectEvent event) { store.commitChanges(); } })); return cp; }
From source file:com.sencha.gxt.theme.base.client.button.ButtonCellDefaultAppearance.java
License:sencha.com license
protected void writeIcon(SafeHtmlBuilder builder, ImageResource icon, int height) { SafeHtml iconHtml = AbstractImagePrototype.create(icon).getSafeHtml(); if (height == -1) { builder.append(templates.icon(style.iconWrap(), iconHtml)); } else {/*from w w w. ja v a2 s .c o m*/ int adjustedHeight = height - heightOffset; SafeStyles heightStyle = SafeStylesUtils.fromTrustedString("height:" + adjustedHeight + "px;"); builder.append(templates.iconWithStyles(style.iconWrap(), heightStyle, iconHtml)); } }
From source file:com.sencha.gxt.theme.base.client.button.ButtonCellDefaultAppearance.java
License:sencha.com license
protected void writeValue(SafeHtmlBuilder builder, SafeHtml value, int width, int height) { SafeStylesBuilder sb = new SafeStylesBuilder(); if (height > 0) { int adjustedHeight = height - heightOffset; sb.append(SafeStylesUtils.fromTrustedString("height:" + adjustedHeight + "px;")); }/* w w w .j a v a 2 s.c o m*/ if (width > 0) { sb.append(SafeStylesUtils.fromTrustedString("width:" + width + "px;")); } builder.append(templates.textWithStyles(style.text(), sb.toSafeStyles(), value)); }
From source file:com.sencha.gxt.theme.base.client.colorpalette.ColorPaletteBaseAppearance.java
License:sencha.com license
@Override public void render(Context context, String value, String[] colors, String[] labels, SafeHtmlBuilder result) { result.appendHtmlConstant("<table class=\"" + style.colorPalette() + "\">"); int mark = 0; int rows = (colors.length + (columnCount - 1)) / columnCount; for (int i = 0; i < rows; i++) { result.appendHtmlConstant("<tr>"); for (int j = 0; j < columnCount && mark < colors.length; j++) { String c = colors[mark]; String label = labels[mark]; SafeHtml cellTemplate = template.cellTemplate(style, label, XDOM.getUniqueId(), i, j, c, SafeStylesUtils .fromTrustedString("background-color: #" + SafeHtmlUtils.htmlEscape(c) + ";"), c.equals(value) ? style.selected() : ""); result.append(cellTemplate); mark++;/*from w ww .j a v a 2 s .c om*/ } result.appendHtmlConstant("</tr>"); } result.appendHtmlConstant("</table>"); }