List of usage examples for com.google.gwt.user.client Element getClassName
@Override
public String getClassName()
From source file:com.extjs.gxt.ui.client.widget.ColorPalette.java
License:sencha.com license
private String getColorFromElement(Element elem) { String className = elem.getClassName(); if (className.indexOf("color-") != -1) { return className.substring(className.indexOf("color-") + 6, className.indexOf("color-") + 12); }/*from w w w .j ava 2s .c o m*/ return null; }
From source file:com.extjs.gxt.ui.client.widget.table.TableView.java
License:Open Source License
protected void processRows(int startIndex) { if (table.getItemCount() == 0) { return;/* ww w . ja v a 2s . c o m*/ } for (int i = 0, len = table.getItemCount(); i < len; i++) { Element row = table.getItem(i).getElement(); String cls = " x-grid3-row-alt "; if (table.isStripeRows()) { boolean isAlt = ((i + 1) % 2 == 0); boolean hasAlt = (" " + row.getClassName() + " ").indexOf(cls) != -1; if (isAlt == hasAlt) { continue; } if (isAlt) { row.setClassName(row.getClassName() + " " + cls); } else { row.setClassName(row.getClassName().replaceFirst(cls, "")); } } } }
From source file:com.extjs.gxt.ui.client.widget.treetable.TreeTableItemUI.java
License:Open Source License
protected void updateCellValues(int col, Element cell, HorizontalAlignment align) { String salign = "left"; if (align == HorizontalAlignment.CENTER) { salign = "center"; } else if (align == HorizontalAlignment.RIGHT) { salign = "right"; }/*from www . j a va2 s .c o m*/ String widthClassName = ((TreeTableItem) item).treeTable.getId() + "-col-" + col; String className = cell.getClassName(); className = (className == null) ? widthClassName : className + " " + widthClassName; cell.setClassName(className); className = DOM.getElementProperty(DOM.getFirstChild(cell), "className"); className = (className == null) ? widthClassName : className + " " + widthClassName; DOM.setElementProperty(DOM.getFirstChild(cell), "className", className); El.fly(cell).subChild(2).setStyleAttribute("textAlign", salign); }
From source file:com.objetdirect.tatami.client.dnd.DnDTreeController.java
License:Open Source License
private static JavaScriptObject getChildByEvent(Event e) { Element node = (Element) e.getTarget(); while (node != null) { if (node.getClassName().contains("dijitTreeContent")) { return node; }/* www . j a v a2 s . co m*/ node = (Element) node.getParentElement(); } return null; }
From source file:com.objetdirect.tatami.client.dnd.WidgetDnDController.java
License:Open Source License
private static JavaScriptObject getChildByEvent(Event e) { Logger.log("GET CHILD BY EVENT " + e); Element node = (Element) e.getTarget(); Logger.log("TARGET " + node); while (node != null) { if (node.getClassName().contains("dojoDndItem")) { Logger.log("FOUND " + node); return node; }/* w ww. j ava 2s . c o m*/ node = (Element) node.getParentElement(); } return null; }
From source file:com.qualogy.qafe.mgwt.client.ui.component.ComponentHelper.java
License:Apache License
public static void setStyle(Element element, String styleClass, String[][] inlineStyles) { if (element == null) { return;//from w w w . j av a2 s . c o m } if (styleClass != null) { if (!element.getClassName().contains(styleClass)) { addStyle(element, styleClass); } } if (inlineStyles != null) { for (int i = 0; i < inlineStyles.length; i++) { if (inlineStyles[i].length == 2) { String attribute = inlineStyles[i][0]; String value = inlineStyles[i][1]; setStyle(element, attribute, value); } } } }
From source file:com.vaadin.client.ComponentLocator.java
License:Apache License
/** * Locates an element based on a DOM path and a base element. * /*from ww w . j a v a2 s . c o m*/ * @param baseElement * The base element which the path is relative to * @param path * String locator (consisting of domChild[x] parts) that * identifies the element * @return The element identified by path, relative to baseElement or null * if the element could not be found. */ private Element getElementByDOMPath(Element baseElement, String path) { String parts[] = path.split(PARENTCHILD_SEPARATOR); Element element = baseElement; for (String part : parts) { if (part.startsWith("domChild[")) { String childIndexString = part.substring("domChild[".length(), part.length() - 1); if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) { if (element.hasChildNodes()) { Element e = element.getFirstChildElement().cast(); String cn = e.getClassName(); if (cn != null && (cn.equals("v-expand") || cn.contains("v-has-caption"))) { element = e; } } } try { int childIndex = Integer.parseInt(childIndexString); element = DOM.getChild(element, childIndex); } catch (Exception e) { return null; } if (element == null) { return null; } } } return element; }
From source file:de.swm.commons.mobile.client.widgets.publictransport.ConnectionListItem.java
License:Apache License
@Override public void setDisabled(boolean disabled) { super.setDisabled(disabled); if (disabled) { // add cover setShowArrow(false);//from www . j av a 2s. co m getElement().getStyle().setPosition(Position.RELATIVE); Element cover = DOM.createDiv(); cover.setClassName( SWMMobile.getTheme().getMGWTCssBundle().getConnectionListItemCss().connectionListItemCover()); DOM.appendChild(getElement(), cover); } else { // remove cover Element cover = null; for (int i = 0; i < DOM.getChildCount(getElement()); i++) { Element el = DOM.getChild(getElement(), i); if (SWMMobile.getTheme().getMGWTCssBundle().getConnectionListItemCss().connectionListItemCover() .equals(el.getClassName())) { cover = el; break; } } if (cover != null) { DOM.removeChild(getElement(), cover); } setShowArrow(true); } }
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 w w . j a va 2 s . c o m*/ } 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> " : "") + "<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:info.magnolia.ui.vaadin.gwt.client.dialog.connector.DialogContainingFormConnector.java
License:Open Source License
private void doResize() { Widget content = getContent().getWidget(); if (content instanceof FormViewImpl) { FormViewImpl formView = (FormViewImpl) content; Element element = view.asWidget().getElement(); NodeList<Node> childNodes = element.getChild(0).getChildNodes(); int footerHeight = 0, headerHeight = 0, marginHeight = 0; List<String> marginElements = Arrays.asList("dialog-description", "dialog-error", "dialog-content", "dialog-footer"); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.getItem(i); if (item.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) item; if (child.getClassName().equalsIgnoreCase("dialog-footer")) { footerHeight = child.getOffsetHeight(); } else if (child.getClassName().isEmpty()) { headerHeight = child.getOffsetHeight(); }// ww w . ja v a 2s . co m if (marginElements.contains(child.getClassName())) { marginHeight += 2; } } } int topMargin = element.getOffsetTop(); int bottomMargin = 0; if ("light".equals(getState().modalityLevel)) { bottomMargin = LIGHT_DIALOG_BOTTOM_MARGIN; } formView.setMaxHeight(view.asWidget().getElement().getOffsetHeight() - footerHeight - headerHeight - marginHeight - topMargin - bottomMargin); } }