Search in sources :

Example 16 with Element

use of com.google.gwt.user.client.Element in project rstudio by rstudio.

the class SliderBar method drawKnob.

/**
   * Draw the knob where it is supposed to be relative to the line.
   */
private void drawKnob() {
    // Abort if not attached
    if (!isAttached()) {
        return;
    }
    // Move the knob to the correct position
    Element knobElement = knobImage.getElement();
    int lineWidth = DOM.getElementPropertyInt(lineElement, "offsetWidth");
    int knobWidth = DOM.getElementPropertyInt(knobElement, "offsetWidth");
    int knobLeftOffset = (int) (lineLeftOffset + (getKnobPercent() * lineWidth) - (knobWidth / 2));
    knobLeftOffset = Math.min(knobLeftOffset, lineLeftOffset + lineWidth - (knobWidth / 2) - 1);
    DOM.setStyleAttribute(knobElement, "left", knobLeftOffset + "px");
}
Also used : Element(com.google.gwt.user.client.Element)

Example 17 with Element

use of com.google.gwt.user.client.Element in project rstudio by rstudio.

the class SliderBar method drawTicks.

/**
   * Draw the tick along the line.
   */
private void drawTicks() {
    // Abort if not attached
    if (!isAttached()) {
        return;
    }
    // Draw the ticks
    int lineWidth = DOM.getElementPropertyInt(lineElement, "offsetWidth");
    if (numTicks > 0) {
        // Create the ticks or make them visible
        for (int i = 0; i <= numTicks; i++) {
            Element tick = null;
            if (i < tickElements.size()) {
                tick = tickElements.get(i);
            } else {
                // Create the new tick
                tick = DOM.createDiv();
                DOM.setStyleAttribute(tick, "position", "absolute");
                DOM.setStyleAttribute(tick, "display", "none");
                DOM.appendChild(getElement(), tick);
                tickElements.add(tick);
            }
            if (enabled) {
                DOM.setElementProperty(tick, "className", "gwt-SliderBar-tick");
            } else {
                DOM.setElementProperty(tick, "className", "gwt-SliderBar-tick gwt-SliderBar-tick-disabled");
            }
            // Position the tick and make it visible
            DOM.setStyleAttribute(tick, "visibility", "hidden");
            DOM.setStyleAttribute(tick, "display", "");
            int tickWidth = DOM.getElementPropertyInt(tick, "offsetWidth");
            int tickLeftOffset = lineLeftOffset + (lineWidth * i / numTicks) - (tickWidth / 2);
            tickLeftOffset = Math.min(tickLeftOffset, lineLeftOffset + lineWidth - tickWidth);
            DOM.setStyleAttribute(tick, "left", tickLeftOffset + "px");
            DOM.setStyleAttribute(tick, "visibility", "visible");
        }
        // Hide unused ticks
        for (int i = (numTicks + 1); i < tickElements.size(); i++) {
            DOM.setStyleAttribute(tickElements.get(i), "display", "none");
        }
    } else {
        // Hide all ticks
        for (Element elem : tickElements) {
            DOM.setStyleAttribute(elem, "display", "none");
        }
    }
}
Also used : Element(com.google.gwt.user.client.Element)

Example 18 with Element

use of com.google.gwt.user.client.Element in project rstudio by rstudio.

the class SliderBar method drawLabels.

/**
   * Draw the labels along the line.
   */
