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:fr.fg.client.core.login.LoginDialog.java

License:Open Source License

@Override
public void setVisible(boolean visible) {
    super.setVisible(visible);

    if (visible) {
        if (Cookies.getCookie("login") != null)
            passwordField.setFocus(true);
        else//  w ww .  j  a v a  2  s .c  o m
            loginField.setFocus(true);
    } else {
        passwordField.setText("");
        loginField.setFocus(false);
        passwordField.setFocus(false);
    }
}

From source file:fr.insalyon.creatis.vip.application.client.view.monitor.job.DebugLayout.java

License:Open Source License

private void configureBottomLayout() {

    bottomLayout = new HLayout(10);
    bottomLayout.setWidth100();/*  ww w  .  ja v  a  2  s . c  o m*/
    bottomLayout.setHeight(25);

    LabelButton closeLabel = new LabelButton("Close", CoreConstants.ICON_CLOSE);
    closeLabel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            refresher.cancel();
            destroy();
        }
    });
    bottomLayout.addMember(closeLabel);

    downloadLabel = new LabelButton("Download File", ApplicationConstants.ICON_MONITOR_DOWNLOAD);
    downloadLabel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            com.google.gwt.user.client.Window.open(GWT.getModuleBaseURL() + "/getfileservice?filepath="
                    + loadedFile + "&" + CoreConstants.COOKIES_SESSION + "="
                    + Cookies.getCookie(CoreConstants.COOKIES_SESSION), "", "");
        }
    });
    downloadLabel.setDisabled(true);
    bottomLayout.addMember(downloadLabel);

    this.addMember(bottomLayout);
}

From source file:fr.insalyon.creatis.vip.application.client.view.monitor.menu.LogsContextMenu.java

License:Open Source License

public LogsContextMenu(LogsTab section, final String simulationID, final String dataName, final String folder,
        boolean isFile) {

    this.section = section;
    this.baseDir = "/" + simulationID + "/" + folder;
    this.setShowShadow(true);
    this.setShadowDepth(10);
    this.setWidth(90);

    MenuItem viewItem = new MenuItem("View File");
    viewItem.setIcon(ApplicationConstants.ICON_PREVIEW);
    viewItem.addClickHandler(new ClickHandler() {
        @Override/*  ww  w.j av  a2 s.co m*/
        public void onClick(MenuItemClickEvent event) {
            new ViewerWindow("Viewing File: " + dataName, simulationID, folder, dataName, "").show();
        }
    });

    MenuItem downloadItem = new MenuItem("Download");
    downloadItem.setIcon(DataManagerConstants.ICON_DOWNLOAD);
    downloadItem.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(MenuItemClickEvent event) {
            Window.open(GWT.getModuleBaseURL() + "/getfileservice?filepath=" + baseDir + "/" + dataName + "&"
                    + CoreConstants.COOKIES_SESSION + "=" + Cookies.getCookie(CoreConstants.COOKIES_SESSION),
                    "", "");
        }
    });

    MenuItem deleteItem = new MenuItem("Delete");
    deleteItem.setIcon(CoreConstants.ICON_DELETE);
    deleteItem.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(MenuItemClickEvent event) {
            SC.confirm("Do you really want to delete '" + baseDir + "/" + dataName + "'?",
                    new BooleanCallback() {
                        @Override
                        public void execute(Boolean value) {
                            if (value != null && value) {
                                delete(baseDir + "/" + dataName);
                            }
                        }
                    });
        }
    });

    if (isFile) {
        this.setItems(viewItem, downloadItem, deleteItem);

    } else {
        this.setItems(downloadItem, deleteItem);
    }
}

From source file:fr.insalyon.creatis.vip.application.client.view.monitor.ViewerWindow.java

License:Open Source License

private void configureToolStrip() {

    toolStrip = new ToolStrip();
    toolStrip.setWidth100();//from  w ww .  jav  a 2 s.  c  om

    ToolStripButton refreshButton = new ToolStripButton();
    refreshButton.setIcon(CoreConstants.ICON_REFRESH);
    refreshButton.setTitle("Refresh");
    refreshButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            load();
        }
    });
    toolStrip.addButton(refreshButton);

    ToolStripButton downloadButton = new ToolStripButton();
    downloadButton.setIcon(DataManagerConstants.ICON_DOWNLOAD);
    downloadButton.setTitle("Download");
    downloadButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            com.google.gwt.user.client.Window.open(GWT.getModuleBaseURL() + "/getfileservice?filepath=" + "/"
                    + simulationID + "/" + folder + "/" + fileName + extension + "&"
                    + CoreConstants.COOKIES_SESSION + "=" + Cookies.getCookie(CoreConstants.COOKIES_SESSION),
                    "", "");
        }
    });
    toolStrip.addButton(downloadButton);
}

