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:org.rebioma.client.UploadView.java

License:Apache License

/**
 * Initialize ClickHandler for private radio, public radio, and upload buttons
 *///  www  . ja  v a  2  s  .c  om
private void initListeners() {

    cancelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            stop();
            setUploadEnable(true);
            uploadListener.onUploadComplete();
        }

    });

    showEmailBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            addHistoryItem(false);
        }
    });

    publicRadioButton.addClickHandler(new ClickHandler() {
        /**
         * Unchecks the private radio button and the modeling check box when the
         * public radio button is clicked.
         * 
         * @see com.google.gwt.user.client.ui.ClickHandler#onClick(com.google.gwt.
         *      user.client.ui.Widget)
         */
        public void onClick(ClickEvent event) {
            if (publicRadioButton.getValue()) {
                privateRadioButton.setValue(false);
                modelingBox.setValue(false);
                addHistoryItem(false);
            }
        }

    });

    privateRadioButton.addClickHandler(new ClickHandler() {
        /**
         * Unchecks the public radio button when the private radio button is
         * clicked.
         * 
         * @see com.google.gwt.user.client.ui.ClickHandler#onClick(com.google.gwt.
         *      user.client.ui.Widget)
         */
        public void onClick(ClickEvent event) {
            if (privateRadioButton.getValue()) {
                publicRadioButton.setValue(false);
                addHistoryItem(false);
            }

        }

    });

    uploadButton.addClickHandler(new ClickHandler() {
        /**
         * When the upload button is clicked, submits the upload form.
         * 
         * @see com.google.gwt.user.client.ui.ClickHandler#onClick(com.google.gwt.
         *      user.client.ui.Widget)
         */
        public void onClick(ClickEvent event) {
            hiddenSessionId.setValue(Cookies.getCookie(ApplicationView.SESSION_ID_NAME));
            //uploadForm.submit();
        }

    });

    modelingBox.addClickHandler(new ClickHandler() {
        /**
         * Sets the modeling box to false if the public radio button is currently
         * checked.
         */
        public void onClick(ClickEvent event) {
            boolean addHistory = true;
            if (publicRadioButton.getValue() && modelingBox.getValue()) {
                modelingBox.setValue(false);
                addHistory = false;
            }
            if (addHistory) {
                addHistoryItem(false);
            }
        }
    });

}

From source file:org.rhq.coregui.client.UserSessionManager.java

License:Open Source License

private static String getPreviousSessionId() {
    return Cookies.getCookie(SESSION_NAME);
}

From source file:org.rhq.coregui.client.UserSessionManager.java

License:Open Source License

private static String getDoomedSessionId() {
    return Cookies.getCookie(DOOMED_SESSION_NAME);
}

From source file:org.sakaiproject.gradebook.gwt.client.GradebookApplication.java

License:Educational Community License

private String getVersion() {
    String version = Cookies.getCookie(AppConstants.VERSION_COOKIE_NAME);

    if (version == null)
        version = "";

    return version;
}

From source file:org.sakaiproject.gradebook.gwt.client.gxt.view.panel.FileUploadPanel.java

License:Educational Community License

