List of usage examples for com.google.gwt.http.client UrlBuilder buildString
public String buildString()
From source file:ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl.java
License:Apache License
@Override public void start() { if (!isInIFrame()) { initializeCursorList();// w ww . j av a 2s . c o m if (r != null) r.removeHandler(); r = Window.addResizeHandler(this); UrlBuilder b = Window.Location.createUrlBuilder(); b.setProtocol("ws"); b.setPath("mouseControlXBrowser"); b.setHash(null); String p = Window.Location.getPort(); Integer port; try { port = p != null ? Integer.parseInt(p) : 8080; } catch (NumberFormatException e) { port = 8080; } b.setPort(port + 1); for (String param : Window.Location.getParameterMap().keySet()) { b.removeParameter(param); } websocket = createWebsocket(this, b.buildString()); if (websocket != null) createOnBeforeUnloadHandler(websocket); } }
From source file:com.allen_sauer.gwt.voices.crowd.client.VoicesCrowd.java
License:Apache License
private void renderSummary(List<TestResultSummary> list, boolean includeUserAgentDetail) { HashSet<TestResults> testResultsSet = getUniqueTestResults(list); // Build HTML table StringBuffer html = new StringBuffer(); if (!embed) { html.append("<div style='font-weight: bold; font-size: 1.2em;'>") .append("<a href='https://github.com/fredsa/gwt-voices'>gwt-voices</a>") .append(" - Sound for your Google Web Toolkit projects.</div>") .append("<div style='font-style: italic; margin-bottom: 1em;'>by Fred Sauer</div>"); html.append("<h3>Your user agent</h3>"); html.append("<div style='margin-left: 1.5em;'>").append(myUserAgent.toString()).append("</div>"); html.append("<h3>Your browser</h3>"); String prettyUserAgent = myTestResultSummary.getPrettyUserAgent(); html.append("<div style='margin-left: 1.5em;'>").append(formatPrettyUserAgentOrNull(prettyUserAgent)) .append("</div>"); html.append("<h3 style='margin-top: 3em;'>HTML5 MIME Type support by User-Agent</h3>"); }//from www. j a v a 2 s . c o m UrlBuilder urlBuilder = Window.Location.createUrlBuilder(); urlBuilder = detail ? urlBuilder.removeParameter("detail") : urlBuilder.setParameter("detail", "1"); String text = (detail ? "Hide" : "Show full") + " user agent values"; html.append("<a href='" + urlBuilder.buildString() + "'>" + text + "</a>"); html.append("<table>"); for (TestResults testResults : testResultsSet) { makeHeaderRow(html, includeUserAgentDetail); HashSet<Tuple<String>> tuples = getMatchingTuples(testResults, list, includeUserAgentDetail); int count = 0; for (Tuple<String> tuple : tuples) { count++; html.append("<tr>"); boolean highlightRow = makeTuple(myTestResultSummary, includeUserAgentDetail).equals(tuple); makeUserAgentCells(html, tuple, highlightRow); if (count == 1) { makeResultCells(html, testResults, tuples.size()); } html.append("</tr>"); } } html.append("</table>"); rootPanel.add(new HTML(html.toString())); }
From source file:com.centretown.parts.client.application.ApplicationPresenter.java
License:Apache License
private String replaceReturnPath(String url) { UrlBuilder builder = Window.Location.createUrlBuilder(); return url.replace("%2F", URL.encode(builder.buildString())); }
From source file:com.dingziran.effective.client.ShowcaseShell.java
License:Apache License
/** * Initialize the {@link ListBox} used for locale selection. *///from w w w. j a va2 s .c om private void initializeLocaleBox() { final String cookieName = LocaleInfo.getLocaleCookieName(); final String queryParam = LocaleInfo.getLocaleQueryParam(); if (cookieName == null && queryParam == null) { // if there is no way for us to affect the locale, don't show the selector localeSelectionCell.getStyle().setDisplay(Display.NONE); return; } String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName(); if (currentLocale.equals("default")) { currentLocale = "en"; } String[] localeNames = LocaleInfo.getAvailableLocaleNames(); for (String localeName : localeNames) { if (!localeName.equals("default")) { String nativeName = LocaleInfo.getLocaleNativeDisplayName(localeName); localeBox.addItem(nativeName, localeName); if (localeName.equals(currentLocale)) { localeBox.setSelectedIndex(localeBox.getItemCount() - 1); } } } localeBox.addChangeHandler(new ChangeHandler() { @SuppressWarnings("deprecation") public void onChange(ChangeEvent event) { String localeName = localeBox.getValue(localeBox.getSelectedIndex()); if (cookieName != null) { // expire in one year Date expires = new Date(); expires.setYear(expires.getYear() + 1); Cookies.setCookie(cookieName, localeName, expires); } if (queryParam != null) { UrlBuilder builder = Location.createUrlBuilder().setParameter(queryParam, localeName); Window.Location.replace(builder.buildString()); } else { // If we are using only cookies, just reload Window.Location.reload(); } } }); }
From source file:com.goodow.web.ui.client.search.DefaultHeader.java
License:Apache License
/** * Initialize the {@link ListBox} used for locale selection. *///from w ww. jav a 2 s. c o m private void initializeLocaleBox() { final String cookieName = LocaleInfo.getLocaleCookieName(); final String queryParam = LocaleInfo.getLocaleQueryParam(); if (cookieName == null && queryParam == null) { // if there is no way for us to affect the locale, don't show the selector localeSelectionCell.getStyle().setDisplay(Display.NONE); return; } String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName(); if (currentLocale.equals("default")) { currentLocale = "zh"; } String[] localeNames = LocaleInfo.getAvailableLocaleNames(); for (String localeName : localeNames) { if (!localeName.equals("default")) { String nativeName = LocaleInfo.getLocaleNativeDisplayName(localeName); localeBox.addItem(nativeName, localeName); if (localeName.equals(currentLocale)) { localeBox.setSelectedIndex(localeBox.getItemCount() - 1); } } } localeBox.addChangeHandler(new ChangeHandler() { @Override @SuppressWarnings("deprecation") public void onChange(final ChangeEvent event) { String localeName = localeBox.getValue(localeBox.getSelectedIndex()); if (cookieName != null) { // expire in one year Date expires = new Date(); expires.setYear(expires.getYear() + 1); Cookies.setCookie(cookieName, localeName, expires); } if (queryParam != null) { UrlBuilder builder = Location.createUrlBuilder().setParameter(queryParam, localeName); Window.Location.replace(builder.buildString()); } else { // If we are using only cookies, just reload Window.Location.reload(); } } }); }
From source file:com.google.gerrit.client.Gerrit.java
License:Apache License
public static String selfRedirect(String suffix) { // Clean up the path. Users seem to like putting extra slashes into the URL // which can break redirections by misinterpreting at either client or server. String path = Location.getPath(); if (path == null || path.isEmpty()) { path = "/"; } else {//w w w . ja v a 2 s . c o m while (path.startsWith("//")) { path = path.substring(1); } while (path.endsWith("//")) { path = path.substring(0, path.length() - 1); } if (!path.endsWith("/")) { path = path + "/"; } } if (suffix != null) { while (suffix.startsWith("/")) { suffix = suffix.substring(1); } path += suffix; } UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Location.getProtocol()); builder.setHost(Location.getHost()); String port = Location.getPort(); if (port != null && !port.isEmpty()) { builder.setPort(Integer.parseInt(port)); } builder.setPath(path); return builder.buildString(); }
From source file:com.googlecode.mgwt.mvp.client.history.HTML5HistorianLegacyImpl.java
License:Apache License
@Override public void replaceState(String data, String title, String url) { UrlBuilder builder = Window.Location.createUrlBuilder(); builder.setHash(data);//from w w w. j a v a2s . com Window.Location.replace(builder.buildString()); }
From source file:com.isotrol.impe3.pms.gui.client.error.ServiceErrorsProcessor.java
License:Open Source License
/** * Processes only the error.//from www . ja v a 2 s . c o m * @param error * @param message the message to display in the alert box. */ private void processError(Throwable error, String message) { Listener<MessageBoxEvent> callback = null; if (error instanceof NoSessionException) { // reload page when exiting alert popup callback = new Listener<MessageBoxEvent>() { public void handleEvent(MessageBoxEvent be) { // Window.Location.reload(); UrlBuilder url = Window.Location.createUrlBuilder().setHash(null); if (pmsUtil.isDisableLogin()) { int index = url.buildString().lastIndexOf("/"); Window.Location.replace(url.buildString().substring(0, index)); } else { Window.Location.replace(url.buildString()); } }; }; } util.error(message, callback); }
From source file:com.isotrol.impe3.pms.gui.client.widget.top.UserInfoPanel.java
License:Open Source License
private void setLogoutUri() { UrlBuilder url = Window.Location.createUrlBuilder().setHash(null); if (pmsUtil.isDisableLogin()) { int index = url.buildString().lastIndexOf("/"); Window.Location.replace(url.buildString().substring(0, index)); } else {/*from w w w. j a v a 2 s.c o m*/ Window.Location.replace(url.buildString()); } }
From source file:com.mecatran.otp.gwt.client.controller.PlannerState.java
License:Open Source License
private void buildUrl() { UrlBuilder urlBuilder = Window.Location.createUrlBuilder(); PlanRequestBean planRequest = getPlanRequestBean(); if (planRequest.getDeparture().isSet(false)) urlBuilder.setParameter("origin", getLocationAsStringParam(planRequest.getDeparture())); if (planRequest.getArrival().isSet(false)) urlBuilder.setParameter("destination", getLocationAsStringParam(planRequest.getArrival())); DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy/MM/dd@HH:mm"); urlBuilder.setParameter(planRequest.isDateDeparture() ? "depart" : "arrive", dtf.format(planRequest.getDate())); if (planRequest.isWheelchairAccessible()) urlBuilder.setParameter("wheelchair", "y"); Set<TransportMode> modes = planRequest.getModes(); String modesStr = ""; for (TransportMode mode : modes) { modesStr = modesStr + mode.toString() + ","; }/* w w w . j a v a 2s . c o m*/ modesStr = modesStr.substring(0, modesStr.length() - 1); urlBuilder.setParameter("modes", modesStr); url = urlBuilder.buildString(); }