本文整理汇总了Java中com.google.gwt.safecss.shared.SafeStylesUtils类的典型用法代码示例。如果您正苦于以下问题:Java SafeStylesUtils类的具体用法?Java SafeStylesUtils怎么用?Java SafeStylesUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeStylesUtils类属于com.google.gwt.safecss.shared包,在下文中一共展示了SafeStylesUtils类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createClosedArrowAndFolderSafeHtml
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
private void createClosedArrowAndFolderSafeHtml(SafeHtmlBuilder sb,
SafeStyles imgStyle) {
SafeHtml rendered;
if (currentRow.getChildren().size() != 0) {
rendered = nodeImageTemplate.cell("ICON_ARROW__CLOSE", imgStyle,
ICON_ARROW_CLOSE);
} else {
SafeStyles imageWidthStyle = SafeStylesUtils
.fromTrustedString("float:left;width:16.0px;");
rendered = nodeImageTemplate.cell("ICON_ARROW__CLOSE",
imageWidthStyle, ICON_CLEAR);
}
sb.append(rendered);
if (treeGrid.isSelectable()) {
createCheckBoxImg(sb, imgStyle);
}
rendered = nodeImageTemplate.cell("ICON_FOLDER__CLOSE", imgStyle,
ICON_FOLDER_CLOSE);
sb.append(rendered);
}
示例2: decorate
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
public static String decorate(SafeHtml toDecorate, String aId, PublishedCell aCell, VerticalAlignmentConstant valign, SafeHtmlBuilder sb) {
SafeStylesBuilder stb = new SafeStylesBuilder();
SafeUri imgSrc = null;
if (aCell != null) {
stb.append(SafeStylesUtils.fromTrustedString(aCell.toStyledWOBackground()));
if (aCell.getIcon() != null) {
ImageResource icon = aCell.getIcon();
imgSrc = icon.getSafeUri();
}
}
String decorId;
if (aId != null && !aId.isEmpty()) {
decorId = aId;
} else {
decorId = Document.get().createUniqueId();
}
if (imgSrc != null)
sb.append(RenderedEditorCell.PaddedCell.INSTANCE.generate(stb.toSafeStyles(), imgSrc, decorId, toDecorate));
else
sb.append(RenderedEditorCell.PaddedCell.INSTANCE.generate(stb.toSafeStyles(), decorId, toDecorate));
return decorId;
}
示例3: createClearIcon
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
private void createClearIcon(SafeHtmlBuilder sb, SafeStyles imgStyle,
int times) {
imageWidthStyle = SafeStylesUtils
.fromTrustedString("float:left;width:16.0px;");
for (int i = 0; i < times; i++) {
rendered = nodeImageTemplate.cell("ICON_ARROW__CLOSE",
imageWidthStyle, ICON_CLEAR);
sb.append(rendered);
}
}
示例4: createCheckBoxImg
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
/**
* @param sb
* @param imgStyle
*/
@SuppressWarnings("unchecked")
private void createCheckBoxImg(SafeHtmlBuilder sb, SafeStyles imgStyle) {
imageWidthStyle = SafeStylesUtils
.fromTrustedString("float:left;width:16.0px;margin-right:2px;");
SelectionModel<T> sm = (SelectionModel<T>) treeGrid.getSelectionModel();
boolean selected = sm.isSelected(currentRow);
if (selected) {
if (currentRow.getChildren().size() > 0) {
if (currentRow.isChidlrenSelected()) {
rendered = nodeImageTemplate.cell("ICON_CHECKBOX",
imageWidthStyle, ICON_CHECHBOX_CHILDS_SELECTED);
} else {
rendered = nodeImageTemplate.cell("ICON_CHECKBOX",
imageWidthStyle, ICON_CHECHBOX_TRUE);
}
} else {
rendered = nodeImageTemplate.cell("ICON_CHECKBOX",
imageWidthStyle, ICON_CHECHBOX_TRUE);
}
} else {
rendered = nodeImageTemplate.cell("ICON_CHECKBOX", imageWidthStyle,
ICON_CHECHBOX_FALSE);
}
sb.append(rendered);
}
示例5: render
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void render(com.google.gwt.cell.client.Cell.Context context,
SafeHtml data, SafeHtmlBuilder sb) {
currentRow = (T) treeGrid.getDataStore().getList()
.get(context.getIndex());
/*
* Always do a null check on the value. Cell widgets can pass null to
* cells if the underlying data contains a null, or if the data arrives
* out of order.
*/
if (data == null) {
return;
}
// generate the image cell
SafeStyles imgStyle = SafeStylesUtils
.fromTrustedString("float:left;cursor:hand;cursor:pointer;");
SafeStyles valueStyle = SafeStylesUtils
.fromTrustedString("float:left;");
SafeHtml rendered;
if (currentRow.getChildren().size() > 0) {
createClearIcon(sb, imgStyle, currentRow.getLevel());
if (!currentRow.isExpand()) {
createClosedArrowAndFolderSafeHtml(sb, imgStyle);
} else {
createOpenArrowAndFolderSafeHtml(sb, imgStyle);
}
} else {
createClearIcon(sb, imgStyle, currentRow.getLevel() + 1);
if (treeGrid.isSelectable()) {
createCheckBoxImg(sb, imgStyle);
}
createLeafSafeHtml(sb, imgStyle);
}
// generate the value cell
rendered = nodeImageTemplate.cellNode("EXPANDABLE_VALUE", valueStyle,
SafeHtmlUtils.fromString(data.asString()));
sb.append(rendered);
}
示例6: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
public void addMenuItem(ImageResource image, String text,
final ActionMenuItemListener<T> listener) {
SafeHtml html = null;
if (image != null) {
SafeUri uri = image.getSafeUri();
int left = image.getLeft();
int top = image.getTop();
int width = image.getWidth();
int height = image.getHeight();
int paddingRight = width + 8;
String background = "url(\"" + uri.asString() + "\") no-repeat "
+ (-left + "px ") + (-top + "px");
SafeStylesBuilder builder = new SafeStylesBuilder();
builder.trustedNameAndValue("background", background)
.width(width, Unit.PX).height(height, Unit.PX)
.paddingRight(paddingRight, Unit.PX);
SafeStyles style = SafeStylesUtils.fromTrustedString(builder
.toSafeStyles().asString());
html = template.menuImageItemContent(style, text);
} else {
html = template.menuItemContent(text);
}
final MenuItem item = new MenuItem(html, new Command() {
@Override
public void execute() {
if (actionsPopup != null && actionsPopup.isVisible())
actionsPopup.hide();
listener.onMenuItemSelected(currentValue);
}
});
menu.addItem(item);
}
示例7: ActionButtonCell
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
public ActionButtonCell(ImageResource imageResource,
String text,
boolean small,
ActionListener<T> listener,
ActionValidator<T> validator) {
super(CLICK, KEYDOWN);
this.listener = listener;
this.validator = validator;
if (template == null) {
template = GWT.create(Template.class);
}
SafeUri uri = imageResource.getSafeUri();
int width = imageResource.getWidth();
int height = imageResource.getHeight();
int paddingLeft = width;
String background = "url(\"" + uri.asString() + "\") no-repeat scroll right center";
SafeStylesBuilder builder = new SafeStylesBuilder();
builder
.trustedNameAndValue("background", background)
.width(width, Unit.PX)
.height(height, Unit.PX)
.paddingLeft(paddingLeft, Unit.PX);
SafeStyles style = SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString());
if (small) {
this.actionButtonHtml = template.actionButtonSmall(Utils.avroUiStyle.cellButton(),
Utils.avroUiStyle.cellButtonSmall(), text, style);
} else {
this.actionButtonHtml = template.actionButton(Utils.avroUiStyle.cellButton(), text, style);
}
}
示例8: FilterTextInputCell
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
public FilterTextInputCell(double width, Unit widthUnit) {
super(BrowserEvents.BLUR, BrowserEvents.CHANGE, BrowserEvents.KEYUP, PASTE);
if (template == null) {
template = GWT.create(Template.class);
}
if (width > 0) {
inputStyle = SafeStylesUtils.forWidth(width, widthUnit);
}
}
示例9: render
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
// Get the view data.
Object key = context.getKey();
ValidationData viewData = getViewData(key);
if (viewData != null && viewData.getValue().equals(value)) {
// Clear the view data if the value is the same as the current value.
clearViewData(key);
viewData = null;
}
/*
* If viewData is null, just paint the contents black. If it is non-null,
* show the pending value and paint the contents red if they are known to
* be invalid.
*/
String pendingValue = (viewData == null) ? null : viewData.getValue();
boolean invalid = (viewData == null) ? false : viewData.isInvalid();
String color = pendingValue != null ? (invalid ? "red" : "blue") : "black";
SafeStyles safeColor = SafeStylesUtils.fromTrustedString("color: " + color + ";");
sb.append(template.input(pendingValue != null ? pendingValue : value, safeColor));
if (invalid) {
sb.appendHtmlConstant(" <span style='color:red;'>");
sb.append(errorMessage);
sb.appendHtmlConstant("</span>");
}
}
示例10: getSafeHtml
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
public SafeHtml getSafeHtml(SafeUri url,int left,int top,int width,int height)
{
String style = "width: " + width + "px; height: " + height + "px; background: url("
+ url.asString() + ") " + "no-repeat " + (-left + "px ")
+ (-top + "px;") + "background-size: "+ width + "px " + height + "px;";
return getTemplate().image(clearImage, SafeStylesUtils.fromTrustedString(style));
}
示例11: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
public void addMenuItem(ImageResource image, String text,
final ActionMenuItemListener listener) {
SafeHtml html = null;
if (image != null) {
SafeUri uri = image.getSafeUri();
int left = image.getLeft();
int top = image.getTop();
int width = image.getWidth();
int height = image.getHeight();
int paddingRight = width + 8;
String background = "url(\"" + uri.asString() + "\") no-repeat "
+ (-left + "px ") + (-top + "px");
SafeStylesBuilder builder = new SafeStylesBuilder();
builder.trustedNameAndValue("background", background)
.width(width, Unit.PX).height(height, Unit.PX)
.paddingRight(paddingRight, Unit.PX);
SafeStyles style = SafeStylesUtils.fromTrustedString(builder
.toSafeStyles().asString());
html = template.menuImageItemContent(style, text);
}
else {
html = template.menuItemContent(text);
}
MenuItem item = new MenuItem(html, new Command() {
@Override
public void execute() {
if (actionsPopup != null && actionsPopup.isVisible())
actionsPopup.hide();
listener.onMenuItemSelected();
}
});
menu.addItem(item);
}
示例12: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
public HandlerRegistration addMenuItem(ImageResource image, String text,
final ActionMenuItemListener listener) {
SafeHtml html = null;
if (image != null) {
SafeUri uri = image.getSafeUri();
int left = image.getLeft();
int top = image.getTop();
int width = image.getWidth();
int height = image.getHeight();
int paddingRight = width + 8;
String background = "url(\"" + uri.asString() + "\") no-repeat "
+ (-left + "px ") + (-top + "px");
SafeStylesBuilder builder = new SafeStylesBuilder();
builder.trustedNameAndValue("background", background)
.width(width, Unit.PX).height(height, Unit.PX)
.paddingRight(paddingRight, Unit.PX);
SafeStyles style = SafeStylesUtils.fromTrustedString(builder
.toSafeStyles().asString());
html = template.menuImageItemContent(style, text);
}
else {
html = template.menuItemContent(text);
}
final MenuItem item = new MenuItem(html, new Command() {
@Override
public void execute() {
if (actionsPopup != null && actionsPopup.isVisible())
actionsPopup.hide();
listener.onMenuItemSelected();
}
});
menu.addItem(item);
HandlerRegistration registration = new HandlerRegistration() {
@Override
public void removeHandler() {
menu.removeItem(item);
}
};
return registration;
}
示例13: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
/**
* Add menu item.
*
* @param image the image
* @param text the text
* @param listener the listener
*/
public void addMenuItem(ImageResource image, String text,
final ActionMenuItemListener listener) {
SafeHtml html = null;
if (image != null) {
SafeUri uri = image.getSafeUri();
int left = image.getLeft();
int top = image.getTop();
int width = image.getWidth();
int height = image.getHeight();
int paddingRight = width + 8;
String background = "url(\"" + uri.asString() + "\") no-repeat "
+ (-left + "px ") + (-top + "px");
SafeStylesBuilder builder = new SafeStylesBuilder();
builder.trustedNameAndValue("background", background)
.width(width, Unit.PX).height(height, Unit.PX)
.paddingRight(paddingRight, Unit.PX);
SafeStyles style = SafeStylesUtils.fromTrustedString(builder
.toSafeStyles().asString());
html = template.menuImageItemContent(style, text);
} else {
html = template.menuItemContent(text);
}
MenuItem item = new MenuItem(html, new Command() {
@Override
public void execute() {
if (actionsPopup != null && actionsPopup.isVisible()) {
actionsPopup.hide();
}
listener.onMenuItemSelected();
}
});
menu.addItem(item);
}
示例14: renderRowValues
import com.google.gwt.safecss.shared.SafeStylesUtils; //导入依赖的package包/类
@Override
protected void renderRowValues(SafeHtmlBuilder sb, List<T> values, int start,
SelectionModel<? super T> selectionModel) {
Cell<T> cell = getCell();
String keyboardSelectedItem = " " + style.cellBrowserKeyboardSelectedItem();
String selectedItem = " " + style.cellBrowserSelectedItem();
String openItem = " " + style.cellBrowserOpenItem();
String evenItem = style.cellBrowserEvenItem();
String oddItem = style.cellBrowserOddItem();
int keyboardSelectedRow = getKeyboardSelectedRow() + getPageStart();
int length = values.size();
int end = start + length;
for (int i = start; i < end; i++) {
T value = values.get(i - start);
boolean isSelected = selectionModel == null ? false : selectionModel.isSelected(value);
boolean isOpen = isOpen(i);
StringBuilder classesBuilder = new StringBuilder();
classesBuilder.append(i % 2 == 0 ? evenItem : oddItem);
if (isOpen) {
classesBuilder.append(openItem);
}
if (isSelected) {
classesBuilder.append(selectedItem);
}
SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
Context context = new Context(i, 0, getValueKey(value));
cell.render(context, value, cellBuilder);
// Figure out which image to use.
SafeHtml image;
if (isOpen) {
image = openImageHtml;
} else if (isLeaf(value)) {
image = LEAF_IMAGE;
} else {
image = closedImageHtml;
}
SafeStyles padding =
SafeStylesUtils.fromTrustedString("padding-right: " + imageWidth + "px;");
if (i == keyboardSelectedRow) {
// This is the focused item.
if (isFocused) {
classesBuilder.append(keyboardSelectedItem);
}
char accessKey = getAccessKey();
if (accessKey != 0) {
sb.append(template.divFocusableWithKey(i, classesBuilder.toString(), padding,
getTabIndex(), getAccessKey(), image, cellBuilder.toSafeHtml()));
} else {
sb.append(template.divFocusable(i, classesBuilder.toString(), padding, getTabIndex(),
image, cellBuilder.toSafeHtml()));
}
} else {
sb.append(template.div(i, classesBuilder.toString(), padding, image, cellBuilder
.toSafeHtml()));
}
}
// Update the child state.
updateChildState(this, true);
}