public FileUploadPanel(final ImportPanel newImportPanel) {

    super();/*from   ww  w  .j a  v a  2  s  .c  o  m*/

    GradebookResources resources = Registry.get(AppConstants.RESOURCES);

    this.newImportPanel = newImportPanel;
    i18n = Registry.get(AppConstants.I18N);
    Registry.get(AppConstants.I18N_TEMPLATES);

    final Gradebook gbModel = Registry.get(AppConstants.CURRENT);

    setLabelWidth(175);

    setHeaderVisible(false);

    String action = new StringBuilder().append(GWT.getHostPageBaseURL()).append(AppConstants.IMPORT_SERVLET)
            .toString();

    setFrame(true);
    setAction(action);
    setEncoding(Encoding.MULTIPART);
    setMethod(Method.POST);
    setPadding(4);
    setButtonAlign(HorizontalAlignment.RIGHT);

    //---------------------------------------------------------------------------

    file = new FileUploadField() {
        @Override
        protected void onChange(ComponentEvent ce) {

            super.onChange(ce);
            ExportType type = ExportType.getExportTypeFromFilename(getValue());
            importTypeComboBox.setSelectionByExportType(type);

        }

    };
    file.setValidator(new Validator() {

        @Override
        public String validate(Field<?> field, String value) {
            if (value != null) {
                int dot = value.lastIndexOf(".");
                if (dot > 0 && ExportType.getExportTypeFromFilename(value.substring(dot)) != null) {
                    return null;
                }
            }
            StringBuffer sb = new StringBuffer(i18n.importFileTypesWarning());

            for (ExportType type : ExportType.values()) {
                sb.append(type.getFileExtension()).append(",");
            }
            sb.deleteCharAt(sb.length() - 1); // TODO: multibyte charset aware?
            return sb.toString();
        }
    });
    file.setAllowBlank(false);
    file.setFieldLabel(i18n.fileLabel());
    file.setName("Test");

    //---security-values------------------------------------------------------------

    HiddenField<String> gradebookUidField = new HiddenField<String>();
    gradebookUidField.setName(AppConstants.REQUEST_FORM_FIELD_GBUID);
    gradebookUidField.setValue(gbModel.getGradebookUid());
    add(gradebookUidField);

    HiddenField<String> formTokenField = new HiddenField<String>();
    formTokenField.setName(AppConstants.REQUEST_FORM_FIELD_FORM_TOKEN);
    formTokenField.setValue(Cookies.getCookie(AppConstants.GB2_TOKEN));
    add(formTokenField);

    //---invisible combo box set by validator for format combo----------------------

    importTypeComboBox = new ExportTypeComboBox();
    importTypeComboBox.setName(AppConstants.IMPORT_PARAM_FILETYPE);
    importTypeComboBox.setAllowBlank(false);
    importTypeComboBox.setVisible(false);

    //---format combo---------------------------------------------------------------

    importFormatInformationMessage = new Html();
    importFormatInformationMessage.setHtml(i18n.fileFormatImportMessageFull());
    importFormatInformationMessage.setStyleName(resources.css().importFormatInformationMessage());

    importFormatComboBox = new FileFormatComboBox();
    importFormatComboBox.setWidth("50%");
    importFormatComboBox.setName(AppConstants.IMPORT_PARAM_FILEFORMAT);
    importFormatComboBox.setEmptyText(i18n.importFormatFieldEmptyText());
    importFormatComboBox.setAllowBlank(false);
    importFormatComboBox.setValidator(new Validator() {

        @Override
        public String validate(Field<?> field, String value) {
            if (value != null) {
                FileFormat f = FileFormat.valueOf(
                        (String) importFormatComboBox.getValue().get(importFormatComboBox.getValueField()));
                if (f != null) {
                    importFormatInformationMessage.setHtml(f.getImportMessage(i18n));

                    if (!f.equals(FileFormat.FULL)) {

                        if (justStructureChoice.getValue()) {
                            return i18n.justStructureNotAllowedMessage() + "'"
                                    + i18n.justStructureCheckboxLabel() + "'";
                        }

                        justStructureChoice.setEnabled(false);

                        return null;
                    }

                    justStructureChoice.setEnabled(true);
                    return null;
                }
                return "This should not happen: format not valid";
            }
            return "This should not happen: format dropdown value == null";
        }
    });

    importFormatSet = new FieldSet();
    importFormatSet.setCollapsible(false);
    importFormatSet.setHeading(i18n.importFormatFieldLabel());
    importFormatSet.setCheckboxToggle(false);
    importFormatSet.setAutoHeight(true);
    importFormatSet.setScrollMode(Scroll.AUTO);
    importFormatSet.setVisible(true);
    importFormatSet.add(importFormatComboBox);
    importFormatSet.add(importFormatInformationMessage);

    //---just-structure check-box----------------------------------------------------

    // GRBK-514
    justStructureChoice = new NullSensitiveCheckBox() {

        @Override
        protected void onClick(ComponentEvent ce) {
            super.onClick(ce);
            // hack for setting it Dirty?
            importFormatComboBox.setSelection(importFormatComboBox.getSelection());
        }

    };
    justStructureChoice.setName(AppConstants.IMPORT_PARAM_STRUCTURE);
    justStructureChoice.setValueAttribute("c");// we just check for ! null server-side

    ToolTipConfig checkBoxToolTipConfig = new ToolTipConfig(i18n.justStructureCheckboxToolTip());
    checkBoxToolTipConfig.setDismissDelay(10000);
    justStructureChoice.setToolTip(checkBoxToolTipConfig);
    justStructureChoice.setFieldLabel(i18n.justStructureCheckboxLabel());
    justStructureChoice.setValue(false);
    justStructureChoice.setAutoHeight(false);
    justStructureChoice.setAutoWidth(false);
    justStructureChoice.addStyleName(resources.css().gbLeftAlignFlushNoWrapInput());

    addListener(Events.Submit, new Listener<FormEvent>() {

        public void handleEvent(FormEvent fe) {
            newImportPanel.readSubmitResponse(fe.getResultHtml());
        }

    });

    //---------------------------------------------------------------------------

    add(importFormatSet);
    add(file);
    add(justStructureChoice);
    add(importTypeComboBox);
}

