Example usage for com.google.gwt.dom.client NodeList getItem

List of usage examples for com.google.gwt.dom.client NodeList getItem

Introduction

In this page you can find the example usage for com.google.gwt.dom.client NodeList getItem.

Prototype

public T getItem(int index) 

Source Link

Usage

From source file:edu.caltech.ipac.firefly.ui.TitleFlasher.java

private static void findFavIcon() {
    Document doc = Document.get();
    NodeList<Element> eleList = doc.getElementsByTagName("link");
    for (int i = 0; (i < eleList.getLength()); i++) {
        Element e = eleList.getItem(i);
        LinkElement le = LinkElement.as(e);
        if ("image/x-icon".equals(le.getType())) {
            if (!StringUtils.isEmpty(le.getHref())) {
                favIconElement = le;/*from   ww  w  . ja  v a2  s .  c  o  m*/
                String favIcon = le.getHref();
                break;
            }
        }
    }
}

From source file:fr.aliasource.webmail.client.AdvancedSearchForms.java

License:GNU General Public License

private void buildSelectBox() {
    folderQuery.clear();/*from   w  w w . j a  v a2 s  .c om*/

    folderQuery.addItem(I18N.strings.allMail(), "-in:trash");

    for (Folder f : folders) {
        GWT.log("webmailctrl: " + WebmailController.get() + " f: " + f, null);
        String displayName = WebmailController.get().displayName(f);
        folderQuery.addItem(displayName, "in:\"" + f.getDisplayName().trim() + "\"");
    }

    folderQuery.addItem("----");
    folderQuery.addItem(I18N.strings.mailAndTrash(I18N.strings.trash()), "in:anywhere");
    folderQuery.addItem("----");
    folderQuery.addItem(I18N.strings.readMail(), "is:read");
    folderQuery.addItem(I18N.strings.unreadMail(), "is:unread");
    folderQuery.addItem("----");

    Element e = folderQuery.getElement();
    NodeList<com.google.gwt.dom.client.Element> toStyle = e.getElementsByTagName("option");
    // Disable separator items
    toStyle.getItem(folderQuery.getItemCount() - 6).setAttribute("disabled", "disabled");
    toStyle.getItem(folderQuery.getItemCount() - 4).setAttribute("disabled", "disabled");
    toStyle.getItem(folderQuery.getItemCount() - 1).setAttribute("disabled", "disabled");

    for (int i = 1; i < toStyle.getLength() - 7; i++) {
        com.google.gwt.dom.client.Element opt = toStyle.getItem(i);
        Folder f = folders[i - 1];
        int margin = 10 * depth(f.getDisplayName());
        opt.setAttribute("style", "margin-left: " + margin + "px");
        fe.put(f, opt);
    }
}

From source file:fr.aliasource.webmail.client.filter.DeliverIntoWidget.java

License:GNU General Public License

private void buildSelectBox(Folder[] folders) {
    folderQuery.clear();/*from  w w  w  .  j  av a  2s  . co m*/

    folderQuery.addItem("Choose folder...", null);

    for (Folder f : folders) {
        String displayName = WebmailController.get().displayName(f);
        folderQuery.addItem(displayName, f.getName());
    }

    Element e = folderQuery.getElement();
    NodeList<com.google.gwt.dom.client.Element> toStyle = e.getElementsByTagName("option");

    for (int i = 1; i < toStyle.getLength(); i++) {
        com.google.gwt.dom.client.Element opt = toStyle.getItem(i);
        Folder f = folders[i - 1];
        int margin = 10 * depth(f.getDisplayName());
        opt.setAttribute("style", "margin-left: " + margin + "px");
    }
}

From source file:fr.fg.client.core.Chat.java

License:Open Source License

