List of usage examples for com.google.gwt.http.client URL decode
public static String decode(String encodedURL)
From source file:org.tbiq.gwt.tools.placeservice.browser.DefaultHistoryTokenParser.java
License:Open Source License
@Override public Map<String, List<String>> parse(String historyToken) { // Ensure the history token is in proper format if (!isValidHistoryToken(historyToken)) { return null; }/* w w w. jav a2 s. c o m*/ // Break up the name/value pair strings String[] nameValuePairStrings = historyToken.split(NAME_VALUE_PAIRS_SEPARATOR); // Loop through the name/value pair strings Map<String, List<String>> keyedValueMap = new HashMap<String, List<String>>(); for (String nameValuePairString : nameValuePairStrings) { // Break up name/value string into name/value pair (always force 2 groups) String[] nameValuePair = nameValuePairString.split(NAME_VALUE_PAIR_SEPARATOR, 2); String name = nameValuePair[0]; String value = nameValuePair[1]; // Add name/value to map if value is not an empty string if (!value.trim().isEmpty()) { // Check if this name doesn't have any values yet List<String> values = keyedValueMap.get(name); if (values == null) { // Create new list to hold values values = new ArrayList<String>(); // Add new list to map keyedValueMap.put(name, values); } // Decode and add new value to the values list for this name value = URL.decode(value); values.add(value); } } return keyedValueMap; }
From source file:org.uberfire.client.mvp.PlaceRequestHistoryMapperImpl.java
License:Apache License
String urlDecode(String value) {
return URL.decode(value);
}
From source file:org.uberfire.ext.widgets.common.client.common.ConcurrentChangePopup.java
License:Apache License
private static String decode(final Path path) { return URL.decode(path.toURI()); }
From source file:org.uberfire.util.URIUtil.java
License:Apache License
public static String decode(String content) { return URL.decode(content); }
From source file:org.unitime.timetable.gwt.client.instructor.TeachingAssignmentsPage.java
License:Apache License
public TeachingAssignmentsPage() { iFilterPanel = new FilterPanel(); Label filterLabel = new Label(MESSAGES.propDepartment()); iFilterPanel.addLeft(filterLabel);/* ww w . ja va 2 s. c o m*/ iFilterBox = new TeachingRequestsFilterBox(null); iFilterPanel.addLeft(iFilterBox); iSearch = new Button(UniTimeHeaderPanel.stripAccessKey(MESSAGES.buttonSearch())); Character searchAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonSearch()); if (searchAccessKey != null) iSearch.setAccessKey(searchAccessKey); iSearch.addStyleName("unitime-NoPrint"); iFilterPanel.addRight(iSearch); iSearch.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { search(); } }); iExportCSV = new Button(UniTimeHeaderPanel.stripAccessKey(MESSAGES.buttonExportCSV())); Character exportCsvAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonExportCSV()); if (exportCsvAccessKey != null) iExportCSV.setAccessKey(exportCsvAccessKey); iExportCSV.addStyleName("unitime-NoPrint"); iFilterPanel.addRight(iExportCSV); iExportCSV.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { export("teaching-assignments.csv"); } }); iExportPDF = new Button(UniTimeHeaderPanel.stripAccessKey(MESSAGES.buttonExportPDF())); Character exportPdfAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonExportPDF()); if (exportPdfAccessKey != null) iExportPDF.setAccessKey(exportCsvAccessKey); iExportPDF.addStyleName("unitime-NoPrint"); iFilterPanel.addRight(iExportPDF); iExportPDF.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { export("teaching-assignments.pdf"); } }); addHeaderRow(iFilterPanel); iTable = new TeachingAssignmentsTable() { @Override protected void onAssignmentChanged(List<AssignmentInfo> assignments) { if (iTable.isVisible()) search(); } }; iTable.setVisible(false); addRow(iTable); LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage()); RPC.execute(new TeachingRequestsPagePropertiesRequest(), new AsyncCallback<TeachingRequestsPagePropertiesResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); iFilterBox.setErrorHint(MESSAGES.failedToInitialize(caught.getMessage())); UniTimeNotifications.error(MESSAGES.failedToInitialize(caught.getMessage()), caught); ToolBox.checkAccess(caught); } @Override public void onSuccess(TeachingRequestsPagePropertiesResponse result) { LoadingWidget.getInstance().hide(); iTable.setProperties(result); Chip department = iFilterBox.getChip("department"); if (department != null) { boolean match = false; for (DepartmentInterface d : result.getDepartments()) { if (d.getDeptCode().equalsIgnoreCase(department.getValue())) { match = true; } } if (!match) iFilterBox.setValue("", true); } if (result.getLastDepartmentId() != null && iFilterBox.getValue().isEmpty()) { for (DepartmentInterface d : result.getDepartments()) { if (d.getId().equals(result.getLastDepartmentId())) { iFilterBox.setValue("department:\"" + d.getDeptCode() + "\"", true); break; } } } } }); if (Window.Location.getHash() != null && Window.Location.getHash().length() > 1) { iFilterBox.setValue(URL.decode(Window.Location.getHash().substring(1)), true); search(); } else { String q = InstructorCookie.getInstance().getQuery(null); if (q != null && !q.isEmpty()) iFilterBox.setValue(q, true); } History.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { if (event.getValue() != null && !event.getValue().isEmpty()) { iFilterBox.setValue(event.getValue().replace("%20", " "), true); search(); } } }); }
From source file:org.unitime.timetable.gwt.client.instructor.TeachingRequestsPage.java
License:Apache License
public TeachingRequestsPage() { iAssigned = "true".equalsIgnoreCase(Location.getParameter("assigned")); if (iAssigned) UniTimePageLabel.getInstance().setPageName(MESSAGES.pageAssignedTeachingRequests()); else/*from w ww .j a v a2 s . co m*/ UniTimePageLabel.getInstance().setPageName(MESSAGES.pageUnassignedTeachingRequests()); iFilterPanel = new FilterPanel(); Label filterLabel = new Label(MESSAGES.propSubjectArea()); iFilterPanel.addLeft(filterLabel); iFilterBox = new TeachingRequestsFilterBox(iAssigned); iFilterPanel.addLeft(iFilterBox); iSearch = new Button(UniTimeHeaderPanel.stripAccessKey(MESSAGES.buttonSearch())); Character searchAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonSearch()); if (searchAccessKey != null) iSearch.setAccessKey(searchAccessKey); iSearch.addStyleName("unitime-NoPrint"); iFilterPanel.addRight(iSearch); iSearch.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { search(); } }); iExportCSV = new Button(UniTimeHeaderPanel.stripAccessKey(MESSAGES.buttonExportCSV())); Character exportCsvAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonExportCSV()); if (exportCsvAccessKey != null) iExportCSV.setAccessKey(exportCsvAccessKey); iExportCSV.addStyleName("unitime-NoPrint"); iFilterPanel.addRight(iExportCSV); iExportCSV.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { export("teaching-requests.csv"); } }); iExportPDF = new Button(UniTimeHeaderPanel.stripAccessKey(MESSAGES.buttonExportPDF())); Character exportPdfAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonExportPDF()); if (exportPdfAccessKey != null) iExportPDF.setAccessKey(exportCsvAccessKey); iExportPDF.addStyleName("unitime-NoPrint"); iFilterPanel.addRight(iExportPDF); iExportPDF.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { export("teaching-requests.pdf"); } }); addHeaderRow(iFilterPanel); iTable = new TeachingRequestsTable() { @Override protected void onAssignmentChanged(List<AssignmentInfo> assignments) { if (iTable.isVisible()) search(); } }; iTable.setVisible(false); addRow(iTable); LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage()); RPC.execute(new TeachingRequestsPagePropertiesRequest(), new AsyncCallback<TeachingRequestsPagePropertiesResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); iFilterBox.setErrorHint(MESSAGES.failedToInitialize(caught.getMessage())); UniTimeNotifications.error(MESSAGES.failedToInitialize(caught.getMessage()), caught); ToolBox.checkAccess(caught); } @Override public void onSuccess(TeachingRequestsPagePropertiesResponse result) { LoadingWidget.getInstance().hide(); iTable.setProperties(result); Chip subject = iFilterBox.getChip("subject"); if (subject != null) { boolean match = false; for (SubjectAreaInterface s : result.getSubjectAreas()) { if (s.getAbbreviation().equalsIgnoreCase(subject.getValue())) { match = true; } } if (!match) iFilterBox.setValue("", true); } if (result.getLastSubjectAreaId() != null && iFilterBox.getValue().isEmpty()) { for (SubjectAreaInterface s : result.getSubjectAreas()) { if (s.getId().equals(result.getLastSubjectAreaId())) { iFilterBox.setValue("subject:\"" + s.getAbbreviation() + "\"", true); break; } } } } }); if (Window.Location.getHash() != null && Window.Location.getHash().length() > 1) { iFilterBox.setValue(URL.decode(Window.Location.getHash().substring(1)), true); search(); } else { String q = InstructorCookie.getInstance().getQuery(iAssigned); if (q != null && !q.isEmpty()) iFilterBox.setValue(q, true); } History.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { if (event.getValue() != null && !event.getValue().isEmpty()) { iFilterBox.setValue(event.getValue().replace("%20", " "), true); search(); } } }); }
From source file:org.unitime.timetable.gwt.client.sectioning.SectioningStatusPage.java
License:Apache License
private void checkLastQuery() { if (Window.Location.getParameter("q") != null) { iFilter.setValue(Window.Location.getParameter("q"), true); if (Window.Location.getParameter("t") != null) { if ("2".equals(Window.Location.getParameter("t"))) { iTabPanel.selectTab(1);/*from ww w .ja va2s. c om*/ } else { iTabPanel.selectTab(0); } } else { loadData(); } } else if (Window.Location.getHash() != null && !Window.Location.getHash().isEmpty()) { String hash = URL.decode(Window.Location.getHash().substring(1)); if (!hash.matches("^[0-9]+\\:?[0-9]*@?$")) { if (hash.endsWith("@")) { iFilter.setValue(hash.substring(0, hash.length() - 1), true); iTabPanel.selectTab(1); } else if (hash.endsWith("$")) { iFilter.setValue(hash.substring(0, hash.length() - 1), true); iTabPanel.selectTab(2); } else { iFilter.setValue(hash, true); loadData(); } } } else { String q = SectioningStatusCookie.getInstance().getQuery(iOnline); if (q != null) iFilter.setValue(q); int t = SectioningStatusCookie.getInstance().getTab(iOnline); if (t >= 0 && t < iTabPanel.getTabCount()) { iTabPanel.selectTab(t, false); iTabIndex = -1; } if (GWT_CONSTANTS.searchWhenPageIsLoaded() && q != null && !q.isEmpty()) loadData(); } }
From source file:org.wte4j.examples.showcase.client.generation.GenerateDocumentPresenter.java
License:Apache License
public void createAndDownlaodDocument() { orderService.createDocument(selectedOrder, selectedTemplate, new AsyncCallback<String>() { @Override// w w w . j av a 2s .com public void onSuccess(String result) { display.hideTemplateList(); String url = GWT.getModuleBaseURL() + "orderService?file=" + result.toString(); url = URL.decode(url); Window.open(url, "parent", ""); } @Override public void onFailure(Throwable caught) { display.hideTemplateList(); showErrorOnFailure(caught); } }); }
From source file:tsd.client.QueryUi.java
License:Open Source License
private void refreshFromQueryString() { final QueryString qs = getQueryString(URL.decode(History.getToken())); maybeSetTextbox(qs, "start", start_datebox.getTextBox()); maybeSetTextbox(qs, "end", end_datebox.getTextBox()); setTextbox(qs, "wxh", wxh); autoreload.setValue(qs.containsKey("autoreload"), true); maybeSetTextbox(qs, "autoreload", autoreoload_interval); final ArrayList<String> newmetrics = qs.get("m"); if (newmetrics == null) { // Clear all metric forms. final int toremove = metrics.getWidgetCount() - 1; addMetricForm("metric 1", 0); metrics.selectTab(0);// w w w .j av a2s .c o m for (int i = 0; i < toremove; i++) { metrics.remove(1); } return; } final int n = newmetrics.size(); // We want this many metrics. ArrayList<String> options = qs.get("o"); if (options == null) { options = new ArrayList<String>(n); } for (int i = options.size(); i < n; i++) { // Make both arrays equal size. options.add(""); // Add missing o's. } for (int i = 0; i < newmetrics.size(); ++i) { if (i == metrics.getWidgetCount() - 1) { addMetricForm("", i); } final MetricForm metric = (MetricForm) metrics.getWidget(i); metric.updateFromQueryString(newmetrics.get(i), options.get(i)); } // Remove extra metric forms. final int m = metrics.getWidgetCount() - 1; // We have this many metrics. int showing = metrics.getTabBar().getSelectedTab(); // Currently selected. for (int i = m - 1; i >= n; i--) { if (showing == i) { // If we're about to remove the currently selected, metrics.selectTab(--showing); // fix focus to not wind up nowhere. } metrics.remove(i); } updatey2range.onEvent(null); maybeSetTextbox(qs, "ylabel", ylabel); maybeSetTextbox(qs, "y2label", y2label); maybeSetTextbox(qs, "yformat", yformat); maybeSetTextbox(qs, "y2format", y2format); maybeSetTextbox(qs, "yrange", yrange); maybeSetTextbox(qs, "y2range", y2range); ylog.setValue(qs.containsKey("ylog")); y2log.setValue(qs.containsKey("y2log")); if (qs.containsKey("key")) { final String key = qs.getFirst("key"); keybox.setValue(key.contains(" box")); horizontalkey.setValue(key.contains(" horiz")); keypos = key.replaceAll(" (box|horiz\\w*)", ""); keypos_map.get(keypos).setChecked(true); } else { keybox.setValue(false); horizontalkey.setValue(false); keypos_map.get("top right").setChecked(true); keypos = ""; } nokey.setValue(qs.containsKey("nokey")); smooth.setValue(qs.containsKey("smooth")); }
From source file:tsd.client.QueryUi.java
License:Open Source License
private void refreshGraph() { final Date start = start_datebox.getValue(); if (start == null) { graphstatus.setText("Please specify a start time."); return;/*from www.ja v a 2s .c o m*/ } final Date end = end_datebox.getValue(); if (end != null && !autoreload.getValue()) { if (end.getTime() <= start.getTime()) { end_datebox.addStyleName("dateBoxFormatError"); graphstatus.setText("End time must be after start time!"); return; } } final StringBuilder url = new StringBuilder(); url.append("/q?start="); final String start_text = start_datebox.getTextBox().getText(); if (start_text.endsWith(" ago") || start_text.endsWith("-ago")) { url.append(start_text); } else { url.append(FULLDATE.format(start)); } if (end != null && !autoreload.getValue()) { url.append("&end="); final String end_text = end_datebox.getTextBox().getText(); if (end_text.endsWith(" ago") || end_text.endsWith("-ago")) { url.append(end_text); } else { url.append(FULLDATE.format(end)); } } else { // If there's no end-time, the graph may change while the URL remains // the same. No browser seems to re-fetch an image once it's been // fetched, even if we destroy the DOM object and re-created it with the // same src attribute. This has nothing to do with caching headers sent // by the server. The browsers simply won't retrieve the same URL again // through JavaScript manipulations, period. So as a workaround, we add // a special parameter that the server will delete from the query. url.append("&ignore=" + nrequests++); } if (!addAllMetrics(url)) { return; } addLabels(url); addFormats(url); addYRanges(url); addLogscales(url); if (nokey.getValue()) { url.append("&nokey"); } else if (!keypos.isEmpty() || horizontalkey.getValue()) { url.append("&key="); if (!keypos.isEmpty()) { url.append(keypos); } if (horizontalkey.getValue()) { url.append(" horiz"); } if (keybox.getValue()) { url.append(" box"); } } url.append("&wxh=").append(wxh.getText()); if (smooth.getValue()) { url.append("&smooth=csplines"); } final String unencodedUri = url.toString(); final String uri = URL.encode(unencodedUri); if (uri.equals(lastgraphuri)) { return; // Don't re-request the same graph. } else if (pending_requests++ > 0) { return; } lastgraphuri = uri; graphstatus.setText("Loading graph..."); asyncGetJson(uri + "&json", new GotJsonCallback() { public void got(final JSONValue json) { if (autoreoload_timer != null) { autoreoload_timer.cancel(); autoreoload_timer = null; } final JSONObject result = json.isObject(); final JSONValue err = result.get("err"); String msg = ""; if (err != null) { displayError("An error occurred while generating the graph: " + err.isString().stringValue()); graphstatus.setText("Please correct the error above."); } else { clearError(); String history = unencodedUri.substring(3) // Remove "/q?". .replaceFirst("ignore=[^&]*&", ""); // Unnecessary cruft. if (autoreload.getValue()) { history += "&autoreload=" + autoreoload_interval.getText(); } if (!history.equals(URL.decode(History.getToken()))) { History.newItem(history, false); } final JSONValue nplotted = result.get("plotted"); final JSONValue cachehit = result.get("cachehit"); if (cachehit != null) { msg += "Cache hit (" + cachehit.isString().stringValue() + "). "; } if (nplotted != null && nplotted.isNumber().doubleValue() > 0) { graph.setUrl(uri + "&png"); graph.setVisible(true); msg += result.get("points").isNumber() + " points retrieved, " + nplotted + " points plotted"; } else { graph.setVisible(false); msg += "Your query didn't return anything"; } final JSONValue timing = result.get("timing"); if (timing != null) { msg += " in " + timing + "ms."; } else { msg += '.'; } } final JSONValue info = result.get("info"); if (info != null) { if (!msg.isEmpty()) { msg += ' '; } msg += info.isString().stringValue(); } graphstatus.setText(msg); if (result.get("etags") != null) { final JSONArray etags = result.get("etags").isArray(); final int netags = etags.size(); for (int i = 0; i < netags; i++) { if (i >= metrics.getWidgetCount()) { break; } final Widget widget = metrics.getWidget(i); if (!(widget instanceof MetricForm)) { break; } final MetricForm metric = (MetricForm) widget; final JSONArray tags = etags.get(i).isArray(); // Skip if no tags were associated with the query. if (null != tags) { for (int j = 0; j < tags.size(); j++) { metric.autoSuggestTag(tags.get(j).isString().stringValue()); } } } } if (autoreload.getValue()) { final int reload_in = Integer.parseInt(autoreoload_interval.getValue()); if (reload_in >= 5) { autoreoload_timer = new Timer() { public void run() { // Verify that we still want auto reload and that the graph // hasn't been updated in the mean time. if (autoreload.getValue() && lastgraphuri == uri) { // Force refreshGraph to believe that we want a new graph. lastgraphuri = ""; refreshGraph(); } } }; autoreoload_timer.schedule(reload_in * 1000); } } if (--pending_requests > 0) { pending_requests = 0; refreshGraph(); } } }); }