use of elemental.dom.Element in project che by eclipse.
the class AnnotationGroupImpl method updateIconVisibility.
private void updateIconVisibility() {
int maxLayer = 0;
final HTMLCollection children = asElemental().getChildren();
for (int i = 0; i < children.length(); i++) {
final Node child = (Node) children.at(i);
if (child instanceof elemental.dom.Element) {
final elemental.dom.Element element = (elemental.dom.Element) child;
final Mappable dataset = element.getDataset();
final int layer = getLayer(dataset);
if (maxLayer < layer) {
maxLayer = layer;
}
}
}
for (int i = 0; i < children.length(); i++) {
final Node child = (Node) children.at(i);
if (child instanceof elemental.dom.Element) {
final elemental.dom.Element element = (elemental.dom.Element) child;
final Mappable dataset = element.getDataset();
final int layer = getLayer(dataset);
if (layer >= maxLayer) {
element.getStyle().removeProperty("display");
} else {
element.getStyle().setDisplay("none");
}
}
}
}
use of elemental.dom.Element in project che by eclipse.
the class ScrollbarSizeCalculator method createContainer.
private Element createContainer() {
Element container = Elements.createDivElement();
final int containerSize = 500;
CSSStyleDeclaration containerStyle = container.getStyle();
containerStyle.setWidth(containerSize, CSSStyleDeclaration.Unit.PX);
containerStyle.setHeight(containerSize, CSSStyleDeclaration.Unit.PX);
containerStyle.setPosition(CSSStyleDeclaration.Position.ABSOLUTE);
containerStyle.setLeft(-containerSize, CSSStyleDeclaration.Unit.PX);
containerStyle.setTop(-containerSize, CSSStyleDeclaration.Unit.PX);
Elements.getBody().appendChild(container);
return container;
}
use of elemental.dom.Element in project che by eclipse.
the class Tooltip method ensureContent.
/**
* Creates the dom for this tooltip's content.
* <p/>
* <code>
* <div class="tooltipPosition">
* <div class="tooltip tooltipAbove/Below/Left/Right">
* tooltipText
* <div class="tooltipTriangle"></div>
* </div>
* </div>
* </code>
*/
private void ensureContent() {
if (contentElement == null) {
contentElement = renderer.renderDom();
if (contentElement == null) {
// Guard against malformed renderers.
Log.warn(getClass(), "Renderer for tooltip returned a null content element");
contentElement = Elements.createDivElement();
contentElement.setTextContent("An empty Tooltip!");
}
if (title != null) {
// Insert a title if one is set.
Element titleElem = Elements.createElement("b");
titleElem.setTextContent(title);
Element breakElem = Elements.createBRElement();
contentElement.insertBefore(breakElem, contentElement.getFirstChild());
contentElement.insertBefore(titleElem, contentElement.getFirstChild());
}
// Set the maximum width.
setMaxWidth(maxWidth);
Elements.addClassName(css.tooltip(), contentElement);
Element triangle = Elements.createDivElement(css.triangle());
contentElement.appendChild(triangle);
setPositionStyle();
}
}
use of elemental.dom.Element in project che by eclipse.
the class SimpleList method attachEventHandlers.
private void attachEventHandlers() {
getView().addEventListener(Event.CLICK, new EventListener() {
@Override
public void handleEvent(Event evt) {
Element listItemElem = CssUtils.getAncestorOrSelfWithClassName((Element) evt.getTarget(), css.listItem());
if (listItemElem == null) {
Log.warn(SimpleList.class, "Unable to find an ancestor that was a list item for a click on: ", evt.getTarget());
return;
}
ListItem<M> listItem = ListItem.cast(listItemElem);
eventDelegate.onListItemClicked(listItem, listItem.getData());
}
}, false);
getView().addEventListener(Event.DBLCLICK, new EventListener() {
@Override
public void handleEvent(Event evt) {
Element listItemElem = CssUtils.getAncestorOrSelfWithClassName((Element) evt.getTarget(), css.listItem());
if (listItemElem == null) {
Log.warn(SimpleList.class, "Unable to find an ancestor that was a list item for a click on: ", evt.getTarget());
return;
}
ListItem<M> listItem = ListItem.cast(listItemElem);
eventDelegate.onListItemDoubleClicked(listItem, listItem.getData());
}
}, false);
}
use of elemental.dom.Element in project che by eclipse.
the class DomUtils method calculateElementOffset.
/**
* Returns an offset to the top-left of a child element relative to the
* top-left of an ancestor element, optionally including any scroll top or
* left in elements from the ancestor (inclusive) to the child (exclusive).
*
* @param ancestorElement
* optional, if null the offset from the top-left of
* the page will be given. Should not be the childElement.
*/
@Deprecated
public static Offset calculateElementOffset(Element childElement, Element ancestorElement, boolean includeScroll) {
Offset offset = new Offset();
Element element = childElement;
for (; element.getOffsetParent() != null && element != ancestorElement; element = element.getOffsetParent()) {
offset.top += element.getOffsetTop();
offset.left += element.getOffsetLeft();
if (!includeScroll) {
offset.top -= element.getOffsetParent().getScrollTop();
offset.left -= element.getOffsetParent().getScrollLeft();
}
}
return offset;
}
Aggregations