public void addMessage(String type, String channelName, String author, String content, String allyTag,
        String allyName, String rights, String time, Integer level, Integer playerRank) {
    boolean hasAllyTag = allyTag != null;

    String richContent = Utilities.parseUrlAndSmilies(content);
    richContent = TacticsTools.parseTacticsLinks(richContent);

    boolean scroll = messagesLayout.getWidgetCount() < 10 || Math.floor(scrollPane.getScroll()) == 1;
    //on dtermine le rang du joueur

    int rank = 0; //rang joueur

    if (rights != null) {
        if (rights.equals(MODERATOR)) {
            rank = 1; //rang modrateur
        } else if (rights.equals(ADMINISTRATOR) || rights.equals(SUPER_ADMINISTRATOR)) {
            rank = 2; //rang administrateur
        }// w  ww.j a va  2s . c  om
    }

    if (type.equals("default")) {
        if (content.startsWith("/me")) {
            // Message d'action (/me)

            content = "<table cellspacing=\"0\">" + "<tr><td><span style=\"color:#FFFFFF;\"><" + time
                    + "> </span></td><td class=\"allyTag\">"
                    + (hasAllyTag ? "<span class=\"allyTag\">[" + allyTag + "]</span> " : "") + "</td><td>"
                    + "<span class=\"sender\">"
                    + (rank != 0
                            ? (rank == 1 ? "<span class=\"bookmark\"></span><span class=\"author\">" + author
                                    : "<span class=\"bookmark\"></span><span class=\"author\">" + author)
                            : "<span class=\"author\">" + author)
                    + "</span></span>" + richContent.substring(3) + "</td></tr></table>";
            type = "action";

        } else {

            // Message standard
            content = "<table cellspacing=\"0\">" + "<tr><td><span style=\"color:#FFFFFF;\"><" + time
                    + "> </span></td><td class=\"allyTag\">"
                    + (hasAllyTag ? "<span class=\"allyTag\">[" + allyTag + "]</span> " : "") + "</td><td>"
                    + "<span class=\"sender\">"
                    + (rank != 0
                            ? (rank == 1 ? "<span class=\"bookmark\"></span><span class=\"author\">" + author
                                    : "<span class=\"bookmark\"></span><span class=\"author\">" + author)
                            : "<span class=\"author\">" + author)
                    + "</span> : </span>"
                    + (rank != 0
                            ? (rank == 1
                                    ? "<span style=\"color:" + moderatorColor + ";\">" + richContent + "</span>"
                                    : "<span style=\"color:" + administratorColor + ";\">" + richContent
                                            + "</span>")
                            : richContent)
                    + "</td></tr></table>";
            type = "default";
        }
    } else if (type.equals("connection")) {
        // Connexion d'un ami
        content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\""
                + (hasAllyTag ? " rel=\"" + allyName + "\"" : "") + ">"
                + (hasAllyTag ? "<span class=\"allyTag\">[" + allyTag + "]</span> " : "") + "</td><td>"
                + "<span class=\"author\">" + author + "</span> s'est connect(e)." + "</td></tr></table>";
        type = "notification";
    } else if (type.equals("disconnection")) {
        // Dconnexion d'un ami
        content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\""
                + (hasAllyTag ? " rel=\"" + allyName + "\"" : "") + ">"
                + (hasAllyTag ? "<span class=\"allyTag\">[" + allyTag + "]</span> " : "") + "</td><td>"
                + "<span class=\"author\">" + author + "</span> s'est dconnect(e)." + "</td></tr></table>";
        type = "notification";
    } else if (type.equals("who") || type.equals("online") || type.equals("moderator")
            || type.equals("allyMembers")) {

        // Liste de joueurs
        String[] players = content.split(",");
        String[] logins = new String[players.length], allyTags = new String[players.length],
                allyNames = new String[players.length], lineClasses = new String[players.length];

        for (int i = 0; i < players.length; i++) {
            String player = players[i];
            lineClasses[i] = "";

            //JSOptionPane.showMessageDialog("player: " + player, "ligne n" + i, JSOptionPane.OK_OPTION, type, null);

            if (player.contains("*")) {
                lineClasses[i] = " friend";
            }

            if (player.contains("|")) {
                int startOffset = 0;
                if (player.contains("*"))
                    startOffset = 1;

                logins[i] = player.substring(startOffset, player.indexOf("|"));
                allyTags[i] = player.substring(player.indexOf("|") + 1, player.lastIndexOf("|"));
                allyNames[i] = player.substring(player.lastIndexOf("|") + 1);
            } else {
                if (player.contains("*"))
                    logins[i] = player.substring(1);
                else
                    logins[i] = player;
                allyTags[i] = null;
                allyNames[i] = null;
            }
        }

        if (type.equals("allyMembers"))
            content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\"></td><td>" + "Il y a "
                    + players.length + " membre" + (players.length > 1 ? "s" : "")
                    + " de votre alliance connect" + (players.length > 1 ? "s" : "") + " :";
        else if (type.equals("moderator"))
            content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\"></td><td>" + "Il y a "
                    + players.length + " moderateur" + (players.length > 1 ? "s" : "") + " connect"
                    + (players.length > 1 ? "s" : "") + " :";
        else
            content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\"></td><td>" + "Il y a "
                    + players.length + " joueur" + (players.length > 1 ? "s" : "") + " connect"
                    + (players.length > 1 ? "s" : "")
                    + (type.equals("who") ? " sur le canal :" : " sur Fallen Galaxy :");
        type = "info";

        for (int i = 0; i < logins.length; i++) {
            //JSOptionPane.showMessageDialog("lineClass: " + lineClasses[i], "ligne n" + i, JSOptionPane.OK_OPTION, type, null);

            content += (i == 0 ? "" : ",") + " "
                    + (allyTags[i] != null
                            ? "<span class=\"inlineAllyTag\" rel=\"" + allyNames[i] + "\">[" + allyTags[i]
                                    + "]</span>&nbsp;"
                            : "")
                    + "<span class=\"author" + lineClasses[i] + "\">" + logins[i] + "</span>";
        }

        content += "</td></tr></table>";

    } else if (type.equals("ping")) {
        // Ping (/ping)
        double ping = Double.parseDouble(content);
        Date date = new Date();
        content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\"></td><td>" + "Ping : "
                + (int) Math.ceil(date.getTime() - ping) + "ms" + "</td></tr></table>";
        type = "info";
    } else if (type.equals("whisperSent")) {
        // Murmure envoy (/whisper)
        content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\"></td><td>" + "Vous murmurez  "
                + (hasAllyTag ? "<span class=\"inlineAllyTag\">[" + allyTag + "]</span> " : "")
                + "<span class=\"author\">" + author + "</span> : " + richContent + "</td></tr></table>";
        type = "whisper";

        if (!author.equals(Settings.getPlayerLogin()))
            lastWhisperAuthor = author;
    } else if (type.equals("whisperReceived")) {
        // Murmure reu (/whisper)
        content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\""
                + (hasAllyTag ? " rel=\"" + allyName + "\"" : "") + ">"
                + (hasAllyTag ? "<span class=\"allyTag\">[" + allyTag + "]</span> " : "") + "</td><td>"
                + "<span class=\"author\">" + author + "</span> vous murmure : " + richContent
                + "</td></tr></table>";
        type = "whisper";

        if (!author.equals(Settings.getPlayerLogin()))
            lastWhisperAuthor = author;
    } else {
        content = "<table cellspacing=\"0\">" + "<tr><td class=\"allyTag\"></td><td>" + richContent
                + "</td></tr></table>";
    }

    OutlineText message = TextManager.getText(content, false, true);

    String channelStyle = "";
    for (int i = 0; i < channels.size(); i++)
        if (channels.get(i).getName().equals(channelName))
            channelStyle = channelsStyles[i];

    message.addStyleName("msg " + type + (channelStyle.length() > 0 ? " channel-" + channelStyle : ""));

    NodeList<com.google.gwt.dom.client.Element> elements = message.getElement().getElementsByTagName("span");

    for (int i = 0; i < elements.getLength(); i++) {
        com.google.gwt.dom.client.Element element = elements.getItem(i);

        if (element.getClassName().toLowerCase().contains("allytag")) {
            String rel = element.getAttribute("rel");

            ToolTipManager.getInstance().register(element, rel.length() == 0 ? allyName : rel);

        }

        if (element.getClassName().contains("sender")) {

            if (rank == 1) {
                String modoPlayer = "Ce joueur est un Modrateur" + "</br>Niveau : " + level
                        + "</br>Classement : " + (playerRank == 1 ? playerRank + "er" : playerRank + "me");
                ToolTipManager.getInstance().register(element, modoPlayer);
            } else if (rank == 2) {
                String adminPlayer = "Ce joueur est un Administrateur" + "</br>Niveau : " + level
                        + "</br>Classement : " + (playerRank == 1 ? playerRank + "er" : playerRank + "me");
                ToolTipManager.getInstance().register(element, adminPlayer);

            } else {
                String normalPlayer = "Niveau : " + level + "</br>Classement : "
                        + (playerRank == 1 ? playerRank + "er" : playerRank + "me");
                ToolTipManager.getInstance().register(element, normalPlayer);
            }
        }
    }

    messagesLayout.add(message);

    // Supprime les premiers messages quand il y en a plus de 50
    if (messagesLayout.getWidgetCount() > 50)
        messagesLayout.remove(0);

    if (!completion.contains(author))
        completion.add(author);

    scrollPane.update();
    if (scroll)
        scrollDown();
}

