Example usage for com.google.gwt.dom.client Style getBorderWidth

List of usage examples for com.google.gwt.dom.client Style getBorderWidth

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style getBorderWidth.

Prototype

public String getBorderWidth() 

Source Link

Usage

From source file:com.goodow.wave.client.wavepanel.blip.SetColor.java

License:Apache License

@Override
public void onBrowserEvent(final Event event) {
    if (DOM.eventGetType(event) == Event.ONCLICK) {
        if (changeElm == null) {
            Window.alert("changeElm is null!");
            return;
        }//from  w w w .j  ava  2s .  co  m

        NodeList<Element> aTags = changeElm.getElementsByTagName("span");
        Element aTag = aTags.getItem(1);
        Element elm = Element.as(event.getEventTarget());
        Style elmStyle = elm.getStyle();
        Style aTagStyle = aTag.getStyle();

        if (elm.getTitle().equals("White") || elm.getTitle().equals("20% Black")) {
            aTagStyle.setBackgroundColor(elmStyle.getBackgroundColor());
            aTagStyle.setColor("black");
            aTagStyle.setBorderStyle(BorderStyle.SOLID);
            aTagStyle.setBorderWidth(1, Unit.PX);
            aTagStyle.setBorderColor("black");
            aTagStyle.setTextDecoration(TextDecoration.NONE);
        } else {
            if (!aTagStyle.getBorderWidth().equals("")) {
                aTagStyle.clearBorderColor();
                aTagStyle.clearBorderStyle();
                aTagStyle.clearBorderWidth();
            }
            aTagStyle.setTextDecoration(TextDecoration.NONE);
            aTagStyle.setBackgroundColor(elmStyle.getBackgroundColor());
            aTagStyle.setColor("white");
        }
        // Window.alert("title:" + elm.getTitle() + ";color:" + elm.getStyle().getBackgroundColor());
    }
}

From source file:com.vaadin.client.ui.VComboBox.java

License:Apache License

/**
 * Calculates the width of the select if the select has undefined width.
 * Should be called when the width changes or when the icon changes.
 * <p>//  www.  jav  a 2  s .co m
 * For internal use only. May be removed or replaced in the future.
 */
public void updateRootWidth() {
    debug("VComboBox: updateRootWidth()");

    if (connector.isUndefinedWidth()) {

        /*
         * When the select has a undefined with we need to check that we are
         * only setting the text box width relative to the first page width
         * of the items. If this is not done the text box width will change
         * when the popup is used to view longer items than the text box is
         * wide.
         */
        int w = WidgetUtil.getRequiredWidth(this);

        if (dataReceivedHandler.isWaitingForInitialData() && suggestionPopupMinWidth > w) {
            /*
             * We want to compensate for the paddings just to preserve the
             * exact size as in Vaadin 6.x, but we get here before
             * MeasuredSize has been initialized.
             * Util.measureHorizontalPaddingAndBorder does not work with
             * border-box, so we must do this the hard way.
             */
            Style style = getElement().getStyle();
            String originalPadding = style.getPadding();
            String originalBorder = style.getBorderWidth();
            style.setPaddingLeft(0, Unit.PX);
            style.setBorderWidth(0, Unit.PX);
            style.setProperty("padding", originalPadding);
            style.setProperty("borderWidth", originalBorder);

            // Use util.getRequiredWidth instead of getOffsetWidth here

            int iconWidth = selectedItemIcon == null ? 0 : WidgetUtil.getRequiredWidth(selectedItemIcon);
            int buttonWidth = popupOpener == null ? 0 : WidgetUtil.getRequiredWidth(popupOpener);

            /*
             * Instead of setting the width of the wrapper, set the width of
             * the combobox. Subtract the width of the icon and the
             * popupopener
             */

            tb.setWidth(suggestionPopupMinWidth - iconWidth - buttonWidth + "px");
        }

        /*
         * Lock the textbox width to its current value if it's not already
         * locked. This can happen after setWidth("") which resets the
         * textbox width to "100%".
         */
        if (!tb.getElement().getStyle().getWidth().endsWith("px")) {
            int iconWidth = selectedItemIcon == null ? 0 : selectedItemIcon.getOffsetWidth();
            tb.setWidth(tb.getOffsetWidth() - iconWidth + "px");
        }
    }
}

From source file:com.vaadin.client.ui.VFilterSelect.java

License:Apache License

/**
 * Calculates the width of the select if the select has undefined width.
 * Should be called when the width changes or when the icon changes.
 * <p>// w  w  w  .  j a  v  a 2s .  c om
 * For internal use only. May be removed or replaced in the future.
 */
public void updateRootWidth() {
    ComponentConnector paintable = ConnectorMap.get(client).getConnector(this);

    if (paintable.isUndefinedWidth()) {

        /*
         * When the select has a undefined with we need to check that we are
         * only setting the text box width relative to the first page width
         * of the items. If this is not done the text box width will change
         * when the popup is used to view longer items than the text box is
         * wide.
         */
        int w = WidgetUtil.getRequiredWidth(this);

        if ((!initDone || currentPage + 1 < 0) && suggestionPopupMinWidth > w) {
            /*
             * We want to compensate for the paddings just to preserve the
             * exact size as in Vaadin 6.x, but we get here before
             * MeasuredSize has been initialized.
             * Util.measureHorizontalPaddingAndBorder does not work with
             * border-box, so we must do this the hard way.
             */
            Style style = getElement().getStyle();
            String originalPadding = style.getPadding();
            String originalBorder = style.getBorderWidth();
            style.setPaddingLeft(0, Unit.PX);
            style.setBorderWidth(0, Unit.PX);
            style.setProperty("padding", originalPadding);
            style.setProperty("borderWidth", originalBorder);

            // Use util.getRequiredWidth instead of getOffsetWidth here

            int iconWidth = selectedItemIcon == null ? 0 : WidgetUtil.getRequiredWidth(selectedItemIcon);
            int buttonWidth = popupOpener == null ? 0 : WidgetUtil.getRequiredWidth(popupOpener);

            /*
             * Instead of setting the width of the wrapper, set the width of
             * the combobox. Subtract the width of the icon and the
             * popupopener
             */

            tb.setWidth((suggestionPopupMinWidth - iconWidth - buttonWidth) + "px");

        }

        /*
         * Lock the textbox width to its current value if it's not already
         * locked
         */
        if (!tb.getElement().getStyle().getWidth().endsWith("px")) {
            int iconWidth = selectedItemIcon == null ? 0 : selectedItemIcon.getOffsetWidth();
            tb.setWidth((tb.getOffsetWidth() - iconWidth) + "px");
        }
    }
}