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

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

Introduction

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

Prototype

public static void removeCookie(String name) 

Source Link

Document

Removes the cookie associated with the given name.

Usage

From source file:com.gwtplatform.carstore.client.application.widget.header.HeaderPresenter.java

License:Apache License

private void resetLoggedInCookie() {
    Cookies.removeCookie(LoginPresenter.LOGIN_COOKIE_NAME);

    logger.info("HeaderPresenter.resetLoggedInCookie(): The cookie was removed from client.");
}

From source file:com.LSH.client.LSH.java

License:Apache License

/**
 * ?   UI/* ww w  . j  a  v a 2 s  . c o m*/
 */
public void onModuleLoad() {

    /*  ? ? */

    String linkWidth = String.valueOf(Window.getClientWidth() / 4);

    // HP = HorizontalPanel; VP = VerticalPanel
    final HorizontalPanel simpleDataHP = new HorizontalPanel(); //  ?  ??
    final HorizontalPanel simpleAnswerHP = new HorizontalPanel(); //  ?  
    final VerticalPanel simpleVP = new VerticalPanel(); //  ? ? ,  

    simpleShortButton.addClickHandler(new SimpleClickHandler()); // ??    
    simpleOriginalLink.addKeyDownHandler(new EnterKeyListener(simpleShortButton)); // ??    ? Enter
    simpleCopyButton.addClickHandler(new CopyClickHandler("simpleAnswer")); // ??       ?

    simpleOriginalLink.setWidth(linkWidth); // ?  ?
    simpleDataHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); // 
    simpleDataHP.setSpacing(5); // ?

    //  
    simpleDataHP.add(simpleOriginalLink);
    simpleDataHP.add(simpleShortButton);

    // ?, ?
    simpleAnswerHP.setSpacing(5);
    simpleAnswerHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    //  
    simpleAnswerHP.add(simpleShortText);
    simpleAnswerHP.add(simpleShortLink);
    simpleAnswerHP.add(simpleCopyButton);

    //  
    simpleVP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    simpleVP.setSpacing(10);
    simpleVP.add(simpleDataHP);
    simpleVP.add(simpleAnswerHP);

    // ?   ?
    simpleShortText.setVisible(false);
    simpleCopyButton.setVisible(false);

    /*  ? ? */
    //  ? ?
    final HorizontalPanel complexLinkHP = new HorizontalPanel(); //  ?  ??
    final HorizontalPanel complexDataHP = new HorizontalPanel(); // 
    final HorizontalPanel complexOptionalData = new HorizontalPanel(); //  
    final HorizontalPanel complexAnswerHP = new HorizontalPanel(); // 

    final VerticalPanel complexVP = new VerticalPanel(); //  ,  
    final VerticalPanel complexOptionalVP = new VerticalPanel(); //  ,  

    EnterKeyListener complexKey = new EnterKeyListener(complexShortButton); //  ?   Enter
    complexCopyButton.addClickHandler(new CopyClickHandler("complexAnswer"));

    // ?     ??
    complexTime.addItem("1 hour");
    complexTime.addItem("12 hours");
    complexTime.addItem("1 day");
    complexTime.addItem("1 week");
    complexTime.addItem("1 month");
    complexTime.addItem("Unlimited");
    complexTime.setSelectedIndex(3);

    // ??  ?
    complexOriginalLink.setWidth(linkWidth);
    complexCount.setWidth("40px");
    complexCount.setValue(10);

    complexShortButton.addClickHandler(new ComplexClickHandler()); //   ?  
    // ?  ?  Enter  ? ?
    complexOriginalLink.addKeyDownHandler(complexKey);
    complexName.addKeyDownHandler(complexKey);
    complexCount.addKeyDownHandler(complexKey);
    complexTime.addKeyDownHandler(complexKey);
    complexPassword.addKeyDownHandler(complexKey);

    // ??     ?
    complexLinkHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    complexLinkHP.setSpacing(5);
    complexLinkHP.add(complexText);
    complexLinkHP.add(complexOriginalLink);

    complexDataHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    complexDataHP.setSpacing(5);
    complexDataHP.add(complexTimeText);
    complexDataHP.add(complexTime);
    complexDataHP.add(complexCountText);
    complexDataHP.add(complexCount);

    complexCount.setAlignment(ValueBoxBase.TextAlignment.CENTER); // ? ? 
    complexCount.setMaxLength(5); // ?? - ?

    complexOptionalData.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    complexOptionalData.setSpacing(5);
    complexOptionalData.add(complexNameText);
    complexOptionalData.add(complexName);
    complexOptionalData.add(complexPasswordText);
    complexOptionalData.add(complexPassword);

    complexAnswerHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    complexAnswerHP.setSpacing(5);
    complexAnswerHP.add(complexShortText);
    complexAnswerHP.add(complexShortLink);
    complexAnswerHP.add(complexCopyButton);

    complexVP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    complexVP.setSpacing(5);
    complexVP.add(complexLinkHP);
    complexVP.add(complexDataHP);

    complexOptionalVP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    complexOptionalVP.setSpacing(5);
    complexOptionalVP.add(complexOptionalData);
    complexOptionalVP.add(complexShortButton);
    complexOptionalVP.add(complexAnswerHP);

    //   
    complexShortText.setVisible(false);
    complexCopyButton.setVisible(false);

    /* ?? ? ?  */

    loginButton.addClickHandler(new ClickHandler() { //        
        @Override
        public void onClick(ClickEvent event) {
            dialog.Login();
        }
    });

    logoutButton.addClickHandler(new ClickHandler() { //  
        @Override
        public void onClick(ClickEvent event) { //  
            Cookies.removeCookie(cookieName); // ?   

            //   ?  ? ???
            loginButton.setVisible(true);
            loginLabel.setHTML("");
            loginLabel.setVisible(false);
            logoutButton.setVisible(false);
        }
    });

    // ??     
    final HorizontalPanel loginHP = new HorizontalPanel();
    loginHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    loginHP.setSpacing(5);
    loginHP.add(loginLabel);
    loginHP.add(logoutButton);
    loginHP.add(loginButton);

    logoutButton.setVisible(false);
    dialog.hide(); //     ?

    // ?    ?
    RootPanel.get("Login").add(loginHP);
    RootPanel.get("SimpleShort").add(simpleVP);
    RootPanel.get("ComplexShort").add(complexVP);
    RootPanel.get("ComplexShortOptional").add(complexOptionalVP);
}

