use of elemental.dom.Element in project che by eclipse.
the class Elements method injectJs.
public static void injectJs(String js) {
Element scriptElem = createElement("script");
scriptElem.setAttribute("language", "javascript");
scriptElem.setTextContent(js);
getBody().appendChild(scriptElem);
}
use of elemental.dom.Element in project che by eclipse.
the class Elements method replaceContents.
/**
* Replaces the contents of an Element with the specified ID, with a single
* element.
*
* @param id
* The ID of the Element that we will erase the contents of.
* @param with
* The element that we will attach to the element that we just
* erased the contents of.
*/
public static void replaceContents(String id, Element with) {
Element parent = getElementById(id);
replaceContents(parent, with);
}
use of elemental.dom.Element in project che by eclipse.
the class Tree method renderTree.
/**
* Renders the tree starting with the root node up until the specified depth.
* <p/>
* This will NOT restore any expansions. If you want to re-render the tree
* obeying previous expansions then,
*
* @param depth
* integer indicating how deep we should auto-expand. -1 means
* render the entire tree.
*/
public void renderTree(int depth) {
// Clear the current view.
Element rootElement = getView().getElement();
rootElement.setInnerHTML("");
rootElement.setAttribute("___depth", "0");
// If the root is not set, we have nothing to render.
D root = getModel().root;
if (root == null) {
return;
}
// Root is special in that we don't render a directory for it. Only its
// children.
List<D> children = getModel().dataAdapter.getChildren(root);
for (int i = 0, n = children.size(); i < n; i++) {
renderRecursive(rootElement, children.get(i), depth);
}
}
use of elemental.dom.Element in project che by eclipse.
the class Tree method getNodeFromElement.
/**
* Returns the tree node whose element is or contains the given element, or
* null if the given element cannot be matched to a tree node.
*/
public TreeNodeElement<D> getNodeFromElement(Element element) {
Css css = getModel().resources.treeCss();
Element treeNodeBody = CssUtils.getAncestorOrSelfWithClassName(element, css.treeNodeBody());
return treeNodeBody != null ? getView().getTreeNodeFromTreeNodeBody(treeNodeBody, css) : null;
}
use of elemental.dom.Element in project che by eclipse.
the class Tree method asWidget.
/** {@inheritDoc} */
@Override
public Widget asWidget() {
if (widget == null) {
widget = new HTML();
Element element = getView().getElement();
widget.getElement().appendChild((Node) element);
widget.getElement().getStyle().setOverflow(Style.Overflow.AUTO);
}
return widget;
}
Aggregations