List of usage examples for com.google.gwt.dom.client Element getClassName
@Override
public String getClassName()
From source file:app.dnd.drag.DraggableCellDecorator.java
License:Apache License
public void onBrowserEvent(Context context, Element parent, final T value, NativeEvent event, ValueUpdater<T> valueUpdater) { if (MOUSE_DOWN.equals(event.getType())) { EventTarget eventTarget = event.getEventTarget(); if (Element.is(eventTarget)) { Element target = eventTarget.cast(); Element wrapper = target.getParentElement(); if (wrapper != null && dragHandlerClass.equals(wrapper.getClassName())) { DNDContext dndContext = dragSource.startDragging(value); dragController.dragStart(dndContext, parent); event.stopPropagation(); event.preventDefault();//from w w w. j a v a2s.c om return; } } } final Element cellParent = getCellParent(parent); cell.onBrowserEvent(context, cellParent, getValue(value), event, getValueUpdater()); }
From source file:asquare.gwt.debug.client.DebugUtil.java
License:Apache License
/** * Get a short description of the element. * /*w w w .j a v a 2 s . c om*/ * @param element a DOM element or <code>null</code> * @return a String or <code>null</code> if <code>element</code> is null */ public static String prettyPrintElement(Element element) { if (element == null) { return String.valueOf(element); } String tagName = element.getTagName(); String id = element.getId(); String classNames = element.getClassName(); String description = null; if ("div".equalsIgnoreCase(tagName) || "span".equalsIgnoreCase(tagName)) { if (id != null && !"".equals(id)) { description = id; } else if (classNames != null && !"".equals(classNames)) { description = classNames; } } else if (tagName.equalsIgnoreCase("button")) { description = ButtonElement.as(element).getValue(); } return (description == null) ? tagName : tagName + '[' + description + ']'; }
From source file:cc.alcina.framework.gwt.client.widget.SelectWithSearch.java
License:Apache License
protected void handleFilterBlur() { new Timer() { @Override/* w w w . j a va 2s .c om*/ public void run() { // https://jira.barnet.com.au/browse/JAD-5053 - IE // blur/scrollbar issue if (BrowserMod.isInternetExplorer()) { Element elt = WidgetUtils.getFocussedDocumentElement(); if (elt != null && elt.getClassName().contains("scroller")) { return; } } hidePopdown(); } }.schedule(250); }
From source file:ch.unifr.pai.twice.multipointer.client.MouseCursor.java
License:Apache License
/** * Recursive method that hides the mouse pointer elements which are below the specific point until the first element is found which is not a mouse pointer. * /*from w w w .j a v a 2 s . co m*/ * @param x * @param y * @param hiddenCursors * - a set which is filled with references to all mouse pointers which had to be hidden to find the underlying element. * @return */ private Element getElementFromPointRec(int x, int y, Set<Element> hiddenCursors) { Element e = elementFromPoint(Document.get(), x, y); e = getElementInFrame(e, x, y); Element tmpE = e; if (e != null && e.getTagName().equalsIgnoreCase("img") && Document.get().getDocumentElement() != e) tmpE = e.getParentElement().getParentElement(); if (tmpE != null && tmpE.getClassName().contains("multiCursor")) { hiddenCursors.add(tmpE); tmpE.getStyle().setDisplay(Display.NONE); e = getElementFromPointRec(x, y, hiddenCursors); } return e; }
From source file:com.alkacon.geranium.client.util.DomUtil.java
License:Open Source License
/** * Clones the given element.<p>/* w ww . j ava 2s . c om*/ * * It creates a new element with the same tag, and sets the class attribute, * and sets the innerHTML.<p> * * @param element the element to clone * * @return the cloned element */ public static com.google.gwt.user.client.Element clone(Element element) { com.google.gwt.user.client.Element elementClone = DOM.createElement(element.getTagName()); elementClone.setClassName(element.getClassName()); elementClone.setInnerHTML(element.getInnerHTML()); return elementClone; }
From source file:com.alkacon.geranium.client.util.DomUtil.java
License:Open Source License
/** * Internal method to indicate if the given element has a CSS class.<p> * // w ww. j a v a2 s . com * @param className the class name to look for * @param element the element * * @return <code>true</code> if the element has the given CSS class */ private static boolean internalHasClass(String className, Element element) { String elementClass = element.getClassName().trim(); boolean hasClass = elementClass.equals(className); hasClass |= elementClass.contains(" " + className + " "); hasClass |= elementClass.startsWith(className + " "); hasClass |= elementClass.endsWith(" " + className); return hasClass; }
From source file:com.bearsoft.gwt.ui.widgets.grid.Grid.java
protected DraggedColumn<T> findTargetDraggedColumn(JavaScriptObject aEventTarget) { if (Element.is(aEventTarget)) { GridSection<T> targetSection = null; Element targetCell = null; Element currentTarget = Element.as(aEventTarget); if (COLUMN_PHANTOM_STYLE.equals(currentTarget.getClassName()) || RULER_STYLE.equals(currentTarget.getClassName())) { return targetDraggedColumn; }/* ww w . ja v a 2s . c o m*/ while ((targetCell == null || targetSection == null) && currentTarget != null && currentTarget != Grid.this.getElement()) { if (targetCell == null) { if ("td".equalsIgnoreCase(currentTarget.getTagName()) || "th".equalsIgnoreCase(currentTarget.getTagName())) { targetCell = currentTarget; } } if (targetSection == null) { if (currentTarget == headerLeft.getElement()) { targetSection = headerLeft; } else if (currentTarget == frozenLeft.getElement()) { targetSection = frozenLeft; } else if (currentTarget == scrollableLeft.getElement()) { targetSection = scrollableLeft; } else if (currentTarget == footerLeft.getElement()) { targetSection = footerLeft; } else if (currentTarget == headerRight.getElement()) { targetSection = headerRight; } else if (currentTarget == frozenRight.getElement()) { targetSection = frozenRight; } else if (currentTarget == scrollableRight.getElement()) { targetSection = scrollableRight; } else if (currentTarget == footerRight.getElement()) { targetSection = footerRight; } } currentTarget = currentTarget.getParentElement(); } if (targetSection != null && targetCell != null) { Column<T, ?> col = targetSection.getHeaderBuilder().getColumn(targetCell); Header<?> header = targetSection.getHeaderBuilder().getHeader(targetCell); if (col != null && header != null) return new DraggedColumn<T>(col, header, targetSection, targetCell, Element.as(aEventTarget)); else return null; } return null; } else { return null; } }
From source file:com.bearsoft.gwt.ui.XElement.java
/** * Selects child nodes based on the passed CSS selector (the selector should * not contain an id).//from w ww . j ava2 s . co m * * @param aClassName * the selector/xpath query * @return the matching elements */ public final List<Element> select(final String aClassName) { final List<Element> result = new ArrayList<>(); iterate(this, new Observer() { @Override public void observe(Element anElement) { if ("*".equals(aClassName)) { result.add(anElement); } else { if (anElement.getClassName() != null && anElement.hasClassName(aClassName)) result.add(anElement); } } }); return result; }
From source file:com.bearsoft.gwt.ui.XElement.java
public final List<Element> selectByPrefix(final String aClassNamePrefix) { final List<Element> result = new ArrayList<>(); iterate(this, new Observer() { @Override/*w w w. j av a2s . co m*/ public void observe(Element anElement) { String classesNames = anElement.getClassName(); if (classesNames != null) { String[] classes = classesNames.split(" "); for (int i = 0; i < classes.length; i++) { if (classes[i].startsWith(aClassNamePrefix)) { result.add(anElement); break; } } } } }); return result; }
From source file:com.brazoft.foundation.gwt.client.ui.Widgets.java
License:Apache License
public static <W extends Widget> W setIcon(W widget, Icon icon, boolean insert) { Element element = widget.getElement(); String className = element.getClassName(); boolean white = mustBeWhiteIcon(className); Element i = ElementResolver.getElementByTagName(element, "i"); if (i == null) { i = ElementResolver.create("i"); if (insert) { widget.getElement().insertFirst(i); } else {/*from w ww . ja va 2 s .c o m*/ widget.getElement().appendChild(i); } } i.setClassName(icon.className(white)); return widget; }