Search in sources :

Example 1 with Mappable

use of elemental.util.Mappable 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;
}
Also used : HTMLCollection(elemental.html.HTMLCollection) Mappable(elemental.util.Mappable) Node(elemental.dom.Node) DivElement(elemental.html.DivElement) Element(elemental.dom.Element) ArrayList(java.util.ArrayList) Element(elemental.dom.Element)

Example 2 with Mappable

use of elemental.util.Mappable 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;
            }
        }
    }
}
Also used : HTMLCollection(elemental.html.HTMLCollection) Mappable(elemental.util.Mappable) Node(elemental.dom.Node) DivElement(elemental.html.DivElement) Element(elemental.dom.Element) Element(elemental.dom.Element)

Example 3 with Mappable

use of elemental.util.Mappable 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");
            }
        }
    }
}
Also used : HTMLCollection(elemental.html.HTMLCollection) Mappable(elemental.util.Mappable) Node(elemental.dom.Node) DivElement(elemental.html.DivElement) Element(elemental.dom.Element) Element(elemental.dom.Element)

Aggregations

Element (elemental.dom.Element)3 Node (elemental.dom.Node)3 DivElement (elemental.html.DivElement)3 HTMLCollection (elemental.html.HTMLCollection)3 Mappable (elemental.util.Mappable)3 ArrayList (java.util.ArrayList)1