Example usage for com.google.gwt.user.client Cookies getCookie

List of usage examples for com.google.gwt.user.client Cookies getCookie

Introduction

In this page you can find the example usage for com.google.gwt.user.client Cookies getCookie.

Prototype

public static String getCookie(String name) 

Source Link

Document

Gets the cookie associated with the given name.

Usage

From source file:com.tensegrity.wpalo.client.WPalo.java

License:Open Source License

private final String setLocale() {
    String val = Window.Location.getParameter("locale");
    if (val == null) {
        val = Cookies.getCookie("locale");
        if (val != null) {
            String url = Window.Location.getHref();
            int index;
            if ((index = url.indexOf("locale=")) != -1) {
                int i2 = url.indexOf("&", index);
                if (i2 == -1) {
                    url = url.substring(0, index) + "locale=" + val;
                } else {
                    url = url.substring(0, index) + "locale=" + val + url.substring(i2);
                }/*from   w  ww  .ja v a2s. co  m*/
            } else {
                if (url.indexOf("?") != -1) {
                    url += "&locale=" + val;
                } else {
                    url += "?locale=" + val;
                }
            }
            // Window.Location.assign(url);
            return url;
        }
    }
    if (val == null || val.isEmpty()) {
        return null;
    }
    if (val.equals(Cookies.getCookie("locale"))) {
        return null;
    }
    Date date = new Date(System.currentTimeMillis() + 1000l * 60l * 60l * 24l * 30l);
    Cookies.setCookie("locale", val, date);
    return null;
}

From source file:com.tensegrity.wpalo.client.WPalo.java

License:Open Source License

private final String setTheme(String url) {
    String val = Window.Location.getParameter("theme");
    if (val == null) {
        val = Cookies.getCookie("theme");
        if (val != null) {
            if (url == null) {
                url = Window.Location.getHref();
            }/*from w  w  w. j  av a2s  .  c  o m*/
            int index;
            if ((index = url.indexOf("theme=")) != -1) {
                int i2 = url.indexOf("&", index);
                if (i2 == -1) {
                    url = url.substring(0, index) + "theme=" + val;
                } else {
                    url = url.substring(0, index) + "theme=" + val + url.substring(i2);
                }
            } else {
                if (url.indexOf("?") != -1) {
                    url += "&theme=" + val;
                } else {
                    url += "?theme=" + val;
                }
            }
            // Window.Location.assign(url);
            return url;
        }
    }
    if (val == null || val.isEmpty()) {
        return url;
    }
    if (val.equals(Cookies.getCookie("theme"))) {
        return url;
    }
    Date date = new Date(System.currentTimeMillis() + 1000l * 60l * 60l * 24l * 30l);
    Cookies.setCookie("theme", val, date);
    return url;
}

From source file:com.threerings.gardens.client.GardensEntryPoint.java

License:Open Source License

@Override
public void onModuleLoad() {
    ClientContext ctx = new ClientContext() {
        public NexusClient client() {
            return _client;
        }//  w w  w  . j  a  v a  2 s.c o m

        public String authToken() {
            return Cookies.getCookie("id_");
        }

        public void setMainPanel(Widget main) {
            if (_main != null) {
                RootPanel.get(CLIENT_DIV).remove(_main);
            }
            RootPanel.get(CLIENT_DIV).add(_main = main);
        }

        protected NexusClient _client = GWTClient.create(8080, /* TODO: get from deployment.properties */
                new GardensSerializer());
        protected Widget _main;
    };

    // if we're logged in, swap out the login UI for the logout UI
    String auth = ctx.authToken(), username = Cookies.getCookie("nm_");
    if (auth != null && username != null) {
        Document.get().getElementById("login").getStyle().setDisplay(Style.Display.NONE);
        Document.get().getElementById("userinfo").getStyle().clearDisplay();
        Document.get().getElementById("username").setInnerText(username);
    }

    Label status = new Label();
    ctx.setMainPanel(status);
    new Connector(ctx, status).connect();
}

From source file:com.vaadin.client.VDebugConsole.java

License:Apache License

private void setToDefaultSizeAndPos() {
    String cookie = Cookies.getCookie(POS_COOKIE_NAME);
    int width, height, top, left;
    boolean autoScrollValue = false;
    if (cookie != null) {
        String[] split = cookie.split(",");
        left = Integer.parseInt(split[0]);
        top = Integer.parseInt(split[1]);
        width = Integer.parseInt(split[2]);
        height = Integer.parseInt(split[3]);
        autoScrollValue = Boolean.valueOf(split[4]);
    } else {//from   w  w  w  . j a va 2 s  . com
        int windowHeight = Window.getClientHeight();
        int windowWidth = Window.getClientWidth();
        width = DEFAULT_WIDTH;
        height = DEFAULT_HEIGHT;

        if (height > windowHeight / 2) {
            height = windowHeight / 2;
        }
        if (width > windowWidth / 2) {
            width = windowWidth / 2;
        }

        top = windowHeight - (height + 10);
        left = windowWidth - (width + 10);
    }
    setPixelSize(width, height);
    setPopupPosition(left, top);
    autoScroll.setValue(autoScrollValue);
}

From source file:com.vaadin.terminal.gwt.client.VDebugConsole.java

License:Open Source License

private void setToDefaultSizeAndPos() {
    String cookie = Cookies.getCookie(POS_COOKIE_NAME);
    int width, height, top, left;
    boolean autoScrollValue = false;
    if (cookie != null) {
        String[] split = cookie.split(",");
        left = Integer.parseInt(split[0]);
        top = Integer.parseInt(split[1]);
        width = Integer.parseInt(split[2]);
        height = Integer.parseInt(split[3]);
        autoScrollValue = Boolean.valueOf(split[4]);
    } else {/*from www .j a va 2s  .  c  o  m*/
        width = 400;
        height = 150;
        top = Window.getClientHeight() - 160;
        left = Window.getClientWidth() - 410;
    }
    setPixelSize(width, height);
    setPopupPosition(left, top);
    autoScroll.setValue(autoScrollValue);
}

From source file:com.webwoz.client.client.WebWOZClient.java

License:Apache License

public void onModuleLoad() {
    // get login cookie
    login = Cookies.getCookie("loggedin");
    stopSession();
}

From source file:com.webwoz.client.client.WebWOZClient.java

License:Apache License

private void loggedIn() {
    user = Integer.parseInt(Cookies.getCookie("user"));
    experiment = Integer.parseInt(Cookies.getCookie("experiment"));
    setLoginScreen(1);/*from  ww  w .  j a  va2s .co m*/
    loadScreen();
    getExperimentSettings();
}

From source file:com.xclinical.mdr.client.util.LoginUtils.java

License:Apache License

/**
 * Retrieves the current credentials./*from w w  w  . java 2  s.  c om*/
 * @return the current credentials.
 */
public static String getCredentials() {
    String sid = Cookies.getCookie(NAME);
    return sid;
}

From source file:cz.filmtit.client.Gui.java

License:Open Source License

/**
 * Get the active sessionID, or null if no user is logged in.
 * Made persistent via cookies.//from w ww  .  j  a  va 2  s .c om
 */
public static String getSessionID() {
    if (sessionID == null) {
        sessionID = Cookies.getCookie(SESSIONID);
    }
    return sessionID;
}

From source file:cz.filmtit.client.PageHandler.java

License:Open Source License

/**
 * load a documentId set through a Cookie
 *//*from w  w  w .j  a va2s . c om*/
private void setDocumentIdFromCookie() {
    // get the parameter
    String id = Cookies.getCookie(DOCUMENTID);
    // parse it
    setDocumentIdFromString(id);
}