本文整理汇总了Java中com.google.gwt.safecss.shared.SafeStylesBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SafeStylesBuilder类的具体用法?Java SafeStylesBuilder怎么用?Java SafeStylesBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeStylesBuilder类属于com.google.gwt.safecss.shared包,在下文中一共展示了SafeStylesBuilder类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageHtml
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的package包/类
private SafeHtml getImageHtml(ImageResource res, VerticalAlignmentConstant valign) {
AbstractImagePrototype proto = AbstractImagePrototype.create(res);
SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML());
// Create the wrapper based on the vertical alignment.
SafeStylesBuilder cssStyles =
new SafeStylesBuilder().appendTrustedString(direction + ":0px;");
if (HasVerticalAlignment.ALIGN_TOP == valign) {
return templates.imageWrapperTop(cssStyles.toSafeStyles(), image);
} else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) {
return templates.imageWrapperBottom(cssStyles.toSafeStyles(), image);
} else {
int halfHeight = (int) Math.round(res.getHeight() / 2.0);
cssStyles.appendTrustedString("margin-top:-" + halfHeight + "px;");
return templates.imageWrapperMiddle(cssStyles.toSafeStyles(), image);
}
}
示例2: render
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的package包/类
@Override
public void render(Context context, C value, SafeHtmlBuilder sb) {
if (treeProvider != null) {
SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
cell.render(context, value, cellBuilder);
int deepness = getDeepness(context);
int outerDivPadding = indent * deepness;
SafeStylesBuilder styles = new SafeStylesBuilder();
if (deepness > 0) {
styles.paddingLeft(outerDivPadding, Style.Unit.PX);
}
styles.position(Style.Position.RELATIVE).height(100, Style.Unit.PCT).toSafeStyles();
sb.append(template.outerDiv(outerDivClasses(context), styles.toSafeStyles(), cellBuilder.toSafeHtml()));
} else {
cell.render(context, value, sb);
}
}
示例3: decorate
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的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;
}
示例4: update
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的package包/类
private void update() {
long currentTime = System.currentTimeMillis();
int time = (int) (currentTime - startTime);
int left = time * WIDTH / MAX_TIME;
int width = WIDTH - left;
String message = second == 0 ? "時間切れ" : ("残り時間約" + second + "秒");
String color = Utility.createBackgroundColorString((double) width / (double) WIDTH);
SafeStyles styles = new SafeStylesBuilder()
.position(Position.ABSOLUTE)
.top(0, Unit.PX)
.left(left, Unit.PX)
.width(width, Unit.PX)
.height(32, Unit.PX)
.trustedBackgroundColor(color)
.zIndex(-5)
.toSafeStyles();
SafeHtml safeHtml = TEMPLATE.bar(message, styles);
html.setHTML(safeHtml);
}
示例5: getImageHtml
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的package包/类
/**
* Get the HTML representation of an image.
*
* @param res the {@link ImageResource} to render as HTML
* @return the rendered HTML
*/
private SafeHtml getImageHtml(ImageResource res) {
// Right-justify image if LTR, left-justify if RTL
AbstractImagePrototype proto = AbstractImagePrototype.create(res);
SafeHtml image = proto.getSafeHtml();
SafeStylesBuilder cssBuilder = new SafeStylesBuilder();
if (LocaleInfo.getCurrentLocale().isRTL()) {
cssBuilder.appendTrustedString("left:0px;");
} else {
cssBuilder.appendTrustedString("right:0px;");
}
cssBuilder.appendTrustedString("width: " + res.getWidth() + "px;");
cssBuilder.appendTrustedString("height: " + res.getHeight() + "px;");
return template.imageWrapper(cssBuilder.toSafeStyles(), image);
}
示例6: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的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.SafeStylesBuilder; //导入依赖的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: update
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的package包/类
@VisibleForTesting
void update() {
// SHOW_ALL_TIMING_MS以降は目隠しを表示しない
int showAllCount = SHOW_ALL_TIMING_MS / UPDATE_PERIOD_MS;
if (++count > showAllCount) {
html.setHTML(new SafeHtmlBuilder().append(prefix).append(SURFIX_TEMPLATE).toSafeHtml());
return;
}
// 目隠しの位置を更新する
int lineWidth = INITIALI_WIDTH * (showAllCount - count) / showAllCount;
for (int i = 0; i < NUMBER_OF_LINE; ++i) {
pos[i] += velocities[i];
if (pos[i] < 0) {
velocities[i] = Math.abs(velocities[i]);
} else if (pos[i] > WIDTH - lineWidth) {
velocities[i] = -Math.abs(velocities[i]);
}
}
// 目隠しを表示する
SafeHtmlBuilder builder = new SafeHtmlBuilder();
builder.append(prefix);
for (int i = 0; i < NUMBER_OF_LINE; ++i) {
SafeStyles styles = new SafeStylesBuilder().position(Position.ABSOLUTE).left(pos[i], Unit.PX)
.top(0, Unit.PX).trustedBackgroundColor(COLORS[i]).width(lineWidth, Unit.PX)
.height(72, Unit.PX).toSafeStyles();
builder.append(HINT_TEMPLATE.line(styles));
}
builder.append(SURFIX_TEMPLATE);
html.setHTML(builder.toSafeHtml());
}
示例9: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的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);
}
示例10: render
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的package包/类
@Override
public void render(final Context context, final T value, SafeHtmlBuilder sb) {
String viewDataId = "";
if (isEditing(context, null, value)) {
final ViewData<T> viewData = getViewData(context.getKey());
viewDataId = viewData.id;
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (isEditing(context, null, value)) {
Element identifiedCellTextSection = Document.get().getElementById(viewData.id);
if (identifiedCellTextSection != null) {
identifiedCellTextSection.blur();
Element table = identifiedCellTextSection;
while (table != null && !"table".equalsIgnoreCase(table.getTagName())) {
table = table.getParentElement();
}
final Element table1 = table;
if (identifiedCellTextSection.getOwnerDocument() == Document.get()) {
startEditing(context, identifiedCellTextSection.getParentElement(), table1.getParentElement(), value, viewData.updater, new Runnable() {
public void run() {
if (onEditorClose != null && table1 != null) {
onEditorClose.closed(table1);
}
}
});
}
}
}
}
});
}
if (renderer == null || !renderer.render(context, viewDataId, value, sb)) {
SafeHtmlBuilder content = new SafeHtmlBuilder();
renderCell(context, value, content);
sb.append(PaddedCell.INSTANCE.generate(new SafeStylesBuilder().toSafeStyles(), viewDataId, content.toSafeHtml()));
}
}
示例11: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的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;
}
示例12: addMenuItem
import com.google.gwt.safecss.shared.SafeStylesBuilder; //导入依赖的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);
}