List of usage examples for com.google.gwt.user.client Cookies getCookie
public static String getCookie(String name)
From source file:gwt.material.design.incubator.client.walkthrough.WalkthroughManager.java
License:Apache License
public static boolean hasWalkthrough(String userName, String appName) { String value = Cookies.getCookie(userName); if (value != null && !value.isEmpty() && appName.equals(value)) { return false; }/*from ww w.j a va 2 s .com*/ if (value == null) { register(userName, appName); } return true; }
From source file:gwt.material.design.incubator.client.walkthrough.WalkthroughManager.java
License:Apache License
public static void unregister(String userName, String appName) { String value = Cookies.getCookie(userName); if (appName.equals(value)) { Cookies.removeCookie(userName);/* www . ja va2 s . co m*/ } }
From source file:harvesterUI.client.mvc.views.AppView.java
License:Open Source License
public void setUserLoginData() { LabelToolItem userWelcomeLabel = new LabelToolItem( HarvesterUI.CONSTANTS.welcome() + " " + HarvesterUI.UTIL_MANAGER.getLoggedUserName()); userWelcomeLabel.setId("userWelcomeLabel"); toolBar.insert(new SeparatorToolItem(), toolBar.getItems().size()); // Language Combo new LanguageComboBox(toolBar); toolBar.insert(userWelcomeLabel, toolBar.getItems().size()); ToolTipConfig config = new ToolTipConfig(); config.setTitle(HarvesterUI.CONSTANTS.editAccountButton()); config.setShowDelay(1000);/*from w w w . ja v a 2 s.c o m*/ config.setText(HarvesterUI.CONSTANTS.editAccountButtonTooltip()); // Dont show on Anonymous if (HarvesterUI.UTIL_MANAGER.getLoggedUserRole() != UserRole.ANONYMOUS && !Cookies.getCookie(CookieManager.SID).equals("LDAP_SESSION_437")) { Button editAccount = new Button(""); editAccount.setIcon(HarvesterUI.ICONS.edit_user()); editAccount.setToolTip(config); editAccount.setSize(28, 28); editAccount.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Dispatcher.get().dispatch(AppEvents.ViewAccountEditForm); } }); toolBar.insert(editAccount, toolBar.getItems().size()); } addLogoutButton(); }
From source file:harvesterUI.client.panels.overviewGrid.MyPagingToolBar.java
License:Open Source License
/** * Creates a new paging tool bar with the given page size. * * @param pageSize the page size/*from ww w.j a v a 2s .c om*/ */ public MyPagingToolBar(final int pageSize, DataGridContainer mainGridContainer) { this.pageSize = pageSize; this.mainGridContainer = mainGridContainer; first = new Button(); first.addListener(Events.Disable, listener); first.addListener(Events.Enable, listener); first.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { first(); } }); prev = new Button(); prev.addListener(Events.Disable, listener); prev.addListener(Events.Enable, listener); prev.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { previous(); } }); next = new Button(); next.addListener(Events.Disable, listener); next.addListener(Events.Enable, listener); next.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { next(); } }); last = new Button(); last.addListener(Events.Disable, listener); last.addListener(Events.Enable, listener); last.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { last(); } }); refresh = new Button(); refresh.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { refresh(); } }); beforePage = new LabelToolItem(); beforePage.setStyleName("my-paging-text"); afterText = new LabelToolItem(); afterText.setStyleName("my-paging-text"); pageText = new TextBox(); if (GXT.isAriaEnabled()) pageText.setTitle("Page"); pageText.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { onPageChange(); } } }); pageText.setWidth("30px"); displayText = new LabelToolItem(); displayText.setId(getId() + "-display"); displayText.setStyleName("my-paging-display"); add(first); add(prev); add(new SeparatorToolItem()); add(beforePage); add(new WidgetComponent(pageText)); add(afterText); add(new SeparatorToolItem()); add(next); add(last); add(new SeparatorToolItem()); add(refresh); add(new FillToolItem()); add(displayText); // Add data providers per page Combo add(new SeparatorToolItem()); add(new LabelToolItem(" " + HarvesterUI.CONSTANTS.rowsPerPage() + " ")); perPageCombo = new SimpleComboBox<String>(); perPageCombo.setWidth(55); perPageCombo.setEditable(false); perPageCombo.setTriggerAction(ComboBox.TriggerAction.ALL); perPageCombo.add("15"); perPageCombo.add("30"); perPageCombo.add("45"); perPageCombo.add("60"); perPageCombo.add("100"); perPageCombo.add("200"); perPageCombo.setId("dataPerPageComboBox"); perPageCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() { @Override public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) { setPageSize(Integer.valueOf(se.getSelectedItem().getValue())); if (perPageCombo.isVisible()) { refresh(); CookieManager cookieManager = (CookieManager) Registry.get(HarvesterUI.COOKIE_MANAGER); cookieManager.saveRowsPerPageData(perPageCombo.getSimpleValue()); } } }); String perPageData = Cookies.getCookie(CookieManager.ROWS_PER_PAGE); if (perPageData != null && !perPageData.isEmpty()) perPageCombo.setSimpleValue(perPageData); else perPageCombo.setSimpleValue("15"); add(perPageCombo); setMessages(new PagingToolBarMessages()); setImages(new PagingToolBarImages()); }
From source file:ibeans.client.IBeansConsole2.java
License:Open Source License
UserInfo getUserInfo() { if (user == null) { String rawCookie = Cookies.getCookie("ibeans-console"); if (rawCookie.equals("")) { UserInfo info = new UserInfo(); return info; } else {/*from w ww. java 2 s .com*/ return new UserInfo(rawCookie); } } else { return user; } }
From source file:it.unibo.cs.v2.client.LoginPage.java
License:Open Source License
public LoginPage() { super(""); FlexTable mainTable = new FlexTable(); errorLabel.setVisible(false);/*from ww w . j a v a 2 s . c o m*/ errorLabel.getElement().getStyle().setColor("red"); disclosure.setContent(new RegistrationForm()); if (Cookies.getCookie("login") != null) { userName.setText(Cookies.getCookie("login")); password.setFocus(true); } else userName.setFocus(true); mainTable.clear(); /* First row */ mainTable.setWidget(0, 0, new HTML("<b>Username</b>")); mainTable.setWidget(0, 1, userName); mainTable.setWidget(1, 0, new HTML("<b>Password</b>")); mainTable.setWidget(1, 1, password); mainTable.setWidget(2, 0, submitButton); mainTable.getElement().setAttribute("align", "center"); add(mainTable); add(errorLabel); add(disclosure); disclosure.getElement().setAttribute("align", "center"); disclosure.setAnimationEnabled(true); disclosure.addCloseHandler(new CloseHandler<DisclosurePanel>() { @Override public void onClose(CloseEvent<DisclosurePanel> event) { ((RegistrationForm) disclosure.getContent()).hideLabel(); } }); submitButton.addClickHandler(this); password.addKeyDownHandler(this); }
From source file:net.cbtltd.client.panel.SessionPopup.java
private VerticalPanel createContent() { VerticalPanel form = new VerticalPanel(); form.addStyleName(CSS.magnify()); final Label closeButton = new Label(); closeButton.addClickHandler(new ClickHandler() { @Override/*from w w w . j ava 2 s . c om*/ public void onClick(ClickEvent event) { SessionPopup.this.hide(); } }); closeButton.addStyleName(AbstractField.CSS.cbtAbstractPopupClose()); form.add(closeButton); final HTML helpLabel = new HTML(CONSTANTS.helpLabel()); helpLabel.addStyleName(AbstractField.CSS.cbtAbstractField()); helpLabel.addStyleName(CSS.helpLabel()); form.add(helpLabel); //----------------------------------------------- // Email address to identify user //----------------------------------------------- emailaddressField = new TextField(this, null, CONSTANTS.emailaddressLabel(), tab++); emailaddressField.setDefaultValue(Cookies.getCookie("emailaddress")); emailaddressField.setFocus(true); emailaddressField.setHelpText(CONSTANTS.emailaddressHelp()); form.add(emailaddressField); //----------------------------------------------- // Password field //----------------------------------------------- passwordField = new PasswordField(this, null, CONSTANTS.passwordLabel(), tab++); passwordField.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { sessionLogin.execute(); } }); passwordField.setSecure(true); passwordField.addStyleName(CSS.passwordField()); passwordField.setHelpText(CONSTANTS.passwordHelp()); form.add(passwordField); //----------------------------------------------- // Request New Password button //----------------------------------------------- passwordcreateButton = new Label(CONSTANTS.passwordcreateLabel()); passwordcreateButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { passwordCreate.execute(); } }); passwordcreateButton.addStyleName(CSS.passwordcreateStyle()); form.add(passwordcreateButton); //----------------------------------------------- // Auto Login field //----------------------------------------------- autologinField = new CheckField(this, null, CONSTANTS.autologinLabel(), tab++); autologinField.setReadOption(Session.LOGGED_OUT, true); autologinField.setDefaultValue(false); //form.add(autologinField); final HorizontalPanel bar = new HorizontalPanel(); bar.addStyleName(AbstractField.CSS.cbtAbstractCommand()); //----------------------------------------------- // Login button //----------------------------------------------- final CommandButton loginButton = new CommandButton(this, CONSTANTS.loginLabel(), sessionLogin, tab++); loginButton.addStyleName(AbstractField.CSS.cbtGradientGreen()); bar.add(loginButton); bar.add(autologinField); form.add(bar); //----------------------------------------------- // Transition array to define the finite state machine //----------------------------------------------- fsm = new ArrayList<Transition>(); fsm.add(new Transition(Session.LOGGED_OUT, loginButton, Session.LOGGED_IN)); onReset(Session.LOGGED_OUT); return form; }
From source file:net.cbtltd.client.panel.SessionPopup.java
private void createActions() { //----------------------------------------------- // Check if User Exists //----------------------------------------------- partyExists = new GuardedRequest<Party>() { protected boolean error() { return (emailaddressField.noValue() || !Party.isEmailAddress(emailaddressField.getValue())); }/*from w ww .j a v a 2 s . c o m*/ protected void send() { super.send(getValue(new PartyExists())); } protected void receive(Party party) { ifMessage((party == null), Level.ERROR, CONSTANTS.partyError(), emailaddressField); } }; //----------------------------------------------- // Check if Session Exists //----------------------------------------------- sessionExists = new GuardedRequest<Session>() { protected boolean error() { return (isPopup || Cookies.getCookie("sid") == null || Cookies.getCookie("sid").isEmpty()); } protected void send() { super.send(new SessionExists(Cookies.getCookie("sid"))); } protected void receive(Session session) { if (session != null) { setValue(session); } } }; //----------------------------------------------- // Login to Create Session //----------------------------------------------- sessionLogin = new GuardedRequest<Session>() { protected boolean error() { return (ifMessage(emailaddressField.noValue(), Level.ERROR, CONSTANTS.emailaddressnoneError(), emailaddressField) || ifMessage(!Party.isEmailAddress(emailaddressField.getValue()), Level.ERROR, CONSTANTS.emailaddressinvalidError(), emailaddressField) || ifMessage(passwordField.noValue(), Level.ERROR, CONSTANTS.passwordError(), passwordField)); } protected void send() { super.send(getValue(new SessionLogin())); } protected void receive(Session session) { setValue(session); } }; //----------------------------------------------- // Create New Password //----------------------------------------------- passwordCreate = new GuardedRequest<Session>() { protected boolean error() { return false; } //return AbstractRoot.noSession() || AbstractRoot.getSession().notState(Session.LOGGED_OUT);} protected void send() { super.send(getValue(new PasswordCreate())); } protected void receive(Session session) { AbstractField.addMessage(Level.TERSE, CONSTANTS.passwordsentLabel(), passwordField); } }; }
From source file:net.europa13.taikai.web.client.TaikaiWebEntryPoint.java
License:Open Source License
private void initState() { //********************************************************************* // Restore application state from cookies. final String taikaiCookie = Cookies.getCookie("taikaiId"); if (taikaiCookie != null) { // try { // Integer i = Integer.parseInt(taikaiCookie); // } // catch (NumberFormatException ex) { // Logger.debug(ex.getMessage()); // } // final ServiceWaiter waiter = new ServiceWaiter(); TaikaiAdminServiceAsync service = GWT.create(TaikaiAdminService.class); service.getTaikai(Integer.parseInt(taikaiCookie), new AsyncCallback<TaikaiProxy>() { public void onFailure(Throwable arg0) { Logger.error("Evenemang " + taikaiCookie + " kan inte laddas in."); start("session"); // waiter.stop(); }//from w ww. ja v a2 s . c o m public void onSuccess(TaikaiProxy taikai) { TaikaiWeb.getSession().setTaikai(taikai); start(History.getToken()); // waiter.stop(); } }); // DeferredCommand.addCommand(waiter); } else { start("session"); } }
From source file:net.eve.finger.client.Net_eve_finger.java
License:Open Source License
/** * This is the entry point method./* w ww .ja va2 s . c o m*/ */ public void onModuleLoad() { // Setup the desktop interface deskMgr.createDesktop(); desktop = deskMgr.getDesktop(); desktop.getTaskBar().setEnabled(false); // Make app level objects (globals) available // to all windows Registry.register("desktop", desktop); Registry.register("fingersvc", fingerSvc); // If there is an old session stored, retrieve it final String cookieSessionID = Cookies.getCookie(COOKIE_SESSION); // Do they have a stored session ID? if (cookieSessionID != null) { // Is it valid? fingerSvc.isSessionValid(cookieSessionID, new AsyncCall<LoginResult>() { @Override public void onSuccess(LoginResult result) { // Valid session? if (result != null) { // Save it sessionID = cookieSessionID; // Get their username username = Cookies.getCookie(COOKIE_NAME); // Save the other data staticLoginData = result; // Load the UI userAuthed(); } else { // They'll have to login showLoginForm(); } } }); } else { // No, ask them to login showLoginForm(); } }