private void drawLabels() {
    // Abort if not attached
    if (!isAttached()) {
        return;
    }
    // Draw the labels
    int lineWidth = DOM.getElementPropertyInt(lineElement, "offsetWidth");
    if (numLabels > 0) {
        // Create the labels or make them visible
        for (int i = 0; i <= numLabels; i++) {
            Element label = null;
            if (i < labelElements.size()) {
                label = labelElements.get(i);
            } else {
                // Create the new label
                label = DOM.createDiv();
                DOM.setStyleAttribute(label, "position", "absolute");
                DOM.setStyleAttribute(label, "display", "none");
                if (enabled) {
                    DOM.setElementProperty(label, "className", "gwt-SliderBar-label");
                } else {
                    DOM.setElementProperty(label, "className", "gwt-SliderBar-label-disabled");
                }
                DOM.appendChild(getElement(), label);
                labelElements.add(label);
            }
            // Set the label text
            double value = minValue + (getTotalRange() * i / numLabels);
            DOM.setStyleAttribute(label, "visibility", "hidden");
            DOM.setStyleAttribute(label, "display", "");
            DOM.setElementProperty(label, "innerHTML", formatLabel(value));
            // Move to the left so the label width is not clipped by the shell
            DOM.setStyleAttribute(label, "left", "0px");
            // Position the label and make it visible
            int labelWidth = DOM.getElementPropertyInt(label, "offsetWidth");
            int labelLeftOffset = lineLeftOffset + (lineWidth * i / numLabels) - (labelWidth / 2);
            labelLeftOffset = Math.min(labelLeftOffset, lineLeftOffset + lineWidth - labelWidth);
            labelLeftOffset = Math.max(labelLeftOffset, lineLeftOffset);
            DOM.setStyleAttribute(label, "left", labelLeftOffset + "px");
            DOM.setStyleAttribute(label, "visibility", "visible");
        }
        // Hide unused labels
        for (int i = (numLabels + 1); i < labelElements.size(); i++) {
            DOM.setStyleAttribute(labelElements.get(i), "display", "none");
        }
    } else {
        // Hide all labels
        for (Element elem : labelElements) {
            DOM.setStyleAttribute(elem, "display", "none");
        }
    }
}
Also used : Element(com.google.gwt.user.client.Element)

Example 19 with Element

use of com.google.gwt.user.client.Element in project perun by CESNET.

the class AdvancedStackPanel method insert.

public void insert(Widget w, int beforeIndex) {
    // header
    Element trh = DOM.createTR();
    Element tdh = DOM.createTD();
    DOM.appendChild(trh, tdh);
    DOM.appendChild(tdh, createHeaderElem());
    // body
    Element trb = DOM.createTR();
    Element tdb = DOM.createTD();
    DOM.appendChild(trb, tdb);
    // DOM indices are 2x logical indices; 2 dom elements per stack item
    beforeIndex = adjustIndex(w, beforeIndex);
    int effectiveIndex = beforeIndex * 2;
    // this ordering puts the body below the header
    DOM.insertChild(body, trb, effectiveIndex);
    DOM.insertChild(body, trh, effectiveIndex);
    // header styling
    setStyleName(tdh, DEFAULT_ITEM_STYLENAME, true);
    DOM.setElementPropertyInt(tdh, "__owner", hashCode());
    DOM.setElementProperty(tdh, "height", "1px");
    // body styling
    setStyleName(tdb, DEFAULT_STYLENAME + "Content", true);
    DOM.setElementProperty(tdb, "height", "100%");
    DOM.setElementProperty(tdb, "vAlign", "top");
    // Now that the DOM is connected, call insert (this ensures that
    // onLoad() is
    // not fired until the child widget is attached to the DOM).
    insert(w, tdb, beforeIndex, false);
    // Update indices of all elements to the right.
    updateIndicesFrom(beforeIndex);
    // Correct visible stack for new location.
    if (visibleStack == -1) {
        showStack(0);
    } else {
        setStackVisible(beforeIndex, false);
        if (visibleStack >= beforeIndex) {
            ++visibleStack;
        }
        // Reshow the stack to apply style names
        setStackVisible(visibleStack, true);
    }
}
Also used : Element(com.google.gwt.user.client.Element)

Example 20 with Element

use of com.google.gwt.user.client.Element in project perun by CESNET.

the class AdvancedStackPanel method setStackContentVisible.

private void setStackContentVisible(int index, boolean visible) {
    Element tr = DOM.getChild(body, (index * 2) + 1);
    UIObject.setVisible(tr, visible);
    getWidget(index).setVisible(visible);
}
Also used : Element(com.google.gwt.user.client.Element)

Aggregations

Element (com.google.gwt.user.client.Element)27 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)1 BlurHandler (com.google.gwt.event.dom.client.BlurHandler)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)1 FormValidator (cz.metacentrum.perun.webgui.client.applicationresources.FormValidator)1 RegistrarFormItemGenerator (cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator)1