use of elemental.html.HTMLCollection in project che by eclipse.
the class ContentAssistWidget method update.
private void update() {
int topVisibleItem = popupBodyElement.getScrollTop() / getItemHeight();
int topDOMItem = Math.max(0, topVisibleItem - (DOM_ITEMS_SIZE - getItemsPerPage()) / 2);
int bottomDOMItem = Math.min(getTotalItems() - 1, topDOMItem + DOM_ITEMS_SIZE - 1);
if (bottomDOMItem == getTotalItems() - 1) {
topDOMItem = Math.max(0, bottomDOMItem - DOM_ITEMS_SIZE + 1);
}
// resize the extra top row
setExtraRowHeight(getExtraTopRow(), topDOMItem);
// replace the DOM items with new content based on the scroll position
HTMLCollection nodes = listElement.getChildren();
for (int i = 0; i <= (bottomDOMItem - topDOMItem); i++) {
Element newNode = createProposalPopupItem(topDOMItem + i);
listElement.replaceChild(newNode, nodes.item(i + 1));
// check if the item is the selected
if (newNode.getId().equals(selectedElement.getId())) {
selectedElement = newNode;
selectedElement.setAttribute("selected", "true");
}
}
// resize the extra bottom row
setExtraRowHeight(getExtraBottomRow(), getTotalItems() - (bottomDOMItem + 1));
// ensure the keyboard focus is in the visible area
if (focused) {
getItem(topDOMItem + (bottomDOMItem - topDOMItem) / 2).focus();
}
}
use of elemental.html.HTMLCollection in project che by eclipse.
the class AnnotationGroupImpl method getMessages.
@Override
public List<String> getMessages() {
final List<String> result = new ArrayList<>();
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 String message = getMessage(dataset);
if (message != null) {
result.add(message);
}
}
}
return result;
}
use of elemental.html.HTMLCollection in project che by eclipse.
the class AnnotationGroupImpl method removeAnnotation.
@Override
public final void removeAnnotation(final Annotation annotation, int offset) {
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();
if (compareStrings(getMessage(dataset), annotation.getText()) && getOffset(dataset) == offset && getLayer(dataset) == annotation.getLayer() && compareStrings(getType(dataset), annotation.getType())) {
// we may not strictly be on the same annotation instance, but it is not discernible
asElemental().removeChild(element);
updateIconVisibility();
break;
}
}
}
}
use of elemental.html.HTMLCollection 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");
}
}
}
}
Aggregations