List of usage examples for com.google.gwt.safecss.shared SafeStylesBuilder trustedNameAndValue
public SafeStylesBuilder trustedNameAndValue(String name, String value)
Append a SafeStyles constructed from a trusted name and a trusted value, i.e., without escaping the name and value.
From source file:org.kaaproject.avro.ui.gwt.client.widget.ActionsButton.java
License:Apache License
public HandlerRegistration addMenuItem(ImageResource image, String text, final ActionMenuItemListener listener) { SafeHtml html = null;// ww w . j a v a 2 s . co m 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; }
From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.cell.ActionButtonCell.java
License:Apache License
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); }/* www .j av a2 s. co m*/ 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); } }
From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.cell.ActionsButtonCell.java
License:Apache License
public ActionsButtonCell(ImageResource imageResource, String text) { super(CLICK, KEYDOWN); if (template == null) { template = GWT.create(Template.class); }/*from w ww . j a v a 2 s . co m*/ SafeStylesBuilder buttonStyleBuilder = new SafeStylesBuilder(); SafeStylesBuilder imageStyleBuilder = new SafeStylesBuilder(); buttonStyleBuilder.verticalAlign(VerticalAlign.MIDDLE).paddingRight(20, Unit.PX); if (imageResource != null) { buttonStyleBuilder.paddingLeft(20, Unit.PX); 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"; imageStyleBuilder.trustedNameAndValue("background", background).width(width, Unit.PX) .height(height, Unit.PX).paddingLeft(paddingLeft, Unit.PX).marginRight(10, Unit.PX); } else { imageStyleBuilder.display(Display.NONE); } SafeStyles buttonStyle = SafeStylesUtils.fromTrustedString(buttonStyleBuilder.toSafeStyles().asString()); SafeStyles imageStyle = SafeStylesUtils.fromTrustedString(imageStyleBuilder.toSafeStyles().asString()); this.actionsButtonHtml = template.actionsButtonUp(buttonStyle, imageStyle, Utils.avroUiStyle.buttonCaret(), text); this.actionsButtonHtmlDown = template.actionsButtonDown(buttonStyle, imageStyle, Utils.avroUiStyle.buttonCaret(), text); actionsPopup = new PopupPanel(true, false); actionsPopup.addStyleName(Utils.avroUiStyle.actionPopup()); actionsPopup.setWidget(menu); }
From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.cell.ActionsButtonCell.java
License:Apache License
public void addMenuItem(ImageResource image, String text, final ActionMenuItemListener<T> listener) { SafeHtml html = null;// www . j a v a 2 s .c o m 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); }
From source file:org.kaaproject.kaa.sandbox.web.client.mvp.view.widget.ActionsLabel.java
License:Apache License
public void addMenuItem(ImageResource image, String text, final ActionMenuItemListener listener) { SafeHtml html = null;/* w w w. j a va 2s . c om*/ 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); }
From source file:org.kaaproject.kaa.server.admin.client.mvp.view.widget.ActionsLabel.java
License:Apache License
public void addMenuItem(ImageResource image, String text, final ActionMenuItemListener listener) { SafeHtml html = null;//ww w . ja v a 2 s. c o m 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); }