From source file:com.nanosim.client.content.other.CwCookies.java

License:Apache License

/**
 * Initialize this example.//from   ww  w.  jav a2  s.  c o  m
 */
@NanosimSource
@Override
public Widget onInitialize() {
    // Create the panel used to layout the content
    Grid mainLayout = new Grid(3, 3);

    // Display the existing cookies
    existingCookiesBox = new ListBox();
    Button deleteCookieButton = new Button(constants.cwCookiesDeleteCookie());
    deleteCookieButton.addStyleName("sc-FixedWidthButton");
    mainLayout.setHTML(0, 0, "<b>" + constants.cwCookiesExistingLabel() + "</b>");
    mainLayout.setWidget(0, 1, existingCookiesBox);
    mainLayout.setWidget(0, 2, deleteCookieButton);

    // Display the name of the cookie
    cookieNameBox = new TextBox();
    mainLayout.setHTML(1, 0, "<b>" + constants.cwCookiesNameLabel() + "</b>");
    mainLayout.setWidget(1, 1, cookieNameBox);

    // Display the name of the cookie
    cookieValueBox = new TextBox();
    Button setCookieButton = new Button(constants.cwCookiesSetCookie());
    setCookieButton.addStyleName("sc-FixedWidthButton");
    mainLayout.setHTML(2, 0, "<b>" + constants.cwCookiesValueLabel() + "</b>");
    mainLayout.setWidget(2, 1, cookieValueBox);
    mainLayout.setWidget(2, 2, setCookieButton);

    // Add a handler to set the cookie value
    setCookieButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String name = cookieNameBox.getText();
            String value = cookieValueBox.getText();
            Date expires = new Date((new Date()).getTime() + COOKIE_TIMEOUT);

            // Verify the name is valid
            if (name.length() < 1) {
                Window.alert(constants.cwCookiesInvalidCookie());
                return;
            }

            // Set the cookie value
            Cookies.setCookie(name, value, expires);
            refreshExistingCookies(name);
        }
    });

    // Add a handler to select an existing cookie
    existingCookiesBox.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            updateExstingCookie();
        }
    });

    // Add a handler to delete an existing cookie
    deleteCookieButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            int selectedIndex = existingCookiesBox.getSelectedIndex();
            if (selectedIndex > -1 && selectedIndex < existingCookiesBox.getItemCount()) {
                String cookieName = existingCookiesBox.getValue(selectedIndex);
                Cookies.removeCookie(cookieName);
                existingCookiesBox.removeItem(selectedIndex);
                updateExstingCookie();
            }
        }
    });

    // Return the main layout
    refreshExistingCookies(null);
    return mainLayout;
}