From source file:fr.insalyon.creatis.vip.datamanager.client.view.common.AppletHTMLPane.java

License:Open Source License

public AppletHTMLPane(String title, String code, String archive, int width, int height, String path,
        boolean unzip, boolean usePool) {

    this.setWidth100();
    this.setHeight100();
    this.setShowEdges(true);

    this.setContents("<html>" + "<head>" + "<meta http-equiv=\"Content-Type\" content=\"text/html; "
            + "charset=UTF-8\">" + "<title>" + title + "</title>" + "</head>" + "<body>" + "<applet width=\""
            + width + "\" height=\"" + height + "\" " + "code=\"" + code + "\" " + "archive=\"applets/"
            + archive + "\" MAYSCRIPT>" + "<param name=\"sessionId\" value=\""
            + Cookies.getCookie(CoreConstants.COOKIES_SESSION) + "\"/>" + "<param name=\"path\" value=\"" + path
            + "\"/>" + "<param name=\"unzip\" value=\"" + unzip + "\"/>" + "<param name=\"pool\" value=\""
            + usePool + "\"/>" + "<param name=\"permissions\" value=\"all-permissions\" />" + "</applet>"
            + "</body>" + "</html>");
}

From source file:fr.insalyon.creatis.vip.portal.client.Main.java

License:Open Source License

private void configureVIP() {

    // Cookies//  ww w  .  j a  va 2s .  c o m
    String email = null;
    String session = null;

    if (Cookies.getCookieNames().contains(CoreConstants.COOKIES_USER)) {
        email = Cookies.getCookie(CoreConstants.COOKIES_USER);
        session = Cookies.getCookie(CoreConstants.COOKIES_SESSION);
    }
    // End-Cookies

    final ConfigurationServiceAsync service = ConfigurationService.Util.getInstance();
    final AsyncCallback<User> callback = new AsyncCallback<User>() {
        @Override
        public void onFailure(Throwable caught) {
            Layout.getInstance().getModal().hide();
            SC.warn("Error while configuring VIP:<br />" + caught.getMessage());
        }

        @Override
        public void onSuccess(User user) {
            Layout.getInstance().getModal().hide();
            Layout.getInstance().authenticate(user);

            //Dropbox account confirmation
            String oauth_token = Window.Location.getParameter("oauth_token");
            if (oauth_token != null && !oauth_token.equals("")) {
                service.activateDropboxAccount(oauth_token, new AsyncCallback<Void>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        Layout.getInstance().setWarningMessage("Cannot activate Dropbox account");
                    }

                    @Override
                    public void onSuccess(Void result) {
                        Layout.getInstance().setNoticeMessage("Successfully activated Dropbox account");

                    }
                });
            }
        }
    };
    service.configure(email, session, callback);
}

From source file:fr.mncc.gwttoolbox.authenticate.client.SecurityController.java

License:Open Source License

private int getCurrentUserRole() {
    int userRole;
    final String role = Cookies.getCookie(Tokens.ROLE);
    if (role == null) {
        userRole = UserRoles.PUBLIC;//from ww  w.j  a v  a  2  s .c  o  m
    } else {
        try {
            userRole = Integer.parseInt(role, 10);
        } catch (NumberFormatException e) {
            userRole = UserRoles.PUBLIC;
        }
    }
    return userRole;
}

From source file:fr.putnami.pwt.doc.client.DocumentationApp.java

License:Open Source License