From source file:fr.fg.client.core.ContractDialog.java

License:Open Source License

private void updateUI() {
    double scroll = missionsPane.getScrollOffset();
    DynamicMessages dynamicMessages = GWT.create(DynamicMessages.class);
    JSRowLayout layout = new JSRowLayout();

    switch (tabbedPane.getSelectedIndex()) {
    case VIEW_CONTRACT_OFFERS:
        acceptBt = new JSButton[contracts.getContractOffersCount()];
        declineBt = new JSButton[contracts.getContractOffersCount()];

        for (int i = 0; i < contracts.getContractOffersCount(); i++) {
            ContractData contract = contracts.getContractOfferAt(i);

            if (i > 0) {
                JSLabel separator = new JSLabel();
                separator.setPixelWidth(450);
                layout.addRow();/*from ww  w . j  a  va  2 s  .  co  m*/
                layout.addComponent(separator);
                layout.addRow();
            }

            StringBuffer missionDescription = new StringBuffer();

            missionDescription.append("<div style=\"padding: 5px; line-height: 20px;\">");
            missionDescription.append("<div class=\"title\">" + contract.getTitle() + "</div>");
            missionDescription.append("<div class=\"emphasize\">" + contract.getMissionType() + "</div>");
            missionDescription.append("<div class=\"small\" style=\"font-style: italic;\">"
                    + contract.getDescription() + "</div>");
            missionDescription.append(
                    "<div><div style=\"float: left; width: 120px;\">Objectif</div><div style=\"padding-left: 120px;\">"
                            + contract.getGoal() + "</div></div>");

            // Quadrants dans lesquels la mission a lieu
            missionDescription.append(
                    "<div><div style=\"float: left; width: 120px;\">Quadrants</div><div style=\"padding-left: 120px;\">");
            for (int j = 0; j < contract.getSectorsCount(); j++) {
                if (j > 0)
                    missionDescription.append(", ");
                missionDescription.append(contract.getSectorAt(j));
            }
            missionDescription.append("</div></div>");

            missionDescription
                    .append("<div><div style=\"float: left; width: 120px;\">Dbut</div>Immdiat</div>");

            // Rcompense de la mission
            missionDescription.append("<div><div style=\"float: left; width: 120px;\">Rcompense</div>"
                    + "<div style=\"padding-left: 120px;\">");
            formatRewards(contract, missionDescription);
            missionDescription.append("</div></div>");

            // Relations
            missionDescription.append("<div><div style=\"float: left; width: 120px;\">Relations</div>"
                    + "<div style=\"padding-left: 120px;\">");
            formatRelationships(contract, missionDescription);
            missionDescription.append("</div></div>");

            missionDescription.append("</div>");

            HTMLPanel missionDescriptionPanel = new HTMLPanel(missionDescription.toString());
            OpenJWT.setElementFloat(missionDescriptionPanel.getElement(), "left");
            missionDescriptionPanel.getElement().getStyle().setProperty("width", "100%");

            NodeList<Element> elements = missionDescriptionPanel.getElement().getElementsByTagName("span");

            for (int j = 0; j < elements.getLength(); j++) {
                Element element = elements.getItem(j);

                if (element.getClassName().toLowerCase().contains("allytag")) {
                    String rel = element.getAttribute("rel");
                    ToolTipManager.getInstance().register(element, rel);
                }
            }

            acceptBt[i] = new JSButton("Accepter");
            acceptBt[i].setPixelWidth(100);
            acceptBt[i].addClickListener(this);

            declineBt[i] = new JSButton("Refuser");
            declineBt[i].setPixelWidth(100);
            declineBt[i].addClickListener(this);

            layout.addComponent(missionDescriptionPanel);
            layout.addRow();
            layout.addComponent(acceptBt[i]);
            layout.addComponent(declineBt[i]);
        }
        break;
    case VIEW_ACTIVE_CONTRACTS:
        giveUpBt = new JSButton[contracts.getActiveContractsCount()];

        for (int i = 0; i < contracts.getActiveContractsCount(); i++) {
            ContractData contract = contracts.getActiveContractAt(i);

            if (i > 0) {
                JSLabel separator = new JSLabel();
                separator.setPixelWidth(450);
                layout.addRow();
                layout.addComponent(separator);
                layout.addRow();
            }

            StringBuffer missionDescription = new StringBuffer();

            missionDescription.append("<div style=\"padding: 5px; line-height: 20px;\">");
            missionDescription.append("<div class=\"title\">" + contract.getTitle() + "</div>");
            missionDescription.append("<div class=\"emphasize\">" + contract.getMissionType() + "</div>");
            missionDescription.append("<div class=\"small\" style=\"font-style: italic;\">"
                    + contract.getDescription() + "</div>");
            missionDescription.append(
                    "<div><div style=\"float: left; width: 120px;\">Objectif</div><div style=\"padding-left: 120px;\">"
                            + contract.getGoal() + "</div></div>");

            // Participants  la mission
            missionDescription.append(
                    "<div><div style=\"float: left; width: 120px;\">Participants</div><div style=\"padding-left: 120px;\">");
            for (int j = 0; j < contract.getAttendeesCount(); j++) {
                if (j > 0)
                    missionDescription.append(", ");

                ContractAttendeeData attendee = contract.getAttendeeAt(j);

                if (attendee.getType().equals(ContractAttendeeData.TYPE_PLAYER)) {
                    if (attendee.getAllyTag().length() > 0)
                        missionDescription.append("<span class=\"inlineAllyTag\" " + "rel=\""
                                + attendee.getAllyName() + "\">[" + attendee.getAllyTag() + "]</span>&nbsp;");
                    missionDescription.append("<span class=\"owner-" + attendee.getTreaty() + "\">"
                            + attendee.getLogin() + "</span>");
                } else {
                    missionDescription.append("<span class=\"owner-" + attendee.getTreaty() + "\">"
                            + attendee.getAllyName() + "</span>");
                }
            }
            missionDescription.append("</div></div>");

            // Rcompense de la mission
            missionDescription.append("<div><div style=\"float: left; width: 120px;\">Rcompense</div>"
                    + "<div style=\"padding-left: 120px;\">");
            formatRewards(contract, missionDescription);
            missionDescription.append("</div></div>");

            // Relations
            missionDescription.append("<div><div style=\"float: left; width: 120px;\">Relations</div>"
                    + "<div style=\"padding-left: 120px;\">");
            formatRelationships(contract, missionDescription);
            missionDescription.append("</div></div>");

            missionDescription.append("</div>");

            HTMLPanel missionDescriptionPanel = new HTMLPanel(missionDescription.toString());
            OpenJWT.setElementFloat(missionDescriptionPanel.getElement(), "left");
            missionDescriptionPanel.getElement().getStyle().setProperty("width", "100%");

            NodeList<Element> elements = missionDescriptionPanel.getElement().getElementsByTagName("span");

            for (int j = 0; j < elements.getLength(); j++) {
                Element element = elements.getItem(j);

                if (element.getClassName().toLowerCase().contains("allytag")) {
                    String rel = element.getAttribute("rel");
                    ToolTipManager.getInstance().register(element, rel);
                }
            }

            layout.addComponent(missionDescriptionPanel);

            if (!contract.isFinished() && (contract.getMissionType().equals("Mission solo")
                    || contract.getMissionType().equals("Mission d'alliance"))) {
                giveUpBt[i] = new JSButton("Abandonner");
                giveUpBt[i].setPixelWidth(100);
                giveUpBt[i].addClickListener(this);

                layout.addRow();
                layout.addComponent(giveUpBt[i]);
            }
        }
        break;
    case VIEW_RELATIONSHIPS:
        String[] colors = { "#ff0000", "#ff3600", "#ff6c00", "#ffa201", "#ffd800", "#d8e201", "#b0ec01",
                "#89f501", "#62ff01" };

        layout.addRowSeparator(20);

        JSLabel relationTitle = new JSLabel("<div class=\"title\">Joueur</div>");
        relationTitle.setAlignment(JSLabel.ALIGN_CENTER);
        relationTitle.setPixelWidth(500);
        layout.addComponent(relationTitle);
        layout.addRow();
        for (int i = 0; i < contracts.getRelationshipsCount(); i++) {
            RelationshipData relationship = contracts.getRelationshipAt(i);
            if (relationship.getType() == 0) {
                if (i > 0)
                    layout.addRow();

                JSLabel factionLabel = new JSLabel("<img src=\"" + Config.getMediaUrl()
                        + "images/misc/blank.gif\" class=\"faction faction-" + relationship.getFactionId()
                        + "\"/>&nbsp;&nbsp;" + relationship.getFactionName());
                factionLabel.setPixelWidth(270);

                JSLabel relationLabel = new JSLabel(
                        dynamicMessages
                                .getString("relationshipLevel" + (relationship.getLevel() < 0 ? "M" : "")
                                        + Math.abs(relationship.getLevel()))
                                + " (" + relationship.getValue() + ")");
                relationLabel.setAlignment(JSLabel.ALIGN_CENTER);
                relationLabel.setPixelWidth(150);
                relationLabel.getElement().getStyle().setProperty("color", colors[relationship.getLevel() + 4]);

                layout.addComponent(JSRowLayout.createHorizontalSeparator(40));
                layout.addComponent(factionLabel);
                layout.addComponent(relationLabel);
            }
        }

        layout.addRowSeparator(10);

        JSLabel relationAllyTitle = new JSLabel("<div class=\"title\">Alliance</div>");
        relationAllyTitle.setAlignment(JSLabel.ALIGN_CENTER);
        relationAllyTitle.setPixelWidth(500);
        layout.addComponent(relationAllyTitle);
        layout.addRow();

        for (int i = 0; i < contracts.getAllyRelationshipsCount(); i++) {
            RelationshipData relationship = contracts.getAllyRelationshipAt(i);
            if (relationship.getType() == 1) {
                layout.addRow();

                JSLabel factionLabel = new JSLabel("<img src=\"" + Config.getMediaUrl()
                        + "images/misc/blank.gif\" class=\"faction faction-" + relationship.getFactionId()
                        + "\"/>&nbsp;&nbsp;" + relationship.getFactionName());
                factionLabel.setPixelWidth(270);

                JSLabel relationLabel = new JSLabel(
                        dynamicMessages
                                .getString("relationshipLevel" + (relationship.getLevel() < 0 ? "M" : "")
                                        + Math.abs(relationship.getLevel()))
                                + " (" + relationship.getValue() + ")");
                relationLabel.setAlignment(JSLabel.ALIGN_CENTER);
                relationLabel.setPixelWidth(150);
                relationLabel.getElement().getStyle().setProperty("color", colors[relationship.getLevel() + 4]);

                layout.addComponent(JSRowLayout.createHorizontalSeparator(40));
                layout.addComponent(factionLabel);
                layout.addComponent(relationLabel);
            }
        }
        break;
    }

    missionsPane.setView(layout);
    missionsPane.setScrollOffset(scroll);
    layout.update();
}

