List of usage examples for com.google.gwt.http.client UrlBuilder removeParameter
public UrlBuilder removeParameter(String name)
From source file:ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl.java
License:Apache License
@Override public void start() { if (!isInIFrame()) { initializeCursorList();//from w ww .ja 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.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>"); }// w w w . java2 s. c om 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.vaadin.client.SuperDevMode.java
License:Apache License
protected static void redirect(boolean devModeOn) { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); if (!devModeOn) { createUrlBuilder.removeParameter("superdevmode"); } else {/*from www .jav a2 s . c om*/ createUrlBuilder.setParameter("superdevmode", ""); } Location.assign(createUrlBuilder.buildString()); }
From source file:com.vaadin.client.VDebugConsole.java
License:Apache License
private void addDevMode() { actions.add(devMode);//w w w. j a v a 2 s . c o m if (Location.getParameter("gwt.codesvr") != null) { devMode.setValue(true); } devMode.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (devMode.getValue()) { addHMParameter(); } else { removeHMParameter(); } } private void addHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.setParameter("gwt.codesvr", "localhost:9997"); Location.assign(createUrlBuilder.buildString()); } private void removeHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.removeParameter("gwt.codesvr"); Location.assign(createUrlBuilder.buildString()); } }); }
From source file:com.vaadin.terminal.gwt.client.VDebugConsole.java
License:Open Source License
public void init() { panel = new FlowPanel(); if (!quietMode) { DOM.appendChild(getContainerElement(), caption); setWidget(panel);/*w w w .j a va2 s . com*/ caption.setClassName("v-debug-console-caption"); setStyleName("v-debug-console"); getElement().getStyle().setZIndex(20000); getElement().getStyle().setOverflow(Overflow.HIDDEN); sinkEvents(Event.ONDBLCLICK); sinkEvents(Event.MOUSEEVENTS); panel.setStyleName("v-debug-console-content"); caption.setInnerHTML("Debug window"); caption.getStyle().setHeight(25, Unit.PX); caption.setTitle(help); show(); setToDefaultSizeAndPos(); actions = new HorizontalPanel(); Style style = actions.getElement().getStyle(); style.setPosition(Position.ABSOLUTE); style.setBackgroundColor("#666"); style.setLeft(135, Unit.PX); style.setHeight(25, Unit.PX); style.setTop(0, Unit.PX); actions.add(clear); actions.add(restart); actions.add(forceLayout); actions.add(analyzeLayout); actions.add(highlight); highlight.setTitle( "Select a component and print details about it to the server log and client side console."); actions.add(savePosition); savePosition.setTitle("Saves the position and size of debug console to a cookie"); actions.add(autoScroll); actions.add(hostedMode); if (Location.getParameter("gwt.codesvr") != null) { hostedMode.setValue(true); } hostedMode.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (hostedMode.getValue()) { addHMParameter(); } else { removeHMParameter(); } } private void addHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.setParameter("gwt.codesvr", "localhost:9997"); Location.assign(createUrlBuilder.buildString()); } private void removeHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.removeParameter("gwt.codesvr"); Location.assign(createUrlBuilder.buildString()); } }); autoScroll.setTitle("Automatically scroll so that new messages are visible"); panel.add(actions); panel.add(new HTML("<i>" + help + "</i>")); clear.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { int width = panel.getOffsetWidth(); int height = panel.getOffsetHeight(); panel = new FlowPanel(); panel.setPixelSize(width, height); panel.setStyleName("v-debug-console-content"); panel.add(actions); setWidget(panel); } }); restart.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String queryString = Window.Location.getQueryString(); if (queryString != null && queryString.contains("restartApplications")) { Window.Location.reload(); } else { String url = Location.getHref(); String separator = "?"; if (url.contains("?")) { separator = "&"; } if (!url.contains("restartApplication")) { url += separator; url += "restartApplication"; } if (!"".equals(Location.getHash())) { String hash = Location.getHash(); url = url.replace(hash, "") + hash; } Window.Location.replace(url); } } }); forceLayout.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // TODO for each client in appconf force layout // VDebugConsole.this.client.forceLayout(); } }); analyzeLayout.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { List<ApplicationConnection> runningApplications = ApplicationConfiguration .getRunningApplications(); for (ApplicationConnection applicationConnection : runningApplications) { applicationConnection.analyzeLayouts(); } } }); analyzeLayout.setTitle("Analyzes currently rendered view and " + "reports possible common problems in usage of relative sizes." + "Will cause server visit/rendering of whole screen and loss of" + " all non committed variables form client side."); savePosition.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String pos = getAbsoluteLeft() + "," + getAbsoluteTop() + "," + getOffsetWidth() + "," + getOffsetHeight() + "," + autoScroll.getValue(); Cookies.setCookie(POS_COOKIE_NAME, pos); } }); highlight.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final Label label = new Label("--"); log("<i>Use mouse to select a component or click ESC to exit highlight mode.</i>"); panel.add(label); highlightModeRegistration = Event.addNativePreviewHandler(new HighlightModeHandler(label)); } }); } log("Starting Vaadin client side engine. Widgetset: " + GWT.getModuleName()); log("Widget set is built on version: " + ApplicationConfiguration.VERSION); logToDebugWindow("<div class=\"v-theme-version v-theme-version-" + ApplicationConfiguration.VERSION.replaceAll("\\.", "_") + "\">Warning: widgetset version " + ApplicationConfiguration.VERSION + " does not seem to match theme version </div>", true); }
From source file:org.geomajas.gwt.client.widget.LocaleSelect.java
License:Open Source License
/** Build the correct URL for the new locale. */ private String buildLocaleUrl(String selectedLocale) { UrlBuilder builder = Window.Location.createUrlBuilder(); builder.removeParameter("locale"); if (!"default".equals(selectedLocale)) { builder.setParameter("locale", selectedLocale); }/* www .j a v a 2s .c o m*/ return builder.buildString(); }
From source file:uk.ac.ncl.openlab.intake24.client.survey.FlatFinalPage.java
License:Apache License
@Override public SimpleSurveyStageInterface getInterface(Callback1<Survey> onComplete, Callback2<Survey, Boolean> onIntermediateStateChange) { final CompletedSurvey finalData = data.finalise(log); final FlowPanel contents = new FlowPanel(); contents.addStyleName("intake24-survey-content-container"); contents.add(new LoadingPanel(messages.submitPage_loadingMessage())); SurveyService.INSTANCE.submitSurvey(EmbeddedData.surveyId, finalData, new MethodCallback<SurveySubmissionResponse>() { @Override// w w w. j a v a2s . com public void onFailure(Method method, Throwable exception) { contents.clear(); if (exception instanceof RequestTimeoutException) { final MethodCallback<SurveySubmissionResponse> outer = this; contents.add( new HTMLPanel(SafeHtmlUtils.fromSafeConstant(messages.submitPage_timeout()))); contents.add(WidgetFactory.createGreenButton(messages.submitPage_tryAgainButton(), "finalPageTryAgainButton", new ClickHandler() { @Override public void onClick(ClickEvent event) { SurveyService.INSTANCE.submitSurvey(EmbeddedData.surveyId, finalData, outer); } })); } else { contents.add( new HTMLPanel(SafeHtmlUtils.fromSafeConstant(messages.submitPage_error()))); } contents.add(new HTMLPanel(finalPageHtml)); } @Override public void onSuccess(Method method, SurveySubmissionResponse response) { contents.clear(); HTMLPanel p = new HTMLPanel(SafeHtmlUtils.fromSafeConstant(messages.submitPage_success())); p.getElement().getStyle().setMarginBottom(30, Style.Unit.PX); contents.add(p); if (response.redirectToFeedback) { HTMLPanel p1 = new HTMLPanel("h4", surveyMessages.finalPage_feedbackLabel()); p1.getElement().getStyle().setMarginBottom(0, Style.Unit.PX); contents.add(p1); Button feedbackButton = WidgetFactory.createGreenButton( surveyMessages.finalPage_feedbackButtonLabel(), "feedbackButton", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { UrlBuilder builder = Window.Location.createUrlBuilder(); for (String paramName : Window.Location.getParameterMap().keySet()) { builder.removeParameter(paramName); } builder.setPath(Window.Location.getPath() + "/feedback"); builder.setHash("/"); Window.open(builder.buildString(), "_blank", ""); } }); contents.add(feedbackButton); } response.followUpUrl.accept(new Option.SideEffectVisitor<String>() { @Override public void visitSome(String url) { if (response.redirectToFeedback) { HTMLPanel p2 = new HTMLPanel("h4", surveyMessages.finalPage_externalFollowUpLabel_afterFeedback()); p2.getElement().getStyle().setMarginBottom(0, Style.Unit.PX); contents.add(p2); } else { HTMLPanel p2 = new HTMLPanel("h4", surveyMessages.finalPage_externalFollowUpLabel_noFeedback()); p2.getElement().getStyle().setMarginBottom(0, Style.Unit.PX); contents.add(p2); } FlowPanel externalLinkDiv = new FlowPanel(); externalLinkDiv.add(WidgetFactory.createGreenButton( surveyMessages.finalPage_externalFollowUpButtonLabel(), "finalPageExternalUrlButton", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { Window.open(url, "_blank", ""); } })); contents.add(externalLinkDiv); } @Override public void visitNone() { } }); contents.add(new HTMLPanel(finalPageHtml)); UxEventsHelper.cleanSessionId(); StateManagerUtil.clearLatestState(AuthCache.getCurrentUserId()); } }); return new SimpleSurveyStageInterface(contents, FlatFinalPage.class.getSimpleName()); }