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:olanto.myTerm.client.Lists.DomainList.java

License:Open Source License

public DomainList() {
    super();//from   w  w w . j  a  v  a 2 s . com
    domCallback = new AsyncCallback<Collection<DomainDTO>>() {
        @Override
        public void onFailure(Throwable caught) {
            Window.alert("Failed to get list of domains");
        }

        @Override
        public void onSuccess(Collection<DomainDTO> result) {
            ArrayList<DomainDTO> res = new ArrayList<>();
            if (res.addAll(result)) {
                int i = 0;
                for (DomainDTO s : res) {
                    addItem(s.getDomainDefaultName(), s.getIdDomain().toString());
                    if (s.getDomainDefaultName()
                            .equalsIgnoreCase(Cookies.getCookie(MyTermCookiesNamespace.Domain))) {
                        i = res.indexOf(s);
                    }
                }
                setSelectedIndex(i);
            }
        }
    };
    this.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            MyTermCookies.updateCookie(MyTermCookiesNamespace.Domain, getItemText(getSelectedIndex()));
        }
    });
    addItem(" ", " ");
    domService.getDomains(domCallback);
}

From source file:olanto.myTerm.client.Lists.DomainList.java

License:Open Source License

public DomainList(final BooleanWrap isEdited) {
    super();/*from w ww  . ja  v  a2 s  .c o  m*/
    domCallback = new AsyncCallback<Collection<DomainDTO>>() {
        @Override
        public void onFailure(Throwable caught) {
            Window.alert("Failed to get list of domains");
        }

        @Override
        public void onSuccess(Collection<DomainDTO> result) {
            ArrayList<DomainDTO> res = new ArrayList<>();
            if (res.addAll(result)) {
                int i = 0;
                for (DomainDTO s : res) {
                    addItem(s.getDomainDefaultName(), s.getIdDomain().toString());
                    if (s.getDomainDefaultName()
                            .equalsIgnoreCase(Cookies.getCookie(MyTermCookiesNamespace.Domain))) {
                        i = res.indexOf(s);
                    }
                }
                setSelectedIndex(i);
            }
        }
    };
    this.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            isEdited.setVal(true);
        }
    });
    addItem(" ", " ");
    domService.getDomains(domCallback);
}

From source file:olanto.myTerm.client.Lists.LangList.java

License:Open Source License

public LangList(final String type) {
    super();/*from  w  w w .j  av  a  2 s .  c o  m*/
    langCallback = new AsyncCallback<Collection<LanguageDTO>>() {
        @Override
        public void onFailure(Throwable caught) {
            MainEntryPoint.statusPanel.setMessage("warning",
                    "Failed to get list of languages, please RELOAD THE PAGE");
        }

        @Override
        public void onSuccess(Collection<LanguageDTO> result) {
            ArrayList<LanguageDTO> res = new ArrayList<>();
            if (res.addAll(result)) {
                int i = 0, j = 0;
                for (LanguageDTO s : res) {
                    langlist.add(s.getLanguageDefaultName());
                    langIDlist.add(s.getIdLanguage());
                    addItem(s.getLanguageDefaultName(), s.getIdLanguage());
                    if (s.getLanguageDefaultName()
                            .equalsIgnoreCase(Cookies.getCookie(MyTermCookiesNamespace.MyTermlangS))) {
                        i = res.indexOf(s);
                    }
                    if (s.getLanguageDefaultName()
                            .equalsIgnoreCase(Cookies.getCookie(MyTermCookiesNamespace.MyTermlangT))) {
                        j = res.indexOf(s);
                    }
                }
                if (type.equals("source")) {
                    setSelectedIndex(i);
                } else {
                    setSelectedIndex(j);
                }
            }
        }
    };
    this.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            if (type.equals("source")) {
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermlangS, getItemText(getSelectedIndex()));
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermIDlangS,
                        getItemText(getSelectedIndex()));
            } else {
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermlangT, getItemText(getSelectedIndex()));
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermIDlangT,
                        getItemText(getSelectedIndex()));
            }
        }
    });
    langService.getLanguages(langCallback);
}

From source file:olanto.myTerm.client.Lists.LangList.java

License:Open Source License