From source file:org.sakaiproject.gradebook.gwt.client.RestBuilder.java

License:Educational Community License

public static RestBuilder getInstance(Method method, String url) {

    String header = null;/*from w  w  w  .  jav a  2s .  c om*/
    switch (method) {
    case DELETE:
    case PUT:
        header = method.name();
        method = Method.POST;
        break;
    }
    RestBuilder builder = new RestBuilder(method.name(), url);

    if (header != null)
        builder.setHeader("X-HTTP-Method-Override", header);

    builder.setHeader("Content-Type", AppConstants.HEADER_CONTENT_TYPE_JSON_UTF8);
    String gb2Token = Cookies.getCookie(AppConstants.GB2_TOKEN);
    if (null == gb2Token || "".equals(gb2Token)) {
        builder.setHeader(AppConstants.X_XSRF_COOKIE, AppConstants.NO_VALUE_COOKIE);
    } else {
        builder.setHeader(AppConstants.X_XSRF_COOKIE, gb2Token);
    }

    return builder;
}

From source file:org.sakaiproject.sgs2.client.Sgs2.java

License:Educational Community License

private Command getMenuScriptsCookies() {
    return new Command() {
        public void execute() {
            Collection<String> cookyNames = Cookies.getCookieNames();
            if (cookyNames.size() == 0) {
                addConsoleMessage(i18nC.commandCookiesMsg1() + new Date().toString());
            } else {
                addConsoleMessage(i18nC.commandCookiesMsg2() + new Date().toString());
                for (String cookyName : cookyNames) {
                    addConsoleMessage(i18nC.commandCookiesName() + cookyName + "<br/>"
                            + i18nC.commandCookiesValue() + Cookies.getCookie(cookyName));
                }/*from   ww w.  j a v a2  s.c  om*/
            }
        }
    };
}

From source file:org.sakaiproject.sgs2.client.Sgs2.java

License:Educational Community License

private String getSecureToken() {
    return Cookies.getCookie(AppConstants.SECURE_TOKEN_NAME);
}

From source file:org.sigmah.client.inject.AuthProvider.java

License:Open Source License

public Authentication get() {

    if (Cookies.getCookie("authToken") != null && Cookies.getCookie("userId") != null
            && Cookies.getCookie("email") != null) {

        return new Authentication(Integer.parseInt(Cookies.getCookie("userId")), Cookies.getCookie("authToken"),
                Cookies.getCookie("email"));

    }/*from w ww .j  a  v  a  2s  . c o  m*/

    Dictionary userInfo;
    try {
        userInfo = Dictionary.getDictionary("UserInfo");
        return new Authentication(Integer.parseInt(userInfo.get("userId")), userInfo.get("authToken"),
                userInfo.get("email"));
    } catch (Exception e) {
        Log.fatal("DictionaryAuthenticationProvider: exception retrieving dictionary from page", e);
        throw new Error();
    }
}

From source file:org.sigmah.client.offline.OfflineStatus.java

License:Open Source License

/**
 * Check whether we are running in off-line mode.
 * @return offline status/*from   w  w w. ja  va  2 s.c  om*/
 */
public boolean isOfflineEnabled() {
    return "enabled".equals(Cookies.getCookie(offlineCookieName));
}