@Override
public void onModuleLoad() {
    Theme theme = new Theme();
    theme.addLink(new CssLink("theme/doc/style/pwt-doc.css", 0));
    ThemeController.get().installTheme(theme);

    if (Cookies.isCookieEnabled()) {
        int cnt = 0;
        try {/*  w ww  .j  ava 2 s.  co m*/
            String cntString = Cookies.getCookie(COOKIE_COUNT_VISIT);
            if (!Strings.isNullOrEmpty(cntString)) {
                cnt = Integer.parseInt(cntString);
            }
        } catch (NumberFormatException e) {
            cnt = 0;
        }
        cnt++;
        Cookies.setCookie(COOKIE_COUNT_VISIT, "" + cnt);
    }

    GoogleAnalytics analytics = GoogleAnalytics.init(ANALYTICS_TRACKER_ID, DOMAIN);
    analytics.forceSSL(true);
    analytics.displayfeatures();
    analytics.handleUncaughtException(true);

    DocumentationDisplay display = new DocumentationDisplay();
    RootPanel.get().add(display);

    SimpleErrorDisplayer errorDisplayer = new SimpleErrorDisplayer();
    errorDisplayer.setConstants((ConstantsWithLookup) GWT.create(ErrorConstants.class));
    ErrorManager.get().setErrorDisplayer(errorDisplayer);
    ErrorManager.get().registerErrorHandler(new UmbrellaExceptionHandler());

    MvpController controller = MvpController.get();
    controller.setDisplay(display);

    controller.setDefaultPlace(WelcomePlace.INSTANCE);

    controller.registerActivity(WelcomePlace.INSTANCE);
    controller.registerActivity(GettingStartedPlace.INSTANCE);
    controller.registerActivity(BootstrapPlace.INSTANCE);
    controller.registerActivity(LayoutsPlace.INSTANCE);
    controller.registerActivity(ComponentsPlace.INSTANCE);
    controller.registerActivity(DataBindingPlace.INSTANCE);
    controller.registerActivity(InternationalizationPlace.INSTANCE);
    controller.registerActivity(NavigationPlace.INSTANCE);
    controller.registerActivity(ServerCallsPlace.INSTANCE);
    controller.registerActivity(ErrorsPlace.INSTANCE);
    controller.registerActivity(CodeEditorPlace.INSTANCE);
    controller.registerActivity(AjaxBotIndexingPlace.INSTANCE);
    controller.registerActivity(GoogleAnalyticsPlace.INSTANCE);
    controller.registerActivity(SamplesPlace.INSTANCE);
    controller.registerActivity(ContactsTablePlace.INSTANCE);
    controller.registerActivity(AddressBookPlace.INSTANCE);
    controller.registerActivity(ComingSoonPlace.INSTANCE);
    controller.registerActivity(DownloadPlace.INSTANCE);

    controller.registerAlias("Tables", ComponentsPlace.INSTANCE);
    controller.registerAlias("Forms", ComponentsPlace.INSTANCE);
    controller.registerAlias("More", LayoutsPlace.INSTANCE);

    controller.handleCurrentHistory();
}

From source file:fr.putnami.pwt.doc.client.rss.PwtDoucmentRssReader.java

License:Open Source License

public void load(final AsyncCallback<List<RssItem>> callback) {
    RequestCallback requestCallback = new RequestCallback() {

        @Override//from   w  w  w. j av a  2s  . c  om
        public void onResponseReceived(Request request, Response response) {
            List<RssItem> items = Lists.newArrayList();
            try {
                Document messageDom = XMLParser.parse(response.getText());

                NodeList nodes = messageDom.getElementsByTagName("item");
                for (int i = 0; i < nodes.getLength() && items.size() < 10; i++) {
                    Element item = (Element) nodes.item(i);
                    RssItem rssItem = new RssItem();
                    rssItem.setTitle(getStringValue(item, "title"));
                    rssItem.setDescription(getStringValue(item, "description"));
                    rssItem.setLink(getStringValue(item, "link"));
                    rssItem.setGuid(getStringValue(item, "guid"));
                    rssItem.setAuthor(getStringValue(item, "author"));
                    rssItem.setPubDate(getDateValue(item, "pubDate"));

                    boolean toAdd = true;

                    if (Cookies.isCookieEnabled()) {
                        String cookie = Cookies.getCookie(getCookieName(rssItem.getGuid()));
                        if (cookie != null && cookie.length() > 0) {
                            toAdd = false;
                        }
                    }
                    if (toAdd) {
                        items.add(rssItem);
                    }
                }

                callback.onSuccess(items);
            } catch (DOMException e) {
                callback.onFailure(e);
            }
        }

        @Override
        public void onError(Request request, Throwable exception) {
            callback.onFailure(exception);
        }
    };
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, this.rssUrl);
    builder.setCallback(requestCallback);
    try {
        builder.send();
    } catch (RequestException e) {
        callback.onFailure(e);
    }

}

From source file:gov.nist.spectrumbrowser.admin.Admin.java

License:Open Source License

@Override
public void onModuleLoad() {
    String sessionToken = Cookies.getCookie(COOKIE);
    if (sessionToken != null) {
        Admin.setSessionToken(sessionToken);
        Admin.getAdminService().verifySessionToken(new SpectrumBrowserCallback<String>() {

            @Override/*from ww w  .jav a2  s.com*/
            public void onSuccess(String result) {
                JSONObject jsonObject = JSONParser.parseLenient(result).isObject();
                if (jsonObject.get("status").isString().stringValue().equals("OK")) {
                    RootPanel.get().clear();

                    Window.setTitle("MSOD:Admin");
                    verticalPanel = new VerticalPanel();
                    verticalPanel.setStyleName("loginPanel");
                    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
                    verticalPanel.setSpacing(20);
                    RootPanel.get().add(verticalPanel);
                    isUserLoggedIn = true;
                    adminScreen = new AdminScreen(verticalPanel, Admin.this);
                    adminScreen.draw();
                } else {
                    Cookies.removeCookie("gov.nist.spectrumbrowser.admin.token");
                    draw();
                }

            }

            @Override
            public void onFailure(Throwable throwable) {
                Window.alert("Error contacting server");
                draw();
            }
        });
    } else {
        draw();
    }
}