List of usage examples for com.google.gwt.http.client URL encodeComponent
@Deprecated public static String encodeComponent(String decodedURLComponent)
From source file:fr.fg.client.core.Client.java
License:Open Source License
public void onModuleLoad() { instance = this; systemInfoVisible = false;/*from ww w . ja v a 2s . c o m*/ setStatus("Chargement..."); GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { public void onUncaughtException(Throwable e) { Utilities.log("Uncaught exception", e); } }); // Charge le fichier XML de dfinition du thme if (Config.isDebug()) OpenJWT.loadStyle(Config.getTheme() + "/style.xml"); else OpenJWT.loadStyle(Config.getServerUrl() + "themeproxy?theme=" + URL.encodeComponent(Config.getTheme())); if (!OpenJWT.isStyleReady()) { Timer timer = new Timer() { @Override public void run() { if (OpenJWT.isStyleReady()) { load(); } else { schedule(100); } } }; timer.schedule(100); } else { load(); } }
From source file:net.opentsdb.tsd.client.QueryUi.java
License:Open Source License
private void addLabels(final StringBuilder url) { final String ylabel = this.ylabel.getText(); if (!ylabel.isEmpty()) { url.append("&ylabel=").append(URL.encodeComponent(ylabel)); }/* w w w . ja va2 s . co m*/ if (y2label.isEnabled()) { final String y2label = this.y2label.getText(); if (!y2label.isEmpty()) { url.append("&y2label=").append(URL.encodeComponent(y2label)); } } }
From source file:net.opentsdb.tsd.client.QueryUi.java
License:Open Source License
private void addFormats(final StringBuilder url) { final String yformat = this.yformat.getText(); if (!yformat.isEmpty()) { url.append("&yformat=").append(URL.encodeComponent(yformat)); }/*from w w w .java2 s .c o m*/ if (y2format.isEnabled()) { final String y2format = this.y2format.getText(); if (!y2format.isEmpty()) { url.append("&y2format=").append(URL.encodeComponent(y2format)); } } }
From source file:org.curriki.gwt.client.widgets.metadata.MetadataEdit.java
License:Open Source License
private void displaySkills(String value, final VerticalPanel panel) { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "/SearchI2G/render?uri=" + URL.encodeComponent(value) + "&language=" + URL.encodeComponent(getLanguages())); try {/* w w w. ja v a 2s. c o m*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("Error at rendering: " + exception); } public void onResponseReceived(Request request, Response response) { if (200 != response.getStatusCode()) { Window.alert( "Error " + response.getStatusCode() + " at rendering: " + response.getStatusText()); return; } panel.clear(); panel.add(new HTML(response.getText())); } }); } catch (RequestException e) { Window.alert("Error at launching rendering: " + e); } }
From source file:org.eurekastreams.web.client.jsni.WidgetJSNIFacadeImpl.java
License:Apache License
/** * Encode a string for use in URL./*from w w w .java 2 s.com*/ * * @param value * the value to encode. * @return the encoded string. */ public String urlEncode(final String value) { return URL.encodeComponent(value); }
From source file:org.eurekastreams.web.client.ui.pages.activity.ActivityContent.java
License:Apache License
/** * Setup bookmarks and custom streams.// w ww . j a v a2s .com */ private void setupStreamsAndBookmarks() { final EventBus eventBus = EventBus.getInstance(); eventBus.addObserver(GotCurrentUserStreamBookmarks.class, new Observer<GotCurrentUserStreamBookmarks>() { private final AvatarUrlGenerator groupUrlGen = new AvatarUrlGenerator(EntityType.GROUP); private final AvatarUrlGenerator personUrlGen = new AvatarUrlGenerator(EntityType.PERSON); public void update(final GotCurrentUserStreamBookmarks event) { bookmarkList.clear(); bookmarksWidgetMap.clear(); List<StreamFilter> sortedStreamFilters = event.getResponse(); Collections.sort(sortedStreamFilters, new StreamFilterNameComparator()); for (final StreamFilter filter : sortedStreamFilters) { JSONObject req = StreamJsonRequestFactory.getJSONRequest(filter.getRequest()); String uniqueId = null; String entityType = null; String imgUrl = ""; if (req.containsKey("query")) { JSONObject query = req.get("query").isObject(); if (query.containsKey(StreamJsonRequestFactory.RECIPIENT_KEY)) { JSONArray recipient = query.get(StreamJsonRequestFactory.RECIPIENT_KEY).isArray(); if (recipient.size() > 0) { JSONObject recipientObj = recipient.get(0).isObject(); uniqueId = recipientObj.get("name").isString().stringValue(); entityType = recipientObj.get("type").isString().stringValue().toLowerCase(); AvatarUrlGenerator urlGen = groupUrlGen; if ("person".equals(entityType)) { urlGen = personUrlGen; } imgUrl = urlGen.getSmallAvatarUrl(filter.getOwnerAvatarId()); } } } if (uniqueId != null && entityType != null) { String bookmarkUrl = entityType + "/" + uniqueId; StreamNamePanel bookmarkFilter = createPanel(filter.getName(), bookmarkUrl, imgUrl, new ClickHandler() { public void onClick(final ClickEvent event) { if (new WidgetJSNIFacadeImpl() .confirm("Are you sure you want to delete this bookmark?")) { StreamBookmarksModel.getInstance().delete(filter.getId()); } event.stopPropagation(); } }, style.deleteBookmark(), "", true); bookmarkList.add(bookmarkFilter); bookmarksWidgetMap.put(bookmarkUrl, bookmarkFilter); } } if (sortedStreamFilters.size() == 0) { Label defaultLabel = new Label("Bookmarks allow you to quickly jump to any stream in Eureka."); defaultLabel.addStyleName(style.noBookmarksMessage()); bookmarkList.add(defaultLabel); } bookmarksLoaded = true; checkInit(); } }); eventBus.addObserver(StreamActivitySubscriptionChangedEvent.class, new Observer<StreamActivitySubscriptionChangedEvent>() { public void update(final StreamActivitySubscriptionChangedEvent ev) { boolean newStatus = ev.getResponse().getReceiveNewActivityNotifications(); setSubscribeStatus(newStatus); String msg = newStatus ? "You will now receive emails for new activities to this stream" : "You will no longer receive emails for new activities to this stream"; eventBus.notifyObservers(new ShowNotificationEvent(new Notification(msg))); } }); eventBus.addObserver(GotStreamActivitySubscriptionResponseEvent.class, new Observer<GotStreamActivitySubscriptionResponseEvent>() { public void update(final GotStreamActivitySubscriptionResponseEvent result) { setSubscribeStatus(result.isSubscribed()); } }); eventBus.addObserver(GotCurrentUserCustomStreamsResponseEvent.class, new Observer<GotCurrentUserCustomStreamsResponseEvent>() { public void update(final GotCurrentUserCustomStreamsResponseEvent event) { filterList.clear(); customStreamWidgetMap.clear(); StreamNamePanel savedBy = createPanel("My Saved Items", "custom/0/" + "{\"query\":{\"savedBy\":\"" + Session.getInstance().getCurrentPerson().getAccountId() + "\"}}", "style/images/customStream.png", null, "", "", false); filterList.add(savedBy); customStreamWidgetMap.put(0L, savedBy); StreamNamePanel likedBy = createPanel("My Liked Items", "custom/1/" + "{\"query\":{\"likedBy\":[{\"type\":\"PERSON\", \"name\":\"" + Session.getInstance().getCurrentPerson().getAccountId() + "\"}]}}/My Liked Items", "style/images/customStream.png", null, "", "", false); filterList.add(likedBy); customStreamWidgetMap.put(1L, likedBy); for (final StreamFilter filter : event.getResponse().getStreamFilters()) { StreamNamePanel filterPanel = createPanel(filter.getName(), "custom/" + filter.getId() + "/" + URL.encodeComponent(filter.getRequest().replace("%%CURRENT_USER_ACCOUNT_ID%%", Session.getInstance().getCurrentPerson().getAccountId())), "style/images/customStream.png", new ClickHandler() { public void onClick(final ClickEvent event) { Dialog.showCentered(new CustomStreamDialogContent((Stream) filter)); event.stopPropagation(); } }, style.editCustomStream(), "edit", false); filterList.add(filterPanel); customStreamWidgetMap.put(filter.getId(), filterPanel); } customStreamsLoaded = true; checkInit(); } }); eventBus.addObserver(StreamSearchBeginEvent.class, new Observer<StreamSearchBeginEvent>() { public void update(final StreamSearchBeginEvent event) { if (null == event.getSearchText()) { eventBus.notifyObservers(new UpdateHistoryEvent(new CreateUrlRequest("search", "", false))); searchBox.setText(""); } } }); }
From source file:org.gss_project.gss.web.client.commands.PasteCommand.java
License:Open Source License
@Override public void execute() { containerPanel.hide();/*from www .j ava2s . c o m*/ Object selection = GSS.get().getCurrentSelection(); if (selection != null && selection instanceof GroupResource) { final ClipboardItem citem = GSS.get().getClipboard().getItem(); GroupResource group = (GroupResource) GSS.get().getCurrentSelection(); if (citem.getUser() != null) { PostCommand cg = new PostCommand(group.getUri() + "?name=" + citem.getUser().getUsername(), "", 201) { @Override public void onComplete() { GSS.get().getGroups().updateGroups(); GSS.get().showUserList(); GSS.get().getClipboard().setItem(null); } @Override public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { int statusCode = ((RestException) t).getHttpStatusCode(); if (statusCode == 405) GSS.get().displayError("You don't have the necessary permissions"); else if (statusCode == 404) GSS.get().displayError("User does not exist"); else if (statusCode == 409) GSS.get().displayError("A user with the same name already exists"); else if (statusCode == 413) GSS.get().displayError("Your quota has been exceeded"); else GSS.get().displayError( "Unable to add user:" + ((RestException) t).getHttpStatusText()); } else GSS.get().displayError("System error adding user:" + t.getMessage()); } }; DeferredCommand.addCommand(cg); return; } } FolderResource selectedFolder = null; if (selection != null && selection instanceof RestResourceWrapper) selectedFolder = ((RestResourceWrapper) selection).getResource(); //TODO:CELLTREE /* else if(GSS.get().getFolders().getCurrent() != null && ((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource() != null) selectedFolder = ((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource(); */ if (selectedFolder != null) { final ClipboardItem citem = GSS.get().getClipboard().getItem(); if (citem != null && citem.getRestResourceWrapper() != null) { String target = selectedFolder.getUri(); target = target.endsWith("/") ? target : target + '/'; target = target + URL.encodeComponent(citem.getRestResourceWrapper().getResource().getName()); if (citem.getOperation() == Clipboard.COPY) { PostCommand cf = new PostCommand(citem.getRestResourceWrapper().getUri() + "?copy=" + target, "", 200) { @Override public void onComplete() { //TODO:CELLTREE //GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent()); GSS.get().getTreeView().updateNodeChildren(GSS.get().getTreeView().getSelection()); GSS.get().getStatusPanel().updateStats(); GSS.get().getClipboard().setItem(null); } @Override public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { int statusCode = ((RestException) t).getHttpStatusCode(); if (statusCode == 405) GSS.get().displayError("You don't have the necessary permissions"); else if (statusCode == 409) GSS.get().displayError("A folder with the same name already exists"); else if (statusCode == 413) GSS.get().displayError("Your quota has been exceeded"); else GSS.get().displayError( "Unable to copy folder:" + ((RestException) t).getHttpStatusText()); } else GSS.get().displayError("System error copying folder:" + t.getMessage()); } }; DeferredCommand.addCommand(cf); } else if (citem.getOperation() == Clipboard.CUT) { PostCommand cf = new PostCommand(citem.getRestResourceWrapper().getUri() + "?move=" + target, "", 200) { @Override public void onComplete() { //TODO:CELLTREE /* List<TreeItem> items = GSS.get().getFolders().getItemsOfTreeForPath(citem.getFolderResource().getUri()); for (TreeItem item : items) if (item.getParentItem() != null && !item.equals(GSS.get().getFolders().getCurrent())) GSS.get().getFolders().updateFolder((DnDTreeItem) item.getParentItem()); GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent()); */ GSS.get().getTreeView().updateNodeChildren(GSS.get().getTreeView().getSelection()); GSS.get().getTreeView().updateNodeChildrenForRemove( citem.getRestResourceWrapper().getResource().getParentURI()); GSS.get().getStatusPanel().updateStats(); GSS.get().getClipboard().setItem(null); } @Override public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { int statusCode = ((RestException) t).getHttpStatusCode(); if (statusCode == 405) GSS.get().displayError("You don't have the necessary permissions"); else if (statusCode == 409) GSS.get().displayError("A folder with the same name already exists"); else if (statusCode == 413) GSS.get().displayError("Your quota has been exceeded"); else GSS.get().displayError( "Unable to move folder:" + ((RestException) t).getHttpStatusText()); } else GSS.get().displayError("System error moving folder:" + t.getMessage()); } }; DeferredCommand.addCommand(cf); } return; } else if (citem != null && citem.getFile() != null) { String target = selectedFolder.getUri(); target = target.endsWith("/") ? target : target + '/'; target = target + URL.encodeComponent(citem.getFile().getName()); if (citem.getOperation() == Clipboard.COPY) { PostCommand cf = new PostCommand(citem.getFile().getUri() + "?copy=" + target, "", 200) { @Override public void onComplete() { GSS.get().showFileList(true); GSS.get().getStatusPanel().updateStats(); GSS.get().getClipboard().setItem(null); } @Override public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { int statusCode = ((RestException) t).getHttpStatusCode(); if (statusCode == 405) GSS.get().displayError("You don't have the necessary permissions"); else if (statusCode == 404) GSS.get().displayError("File not found"); else if (statusCode == 409) GSS.get().displayError("A file with the same name already exists"); else if (statusCode == 413) GSS.get().displayError("Your quota has been exceeded"); else GSS.get().displayError( "Unable to copy file:" + ((RestException) t).getHttpStatusText()); } else GSS.get().displayError("System error copying file:" + t.getMessage()); } }; DeferredCommand.addCommand(cf); } else if (citem.getOperation() == Clipboard.CUT) { PostCommand cf = new PostCommand(citem.getFile().getUri() + "?move=" + target, "", 200) { @Override public void onComplete() { GSS.get().showFileList(true); GSS.get().getStatusPanel().updateStats(); GSS.get().getClipboard().setItem(null); } @Override public void onError(Throwable t) { GWT.log("", t); if (t instanceof RestException) { int statusCode = ((RestException) t).getHttpStatusCode(); if (statusCode == 405) GSS.get().displayError("You don't have the necessary permissions"); else if (statusCode == 404) GSS.get().displayError("File not found"); else if (statusCode == 409) GSS.get().displayError("A file with the same name already exists"); else if (statusCode == 413) GSS.get().displayError("Your quota has been exceeded"); else GSS.get().displayError( "Unable to copy file:" + ((RestException) t).getHttpStatusText()); } else GSS.get().displayError("System error copying file:" + t.getMessage()); } }; DeferredCommand.addCommand(cf); } return; } else if (citem != null && citem.getFiles() != null) { List<FileResource> res = citem.getFiles(); List<String> fileIds = new ArrayList<String>(); String target = selectedFolder.getUri(); target = target.endsWith("/") ? target : target + '/'; if (citem.getOperation() == Clipboard.COPY) { for (FileResource fileResource : res) { String fileTarget = target + fileResource.getName(); fileIds.add(fileResource.getUri() + "?copy=" + fileTarget); } int index = 0; executeCopyOrMove(index, fileIds); } else if (citem.getOperation() == Clipboard.CUT) { for (FileResource fileResource : res) { String fileTarget = target + fileResource.getName(); fileIds.add(fileResource.getUri() + "?move=" + fileTarget); } int index = 0; executeCopyOrMove(index, fileIds); } return; } } }
From source file:org.gss_project.gss.web.client.DnDFolderPopupMenu.java
License:Open Source License
private void copyFiles(final FolderResource ftarget, List<FileResource> files) { List<String> fileIds = new ArrayList<String>(); String target = ftarget.getUri(); target = target.endsWith("/") ? target : target + '/'; for (FileResource fileResource : files) { String fileTarget = target + URL.encodeComponent(fileResource.getName()); fileIds.add(fileResource.getUri() + "?copy=" + fileTarget); }/*from w ww . ja va 2 s. co m*/ int index = 0; executeCopyOrMoveFiles(index, fileIds); }
From source file:org.gss_project.gss.web.client.DnDFolderPopupMenu.java
License:Open Source License
private void moveFiles(final FolderResource ftarget, List<FileResource> files) { List<String> fileIds = new ArrayList<String>(); String target = ftarget.getUri(); target = target.endsWith("/") ? target : target + '/'; for (FileResource fileResource : files) { String fileTarget = target + URL.encodeComponent(fileResource.getName()); fileIds.add(fileResource.getUri() + "?move=" + fileTarget); }/*from w ww. j av a 2 s.co m*/ int index = 0; executeCopyOrMoveFiles(index, fileIds); }
From source file:org.gss_project.gss.web.client.FileList.java
License:Open Source License
@Override public void onBrowserEvent(Event event) { if (files == null || files.size() == 0) { if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { menuShowing = new FileContextMenu(images, false, true); menuShowing = menuShowing.onEmptyEvent(event); event.preventDefault();/* w ww .ja va2s. c o m*/ event.cancelBubble(true); } return; } if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() != 0) { GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null); menuShowing = new FileContextMenu(images, false, false); menuShowing = menuShowing.onEvent(event); event.cancelBubble(true); event.preventDefault(); } else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) { menuShowing = new FileContextMenu(images, false, true); menuShowing = menuShowing.onEmptyEvent(event); event.cancelBubble(true); event.preventDefault(); } else if (DOM.eventGetType(event) == Event.ONDBLCLICK) if (getSelectedFiles().size() == 1) { GSS app = GSS.get(); FileResource file = getSelectedFiles().get(0); String dateString = RestCommand.getDate(); String resource = file.getUri().substring(app.getApiPath().length() - 1, file.getUri().length()); String sig = app.getCurrentUserResource().getUsername() + " " + RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken())); Window.open(file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date=" + URL.encodeComponent(dateString), "_blank", ""); event.preventDefault(); return; } super.onBrowserEvent(event); }