List of usage examples for com.google.gwt.user.client Cookies getCookie
public static String getCookie(String name)
From source file:cc.kune.core.client.cookies.CookiesManagerImpl.java
License:GNU Affero Public License
@Override public String getAuthCookie() { return Cookies.getCookie(SessionConstants.USERHASH); }
From source file:cc.kune.core.client.cookies.MotdManager.java
License:GNU Affero Public License
public MotdManager() { SessionInstance.get().onAppStart(true, new AppStartHandler() { @Override/*ww w . ja v a 2 s . co m*/ public void onAppStart(final AppStartEvent event) { final Timer timer = new Timer() { @Override public void run() { final MotdDTO motd = event.getInitData().getMotd(); if (motd == null) { return; } final String cookieName = motd.getCookieName(); final String motdCookie = Cookies.getCookie(cookieName); if (motdCookie == null) { final Builder builder = new BasicTopDialog.Builder("k-motd", true, false, I18n.getDirection()); // motdDialog.addStyleName("k-motd-dialog"); if (motd.getTitle() != null) { builder.title(motd.getTitle()); } final BasicTopDialog dialog = builder.build(); dialog.setFirstBtnText(motd.getOkBtnText()); dialog.setCloseBtnVisible(true); Log.info("Motd message: " + motd.getMessage()); final HTML message = new HTML(motd.getMessage() + motd.getMessageBottom()); dialog.getInnerPanel().add(message); dialog.setSecondBtnText(motd.getCloseBtnText()); dialog.getSecondBtn().addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { setCookie(cookieName, CookieUtils.inDays(90)); dialog.hide(); } }); if (motd.getShouldRemember() > 0) { final CustomButton laterBtn = new CustomButton((I18n.t("Maybe later"))); laterBtn.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { setCookie(cookieName, CookieUtils.inDays(motd.getShouldRemember())); dialog.hide(); } }); dialog.getBtnPanel().add(laterBtn); } dialog.getFirstBtn().addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { setCookie(cookieName, CookieUtils.inDays(7)); KuneWindowUtils.open(motd.getOkBtnUrl()); dialog.hide(); } }); dialog.show(); } } }; timer.schedule(10000); } }); }
From source file:cc.kune.gadget.client.statecookie.CookieStateStore.java
License:GNU Affero Public License
/** * Restore state from cookie (only for test purposes). *//*from w w w. j a v a 2 s. c o m*/ public void restoreStateFromCookie() { AutoBean<StateLocal> stateLocal; Map<String, String> map; final String stateCookie = Cookies.getCookie(cookieName); if (stateCookie != null) { // Restoring state from cookie (deserialization) stateLocal = AutoBeanCodex.decode(factory, StateLocal.class, stateCookie); map = stateLocal.as().getMap(); } else { // Create a new state object (first run) stateLocal = factory.getStateLocal(); map = new HashMap<String, String>(); } for (final String key : map.keySet()) { final String value = map.get(key); // Setting the real state with cookie values wave.getState().submitValue(key, value); } }
From source file:cc.kune.wave.client.kspecific.tutorial.InboxTutorial.java
License:GNU Affero Public License
@Inject public InboxTutorial(GSpaceArmor armor, EventBus eventBus, final WaveClientProvider waveClient) { final String cookie = Cookies.getCookie(COOKIE_NAME); if (cookie == null) { initWidget(uiBinder.createAndBindUi(this)); armor.wrapDiv(PolymerId.INBOX_TUTORIAL).add(this); selectHandler = eventBus.addHandler(SpaceSelectEvent.getType(), new SpaceSelectHandler() { @Override/*ww w . j a va 2s. c om*/ public void onSpaceSelect(SpaceSelectEvent event) { if (event.getSpace().equals(Space.userSpace)) { final String encodedToken = HistoryUtils.undoHashbang(History.getToken()); if (encodedToken != null && !encodedToken.isEmpty() && TokenMatcher.isInboxToken(encodedToken)) { // Inbox without wave opened setVisible(true); waveClient.get().clear(); } } } }); openHandler = eventBus.addHandler(AfterOpenWaveEvent.getType(), new AfterOpenWaveHandler() { @Override public void onAfterOpenWave(AfterOpenWaveEvent event) { setVisible(false); } }); subtitleLabel.setText(I18n.tWithNT("This is your", "Followed by 'inbox', so 'This is your inbox'")); titleLabel.setText(I18n.t("Inbox")); createLabel.setText(I18n.t("Here you can create, edit and comment documents")); addContactLabel.setText(I18n.t("Share them with your contacts")); publishLabel.setText(I18n.t("Publish them in your groups")); notificationsLabel .setText(I18n.t("Get notifications of changes, coments or new documents shared with you")); orderedLabel.setText( I18n.t("And to have a cronological ordered list of all the contents you are participating in")); btn.setText(I18n.t("I got it!")); btn.setType(ButtonType.PRIMARY); btn.setSize(ButtonSize.LARGE); btn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { $(InboxTutorial.this).as(Effects).fadeTo(400, 0); Cookies.setCookie(COOKIE_NAME, null, CookieUtils.expireInYears(), CookieUtils.getDomain(), "/", false); selectHandler.removeHandler(); openHandler.removeHandler(); } }); } }
From source file:cimav.visorglass.client.widgets.PanelesLayout.java
License:Apache License
@Override protected void onLoad() { super.onLoad(); // widgetPanelDocumentos = splitLayoutPanel.getWidget(IDX_DOCUMENTOS_PANEL); // widgetPanelVisor = splitLayoutPanel.getWidget(IDX_VISOR_PANEL); // Carga cookies String cookieActiveArbolPanel = Cookies.getCookie(SGC_COOKIE_ACTIVE_ARBOL_PANEL); cookieActiveArbolPanel = cookieActiveArbolPanel == null ? "true" : cookieActiveArbolPanel; // nulos son true boolean valor = cookieActiveArbolPanel.toLowerCase().equals("true") ? true : false; btnArbol.setActive(valor);//from w w w .jav a2 s .co m // ojo: Active y Hidden tienen efectos contrarios splitLayoutPanel.setWidgetHidden(splitLayoutPanel.getWidget(IDX_ARBOL_PANEL), !valor); String cookieActiveDocumentos = Cookies.getCookie(SGC_COOKIE_ACTIVE_DOCUMENTOS_PANEL); cookieActiveDocumentos = cookieActiveDocumentos == null ? "true" : cookieActiveDocumentos; // nulos son true valor = cookieActiveDocumentos.toLowerCase().equals("true") ? true : false; btnDocumentos.setActive(valor); splitLayoutPanel.setWidgetHidden(splitLayoutPanel.getWidget(IDX_DOCUMENTOS_PANEL), !valor); String cookieActiveVisor = Cookies.getCookie(SGC_COOKIE_ACTIVE_VISOR_PANEL); cookieActiveVisor = cookieActiveVisor == null ? "true" : cookieActiveVisor; // nulos son true valor = cookieActiveVisor.toLowerCase().equals("true") ? true : false; btnVisor.setActive(valor); splitLayoutPanel.setWidgetHidden(splitLayoutPanel.getWidget(IDX_VISOR_PANEL), !valor); String cookieWidthArbolPanel = Cookies.getCookie(SGC_COOKIE_WIDTH_ARBOL_PANEL); String cookieWidthVisorPanel = Cookies.getCookie(SGC_COOKIE_WIDTH_VISOR_PANEL); int widthArbolPanel; int widthVisorPanel; try { widthArbolPanel = Integer.valueOf(cookieWidthArbolPanel); widthVisorPanel = Integer.valueOf(cookieWidthVisorPanel); } catch (Exception e) { widthArbolPanel = 360; // Default widthVisorPanel = 360; // Default } splitLayoutPanel.setWidgetSize(flowPanelDecoratorArbol, Integer.valueOf(widthArbolPanel)); splitLayoutPanel.setWidgetSize(flowPanelDecoratorVisor, Integer.valueOf(widthVisorPanel)); }
From source file:cl.uai.client.EMarkingWeb.java
License:Open Source License
/** * This is the entry point method./* w ww .j a v a 2s .c o m*/ */ public void onModuleLoad() { // Pointer to CSS manager. It has to go first! GWT.<Resources>create(Resources.class).css().ensureInjected(); // Log messages String msg = "\nInitializing EMarking 3.0\n" + "Platform: " + Navigator.getPlatform() + "\n" + "User agent: " + Navigator.getUserAgent() + "\n" + "App name: " + Navigator.getAppName() + "\n" + "App code name: " + Navigator.getAppCodeName() + "\n" + "App version: " + Navigator.getAppVersion(); logger.fine(msg); // List of errors after trying to initialize ArrayList<String> errors = new ArrayList<String>(); // Get id for eMarkingWeb's DIV tag final String eMarkingDivId = "emarking"; if (RootPanel.get(eMarkingDivId) == null) { errors.add("Can not initalize. EMarking requires an existing DIV tag with id: emarking."); return; } RootPanel.get(eMarkingDivId).add(new Label("Loading")); int draftId = 0; int preferredWidth = 860; boolean showRubric = true; boolean showColors = false; try { // First, if there's a URL parameter, replace the value if (Window.Location.getParameter("id") != null) { draftId = Integer.parseInt(Window.Location.getParameter("id")); } // Validate that the submission id is a positive integer if (draftId <= 0) { errors.add("Submission id must be a non negative integer."); } // Reading the image width float imagewidth = 0; if (RootPanel.get(eMarkingDivId).getElement().getAttribute("imagewidth") != null) imagewidth = Float.parseFloat(RootPanel.get(eMarkingDivId).getElement().getAttribute("imagewidth")); String cookie_width = Cookies.getCookie("emarking_width"); if (cookie_width != null) { preferredWidth = Integer.parseInt(cookie_width); } else if (imagewidth > 0) { preferredWidth = (int) (imagewidth / 0.6f); } // Validate that the preferredWidth is a positive integer greater than 10 if (preferredWidth <= 10) { errors.add("Preferred width should be a positive integer greater than 10."); } // Validate that the preferredWidth is a positive integer greater than 10 if (preferredWidth <= 10) { errors.add("Preferred width should be a positive integer greater than 10."); } String cookie_showrubric = Cookies.getCookie("emarking_showrubric"); if (cookie_showrubric != null) { showRubric = Integer.parseInt(cookie_showrubric) == 1; } String cookie_showcolors = Cookies.getCookie("emarking_showcolors"); if (cookie_showcolors != null) { showColors = Integer.parseInt(cookie_showcolors) == 1; } } catch (Exception e) { logger.severe(e.getMessage()); errors.add( "Error in HTML for eMarkingWeb can not initalize. Invalid submissionId value (must be integer)."); } // Read div attribute for readonly String moodleurl = null; if (RootPanel.get(eMarkingDivId).getElement().getAttribute("moodleurl") != null) moodleurl = RootPanel.get(eMarkingDivId).getElement().getAttribute("moodleurl"); logger.fine("\nShowRubric: " + showRubric + "\nShow colors:" + showColors + "\nPreferred width:" + preferredWidth + "\nMoodle ajax url: " + moodleurl); if (moodleurl == null) errors.add("Invalid Moodle ajax url"); // If there are errors die with a configuration message if (errors.size() > 0) { Label errorsLabel = new Label(); String text = ""; for (int i = 0; i < errors.size(); i++) { text += "\n" + errors.get(i); } errorsLabel.setText(text); errorsLabel.setTitle("Fatal error while initializing eMarking-Web"); RootPanel.get(eMarkingDivId).clear(); RootPanel.get(eMarkingDivId).add(errorsLabel); } else { // Set eMarking's main interface submission id according to HTML MarkingInterface.setDraftId(draftId); EMarkingConfiguration.setShowRubricOnLoad(showRubric); EMarkingConfiguration.setColoredRubric(showColors); // Ajax URL in moodle EMarkingConfiguration.setMoodleUrl(moodleurl); // Automagically resize popup to use most of the window int width = screenWidth(); int height = screenHeight(); // Preferred width can not be bigger than the screen if (width < preferredWidth) { preferredWidth = width; } // Resize the popup window and move it to the top left corner Window.resizeTo(preferredWidth, height); Window.moveTo(0, 0); // Initialize eMarking's interface markingInterface = new MarkingInterface(); // Add eMarking to the browser RootPanel.get(eMarkingDivId).clear(); RootPanel.get(eMarkingDivId).add(markingInterface); RootPanel.getBodyElement().focus(); } }
From source file:cl.uai.client.rubric.RubricPanel.java
License:Open Source License
/** * Creates the rubric panel//www.j a v a2s . c o m */ public RubricPanel(boolean isPopup) { this.popupInterface = isPopup; mainPanel = new VerticalPanel(); mainPanel.addStyleName(Resources.INSTANCE.css().rubricpanel()); // Adds the title rubricTitle = new Label(); rubricTitle.addStyleName(Resources.INSTANCE.css().rubrictitle()); // Adds the checkbox rubricFilter = new ListBox(); rubricFilter.addItem(MarkingInterface.messages.ShowAll(), "all"); rubricFilter.addItem(MarkingInterface.messages.ShowMarkingPending(), "unmarked"); rubricFilter.addItem(MarkingInterface.messages.ShowRegradePending(), "regrade"); // rubricFilter.addItem(MarkingInterface.messages.HideRubric(), "hide"); rubricFilter.addStyleName(Resources.INSTANCE.css().rubricfilterselect()); rubricFilter.setSelectedIndex(0); String cookieFilter = Cookies.getCookie("emarking_rubricfilter"); if (cookieFilter != null) { if (cookieFilter.equals("unmarked")) { rubricFilter.setSelectedIndex(1); } else if (cookieFilter.equals("regrade")) { rubricFilter.setSelectedIndex(2); } } rubricFilter.addChangeHandler(new RubricFilterListBoxValueChangeHandler()); // An horizontal panel holds title and checkbox hpanelTitle = new HorizontalPanel(); hpanelTitle.addStyleName(Resources.INSTANCE.css().rubrictitlepanel()); hpanelTitle.add(rubricTitle); hpanelTitle.setCellHorizontalAlignment(rubricTitle, HasHorizontalAlignment.ALIGN_LEFT); hpanelTitle.add(rubricFilter); hpanelTitle.setCellHorizontalAlignment(rubricFilter, HasHorizontalAlignment.ALIGN_RIGHT); hpanelTitle.setCellVerticalAlignment(rubricFilter, HasVerticalAlignment.ALIGN_MIDDLE); mainPanel.add(hpanelTitle); generalFeedbackInterface = new GeneralFeedbackInterface(); // Adds the scroll panel containing the rubric table rubricTable = new VerticalPanel(); rubricTable.addStyleName(Resources.INSTANCE.css().rubrictable()); scrollRubric = new ScrollPanel(); if (isPopupInterface()) { scrollRubric.add(rubricTable); mainPanel.add(scrollRubric); } else { mainPanel.add(rubricTable); } initWidget(mainPanel); }
From source file:client.helper.GuiLogger.java
License:Open Source License
/** * @return//from ww w. j a v a 2 s.c om */ private static final int getLogLevel() { final String value = Cookies.getCookie("LogLevel"); if (null != value) { return Integer.valueOf(value).intValue(); } else { return GuiLogger.TRACE; } }
From source file:client.tools.page.ConsoleSettingsPage.java
License:Open Source License
/** * @return//from w w w . ja v a 2s. co m */ private final int getValue() { final String value = Cookies.getCookie("LogLevel"); if (null != value) { return Integer.valueOf(value).intValue(); } else { return GuiLogger.TRACE; } }
From source file:com.adamantium.company.gwtp.client.application.details.address.AddressPresenter.java
License:Apache License
@Override protected void onReset() { super.onReset(); dispatcher.execute(new GetAddressAction(companyId), new AsyncCallback<GetAddressResult>() { @Override//ww w.j a v a 2s .c om public void onFailure(Throwable caught) { getView().setAddress(""); Window.alert("Error: unable to get company address from server"); } @Override public void onSuccess(GetAddressResult result) { if (Cookies.getCookie("JSESSIONID") == null) { System.out.println("Set security cookie."); Cookies.setCookie("JSESSIONID", "JSESSIONID"); } getView().setAddress(result.getAddress()); } }); }