From source file:com.sencha.gxt.state.client.CookieProvider.java

License:sencha.com license

@Override
public void clear(String name) {
    Cookies.removeCookie(name);
}

From source file:com.smvp4g.mvp.client.core.utils.LoginUtils.java

License:Open Source License

/**
 * Log out.
 */
public static void logOut() {
    Cookies.removeCookie(SESSION_ID);
    Cookies.removeCookie(USER_NAME);
    Cookies.removeCookie(ROLE);
}

From source file:com.therdl.client.app.AppController.java

/**
 * Binds the event handler instances to their specific events
 *
 * @ LogOutEvent  for user log out flow/*w w w.  ja v a  2 s. c o m*/
 * @ SnipViewEvent this event creates a new SnipView, is noteworthy as it is fired after
 * a JSNI callback from the Closure SnipListWidget code
 */
private void bind() {

    History.addValueChangeHandler(this);

    Log.info("AppController bind() addValueChangeHandler");

    // logout event handler
    GuiEventBus.EVENT_BUS.addHandler(LogOutEvent.TYPE, new LogOutEventEventHandler() {
        @Override
        public void onLogOutEvent(LogOutEvent onLogOutEvent) {
            currentUserBean = RDLUtils.resetCurrentUserBeanFields(currentUserBean);
            Cookies.removeCookie("sid");
            History.newItem(RDLConstants.Tokens.LOG_OUT);
            History.fireCurrentHistoryState();
        }
    });

    // SnipView event handler
    GuiEventBus.EVENT_BUS.addHandler(SnipViewEvent.TYPE, new SnipViewEventHandler() {

        @Override
        public void onSnipSelectEvent(SnipViewEvent event) {
            if (Global.moduleName.equals(RDLConstants.Modules.IDEAS))
                History.newItem(RDLConstants.Tokens.SNIP_VIEW + ":" + event.getSnipId());
            else if (Global.moduleName.equals(RDLConstants.Modules.STORIES))
                History.newItem(RDLConstants.Tokens.THREAD_VIEW + ":" + event.getSnipId());
            else if (Global.moduleName.equals(RDLConstants.Modules.IMPROVEMENTS))
                History.newItem(RDLConstants.Tokens.PROPOSAL_VIEW + ":" + event.getSnipId());
            else if (Global.moduleName.equals(RDLConstants.Modules.SERVICES))
                History.newItem(RDLConstants.Tokens.SERVICE_VIEW + ":" + event.getSnipId());
        }
    });
}

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

License:Apache License

/**
 * Clears the credentials store.
 */
public static void clearCredentials() {
    Cookies.removeCookie(NAME);
}

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

License:Open Source License

/**
 * Set the active sessionID, or set null to unset the sessionID.
 * Made persistent via cookies./*from w w  w. j a  va 2 s.co  m*/
 */
public static void setSessionID(String newSessionID) {
    if (newSessionID == null) {
        Cookies.removeCookie(SESSIONID);
    } else {
        Cookies.setCookie(SESSIONID, newSessionID, getDateIn1Year());
    }
    sessionID = newSessionID;
}

From source file:edu.caltech.ipac.firefly.core.Application.java

