List of usage examples for com.google.gwt.http.client URL encodePathSegment
public static String encodePathSegment(String decodedURLComponent)
From source file:com.bramosystems.oss.player.core.client.ui.FlashMediaPlayer.java
License:Apache License
/** * Constructs <code>FlashMediaPlayer</code> with the specified {@code height} and * {@code width} to playback media located at {@code mediaURL}. Media playback * begins automatically if {@code autoplay} is {@code true}. * * <p> {@code height} and {@code width} are specified as CSS units. A value of {@code null} * for {@code height} or {@code width} puts the player in embedded mode. When in embedded mode, * the player is made invisible on the page and media state events are propagated to registered * listeners only. This is desired especially when used with custom sound controls. For custom * video-playback control, specify valid CSS values for {@code height} and {@code width} but hide the * player controls with {@code setControllerVisible(false)}. * * @param mediaURL the URL of the media to playback * @param autoplay {@code true} to start playing automatically, {@code false} otherwise * @param height the height of the player * @param width the width of the player. * * @throws PluginVersionException if the required Flash plugin version is not installed on the client. * @throws PluginNotFoundException if the Flash plugin is not installed on the client. *//*from w w w . j av a 2s . c o m*/ public FlashMediaPlayer(final String mediaURL, final boolean autoplay, String height, String width) throws PluginNotFoundException, PluginVersionException { this(); _height = height; _width = width; isEmbedded = (height == null) || (width == null); if (isEmbedded) { _height = "0px"; _width = "0px"; } swf = new SWFWidget(FMPStateManager.getSWFImpl(), "100%", _height, req); swf.setFlashVar("playerId", swf.getId()); swf.setFlashVar("autoplay", Boolean.toString(autoplay)); swf.setFlashVar("evtPfx", ((CorePlayerProvider) getWidgetFactory("core")).getFMPHandlerPrefix(swf.getId())); swf.setFlashVar("mediaURL", URL.encodePathSegment(mediaURL)); swf.commitFlashVars(); swf.addProperty("allowScriptAccess", "always"); swf.addProperty("allowFullScreen", "true"); swf.addProperty("bgcolor", "#000000"); playerId = swf.getId(); ((CorePlayerProvider) getWidgetFactory("core")).initFMPHandler(playerId, new FMPStateManager.FMPStateCallback() { @Override public void onInit() { impl = FlashMediaPlayerImpl.getPlayer(playerId); for (String url : _playlistCache) { impl.addToPlaylist(url); } firePlayerStateEvent(PlayerStateEvent.State.Ready); } @Override public void onMessage(int type, String message) { if (type == 1) { fireError(message); } else { fireDebug(message); } } @Override public void onProgress(double progress) { fireLoadingProgress(progress); } @Override public void onMediaInfo(String info) { MediaInfo mi = new MediaInfo(); FMPStateManager.fillMediaInfoImpl(info, mi); fireMediaInfoAvailable(mi); } @Override public void onEvent(int type, boolean buttonDown, boolean alt, boolean ctrl, boolean shift, boolean cmd, int stageX, int stageY) { int button = buttonDown ? NativeEvent.BUTTON_LEFT : NativeEvent.BUTTON_RIGHT; int screenX = -1, screenY = -1; Document _doc = Document.get(); NativeEvent event = null; switch (type) { case 1: // mouse down event = _doc.createMouseDownEvent(1, screenX, screenY, stageX, stageY, ctrl, alt, shift, cmd, button); break; case 2: // mouse up event = _doc.createMouseUpEvent(1, screenX, screenY, stageX, stageY, ctrl, alt, shift, cmd, button); break; case 3: // mouse move event = _doc.createMouseMoveEvent(1, screenX, screenY, stageX, stageY, ctrl, alt, shift, cmd, button); break; case 10: // click event = _doc.createClickEvent(1, screenX, screenY, stageX, stageY, ctrl, alt, shift, cmd); break; case 11: // double click event = _doc.createDblClickEvent(1, screenX, screenY, stageX, stageY, ctrl, alt, shift, cmd); break; case 20: // key down event = _doc.createKeyDownEvent(ctrl, alt, shift, cmd, stageX); break; case 21: // key press event = _doc.createKeyPressEvent(ctrl, alt, shift, cmd, stageX); break; case 22: // key up event = _doc.createKeyUpEvent(ctrl, alt, shift, cmd, stageX); break; } DomEvent.fireNativeEvent(event, FlashMediaPlayer.this); } @Override public void onStateChanged(int stateId, int listIndex) { switch (stateId) { case 1: // loading started... //// listener.onPlayerReady(); break; case 2: // play started... firePlayStateEvent(PlayStateEvent.State.Started, listIndex); break; case 3: // play stopped... firePlayStateEvent(PlayStateEvent.State.Stopped, listIndex); break; case 4: // play paused... firePlayStateEvent(PlayStateEvent.State.Paused, listIndex); break; case 9: // play finished... firePlayStateEvent(PlayStateEvent.State.Finished, listIndex); break; case 10: // loading complete ... fireLoadingProgress(1.0); break; } } @Override public void onFullScreen(boolean fullscreen) { firePlayerStateEvent(fullscreen ? PlayerStateEvent.State.FullScreenStarted : PlayerStateEvent.State.FullScreenFinished); } }); if (!isEmbedded) { addMediaInfoHandler(new MediaInfoHandler() { @Override public void onMediaInfoAvailable(MediaInfoEvent event) { MediaInfo info = event.getMediaInfo(); if (info.getAvailableItems().contains(MediaInfoKey.VideoHeight) || info.getAvailableItems().contains(MediaInfoKey.VideoWidth)) { checkVideoSize(Integer.parseInt(info.getItem(MediaInfoKey.VideoHeight)), Integer.parseInt(info.getItem(MediaInfoKey.VideoWidth))); } } }); } initWidget(swf); }
From source file:com.dawg6.web.dhcalc.client.LeaderboardPanel.java
License:Open Source License
protected void showPaperdoll() { String btag = getSelectedAccount(); Realm realm = mainPanel.getSelectedRealm(); if ((realm != null) && (btag != null)) { String[] split = btag.split("#"); MainPanel.openPaperdoll(realm.name(), URL.encodePathSegment(split[0]), Integer.valueOf(split[1]), Integer.valueOf(split[2])); }//from w w w. jav a 2 s . com }
From source file:com.dawg6.web.dhcalc.client.MainPanel.java
License:Open Source License
protected void showPaperdoll() { if (this.career == null) { ApplicationPanel.showErrorDialog("Fetch Hero List First"); return;/*from ww w.j a v a 2s .com*/ } int index = heroList.getSelectedIndex(); if (index >= 0) { String value = heroList.getValue(index); if (value.length() == 0) { ApplicationPanel.showErrorDialog("Fetch Hero List First"); return; } openPaperdoll(realm.name(), URL.encodePathSegment(profile), tag, Integer.valueOf(value)); // PaperdollPanel panel = new PaperdollPanel(); // panel.load(realm, profile, tag, Integer.valueOf(value)); // // ApplicationPanel.showDialogBox("Paperdoll", panel, // ApplicationPanel.OK, null); } else { ApplicationPanel.showErrorDialog("Select a Hero"); return; } }
From source file:com.fullmetalgalaxy.model.SharedMethods.java
License:Open Source License
/** * Returns a string where all characters that are not valid for a URL * component have been escaped. The escaping of a character is done by * converting it into its UTF-8 encoding and then encoding each of the * resulting bytes as a %xx hexadecimal escape sequence. * // w w w. j a v a 2 s . co m * <p> * The following character sets are <em>not</em> escaped by this method: * <ul> * <li>ASCII digits or letters</li> * <li>ASCII punctuation characters: * * <pre>- _ . ! ~ * ' ( )</pre> * </li> * </ul> * </p> * * <p> * Notice that this method <em>does</em> encode the URL component delimiter * characters:<blockquote> * * <pre> * ; / ? : & = + $ , # * </pre> * * </blockquote> * </p> * * @param decodedURLComponent a string containing invalid URL characters * @return a string with all invalid URL characters escaped * * @throws NullPointerException if decodedURLComponent is <code>null</code> */ public static String encodePathSegment(String decodedURLComponent) { if (decodedURLComponent == null) { return null; } return URL.encodePathSegment(decodedURLComponent); }
From source file:com.google.appinventor.client.youngandroid.TextValidators.java
License:Open Source License
/** * Checks whether the argument is a legal filename, meaning * it is unchanged by URL encoding and it meets the aapt * requirements as follows:/*from ww w . ja va 2 s. co m*/ * - all characters must be 7-bit printable ASCII * - none of { '/' '\\' ':' } * @param filename The filename (not path) of uploaded file * @return {@code true} if the argument is a legal filename, {@code false} * otherwise */ public static boolean isValidCharFilename(String filename) { return !filename.contains("'") && filename.equals(URL.encodePathSegment(filename)); }
From source file:com.google.gerrit.client.groups.GroupInfo.java
License:Apache License
public final void setOwnerUUID(AccountGroup.UUID uuid) { owner_id(URL.encodePathSegment(uuid.get())); }
From source file:com.google.gerrit.plugin.client.rpc.RestApi.java
License:Apache License
public RestApi id(String id) { return idRaw(URL.encodePathSegment(id)); }
From source file:com.gwtplatform.common.client.ClientUrlUtils.java
License:Apache License
@Override public String encodePathSegment(String decodedPathSegment) { return URL.encodePathSegment(decodedPathSegment); }
From source file:com.kk_electronic.kkportal.scada.ScadaJsonCaller.java
License:Open Source License
/** * Using {@link ISecurityService#Login(String, String, AsyncCallback)} as an * example the result should be:/*from w w w . j a va2 s.co m*/ * * <pre> * http://77.243.35.41:8732/ParkServices/ParkService/JSON/Login?userName=******&password=****** * </pre> * */ @Override public <T> void execute(final Request<T> request) { // First we add the semi static part StringBuilder sb = new StringBuilder("http://"); sb.append("77.243.35.41"); sb.append(":"); sb.append(8732); sb.append("/ParkServices/ParkService/JSON/"); // The last part of the url is made from the method name and the // parameters sb.append(request.getMethod()); String[] names = request.getNames(); Object[] values = request.getParams(); // The first key-value pair must be separated by a "?" char sep = '?'; // For every pair for (int i = 0, l = Math.min(names.length, values.length); i < l; i++) { // We skip the parameter name if the value is null if (values[i] != null) { sb.append(sep); sep = '&'; // We urlencode both the key sb.append(URL.encodePathSegment(names[i])); sb.append('='); // and the value sb.append(URL.encodePathSegment(values[i].toString())); } } // We call the proxy to fetch the result proxy.fetch(sb.toString(), null, new AsyncCallback<HttpResult>() { @Override public void onSuccess(HttpResult result) { // We have a holder for the decoded value T r = null; JSONValue s; try { // Using information in the request object we can decode the // json // Why? To allow the same json to be decoded to different // java beans, so metadata such a class name does not need // to be transfered. s = encoder.decode(result.body); r = encoder.validate(s, r, request.getReturnValueType()); request.onSuccess(r); } catch (UnableToDeserialize e) { request.onFailure(e); } } @Override public void onFailure(Throwable caught) { request.onFailure(caught); } }); }
From source file:com.openkm.frontend.client.util.Util.java
License:Open Source License
/** * Encode path elements/*from w ww. j a va 2 s .c o m*/ */ public static String encodePathElements(String path) { String[] eltos = path.split("\\/"); String ret = ""; for (int i = 1; i < eltos.length; i++) { ret = ret.concat("/").concat(URL.encodePathSegment(eltos[i])); } return ret; }