From source file:fr.putnami.pwt.core.service.client.CsrfController.java

License:Open Source License

private void init() {
    NodeList<Element> tags = Document.get().getElementsByTagName("meta");
    for (int i = 0; i < tags.getLength(); i++) {
        MetaElement metaTag = (MetaElement) tags.getItem(i);
        String metaName = metaTag.getName();
        String metaContent = metaTag.getContent();
        if (META_NAME_CSRF_TOKEN.equals(metaName) && !Strings.isNullOrEmpty(metaContent)) {
            this.token = metaContent;
        }//from  ww  w.j av  a  2 s.  c  om
        if (META_NAME_CSRF_HEADER.equals(META_NAME_CSRF_HEADER) && !Strings.isNullOrEmpty(metaContent)) {
            this.header = metaContent;
        }
    }
}

From source file:fr.putnami.pwt.core.theme.client.DefaultThemeController.java

License:Open Source License

/**
 * Removes all link tags in the head if not initialized.
 *//*from ww w .j  a va  2  s .  c o  m*/
private void removeCssLinks() {
    if (this.isInit) {
        return;
    }
    this.isInit = true;
    // Remove all existing link element
    NodeList<Element> links = this.getHead().getElementsByTagName(LinkElement.TAG);
    int size = links.getLength();
    for (int i = 0; i < size; i++) {
        LinkElement elem = LinkElement.as(links.getItem(0));
        if ("stylesheet".equals(elem.getRel())) {
            elem.removeFromParent();
        }
    }
}