private void initAndShow() {

    // initialize JossoUtil... supply context information
    JossoUtil.init(Application.getInstance().getProperties().getProperty("sso.server.url"),
            GWT.getModuleBaseURL(),/*from w ww .  j  a  va  2 s. co  m*/
            Application.getInstance().getProperties().getProperty("sso.user.profile.url"));

    commandTable = creator.makeCommandTable();
    toolBar = creator.getToolBar();
    layoutManager = creator.makeLayoutManager();
    if (creator.isApplication()) {
        requestHandler = getRequestHandler();
        History.addValueChangeHandler(requestHandler);
    }

    nullFrame = new Frame();
    nullFrame.setSize("0px", "0px");
    nullFrame.setVisible(false);

    RootPanel root = RootPanel.get();
    root.clear();
    root.add(nullFrame);
    if (BrowserUtil.isTouchInput())
        root.addStyleName("disable-select");

    if (getLayoutManager() != null)
        getLayoutManager().layout(creator.getLoadingDiv());

    checkMobilAppInstall();

    if (SupportedBrowsers.isSupported()) {
        if (appReady != null) {
            appReady.ready();
        }

        if (creator.isApplication()) {
            // save the current state when you leave.
            DeferredCommand.addCommand(new Command() {
                public void execute() {
                    Window.addCloseHandler(new CloseHandler<Window>() {
                        public void onClose(CloseEvent<Window> windowCloseEvent) {
                            gotoUrl(null, false);
                        }
                    });
                }
            });

            // coming back from prior session
            String ssoBackTo = Cookies.getCookie(PRIOR_STATE);
            final Request prevState = Request.parse(ssoBackTo);
            if (prevState != null && prevState.isSearchResult()) {
                Cookies.removeCookie(PRIOR_STATE);
                History.newItem(ssoBackTo, true);
            } else {
                // url contains request params
                String qs = Window.Location.getQueryString().replace("?", "");
                if (!StringUtils.isEmpty(qs) && !qs.contains(IGNORE_QUERY_STR)) {
                    String qsDecoded = URL.decodeQueryString(qs);
                    String base = Window.Location.getHref();
                    base = base.substring(0, base.indexOf("?"));
                    String newUrl = base + "#" + URL.encodePathSegment(qsDecoded);
                    Window.Location.replace(newUrl);
                } else {
                    String startToken = History.getToken();
                    if (StringUtils.isEmpty(startToken)) {
                        goHome();
                    } else {
                        requestHandler.processToken(startToken);
                    }
                }
            }
            if (backgroundMonitor != null)
                backgroundMonitor.syncWithCache(null);
        }
    } else {
        hideDefaultLoadingDiv();
        SupportedBrowsers.showUnsupportedMessage();
    }

}

From source file:eml.studio.client.ui.panel.LoginPanel.java

License:Open Source License

public LoginPanel() {
    this.setStyleName("bda-login");
    boolean checked = Boolean.parseBoolean(Cookies.getCookie("bdachecked"));
    checkBox.setValue(checked);/*from  w  w  w .  j a  v  a  2  s .c om*/

    Label emailLabel = new Label(Constants.logUIMsg.email());
    emailField.setStyleName("form-control");
    emailField.setValue(Cookies.getCookie("bdaemail"));
    Label passwordLabel = new Label(Constants.logUIMsg.password());
    passwordField.setStyleName("form-control");
    if (checked)
        passwordField.setValue(UUID.randomID());

    errorLabel.addStyleName("bad-login-error");

    checkBox.setStyleName("bda-login-checkbox");
    forgetLabel.setStyleName("bda-login-forgetpwd");
    pwdPanel.setStyleName("bda-form-group");
    pwdPanel.add(checkBox);
    pwdPanel.add(forgetLabel);

    signinButton.addStyleName("button-style");
    signinButton.getElement().getStyle().setMarginLeft(7, Unit.PX);
    signinButton.getElement().getStyle().setMarginRight(60, Unit.PX);
    signupButton.addStyleName("button-style");
    btnPanel.setStyleName("bda-form-group");
    btnPanel.add(signinButton);
    btnPanel.add(signupButton);

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(emailLabel);
    hp.add(guestLabel);
    guestLabel.getElement().getStyle().setWidth(100, Unit.PX);
    guestLabel.getElement().getStyle().setTextAlign(TextAlign.RIGHT);
    guestLabel.getElement().getStyle().setMarginLeft(80, Unit.PX);
    guestLabel.getElement().getStyle().setCursor(Cursor.POINTER);
    loginContainer.add(hp);
    loginContainer.add(emailField);
    loginContainer.add(passwordLabel);
    loginContainer.add(passwordField);
    loginContainer.add(errorLabel);
    loginContainer.add(pwdPanel);
    loginContainer.add(btnPanel);

    loginContainer.setStyleName("bda-login-form");
    loginContainer.setBorderWidth(0);
    loginContainer.setStyleName((String) null);

    this.add(loginContainer);

    passwordField.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            autoLogin = false;
        }

    });

    checkBox.addValueChangeHandler(new ValueChangeHandler() {

        @Override
        public void onValueChange(ValueChangeEvent event) {
            // Window.alert( checkBox.getValue().toString() );
            Cookies.setCookie("bdachecked", checkBox.getValue().toString(), Util.getCookieExpireDate());
            if (!getRemmenber()) {
                Cookies.removeCookie("bdaserial");
                Cookies.removeCookie("bdatoken");
            }
        }

    });
}