public LangList(long ownerID, final String type) {
    super();// w  ww  . ja  v a2  s. c  om
    langCallback = new AsyncCallback<Collection<LanguageDTO>>() {
        @Override
        public void onFailure(Throwable caught) {
            MainEntryPoint.statusPanel.setMessage("warning", "Failed to get list of languages");
        }

        @Override
        public void onSuccess(Collection<LanguageDTO> result) {
            ArrayList<LanguageDTO> res = new ArrayList<>();
            if (res.addAll(result)) {
                int i = 0, j = 0;
                for (LanguageDTO s : res) {
                    langlist.add(s.getLanguageDefaultName());
                    langIDlist.add(s.getIdLanguage());
                    addItem(s.getLanguageDefaultName(), s.getIdLanguage());
                    if (s.getLanguageDefaultName()
                            .equalsIgnoreCase(Cookies.getCookie(MyTermCookiesNamespace.MyTermlangSrc))) {
                        i = res.indexOf(s);
                    }
                    if (s.getLanguageDefaultName()
                            .equalsIgnoreCase(Cookies.getCookie(MyTermCookiesNamespace.MyTermlangTgt))) {
                        j = res.indexOf(s);
                    }
                }
                if (type.equals("source")) {
                    setSelectedIndex(i);
                } else {
                    setSelectedIndex(j);
                }
            }
        }
    };
    this.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            if (type.equals("source")) {
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermlangSrc,
                        getItemText(getSelectedIndex()));
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermIDlangSrc,
                        getValue(getSelectedIndex()));
            } else {
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermlangTgt,
                        getItemText(getSelectedIndex()));
                MyTermCookies.updateCookie(MyTermCookiesNamespace.MyTermIDlangTgt,
                        getValue(getSelectedIndex()));
            }
        }
    });
    langService.getLanguagesByOwner(ownerID, langCallback);
}

From source file:olanto.myTerm.client.Lists.ResourcesList.java

License:Open Source License

public ResourcesList(String ownerMailing, final String role) {
    super();//from   w ww  .  j a v a2 s.c  o  m
    RsrcCallback = new AsyncCallback<Collection<ResourceDTO>>() {
        @Override
        public void onFailure(Throwable caught) {
            MainEntryPoint.statusPanel.setMessage("warning",
                    "Failed to get list of resources, please RELOAD THE PAGE");
        }

        @Override
        public void onSuccess(Collection<ResourceDTO> result) {
            if (result != null) {
                if (role.equals("READER")) {
                    addItem("ALL", "-1");
                    rsrclist.add("ALL");
                    rsrcIDlist.add(0L);
                }
                ArrayList<ResourceDTO> res = new ArrayList<>();
                if (res.addAll(result)) {
                    int i = 0;
                    for (ResourceDTO s : res) {
                        rsrclist.add(s.getResourceName());
                        rsrcIDlist.add(s.getIdResource());
                        addItem(s.getResourceName(), s.getIdResource().toString());
                        if (s.getResourceName()
                                .equalsIgnoreCase(Cookies.getCookie(MyTermCookiesNamespace.Resource))) {
                            i = res.indexOf(s);
                        }
                    }

                    setSelectedIndex(i);
                }
            }
        }
    };
    this.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            MyTermCookies.updateCookie(MyTermCookiesNamespace.Resource, getItemText(getSelectedIndex()));
        }
    });
    rsrcService.getResourcesByOwner(ownerMailing, role, RsrcCallback);
}

From source file:olanto.myTerm.client.Widgets.REDACTORWidget.java

License:Open Source License