From source file:fr.putnami.pwt.core.widget.client.DocumentMeta.java

License:Open Source License

/**
 * Return the first meta tag from the head section with name matching. <br>
 * If createIfMissing the tag is created and added at the end of the head section.<br>
 * <p>//from w  ww. j  a  v a2  s  .c om
 * <strong>Note : </strong> the name is case insensitive
 * </p>
 *
 * @param name the name attribute of the metta tag
 * @param createIfMissing create the tag in the head section if missing
 * @return meta tag element or null
 */
public static MetaElement getDescriptionTag(String name, boolean createIfMissing) {
    Document doc = Document.get();
    HeadElement head = doc.getHead();
    assert head != null : "No head section found in the document";
    assert name != null : "the name must not be null";

    NodeList<Element> tags = head.getElementsByTagName("meta");
    MetaElement metaTag = null;
    for (int i = 0; i < tags.getLength(); i++) {
        metaTag = (MetaElement) tags.getItem(i);
        if (name.equalsIgnoreCase(metaTag.getName())) {
            return metaTag;
        }
    }
    if (createIfMissing) {
        metaTag = doc.createMetaElement();
        metaTag.setName(name);
        head.appendChild(metaTag);
    }
    return metaTag;
}

From source file:gwt.material.design.client.base.helper.DOMHelper.java

License:Apache License

public static Element getElementByAttribute(NodeList<Element> elems, String attr, String value) {
    if (elems != null) {
        for (int i = 0; i < elems.getLength(); i++) {
            Element child = elems.getItem(i);
            if (child.getAttribute(attr).equals(value)) {
                return child;
            }/*from  w w  w. ja va 2  s .c  o m*/
        }
    }
    return null;
}

From source file:gwt.material.design.client.ui.MaterialRange.java

License:Apache License

/**
 * Try to identify the embedded range elements input field (see ui xml)
 * @return The found element or null if none found.
 *///from  w w  w  .j  a v  a  2  s  .  c o  m
private Element getRangeElement() {
    if (rangeElement == null) {
        NodeList<Element> elements = this.getElement().getElementsByTagName(INPUT);
        if (elements != null && elements.getLength() > 0) {
            rangeElement = elements.getItem(0);
        }
    }
    return rangeElement;
}