List of usage examples for com.google.gwt.user.client Cookies getCookie
public static String getCookie(String name)
From source file:eml.studio.client.mvp.presenter.AccountLoader.java
License:Open Source License
/** * Reload search result/*from w ww. j av a2 s .co m*/ */ private void reload() { resultStart = (currentPage - 1) * 13; if (currentPage == lastPage) { everyPageSize = resultSize - resultStart; } else { everyPageSize = 13; } adminView.getUserGrid().resize(everyPageSize + 1, 7); adminView.getUserGrid().setText(0, 0, "Email"); adminView.getUserGrid().setText(0, 1, "Username"); adminView.getUserGrid().setText(0, 2, "Company"); adminView.getUserGrid().setText(0, 3, "Position"); adminView.getUserGrid().setText(0, 4, "Join Date"); adminView.getUserGrid().setText(0, 5, "Power"); adminView.getUserGrid().setText(0, 6, "Operation"); Account currentAccount = new Account(); currentAccount.setEmail(Cookies.getCookie("bdaemail")); accountService.search(currentAccount, searchAccount, resultStart, everyPageSize, new AsyncCallback<List<Account>>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(List<Account> result) { // TODO Auto-generated method stub for (int i = 0; i < everyPageSize; i++) { adminView.getUserGrid().setText(i + 1, 0, result.get(i).getEmail()); adminView.getUserGrid().setText(i + 1, 1, result.get(i).getUsername()); adminView.getUserGrid().setText(i + 1, 2, result.get(i).getCompany()); adminView.getUserGrid().setText(i + 1, 3, result.get(i).getPosition()); adminView.getUserGrid().setText(i + 1, 4, formatter.format(result.get(i).getCreatetime())); final HorizontalPanel powerField = new HorizontalPanel(); final CheckBox cb1 = new CheckBox(); final CheckBox cb2 = new CheckBox(); final CheckBox cb3 = new CheckBox(); Label lb1 = new Label(Constants.adminUIMsg.power1()); Label lb2 = new Label(Constants.adminUIMsg.power2()); Label lb3 = new Label(Constants.adminUIMsg.power3()); lb1.getElement().getStyle().setMarginTop(1, Unit.PX); lb2.getElement().getStyle().setMarginTop(1, Unit.PX); lb3.getElement().getStyle().setMarginTop(1, Unit.PX); cb1.getElement().getStyle().setMarginLeft(5, Unit.PX); cb2.getElement().getStyle().setMarginLeft(5, Unit.PX); cb3.getElement().getStyle().setMarginLeft(5, Unit.PX); powerField.add(cb1); powerField.add(lb1); powerField.add(cb2); powerField.add(lb2); powerField.add(cb3); powerField.add(lb3); String arr[] = result.get(i).getPower().split(""); if (arr[1].equals("1")) { cb1.setValue(true); } if (arr[2].equals("1")) { cb2.setValue(true); } if (arr[3].equals("1")) { cb3.setValue(true); } cb1.setEnabled(false); cb2.setEnabled(false); cb3.setEnabled(false); adminView.getUserGrid().setWidget(i + 1, 5, powerField); final String userEmail = result.get(i).getEmail(); final Label editUser = new Label(); editUser.setTitle(Constants.adminUIMsg.editPower()); editUser.addStyleName("admin-user-edit"); editUser.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub cb1.setEnabled(true); cb2.setEnabled(true); cb3.setEnabled(true); editUser.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub String newPower = ""; if (cb1.getValue()) { newPower = newPower + "1"; } else { newPower = newPower + "0"; } if (cb2.getValue()) { newPower = newPower + "1"; } else { newPower = newPower + "0"; } if (cb3.getValue()) { newPower = newPower + "1"; } else { newPower = newPower + "0"; } Account account = new Account(); account.setEmail(userEmail); account.setPower(newPower); accountService.updatePower(account, new AsyncCallback<Account>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(Account result) { // TODO Auto-generated method stub if (result != null) { alertPanel.setContent(Constants.adminUIMsg.powerSuccess()); alertPanel.show(); } } }); } }); } }); Label deleteUser = new Label(); deleteUser.setTitle(Constants.adminUIMsg.deleteUser()); deleteUser.addStyleName("admin-user-delete"); deleteUser.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub deletePanel.setContent(Constants.adminUIMsg.userDelete1() + userEmail + Constants.adminUIMsg.userDelete2()); deletePanel.show(); deletePanel.getConfirmBtn().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub Account account = new Account(); account.setEmail(userEmail); accountService.deleteAccount(account, new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub deletePanel.hide(); alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(String result) { // TODO Auto-generated method stub if (result.equals("success")) { deletePanel.hide(); alertPanel.setContent(Constants.adminUIMsg.userSuccess()); alertPanel.show(); } else { deletePanel.hide(); alertPanel.setContent(result); alertPanel.show(); } } }); } }); } }); HorizontalPanel operate = new HorizontalPanel(); operate.addStyleName("admin-user"); operate.add(editUser); operate.add(deleteUser); if (!userEmail.equals(AppController.email)) { adminView.getUserGrid().setWidget(i + 1, 6, operate); } } } }); }
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 o m 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"); } } }); }
From source file:es.deusto.weblab.client.WebLabClient.java
License:Open Source License
private void selectLanguage() { if (localeConfigured()) return;//from ww w. j a va 2s . co m final String weblabLocaleCookie = Cookies.getCookie(WebLabClient.LOCALE_COOKIE); if (weblabLocaleCookie != null) { String currentLocaleName = LocaleInfo.getCurrentLocale().getLocaleName(); if (currentLocaleName.equals("default")) currentLocaleName = "en"; if (!currentLocaleName.equals(weblabLocaleCookie)) WebLabClient.refresh(weblabLocaleCookie); return; } // Else, check if there is a default language. If there is, show it this.languageDecisionPending = true; }
From source file:es.deusto.weblab.client.WebLabLabLoader.java
License:Open Source License
public void loadLabApp() { // We need to initialize the AudioManager singleton AudioManager.initialize(this.configurationManager); try {//from ww w.ja v a 2s . c o m ExperimentFactory.loadExperiments(this.configurationManager); } catch (final Exception e) { this.weblabClient.showError("Error checking experiments: " + e.getMessage()); e.printStackTrace(); return; } final ILabCommunication communications = new LabCommunication(this.configurationManager); final PollingHandler pollingHandler = new PollingHandler(this.configurationManager); final boolean isUsingMobile = this.weblabClient.isMobile(); final ILabController controller = new LabController(this.configurationManager, communications, pollingHandler, isUsingMobile, this.isFacebook()); pollingHandler.setController(controller); final IWlLabThemeLoadedCallback themeLoadedCallback = new IWlLabThemeLoadedCallback() { @Override public void onThemeLoaded(final LabThemeBase theme) { controller.setUIManager(theme); boolean stillWaiting = false; try { String providedSessionId = Window.Location.getParameter(WebLabLabLoader.SESSION_ID_URL_PARAM); if (providedSessionId == null) providedSessionId = HistoryProperties.getValue(WebLabLabLoader.SESSION_ID_URL_PARAM); String providedReservationId = Window.Location .getParameter(WebLabLabLoader.RESERVATION_ID_URL_PARAM); if (providedReservationId == null) providedReservationId = HistoryProperties .getValue(WebLabLabLoader.RESERVATION_ID_URL_PARAM); ExperimentID experimentId = null; if (providedReservationId != null) { final String selectedExperimentName = HistoryProperties .getValue(HistoryProperties.EXPERIMENT_NAME); final String selectedExperimentCategory = HistoryProperties .getValue(HistoryProperties.EXPERIMENT_CATEGORY); experimentId = new ExperimentID(new Category(selectedExperimentCategory), selectedExperimentName); } if (providedReservationId != null && experimentId != null) { final String reservationId; final int position = providedReservationId.indexOf(';'); if (position >= 0) { reservationId = providedReservationId.substring(0, position); final String cookie = providedReservationId.substring(position + 1); Cookies.setCookie(WebLabLabLoader.WEBLAB_SESSION_ID_COOKIE, cookie, null, null, WebLabClient.baseLocation + "/weblab/", false); } else reservationId = providedReservationId; controller.startReserved(new SessionID(reservationId), experimentId); } else if (providedSessionId != null) { final String sessionId; final int position = providedSessionId.indexOf(';'); if (position >= 0) { sessionId = providedSessionId.substring(0, position); final String cookie = providedSessionId.substring(position + 1); Cookies.setCookie(WebLabLabLoader.WEBLAB_SESSION_ID_COOKIE, cookie, null, null, WebLabClient.baseLocation + "/weblab/", false); } else sessionId = providedSessionId; controller.startLoggedIn(new SessionID(sessionId), true); } else { final String possibleSessionId = Cookies .getCookie(WebLabLabLoader.WEBLAB_SESSION_ID_COOKIE); if (possibleSessionId == null) { theme.onInit(); // If it's still null... } else { final SessionID tentativeSessionId; if (possibleSessionId.contains(".")) tentativeSessionId = new SessionID( possibleSessionId.substring(0, possibleSessionId.indexOf('.'))); else tentativeSessionId = new SessionID(possibleSessionId); controller.checkSessionIdStillValid(tentativeSessionId, new IValidSessionCallback() { @Override public void sessionRejected() { theme.onInit(); WebLabLabLoader.this.weblabClient.putWidget(theme.getWidget()); theme.onLoaded(); } @Override public void sessionConfirmed() { controller.startLoggedIn(tentativeSessionId, false); } }); } } System.out.println("----->>> providedSessionId " + providedSessionId); System.out.println("----->>> providedReservationId " + providedReservationId); System.out.println("----->>> experimentId " + experimentId); } catch (final Exception e) { WebLabLabLoader.this.weblabClient.showError("Error initializing theme: " + e.getMessage()); e.printStackTrace(); return; } if (!stillWaiting) { WebLabLabLoader.this.weblabClient.putWidget(theme.getWidget()); theme.onLoaded(); } } @Override public void onFailure(Throwable e) { WebLabLabLoader.this.weblabClient.showError("Error creating theme: " + e.getMessage() + "; " + e); return; } }; try { LabThemeFactory.themeFactory(this.configurationManager, controller, this.configurationManager.getProperty(WebLabClient.THEME_PROPERTY, WebLabClient.DEFAULT_THEME), isUsingMobile, themeLoadedCallback); } catch (final Exception e) { this.weblabClient.showError("Error creating theme: " + e.getMessage() + "; " + e); return; } }
From source file:eu.riscoss.client.RiscossJsonClient.java
License:Apache License
public static String getDomain() { String domain = Cookies.getCookie(CookieNames.DOMAIN_KEY); return domain; }
From source file:eu.riscoss.client.RiscossJsonClient.java
License:Apache License
public static String getToken() { String token = Cookies.getCookie(CookieNames.TOKEN_KEY); // A null or empty string gives an error when setting it in the request header if (token == null) token = "-"; return token; }
From source file:eu.riscoss.client.RiscossWebApp.java
License:Apache License
public void onModuleLoad() { String domain = Cookies.getCookie(CookieNames.DOMAIN_KEY); Log.println("Current domain: " + domain); RiscossCall.fromCookies().withDomain(null).auth().fx("username").get(new JsonCallback() { @Override//from ww w .j a v a 2 s. c om public void onSuccess(Method method, JSONValue response) { if (response != null) { if (response.isString() != null) username = response.isString().stringValue(); } if (username == null) username = ""; Log.println("username: " + username); RiscossJsonClient.selectDomain(RiscossCall.getDomain(), new JsonCallback() { @Override public void onSuccess(Method method, JSONValue response) { Log.println("Domain check response: " + response); if (response == null) showDomainSelectionDialog(); else if (response.isString() == null) showDomainSelectionDialog(); else loadSitemap(); } @Override public void onFailure(Method method, Throwable exception) { Window.alert(exception.getMessage()); } }); } @Override public void onFailure(Method method, Throwable exception) { Window.alert(exception.getMessage()); } }); }
From source file:fast.servicescreen.client.gui.codegen_js.CodeGenerator.java
License:Open Source License
/** * This method send the current template to * an service which writes a js and a html file with it as content. * *//*from w w w . j a v a2s . c o m*/ public void write_JS_File(boolean isLocal) { //create GWT service impl. service = GWT.create(RequestService.class); //send pre - trans - post code to server service.saveJsFileOnServer(isLocal, screen.getName(), prehtml, helperMethods + rootTemplate, posthtml, new AsyncCallback<String>() { @Override public void onSuccess(String result) { GWT.log("Writing .js file to RequestService succed..", null); Window.alert(result); } @Override public void onFailure(Throwable caught) { GWT.log("ERROR while writing .js file to RequestService..", null); Window.alert(caught.getLocalizedMessage()); } }); //shareBuildingBlock(): //url and header String url = "http://localhost:13337/" /*URL_Settings.getGVS_URL()*/ + "buildingblock/resource"; final String cookie = "fastgvsid=" + Cookies.getCookie("fastgvsid"); final HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Cookie", cookie); //build operator String jsonObject = createBuildingBlock(); String body = "buildingblock=" + jsonObject; //upload to GVS service.sendHttpRequest_POST(url, headers, body, new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(String result) { if (result != null && result != "-1" && result.startsWith("{")) { JSONValue resourceVal = JSONParser.parse(result); JSONObject resourceObj = resourceVal.isObject(); JSONValue idVal = resourceObj.get("id"); JSONNumber idNum = idVal.isNumber(); String id = idNum.toString(); if (id != null) { String shareUrl = "http://127.0.0.1:13337/" + "buildingblock/" + id + "/sharing"; service.sendHttpRequest_POST(shareUrl, headers, "", new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { //Resource couldn't be shared System.out.println("Resource couldn't be shared" + caught.getMessage()); } @Override public void onSuccess(String result) { //Resource was shared System.out.println("Resource was shared: " + result); } }); } } } }); }
From source file:fast.servicescreen.client.rpc.ShareResourceHandler.java
License:Open Source License
public String share(BuildingBlock res) { final String resultString = ""; //url and header String url = gvsUrl + "buildingblock/resource"; final String cookie = "fastgvsid=" + Cookies.getCookie("fastgvsid"); final HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Cookie", cookie); //build operator String body = "buildingblock=" + buildResource(res); // Window.alert("Resource: " + body); //upload to GVS shResService = GWT.create(RequestService.class); shResService.sendHttpRequest_POST(url, headers, body, new AsyncCallback<String>() { @Override//from www.j a va 2 s .com public void onFailure(Throwable caught) { } @Override public void onSuccess(String result) { if (result != null && result != "-1") { JSONValue resourceVal = JSONParser.parse(result); JSONObject resourceObj = resourceVal.isObject(); JSONValue idVal = resourceObj.get("id"); JSONNumber idNum = idVal.isNumber(); String id = idNum.toString(); if (id != null) { String shareUrl = gvsUrl + "buildingblock/" + id + "/sharing"; shResService.sendHttpRequest_POST(shareUrl, headers, "", new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { //Resource couldn't be shared System.out.println("Resource couldn't be shared" + caught.getMessage()); } @Override public void onSuccess(String result) { //Resource was shared System.out.println("Resource was shared: " + result); } }); } } } }); return resultString; }
From source file:fr.fg.client.core.login.LoginDialog.java
License:Open Source License
public LoginDialog(ActionCallback callback) { super(((StaticMessages) GWT.create(StaticMessages.class)).gameConnection(), false, true, false); this.callback = callback; StaticMessages messages = (StaticMessages) GWT.create(StaticMessages.class); // Liste des galaxies JSLabel galaxyLabel = new JSLabel(" " + messages.galaxy()); galaxyLabel.setPixelWidth(100);/*from w ww . j a v a2 s . co m*/ galaxyComboBox = new JSComboBox(); galaxyComboBox.setPixelWidth(200); // Login JSLabel loginLabel = new JSLabel(" " + messages.login()); loginLabel.setPixelWidth(100); loginField = new JSTextField(); loginField.setPixelWidth(200); if (Cookies.getCookie("login") != null) loginField.setText(Cookies.getCookie("login")); // Mot de passe JSLabel passwordLabel = new JSLabel(" " + messages.password()); passwordLabel.setPixelWidth(100); passwordField = new JSPasswordField(); passwordField.setPixelWidth(200); passwordField.addKeyboardListener(this); // Mot de passe oubli forgottenPasswordLabel = new JSLabel("<a unselectable=\"on\">" + messages.passwordForgotten() + "</a>"); forgottenPasswordLabel.setPixelWidth(300); forgottenPasswordLabel.setAlignment(JSLabel.ALIGN_CENTER); // Bouton connexion loginBt = new JSButton(messages.connect()); loginBt.setPixelWidth(100); loginBt.addClickListener(this); // Bouton inscription registerBt = new JSButton(messages.register()); registerBt.setPixelWidth(100); registerBt.addClickListener(this); JSRowLayout layout = new JSRowLayout(); layout.addComponent(galaxyLabel); layout.addComponent(galaxyComboBox); layout.addRow(); layout.addComponent(loginLabel); layout.addComponent(loginField); layout.addRow(); layout.addComponent(passwordLabel); layout.addComponent(passwordField); layout.addRow(); layout.addComponent(forgottenPasswordLabel); layout.addRowSeparator(5); layout.addComponent(loginBt); layout.addComponent(registerBt); layout.setRowAlignment(JSRowLayout.ALIGN_CENTER); setComponent(layout); centerOnScreen(); sinkEvents(Event.ONCLICK); }