List of usage examples for com.google.gwt.http.client UrlBuilder setPort
public UrlBuilder setPort(int port)
From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java
License:Apache License
public static UrlBuilder getBaseUrlBuilder() { UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Window.Location.getProtocol()); builder.setHost(Window.Location.getHostName()); String port = Window.Location.getPort(); if (port != null && port.length() > 0) { builder.setPort(Integer.parseInt(port)); }//from w w w . j a va2 s . c o m return builder; }
From source file:ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl.java
License:Apache License
@Override public void start() { if (!isInIFrame()) { initializeCursorList();/*from w w w.j a v a 2 s .c om*/ 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.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 {/*from w w w. j av a2s . 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:org.broadleafcommerce.openadmin.client.BLCMain.java
License:Apache License
public static String buildStoreFrontBaseUrl(String path) { String prefix = storeFrontWebAppPrefix; if (prefix.startsWith("/")) { UrlBuilder urlBuilder = new UrlBuilder(); urlBuilder.setHost(com.google.gwt.user.client.Window.Location.getHost()); String port = com.google.gwt.user.client.Window.Location.getPort(); if (port != null && port.length() > 0) { urlBuilder.setPort(Integer.valueOf(port)); }//from w ww . j av a 2 s . co m urlBuilder.setProtocol(com.google.gwt.user.client.Window.Location.getProtocol()); urlBuilder.setPath(prefix + (path == null ? "" : path)); return urlBuilder.buildString(); } return prefix + (path == null ? "" : path); }
From source file:org.eurekastreams.web.client.ui.pages.master.ConnectEntryPoint.java
License:Apache License
/** * Determines the URL to use to launch the main app. *//*from www. j av a 2s . co m*/ private void determineLaunchPage() { String param = Window.Location.getParameter("_main"); if (param != null && !param.isEmpty()) { mainAppLaunchUrl = param; } else { String path = Window.Location.getPath(); int index = path.lastIndexOf('/'); if (index >= 0 && path.length() > index + 1) { UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Window.Location.getProtocol()); builder.setHost(Window.Location.getHost()); try { builder.setPort(Integer.parseInt(Window.Location.getPort())); } catch (Exception ex) { int makeCheckstyleShutUp = 1; } builder.setPath(path.substring(0, index)); mainAppLaunchUrl = builder.buildString(); } } }
From source file:org.pentaho.mantle.client.ui.tabs.MantleTab.java
License:Open Source License
public void createDeepLink() { if (getContent() instanceof IFrameTabPanel) { PromptDialogBox dialogBox = new PromptDialogBox(Messages.getString("deepLink"), //$NON-NLS-1$ Messages.getString("ok"), Messages.getString("cancel"), false, //$NON-NLS-1$ //$NON-NLS-2$ true);/*from ww w.j a v a 2 s . c om*/ String startup = ((IFrameTabPanel) getContent()).getUrl(); if (!StringUtils.isEmpty(((IFrameTabPanel) getContent()).getDeepLinkUrl())) { startup = ((IFrameTabPanel) getContent()).getDeepLinkUrl(); } UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Window.Location.getProtocol()); builder.setHost(Window.Location.getHostName()); try { builder.setPort(Integer.parseInt(Window.Location.getPort())); } catch (NumberFormatException e) { builder.setPort(UrlBuilder.PORT_UNSPECIFIED); } builder.setPath(Window.Location.getPath()); //UrlBuilder will encode spaces as '+' which is a valid special character so we replace all spaces with '%20' builder.setParameter("name", getLabelText().replaceAll("\\s", "%20")); //the startup string is already encoded with ':' being replaced with '\t' and then encoded again... builder.setParameter("startup-url", startup); final TextArea urlbox = new TextArea(); //encode any space characters urlbox.setText(builder.buildString()); urlbox.setReadOnly(true); urlbox.setVisibleLines(3); dialogBox.setContent(urlbox); urlbox.setHeight("80px"); urlbox.setWidth("600px"); urlbox.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { urlbox.selectAll(); } }); dialogBox.center(); urlbox.selectAll(); } }
From source file:org.sigmah.client.util.ClientUtils.java
License:Open Source License
/** * Returns the current application URL (with current optional parameters) with the given additional parameter * {@code paramName}./*from w w w . j a va2 s .c o m*/ * * @param withParameters * {@code true} to retrieve existing current URL parameters, {@code false} to forget them. * @param paramName * The parameter name. * @param paramValues * The parameter value(s). * @return the current application URL (with current optional parameters) with the given additional parameter * {@code paramName}. */ public static String getApplicationUrl(boolean withParameters, String paramName, String... paramValues) { final UrlBuilder urlBuilder = new UrlBuilder(); urlBuilder.setProtocol(Location.getProtocol()); urlBuilder.setHost(Location.getHost()); final Integer port = asInt(Location.getPort()); if (port != null) { urlBuilder.setPort(port); } urlBuilder.setPath(Location.getPath()); if (Location.getParameterMap() != null) { // "?gwt.codesvr=127.0.0.1:9997" for example. for (final Entry<String, List<String>> param : Location.getParameterMap().entrySet()) { if ("gwt.codesvr".equalsIgnoreCase(param.getKey()) && isNotEmpty(param.getValue())) { // Hosted mode parameter exception. urlBuilder.setParameter(param.getKey(), param.getValue().get(0)); } else if (withParameters) { final String[] values = param.getValue() != null ? param.getValue().toArray(new String[param.getValue().size()]) : null; urlBuilder.setParameter(param.getKey(), values); } } } if (isNotBlank(paramName) && paramValues != null) { urlBuilder.setParameter(paramName, paramValues); } return urlBuilder.buildString(); }
From source file:org.sigmah.client.util.ClientUtils.java
License:Open Source License
/** * Appends an additional path to the application URL. * /*from w w w.jav a2 s . c om*/ * @param additionalPath * The additional path to append to the application URL. * @return the new URL. */ public static String appendToApplicationUrl(String additionalPath) { final UrlBuilder urlBuilder = new UrlBuilder(); urlBuilder.setProtocol(Location.getProtocol()); urlBuilder.setHost(Location.getHost()); final Integer port = asInt(Location.getPort()); if (port != null) { urlBuilder.setPort(port); } urlBuilder.setPath(Location.getPath() + additionalPath); return urlBuilder.buildString(); }
From source file:org.xdi.oxd.license.admin.client.ui.LicenseCryptDetailsPresenter.java
License:Open Source License
private void onMonthlyStatisticButton() { UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Window.Location.getProtocol()); builder.setHost(Window.Location.getHost()); String port = Window.Location.getPort(); if (port != null && port.length() > 0) { builder.setPort(Integer.parseInt(port)); }//from w ww . j a v a 2 s . c o m builder.setPath("/oxLicense/rest/statistic"); builder.setParameter("licenseId", selectionModel.getSelectedSet().iterator().next().getLicenseId()); Window.open(builder.buildString(), "_blank", null); }