List of usage examples for com.google.gwt.safehtml.shared UriUtils fromString
public static SafeUri fromString(String s)
From source file:br.com.silvaesouza.sampleext.client.model.Photo.java
License:sencha.com license
public SafeUri getPathUri() { return UriUtils.fromString(getPath()); }
From source file:com.ait.lienzo.client.core.shape.AbstractImageShape.java
License:Open Source License
protected String toValidURL(String url) { if (url.startsWith("data:")) { return url; }/*from ww w .j a v a2 s. c o m*/ if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) { throw new NullPointerException("null or empty or invalid url"); } url = UriUtils.fromString(url).asString(); if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) { throw new NullPointerException("null or empty or invalid url"); } return url; }
From source file:com.ait.lienzo.client.core.shape.json.validators.URLValidator.java
License:Open Source License
@Override public void validate(JSONValue jval, ValidationContext ctx) throws ValidationException { if (null == jval) { ctx.addBadTypeError("URL"); return;/*from w w w . j av a 2s.c o m*/ } JSONString str = jval.isString(); if (null == str) { ctx.addBadTypeError("URL"); return; } String url = str.toString(); if (url.startsWith("data:")) { return; } if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) { ctx.addBadTypeError("URL"); return; } url = UriUtils.fromString(url).asString(); if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) { ctx.addBadTypeError("URL"); return; } }
From source file:com.ait.lienzo.client.core.shape.Movie.java
License:Open Source License
private final MovieAnimation doInitialize() { if (null != m_video) { setErrorHandler(this, m_video.getVideoElement()); String url = getURL();/*from w ww . j a va 2s . co m*/ if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) { throw new NullPointerException("null or empty or invalid url"); } url = UriUtils.fromString(url).asString(); if ((null == url) || ((url = url.trim()).isEmpty()) || (url.startsWith("#"))) { throw new NullPointerException("null or empty or invalid url"); } m_video.setSrc(url); m_video.setLoop(isLoop()); m_video.setVisible(false); m_video.setPlaybackRate(getPlaybackRate()); m_video.setPreload(MediaElement.PRELOAD_AUTO); if (getAttributes().isDefined(Attribute.VOLUME)) { m_video.setVolume(getVolume()); } setSizes(); return new MovieAnimation(this, m_video); } else { return null; } }
From source file:com.akanoo.client.widgets.UserCell.java
License:Apache License
@Override public void render(com.google.gwt.cell.client.Cell.Context context, UserInfo value, SafeHtmlBuilder sb) { Style style = resources.userCellStyle(); SafeUri thumbUrl = null;//ww w. ja v a 2 s. c o m if (value.thumbUrl != null) try { thumbUrl = UriUtils.fromString(value.thumbUrl); } catch (Exception ex) { } if (thumbUrl != null) sb.append(template.cell(style.cell(), style.thumb(), thumbUrl, style.name(), value.name)); else sb.append(template.cellSimple(style.cell(), style.name(), value.name)); }
From source file:com.imaginedreal.gwt.palantir.client.activities.search.SearchViewGwtImpl.java
License:Apache License
public SearchViewGwtImpl() { handleOnLoad();//from w w w . jav a2s. c om cellList = new CellList<Book>(new BookCell<Book>() { @Override public SafeUri getBookCoverUrl(Book model) { return UriUtils.fromString(model.getBookCoverUrl()); } @Override public String getTitle(Book model) { return model.getTitle(); } @Override public String getBriefSynopsis(Book model) { String briefSynopsis = ""; if (MGWT.getOsDetection().isPhone()) { briefSynopsis = ParserUtils.ellipsis(model.getBriefSynopsis(), 128); } else { briefSynopsis = ParserUtils.ellipsis(model.getBriefSynopsis(), 512); } return briefSynopsis; } }); searchBox = new MSearchBox(); searchBox.setPlaceHolder("Search Bookshare"); searchBox.addSearchSubmitHandler(new SearchSubmitHandler() { @Override public void onEvent(SearchSubmitEvent event) { if (presenter != null) { presenter.onSearchTextChanged(searchBox.getText()); } } }); initWidget(uiBinder.createAndBindUi(this)); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.forms.ComboBoxExample.java
License:sencha.com license
public Widget asWidget() { if (vp == null) { vp = new VerticalPanel(); vp.setSpacing(10);//from ww w . jav a2s .co m StateProperties props = GWT.create(StateProperties.class); ListStore<State> states = new ListStore<State>(props.abbr()); states.addAll(TestData.getStates()); ComboBox<State> combo = new ComboBox<State>(states, props.name()); addHandlersForEventObservation(combo, props.name()); combo.setEmptyText("Select a state..."); combo.setWidth(150); combo.setTypeAhead(true); combo.setTriggerAction(TriggerAction.ALL); vp.add(combo); states = new ListStore<State>(props.abbr()); states.addAll(TestData.getStates()); combo = new ComboBox<State>(states, props.name(), new AbstractSafeHtmlRenderer<State>() { public SafeHtml render(State item) { final ComboBoxTemplates comboBoxTemplates = GWT.create(ComboBoxTemplates.class); return comboBoxTemplates.state(item.getSlogan(), item.getName()); } }); addHandlersForEventObservation(combo, props.name()); combo.setEmptyText("Select a state..."); combo.setWidth(150); combo.setTypeAhead(true); combo.setTriggerAction(TriggerAction.ALL); vp.add(combo); final CountryProperties countryProps = GWT.create(CountryProperties.class); ListStore<Country> countries = new ListStore<Country>(countryProps.abbr()); countries.addAll(TestData.getCountries()); final String moduleBaseUrl = GWT.getHostPageBaseURL(); ComboBox<Country> combo2 = new ComboBox<Country>(countries, countryProps.name(), new AbstractSafeHtmlRenderer<Country>() { final ComboBoxTemplates comboBoxTemplates = GWT.create(ComboBoxTemplates.class); public SafeHtml render(Country item) { SafeUri imageUri = UriUtils .fromString(moduleBaseUrl + "examples/images/flags/" + item.getAbbr() + ".png"); return comboBoxTemplates.country(imageUri, item.getName()); } }); addHandlersForEventObservation(combo2, countryProps.name()); combo2.setWidth(150); combo2.setTypeAhead(true); combo2.setTriggerAction(TriggerAction.ALL); vp.add(combo2); } return vp; }
From source file:com.seanchenxi.gwt.serenity.client.view.impl.DiscussionViewImpl.java
License:Apache License
public void setAuthorInfo(String gravatar, String name, String url, Date date) { SafeUri avatar = getGravatarUri(gravatar); String dateString = SerenityUtil.toDateTimeString(date); String authorCSS = getStyle().discussionAuthor(); String dateCSS = getStyle().discussionDate(); String avatarCSS = getStyle().avatar(); if (url != null && !url.isEmpty()) { SafeUri site = UriUtils.fromString(url); author.setHTML(TEMPLATE.AuthorMetaWithUrl(avatar, AVATAR_SIZE, name, dateString, site, authorCSS, dateCSS, avatarCSS));/*from w ww .ja v a 2 s. c om*/ } else { author.setHTML( TEMPLATE.AuthorMeta(avatar, AVATAR_SIZE, name, dateString, authorCSS, dateCSS, avatarCSS)); } }
From source file:com.seanchenxi.gwt.serenity.client.view.impl.DiscussionViewImpl.java
License:Apache License
private SafeUri getGravatarUri(String gravatar) { if (gravatar != null && !gravatar.isEmpty()) return UriUtils.fromString(gravatar + "?s=" + AVATAR_SIZE + "&d=mm"); else// w w w . jav a2s .c om return resource.avatar32().getSafeUri(); }
From source file:com.urlisit.siteswrapper.cloud.widgets.ImageLogo.java
License:Apache License
/** * //from ww w.java 2s . co m */ public ImageLogo(View view) { this.view = view; leftPercent = BigDecimal.valueOf(Double.parseDouble(view.getLookAndFeel().getLogoLeftPercent())); topPercent = BigDecimal.valueOf(Double.parseDouble(view.getLookAndFeel().getLogoTopPercent())); widthPercent = BigDecimal.valueOf(Double.parseDouble(view.getLookAndFeel().getLogoWidthPercent())); //logo.setVisible(false); loaded = false; logo.getElement().getStyle().setOpacity(Double.valueOf(view.getLiterals().zero())); logo.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { //logo.setVisible(true); loaded = true; resize(); fadeIn(); } }); view.getPanel().add(logo); logo.setUrl(UriUtils.fromString(view.getPage().getLogoImage())); }