List of usage examples for com.google.gwt.storage.client Storage getSessionStorageIfSupported
public static Storage getSessionStorageIfSupported()
From source file:ch.unifr.pai.twice.utils.device.client.UUID.java
License:Apache License
/** * If no identifier is defined, this method tries to recover it from the HTML5 session storage if available or generates a new UUID and stores it if * possible.//from w w w .ja v a2 s . c o m * * * @return the currently valid identifier of this device (the return value is never null!) */ public static String get() { if (uuid == null) { Storage s = Storage.getSessionStorageIfSupported(); if (s != null) { uuid = s.getItem("ch.unifr.pai.mice.uuid"); } if (uuid == null) { uuid = UUIDGenerator.uuid(); if (s != null) s.setItem("ch.unifr.pai.mice.uuid", uuid); } } return uuid; }
From source file:ch.unifr.pai.twice.widgets.mpbrowser.client.MPBrowser.java
License:Apache License
@Override public void onModuleLoad() { multiCursor.start();//ww w . j av a 2 s . c om scrollBar.getElement().getStyle().setBackgroundColor("lightgrey"); scrollBar.addNorth(scrollUp, 30); scrollBar.addSouth(scrollDown, 30); scrollBar.add(new HTML()); textBox.setWidth("100%"); navig.add(backward); navig.add(forward); navig.setCellWidth(backward, "50px"); navig.setCellWidth(forward, "50px"); navig.add(textBox); navig.setWidth("100%"); Storage s = Storage.getSessionStorageIfSupported(); if (s != null) { String type = s.getItem("ch.unifr.pai.mice.deviceType"); if (type == null || !type.equals("multicursor")) { s.setItem("ch.unifr.pai.mice.deviceType", "multicursor"); } } frame.setUrl(GWT.getHostPageBaseURL() + "http://www.google.ch"); frame.setHeight("100%"); frame.setWidth("100%"); frame.getElement().setAttribute("scrolling", "no"); frame.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { if (frame.getUrl() != null && !frame.getUrl().startsWith(GWT.getHostPageBaseURL())) { frame.setUrl(GWT.getHostPageBaseURL() + frame.getUrl()); updateScrollBar(); } Document d = IFrameElement.as(frame.getElement()).getContentDocument(); textBox.setValue(d.getURL()); } }); scrollBar2.getElement().getStyle().setBackgroundColor("lightgrey"); scrollBar2.addNorth(scrollUp2, 30); scrollBar2.addSouth(scrollDown2, 30); scrollBar2.add(new HTML()); textBox2.setWidth("100%"); navig2.add(backward2); navig2.add(forward2); navig2.setCellWidth(backward2, "50px"); navig2.setCellWidth(forward2, "50px"); navig2.add(textBox2); navig2.setWidth("100%"); frame2.setUrl(GWT.getHostPageBaseURL() + "http://www.google.ch"); frame2.setHeight("100%"); frame2.setWidth("100%"); frame2.getElement().setAttribute("scrolling", "no"); frame2.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { if (frame2.getUrl() != null && !frame2.getUrl().startsWith(GWT.getHostPageBaseURL())) { frame2.setUrl(GWT.getHostPageBaseURL() + frame2.getUrl()); updateScrollBar2(); } Document d = IFrameElement.as(frame2.getElement()).getContentDocument(); textBox2.setValue(d.getURL()); } }); DockLayoutPanel p = new DockLayoutPanel(Unit.PX); p.addNorth(navig, 25); p.addEast(scrollBar, 30); p.add(frame); browserSplit.addNorth(p, 500); DockLayoutPanel p2 = new DockLayoutPanel(Unit.PX); p2.addNorth(navig2, 25); p2.addEast(scrollBar2, 30); p2.add(frame2); browserSplit.add(p2); RootLayoutPanel.get().add(browserSplit); }
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.ProxyBody.java
License:Apache License
/** * Register required listeners and set up the basic objects *//*from w w w. ja v a 2 s. com*/ public void initialize() { Event.addNativePreviewHandler(new NativePreviewHandler() { /** * Rewrites the URLs on mouse down if somebody clicks on an anchor element * * @see com.google.gwt.user.client.Event.NativePreviewHandler#onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent) */ @Override public void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == Event.ONMOUSEDOWN) { EventTarget t = event.getNativeEvent().getEventTarget(); Element e = (Element) Element.as(t); if (e != null && e.getTagName().equalsIgnoreCase("a")) rewriteUrls(e); } } }); Storage s = Storage.getSessionStorageIfSupported(); if (s != null) { RootPanel.get().add(new Label("Multicursor: " + s.getItem("ch.unifr.pai.mice.deviceType"))); } publishInterfaces(); rewriteUrls((Element) Document.get().getDocumentElement()); addDomChangeEvents(); // screenShot.start(); if (!isParentFrame()) { Element e = DOM.getElementById("miceNavigation"); if (e != null) e.removeFromParent(); } }
From source file:com.ait.tooling.nativetools.client.storage.SessionStorage.java
License:Open Source License
private SessionStorage() { super(CacheType.SESSION, Storage.getSessionStorageIfSupported()); }
From source file:com.gsr.myschool.common.client.security.SecurityUtils.java
License:Apache License
public SecurityUtils() { sessionStorage = new StorageMap(Storage.getSessionStorageIfSupported()); }
From source file:com.ponysdk.ui.terminal.PonySDK.java
License:Apache License
@Export public void start() { log("starting..."); try {/* ww w. j av a 2s .c o m*/ Long viewID = null; final Storage storage = Storage.getSessionStorageIfSupported(); if (storage != null) { final String v = storage.getItem(APPLICATION.VIEW_ID); if (v != null && !v.isEmpty()) viewID = Long.parseLong(v); } final PTInstruction requestData = new PTInstruction(); final JSONArray cookies = new JSONArray(); // load all cookies at startup final Collection<String> cookieNames = Cookies.getCookieNames(); if (cookieNames != null) { int i = 0; for (final String cookie : cookieNames) { final JSONObject jsoObject = new JSONObject(); jsoObject.put(PROPERTY.KEY, new JSONString(cookie)); jsoObject.put(PROPERTY.VALUE, new JSONString(Cookies.getCookie(cookie))); cookies.set(i++, jsoObject); } } requestData.put(APPLICATION.KEY, APPLICATION.KEY_.START); requestData.put(APPLICATION.SEQ_NUM, 0); requestData.put(HISTORY.TOKEN, History.getToken()); requestData.put(PROPERTY.COOKIES, cookies); if (viewID != null) requestData.put(APPLICATION.VIEW_ID, viewID); final RequestCallback requestCallback = new RequestCallback() { @Override public void onDataReceived(final JSONObject data) { try { if (data.containsKey(APPLICATION.VIEW_ID)) { applicationViewID = (long) data.get(APPLICATION.VIEW_ID).isNumber().doubleValue(); if (storage != null) storage.setItem(APPLICATION.VIEW_ID, Long.toString(applicationViewID)); uiBuilder.init(applicationViewID, requestBuilder); } uiBuilder.update(data); } catch (final RuntimeException exception) { log.log(Level.SEVERE, "Failed to process data with error #" + exception.getMessage() + ", data: " + data, exception); } } @Override public void onError(final Throwable exception) { uiBuilder.onCommunicationError(exception); } }; requestBuilder = newRequestBuilder(requestCallback); requestBuilder.send(requestData.toString()); } catch (final Exception e) { log.log(Level.SEVERE, "Loading application has failed #" + e.getMessage(), e); } }
From source file:com.seanchenxi.gwt.storage.client.StorageExt.java
License:Apache License
/** * Returns a Session Storage./*from www . j a v a2 s .co m*/ * * @return the sessionStorage instance, or <code>null</code> if Web Storage is NOT supported. */ public static StorageExt getSessionStorage() { if (sessionStorage == null && Storage.isSessionStorageSupported()) { sessionStorage = new StorageExt(Storage.getSessionStorageIfSupported()); } return sessionStorage; }
From source file:com.sencha.gxt.data.client.loader.StorageReadProxy.java
License:sencha.com license
/** * Creates a storage read proxy that retrieves data from HTML5 browser based * storage./*w w w .ja v a 2s .com*/ * * @param session true to use session storage, false to use local storage */ public StorageReadProxy(boolean session) { this(session ? Storage.getSessionStorageIfSupported() : Storage.getLocalStorageIfSupported()); }
From source file:com.sencha.gxt.data.client.loader.StorageWriteProxy.java
License:sencha.com license
/** * Creates a storage write proxy that saves a key and value to HTML5 browser * based storage.// w ww.j av a 2 s . c o m * * @param session true to use session storage, false to use local storage */ public StorageWriteProxy(boolean session) { this(session ? Storage.getSessionStorageIfSupported() : Storage.getLocalStorageIfSupported()); }
From source file:com.vaadin.client.SuperDevMode.java
License:Apache License
private static void setSession(String key, String value) { Storage.getSessionStorageIfSupported().setItem(key, value); }