List of usage examples for com.google.gwt.http.client URL decode
public static String decode(String encodedURL)
From source file:org.dataconservancy.dcs.access.client.presenter.FacetedSearchPresenter.java
License:Apache License
public static String searchURL(String query, int offset, boolean context, int max, String... params) { String decodedQuery = URL.decode(query); //prevent double encoding (Firefox already encodes) String encodedQuery = URL.encodeQueryString(decodedQuery); String s = SeadApp.accessurl + SeadApp.queryPath + "?q=" + encodedQuery + "&offset=" + offset + "&max=" + max;//from www . j a v a 2 s . com if (context) { s = s + "&_hl=true&_hl.requireFieldMatch=true&_hl.fl=" + URL.encodeQueryString("*"); } for (int i = 0; i < params.length; i += 2) { s = s + "&" + params[i] + "=" + params[i + 1]; } return s; }
From source file:org.drools.guvnor.client.place.PlaceBuilderUtil.java
License:Apache License
public static Place buildPlaceFromWindow() { // ?id=org.drools.guvnor.editors.DRL // ?uuid=VFS.file_id // final String id = Window.Location.getParameter("id"); final String uuid = Window.Location.getParameter("uuid"); return new TextEditorPlace("SomeName|" + URL.decode(uuid)); }
From source file:org.eclipse.che.ide.ext.runner.client.actions.ChooseRunnerAction.java
License:Open Source License
@Nullable private String getDefaultRunnerName() { CurrentProject currentProject = appContext.getCurrentProject(); if (currentProject == null) { return null; }//from w ww .j av a 2 s .co m String defaultRunner = currentProject.getRunner(); if (defaultRunner == null) { return null; } defaultRunner = URL.decode(defaultRunner); for (Environment e : systemRunners) { if (e.getId().equals(defaultRunner)) { return e.getName(); } } for (Environment e : projectRunners) { if (e.getId().equals(defaultRunner)) { return e.getName(); } } return defaultRunner.substring(defaultRunner.lastIndexOf('/') + 1); }
From source file:org.eclipse.che.ide.ext.runner.client.runneractions.impl.environments.GetProjectEnvironmentsAction.java
License:Open Source License
/** {@inheritDoc} */ @Override/* ww w .j ava 2s .c o m*/ public void perform() { final CurrentProject currentProject = appContext.getCurrentProject(); if (currentProject == null || !runnerUtil.hasRunPermission()) { return; } final ProjectDescriptor descriptor = currentProject.getProjectDescription(); AsyncRequestCallback<RunnerEnvironmentTree> callback = callbackBuilderProvider.get() .unmarshaller(RunnerEnvironmentTree.class).success(new SuccessCallback<RunnerEnvironmentTree>() { @Override public void onSuccess(RunnerEnvironmentTree result) { TemplatesContainer panel = templatesPanelProvider.get(); List<Environment> projectEnvironments = panel.addEnvironments(result, PROJECT); String defaultRunner = currentProject.getRunner(); if (defaultRunner != null) { defaultRunner = URL.decode(defaultRunner); setDefaultRunner(defaultRunner, projectEnvironments, panel); } chooseRunnerAction.addProjectRunners(projectEnvironments); } }).failure(new FailureCallback() { @Override public void onFailure(@Nonnull Throwable reason) { notificationManager.showError(locale.customRunnerGetEnvironmentFailed()); } }).build(); projectService.getRunnerEnvironments(descriptor.getPath(), callback); }
From source file:org.gss_project.gss.web.client.GSS.java
License:Open Source License
/** * Display the 'loading' indicator./* w w w . j a v a2 s. c o m*/ */ public void showLoadingIndicator(String message, String path) { if (path != null) { if (path.contains("?")) path = path.substring(0, path.indexOf('?')); String[] split = path.split("/"); message = message + " " + URL.decode(split[split.length - 1]); } topPanel.getLoading().show(message); }
From source file:org.jahia.ajax.gwt.client.widget.content.FileUploader.java
License:Open Source License
public FileUploader(final Linker linker, final GWTJahiaNode location, String defaultUploadOption) { super();// w w w .j a v a 2 s .com if ("rename".equalsIgnoreCase(defaultUploadOption)) { uploadOption = UploadOption.RENAME; } else if ("version".equalsIgnoreCase(defaultUploadOption)) { uploadOption = UploadOption.VERSION; } else { uploadOption = UploadOption.AUTO; } setHeadingHtml(Messages.get("uploadFile.label")); setSize(500, 500); setResizable(false); ButtonBar buttons = new ButtonBar(); final ProgressBar bar = new ProgressBar(); bar.setWidth(200); form = new FormPanel(); String entryPoint = JahiaGWTParameters.getServiceEntryPoint(); if (entryPoint == null) { entryPoint = "/gwt/"; } form.setHeaderVisible(false); form.setBorders(false); form.setBodyBorder(false); form.setAction(entryPoint + "fileupload"); form.setEncoding(FormPanel.Encoding.MULTIPART); form.setMethod(FormPanel.Method.POST); form.setLabelWidth(200); setModal(true); // upload location Hidden dest = new Hidden(); dest.setName("uploadLocation"); // unzip parameter final CheckBox unzip = new CheckBox(); unzip.setFieldLabel(Messages.get("autoUnzip.label")); unzip.setName("unzip"); String parentPath = location.getPath(); if (location.isFile().booleanValue()) { int index = parentPath.lastIndexOf("/"); if (index > 0) { parentPath = parentPath.substring(0, index); } } dest.setValue(parentPath); form.add(dest); form.add(unzip); form.addListener(Events.Submit, new Listener<FormEvent>() { public void handleEvent(FormEvent ce) { String r = ce.getResultHtml(); if (r == null) { return; } if (r.contains("UPLOAD-SIZE-ISSUE:")) { MessageBox .alert(Messages.get("label.error"), new DirectionalTextHelper( (new HTML(r.replace("UPLOAD-SIZE-ISSUE:", ""))).getElement(), true) .getTextOrHtml(false), null); } else if (r.contains("UPLOAD-ISSUE:")) { unmask(); final Dialog dl = new Dialog(); dl.setModal(true); dl.setHeadingHtml(Messages.get("label.error")); dl.setHideOnButtonClick(true); dl.setLayout(new FlowLayout()); dl.setWidth(300); dl.setScrollMode(Style.Scroll.NONE); dl.add(new HTML( new DirectionalTextHelper((new HTML(r.replace("UPLOAD-ISSUE:", ""))).getElement(), true) .getTextOrHtml(false))); dl.setHeight(150); dl.show(); } } }); Button cancel = new Button(Messages.get("label.cancel"), new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent event) { hide(); } }); final Button submit = new Button(Messages.get("label.ok"), new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent event) { try { mask(Messages.get("message.uploading", "Uploading..."), "x-mask-loading"); form.submit(); } catch (Exception e) { unmask(); bar.reset(); bar.setVisible(false); com.google.gwt.user.client.Window.alert(Messages.get("checkUploads.label")); } } }); buttons.add(submit); buttons.add(cancel); setButtonAlign(Style.HorizontalAlignment.CENTER); setBottomComponent(buttons); final UploadPanel p = new UploadPanel(); form.add(p); form.addListener(Events.BeforeSubmit, new Listener<FormEvent>() { public void handleEvent(FormEvent formEvent) { bar.setVisible(true); bar.auto(); } }); form.addListener(Events.Submit, new Listener<FormEvent>() { public void handleEvent(FormEvent formEvent) { bar.reset(); String selectFileAfterDataUpdate = null; String result = formEvent.getResultHtml(); removeAll(); String[] results = result.split("\n"); final List<Field[]> exists = new ArrayList<Field[]>(); for (int i = 0; i < results.length; i++) { String s = new HTML(results[i]).getText(); if (s.startsWith("OK:")) { if (selectFileAfterDataUpdate == null) { selectFileAfterDataUpdate = URL.decode(s.substring("OK: ".length())); } } else if (s.startsWith("EXISTS:")) { int i1 = s.indexOf(' '); int i2 = s.indexOf(' ', i1 + 1); int i3 = s.indexOf(' ', i2 + 1); final String key = URL.decode(s.substring(i1 + 1, i2)); final String tmp = URL.decode(s.substring(i2 + 1, i3)); final String name = URL.decode(s.substring(i3 + 1)); addExistingToForm(exists, key, tmp, name, submit); } } if (!exists.isEmpty()) { submit.removeAllListeners(); submit.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent event) { mask(Messages.get("message.uploading", "Uploading..."), "x-mask-loading"); submit.setEnabled(false); final List<Field[]> list = new ArrayList<Field[]>(exists); exists.clear(); removeAll(); List<String[]> uploadeds = new ArrayList<String[]>(); for (final Field[] exist : list) { final String tmpName = (String) exist[0].getValue(); // selected index correspond to the action: ie. 3=versioning final int operation = ((SimpleComboBox) exist[1]).getSelectedIndex(); final String newName = (String) exist[2].getValue(); uploadeds.add(new String[] { location.getPath(), tmpName, Integer.toString(operation), newName }); } JahiaContentManagementService.App.getInstance().uploadedFile(uploadeds, new BaseAsyncCallback() { public void onSuccess(Object result) { endUpload(unzip, linker); } @Override public void onFailure(Throwable caught) { super.onFailure(caught); MessageBox.alert(Messages.get("label.error", "error"), caught.getLocalizedMessage(), null); Map<String, Object> data = new HashMap<String, Object>(); data.put(Linker.REFRESH_ALL, true); linker.refresh(data); unmask(); hide(); } }); } }); layout(); } else { if (selectFileAfterDataUpdate != null) { linker.setSelectPathAfterDataUpdate( Arrays.asList(location.getPath() + "/" + selectFileAfterDataUpdate)); } endUpload(unzip, linker); } } }); add(form); setScrollMode(Style.Scroll.AUTO); show(); }
From source file:org.jahia.ajax.gwt.client.widget.edit.mainarea.MainModule.java
License:Open Source License
public void initWithLinker(EditLinker linker) { this.editLinker = linker; ((ToolbarHeader) head).removeAllTools(); if (config.getMainModuleToolbar() != null && !config.getMainModuleToolbar().getGwtToolbarItems().isEmpty()) { for (GWTJahiaToolbarItem item : config.getMainModuleToolbar().getGwtToolbarItems()) { ((ToolbarHeader) head).addItem(linker, item); }//from ww w . j a v a2 s . c o m head.addTool(new ToolButton("x-tool-refresh", new SelectionListener<IconButtonEvent>() { public void componentSelected(IconButtonEvent event) { Map<String, Object> data = new HashMap<String, Object>(); data.put(Linker.REFRESH_MAIN, true); refresh(data); } })); ((ToolbarHeader) head).attachTools(); headContainer.add(head); headContainer.show(); } else { headContainer.hide(); } String location = newLocation; newLocation = null; String hash = Window.Location.getHash(); if (location == null && !hash.equals("") && hash.contains("|")) { location = hash.substring(hash.indexOf('|') + 1); } if (location == null) { location = Window.Location.getPath(); } if (location.contains("://")) { location = location.substring(location.indexOf("://") + 3); location = location.substring(location.indexOf("/")); } if (location.startsWith(JahiaGWTParameters.getContextPath() + config.getDefaultUrlMapping() + "/")) { location = location.replaceFirst(config.getDefaultUrlMapping(), config.getDefaultUrlMapping() + "frame"); } if (location.contains("frame/") && !isValidUrl(location)) { String start = location.substring(0, location.indexOf("frame/")); start = start.substring(JahiaGWTParameters.getContextPath().length()); location = location.replaceFirst(start + "frame/", config.getDefaultUrlMapping() + "frame/"); } StringBuilder url = new StringBuilder(64); url.append(URL.decode(location)); appendQueryString(url); location = url.toString(); resetFramePosition(); goToUrl(location, true, true, true); // scrollContainer.sinkEvents(); Listener<ComponentEvent> listener = new Listener<ComponentEvent>() { public void handleEvent(ComponentEvent ce) { setCtrlActive(ce); makeSelected(); } }; // on click listener scrollContainer.addListener(Events.OnClick, listener); // on double click listener scrollContainer.addListener(Events.OnDoubleClick, new EditContentEnginePopupListener(this, editLinker)); if (config.getContextMenu() != null) { // contextMenu contextMenu = new ActionContextMenu(config.getContextMenu(), editLinker) { @Override public boolean beforeShow() { makeSelected(); if (editLinker.getSelectionContext().getSingleSelection() == editLinker.getSelectionContext() .getMainNode()) { Module selectedModule = editLinker.getSelectedModule(); return selectedModule != null && selectedModule instanceof SimpleModule && super.beforeShow(); } return super.beforeShow(); } }; scrollContainer.setContextMenu(contextMenu); } infoLayers.initWithLinker(linker); }
From source file:org.n52.client.Application.java
License:Open Source License
public static void finishStartup() { try {//from ww w . j a v a2s .c o m String currentUrl = URL.decode(Window.Location.getHref()); if (hasQueryString(currentUrl) && !isGwtHostedModeParameterOnly()) { String[] services = getDecodedParameters(SERVICES); String[] versions = getDecodedParameters(VERSIONS); String[] features = getDecodedParameters(FEATURES); String[] offerings = getDecodedParameters(OFFERINGS); String[] procedures = getDecodedParameters(PROCEDURES); String[] phenomenons = getDecodedParameters(PHENOMENONS); String[] options = getDecodedParameters("options"); TimeRange timeRange = createTimeRange(); String locale = Window.Location.getParameter("locale"); if (isLocaleOnly(services, versions, offerings, features, procedures, phenomenons, locale)) { return; } if (!isAllParametersAvailable(services, versions, offerings, features, procedures, phenomenons)) { getToasterInstance().addErrorMessage(i18n.errorUrlParsing()); return; } if (timeRange.isSetStartAndEnd()) { fireNewTimeRangeEvent(timeRange); } PermalinkController permalinkController = new PermalinkController(); for (int i = 0; i < services.length; i++) { final String service = services[i]; final String version = versions[i]; final String offering = offerings[i]; final String procedure = procedures[i]; final String phenomenon = phenomenons[i]; final String feature = features[i]; SosTimeseries sosTimeseries = new SosTimeseries(); sosTimeseries.setFeature(new Feature(feature, service)); sosTimeseries.setOffering(new Offering(offering, service)); sosTimeseries.setPhenomenon(new Phenomenon(phenomenon, service)); sosTimeseries.setSosService(new SosService(service, version)); sosTimeseries.setProcedure(new Procedure(procedure, service)); GWT.log("Timeseries to load: " + sosTimeseries); TimeseriesRenderingOptions tsOptions = null; if (options != null && options.length > i) { tsOptions = createRenderingOptions(options[i]); GWT.log("with options: " + options[i]); permalinkController.addTimeseries(sosTimeseries, tsOptions); } else { permalinkController.addTimeseries(sosTimeseries); } SOSMetadataBuilder builder = new SOSMetadataBuilder().addServiceURL(service) .addServiceVersion(version); SOSMetadata sosMetadata = new SOSMetadata(builder); getMainEventBus().fireEvent(new StoreSOSMetadataEvent(sosMetadata)); getMainEventBus().fireEvent(new GetPhenomenonsEvent.Builder(service).build()); getMainEventBus().fireEvent(new GetFeatureEvent(service, feature)); getMainEventBus().fireEvent(new GetOfferingEvent(service, offering)); getMainEventBus().fireEvent(new GetProcedureEvent(service, procedure)); getMainEventBus().fireEvent(new GetStationForTimeseriesEvent(sosTimeseries)); getMainEventBus().fireEvent(new GetStationsWithinBBoxEvent(service, null)); getMainEventBus().fireEvent(new NewSOSMetadataEvent()); } } else { showStationSelectorWhenConfigured(); } } catch (Exception e) { if (!GWT.isProdMode()) { GWT.log("Error evaluating permalink!", e); } showStationSelectorWhenConfigured(); getToasterInstance().addErrorMessage(i18n.errorUrlParsing()); } finally { finalEvents(); } }
From source file:org.opencms.ade.galleries.client.ui.CmsImageGalleryField.java
License:Open Source License
/** * Parses the value and all its informations.<p> * First part is the URL of the image. The second one describes the scale of this image.<p> * The last one sets the selected format.<p> * * @param value that should be parsed/* w ww . j av a2 s.co m*/ * * @return the URL of the image without any parameters */ private String parseValue(String value) { m_croppingParam = CmsCroppingParamBean.parseImagePath(value); String path = ""; String params = ""; if (value.indexOf("?") > -1) { path = value.substring(0, value.indexOf("?")); params = value.substring(value.indexOf("?")); } else { path = value; } int indexofscale = params.indexOf(PARAMETER_SCALE); if (indexofscale > -1) { String scal = ""; int hasmoreValues = params.lastIndexOf("&"); if (hasmoreValues > indexofscale) { scal = params.substring(indexofscale, params.indexOf("&")).replace(PARAMETER_SCALE, ""); } else { scal = params.substring(indexofscale).replace(PARAMETER_SCALE, ""); } if (!scal.equals(m_scaleValue)) { m_scaleValue = scal; } params = params.replace(PARAMETER_SCALE + m_scaleValue, ""); } int indexofformat = params.indexOf(PARAMETER_FORMAT); if (indexofformat > -1) { int hasmoreValues = params.lastIndexOf("&"); if (hasmoreValues > indexofformat) { m_selectedFormat = params.substring(indexofformat, hasmoreValues).replace(PARAMETER_FORMAT, ""); } else { m_selectedFormat = params.substring(indexofformat).replace(PARAMETER_FORMAT, ""); } params = params.replace(PARAMETER_FORMAT + m_selectedFormat, ""); m_formatSelection.selectValue(m_selectedFormat); } int indexofdescritption = params.indexOf(PARAMETER_DESC); if (indexofdescritption > -1) { int hasmoreValues = params.lastIndexOf("&"); if (hasmoreValues > indexofdescritption) { m_description = params.substring(indexofdescritption, hasmoreValues).replace(PARAMETER_DESC, ""); } else { m_description = params.substring(indexofdescritption).replace(PARAMETER_DESC, ""); } params = params.replace(PARAMETER_DESC + m_description, ""); m_description = URL.decode(m_description); m_descriptionArea.setFormValueAsString(m_description); } updateUploadTarget(CmsResource.getFolderPath(path)); if (!path.isEmpty()) { String imageLink = CmsCoreProvider.get().link(path); setImagePreview(imageLink); } else { m_imagePreview.setInnerHTML(""); } return path; }
From source file:org.openxdata.sharedlib.client.widget.WidgetEx.java
public static String getTabDisplayText(String html) { if (html.indexOf("<") > 0) html = URL.decode(html); if (html.indexOf("</") > 0) html = html.substring(html.indexOf(">") + 1, html.indexOf("</")); return html;// w w w. j a va 2 s .co m }