public REDACTORWidget(long idOwner, HashMap<String, SysFieldDTO> sysFields, HashMap<String, String> sysMsg) {
    ownerID = idOwner;//w  w  w . j  ava 2 s  .c  o  m
    sFields = sysFields;
    sysMsgs = sysMsg;
    resultsPanel = new ResultsContainerREDACTOR(sysMsg);
    fixGwtNav();
    searchMenu = new SearchHeaderREDACTOR(ownerID, sysMsg);
    add(searchMenu);
    add(resultsPanel);
    // Create an asynchronous callback to handle the result.
    termAddCallback = new AsyncCallback<String>() {
        @Override
        public void onSuccess(String result) {
            searchMenu.btnAdd.setEnabled(true);
            if (result != null) {
                resultsPanel.addnewcpt.setVisible(true);
                MainEntryPoint.statusPanel.setMessage("message", "Found an existing entry of the same form");
                resultsPanel.sideRes.setWidget(new HTML(result));
                History.newItem("found");
            } else {
                new MyDialog("Term not found would you like to create a new Entry?", 0, "").show();
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            searchMenu.btnAdd.setEnabled(true);
            resultsPanel.sideRes.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }
    };
    termAddCallbackWS = new AsyncCallback<String>() {
        @Override
        public void onSuccess(String result) {
            searchMenu.btnAdd.setEnabled(true);
            if (result != null) {
                resultsPanel.addnewcpt.setVisible(true);
                resultsPanel.sideRes.setWidget(new HTML(result));
                History.newItem("found");
            } else {
                History.newItem("notfound");
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            searchMenu.btnAdd.setEnabled(true);
            resultsPanel.sideRes.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }
    };
    termAddedCallback = new AsyncCallback<String>() {
        @Override
        public void onSuccess(String result) {
            searchMenu.btnAdd.setEnabled(true);
            if (result != null) {
                History.newItem("added");
            } else {
                History.newItem("notadded");
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            resultsPanel.sideRes.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }
    };
    // Create an asynchronous callback to handle the result.
    entrySaveCallback = new AsyncCallback<ConceptEntryDTO>() {
        @Override
        public void onSuccess(ConceptEntryDTO result) {
            if (result != null) {
                conceptEntryDTO = result;
                //                Window.alert(conceptEntryDTO.toStringDTO());
                refreshContentFromConceptEntryDTO();
                History.newItem("saved");
            } else {
                History.newItem("notsaved");
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            addcpt.save.setEnabled(true);
            resultsPanel.conceptDetails.clear();
            resultsPanel.termsDetails.clear();
            resultsPanel.conceptDetails.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }
    };
    entrySubmitCallback = new AsyncCallback<String>() {
        @Override
        public void onSuccess(String result) {
            if (result != null) {
                History.newItem("submitted");
            } else {
                History.newItem("notsubmitted");
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            addcpt.submit.setEnabled(true);
            resultsPanel.sideCurrent.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }
    };
    entryDeleteCallback = new AsyncCallback<String>() {
        @Override
        public void onSuccess(String result) {
            if (result != null) {
                History.newItem("deleted");
            } else {
                History.newItem("notdeleted");
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            resultsPanel.sideCurrent.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }
    };
    workspaceCallback = new AsyncCallback<String>() {
        @Override
        public void onSuccess(String result) {
            if (result != null) {
                resultsPanel.sideCurrent.setWidget(new HTML(result));
            } else {
                resultsPanel.sideCurrent.setWidget(new HTML("No current entries"));
            }
            MainEntryPoint.statusPanel.clearMessages();
            String srch = searchMenu.searchField.getText();
            String lan = searchMenu.langSrc.getValue(searchMenu.langSrc.getSelectedIndex());
            if ((lan == null) || (lan.isEmpty())) {
                lan = Cookies.getCookie(MyTermCookiesNamespace.MyTermIDlangSrc);
            }
            if ((srch != null) && (!srch.isEmpty())) {
                getService().getAddResult(searchMenu.searchField.getText(), lan,
                        searchMenu.rsrc.getValue(searchMenu.rsrc.getSelectedIndex()),
                        searchMenu.dom.getItemText(searchMenu.dom.getSelectedIndex()), ownerID,
                        termAddCallbackWS);
            }
            History.newItem("loaded");
        }

        @Override
        public void onFailure(Throwable caught) {
            resultsPanel.sideCurrent.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }
    };
    getConceptDetailsCallback = new AsyncCallback<ConceptEntryDTO>() {
        @Override
        public void onFailure(Throwable caught) {
            resultsPanel.termsDetails.setWidget(new Label("Communication failed"));
            History.newItem("page1");
        }

        @Override
        public void onSuccess(ConceptEntryDTO result) {
            conceptEntryDTO = result;
            //                Window.alert(conceptEntryDTO.toStringDTO());
            refreshContentFromConceptEntryDTO();
            History.newItem("loaded");
        }
    };

    searchMenu.btnAdd.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (isEdited.getVal()) {
                new MyDialog(
                        "You have edited this entry. Are you sure that you want to abort all the modifications?",
                        2, "add").show();
            } else {
                History.newItem("add");
            }

        }
    });
    // Listen for the button clicks
    searchMenu.searchField.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (isEdited.getVal()) {
                    new MyDialog(
                            "You have edited this entry. Are you sure that you want to abort all the modifications?",
                            2, "add").show();
                } else {
                    History.newItem("add");
                }
            }
        }
    });
    searchMenu.langSrc.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            commandPage1();
        }
    });
    resultsPanel.addnewcpt.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            createNewConceptEntry();
        }
    });
    resultsPanel.adjustSize(0.25f, 0.25f);
    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            MainEntryPoint.statusPanel.clearMessages();
            String command = event.getValue();
            if (command.contains("WSnew")) {
                if (isEdited.getVal()) {
                    new MyDialog(
                            "You have edited this entry. Are you sure that you want to abort all the modifications?",
                            2, command).show();
                } else {
                    long conceptID = Long.parseLong(command.substring(5));
                    getService().getRedactorDetailsForConcept(conceptID, ownerID,
                            searchMenu.langSrc.getLangIDs(), getConceptDetailsCallback);
                }
            } else {
                switch (command) {
                case "page1":
                    commandPage1();
                    break;
                case "add":
                    commandAdd();
                    break;
                case "saved":
                    commandSaved();
                    break;
                case "notsaved":
                    commandNotSaved();
                    break;
                case "deleted":
                    commandDeleted();
                    break;
                case "notdeleted":
                    commandNotDeleted();
                    break;
                case "added":
                    commandAdded();
                    break;
                case "notadded":
                    commandNotAdded();
                    break;
                case "submitted":
                    commandSubmitted();
                    break;
                case "notsubmitted":
                    commandNotSubmitted();
                    break;
                case "loaded":
                    commandLoaded();
                    break;
                case "escape":
                    commandEscape();
                    break;
                }
            }
        }
    });
}

From source file:olanto.myTerm.client.Widgets.REDACTORWidget.java

License:Open Source License

private void commandPage1() {
    MainEntryPoint.statusPanel.setMessage("warning", "Retrieving entries, please wait...");
    resultsPanel.sideRes.clear();/*from  ww  w.ja v  a  2  s . co m*/
    searchMenu.btnAdd.setEnabled(true);
    String lan = searchMenu.langSrc.getValue(searchMenu.langSrc.getSelectedIndex());
    if ((lan == null) || (lan.isEmpty())) {
        lan = Cookies.getCookie(MyTermCookiesNamespace.MyTermIDlangSrc);
    }
    getService().getWorkspaceElements(lan, ownerID, workspaceCallback);
}

From source file:olanto.myTerm.client.Widgets.REDACTORWidget.java

License:Open Source License

private void commandAdd() {
    resultsPanel.termsDetails.clear();/*w  w  w.j  ava 2  s  .c om*/
    resultsPanel.conceptDetails.clear();
    searchMenu.btnAdd.setEnabled(false);
    resultsPanel.sideRes.clear();
    MainEntryPoint.statusPanel.setMessage("warning", "Adding a new entry entry, please wait...");
    if (searchMenu.searchField.getText().isEmpty()) {
        Window.alert("Please indicate the term's form");
        MainEntryPoint.statusPanel.setMessage("message", "No entries were added");
        History.newItem("notadded");
    } else {
        String lan = searchMenu.langSrc.getValue(searchMenu.langSrc.getSelectedIndex());
        if ((lan == null) || (lan.isEmpty())) {
            lan = Cookies.getCookie(MyTermCookiesNamespace.MyTermIDlangSrc);
        }
        getService().getAddResult(searchMenu.searchField.getText(), lan,
                searchMenu.rsrc.getValue(searchMenu.rsrc.getSelectedIndex()),
                searchMenu.dom.getItemText(searchMenu.dom.getSelectedIndex()), ownerID, termAddCallback);
    }
}

From source file:olanto.myTerm.client.Widgets.REVISORWidget.java

License:Open Source License

private void commandPage2() {
    isEdited.setVal(false);/*from   w  ww.j  av a  2  s  . c  o m*/
    MainEntryPoint.statusPanel.setMessage("warning", "Retrieving entries, please wait...");
    searchMenu.btnSearch.setEnabled(true);
    String lan = searchMenu.langSrc.getValue(searchMenu.langSrc.getSelectedIndex());
    if ((lan == null) || (lan.isEmpty())) {
        lan = Cookies.getCookie(MyTermCookiesNamespace.MyTermIDlangSrc);
    }
    getService().getApproveElements("", lan, searchMenu.langSrc.getLangIDs(), searchMenu.rsrc.getResourcesIDs(),
            searchMenu.dom.getItemText(searchMenu.dom.getSelectedIndex()), ownerID, workspaceCallback);
}

From source file:opus.gwt.management.console.client.dashboard.DeleteProjectPanel.java

License:Apache License

private void setupDeleteForm() {
    deleteForm.setMethod(FormPanel.METHOD_POST);
    deleteForm.setVisible(false);// w ww  . java2 s. co m
    deleteForm.setAction(JSVarHandler.getDeployerBaseURL()
            + deleteProjectURL.replaceAll("/projectName/", "/" + projectName + "/"));
    titlePanel.add(deleteForm);
    final String deletedProject = projectName;
    deleteForm.addSubmitHandler(new FormPanel.SubmitHandler() {
        public void onSubmit(SubmitEvent event) {
            deleteForm.add(new Hidden("csrfmiddlewaretoken", Cookies.getCookie("csrftoken")));
        }
    });
    deleteForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
        public void onSubmitComplete(SubmitCompleteEvent event) {
            eventBus.fireEvent(new DeleteProjectEvent(projectName));
        }
    });
}