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

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

Introduction

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

Prototype

public void setWidth(double value, Unit unit) 

Source Link

Usage

From source file:gwt.material.design.addins.client.ui.MaterialCutOut.java

License:Apache License

public MaterialCutOut() {
    super(Document.get().createDivElement());
    focus = Document.get().createDivElement();
    getElement().appendChild(focus);/*w ww . j  ava2 s  . com*/

    setStyleName("material-cutout");
    Style style = getElement().getStyle();
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
    style.setPosition(Position.FIXED);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    style.setOverflow(Overflow.HIDDEN);
    style.setZIndex(10000);
    style.setDisplay(Display.NONE);

    focus.setClassName("material-cutout-focus");
    style = focus.getStyle();
    style.setProperty("content", "\'\'");
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(-1);
}

From source file:gwt.material.design.addins.client.ui.MaterialCutOut.java

License:Apache License

/**
 * Gets the computed background color, based on the backgroundColor CSS
 * class./*w  w w  . j  a v a 2  s .  co m*/
 */
private void setupComputedBackgroundColor() {
    // temp is just a widget created to evaluate the computed background
    // color
    MaterialWidget temp = new MaterialWidget(Document.get().createDivElement());
    temp.setBackgroundColor(backgroundColor);

    // setting a style to make it invisible for the user
    Style style = temp.getElement().getStyle();
    style.setPosition(Position.FIXED);
    style.setWidth(1, Unit.PX);
    style.setHeight(1, Unit.PX);
    style.setLeft(-10, Unit.PX);
    style.setTop(-10, Unit.PX);
    style.setZIndex(-10000);

    // adding it to the body (on Chrome the component must be added to the
    // DOM before getting computed values).
    String computed = ColorHelper.setupComputedBackgroundColor(backgroundColor);

    // convert rgb to rgba, considering the opacity field
    if (opacity < 1 && computed.startsWith("rgb(")) {
        computed = computed.replace("rgb(", "rgba(").replace(")", ", " + opacity + ")");
    }

    computedBackgroundColor = computed;
}

From source file:ilarkesto.gwt.client.desktop.ASidebarWidget.java

License:Open Source License

@Override
public final Updatable update() {
    container.clear();// ww  w  . ja v  a 2s.c om
    container.getElement().getStyle().setWidth(WIDTH - (Widgets.defaultSpacing * 2), Unit.PX);
    container.getElement().getStyle().setHeight(100, Unit.PCT);
    container.getElement().getStyle().setPosition(Position.FIXED);
    container.getElement().getStyle().setPadding(Widgets.defaultSpacing, Unit.PX);

    wrapper.getElement().setId("SidebarWidget");
    Style style = wrapper.getElement().getStyle();
    style.setWidth(WIDTH, Unit.PX);
    style.setHeight(100, Unit.PCT);
    style.setDisplay(Display.NONE);

    onUpdate();
    return this;
}

From source file:ilarkesto.gwt.client.desktop.fields.AEditableDropdownField.java

License:Open Source License

private RadioButton createRadioButton(boolean horizontal, String key, String label) {
    RadioButton radioButton = new RadioButton(getId(), label);
    radioButton.getElement().setId(getId() + "_radiobutton_");

    radioButton.setValue(isSelectedOptionKey(key));

    if (getEditVetoMessage() != null) {
        radioButton.setEnabled(false);//from   w  w  w.j a  v  a  2 s.com
        radioButton.setTitle(getEditVetoMessage());
    }

    Style style = radioButton.getElement().getStyle();
    style.setProperty("minWidth", "100px");
    style.setProperty("minHeight", "32px");
    style.setDisplay(Display.BLOCK);
    style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT);
    style.setWidth(horizontal ? getTextBoxWidth() / 2 : getTextBoxWidth(), Unit.PX);
    style.setMarginRight(Widgets.defaultSpacing, Unit.PX);
    if (NULL_KEY.equals(key)) {
        style.setColor(Colors.greyedText);
    }

    if (!isParentMultiField()) {
        radioButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                if (fieldEditorDialogBox == null)
                    return;
                fieldEditorDialogBox.submit();
            }
        });
    }
    radioButtons.put(key, radioButton);
    return radioButton;
}

From source file:ilarkesto.gwt.client.desktop.fields.AEditableDropdownField.java

License:Open Source License

private ListBox createListBox() {
    listBox = new ListBox();
    listBox.getElement().setId(getId() + "_listBox");
    Style style = listBox.getElement().getStyle();
    style.setWidth(getTextBoxWidth(), Unit.PX);
    style.setPadding(Widgets.defaultSpacing, Unit.PX);

    int i = 0;/* w ww.j  a v a  2 s  .c  o  m*/
    String selectedKey = getSelectedOptionKey();
    int selectedIndex = -1;
    if (!isMandatory()) {
        listBox.addItem("", NULL_KEY);
        selectedIndex = 0;
        i++;
    }

    EnumMapper<String, String> options = getOptions();
    Collection<String> keys = options.getKeys();
    for (String key : keys) {
        String label = options.getValueForKey(key);
        listBox.addItem(label, key);
        if (Utl.equals(selectedKey, key))
            selectedIndex = i;
        i++;
    }
    if (selectedIndex >= 0)
        listBox.setSelectedIndex(selectedIndex);
    if (getEditVetoMessage() == null) {
    } else {
        listBox.setEnabled(false);
        listBox.setTitle(getEditVetoMessage());
    }

    // listBox.addClickHandler(new ClickHandler() {
    //
    // @Override
    // public void onClick(ClickEvent event) {
    // if (fieldEditorDialogBox == null) return;
    // fieldEditorDialogBox.submit();
    // }
    // });

    if (keys.size() < 3) {
        listBox.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {
                if (fieldEditorDialogBox == null)
                    return;
                fieldEditorDialogBox.submit();
                // NativeEvent nat = event.getNativeEvent();
                // Log.TEST("onChange:", nat.getType(), nat.getRelatedEventTarget(),
                // nat.getCurrentEventTarget()
                // .getClass(), nat.getKeyCode(), nat.getButton(), nat.getCharCode());
            }
        });
    }

    listBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            onSelectionChanged();
        }

    });

    listBox.addKeyUpHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() != 13)
                return;
            if (fieldEditorDialogBox == null)
                return;
            fieldEditorDialogBox.submit();
        }
    });

    return listBox;
}

From source file:ilarkesto.gwt.client.desktop.fields.AEditableMultiSelectionField.java

License:Open Source License

private IsWidget createCheckboxesEditorWidget(Collection<String> optionKeys) {
    checkboxes = new LinkedHashMap<String, CheckBox>();

    boolean horizontal = isHorizontal();
    Panel panel = horizontal ? new FlowPanel() : new VerticalPanel();

    Collection<String> selectedKeys = getSelectedOptionKeys();

    int inRow = 0;

    for (String key : optionKeys) {
        String label = getTextForOption(getValueForKey(key));
        CheckBox checkBox = new CheckBox(label);
        checkBox.getElement().setId(getId() + "_checkbox_" + key);
        checkBox.setValue(selectedKeys.contains(key));
        if (getEditVetoMessage() == null) {
        } else {/*from  w  w  w  . j  a v a2 s  .  com*/
            checkBox.setEnabled(false);
            checkBox.setTitle(getEditVetoMessage());
        }
        updateStyle(checkBox);
        checkBox.addValueChangeHandler(new CheckboxChangeHandler(checkBox));
        if (horizontal) {
            Style style = checkBox.getElement().getStyle();
            style.setProperty("minWidth", "100px");
            style.setDisplay(Display.BLOCK);
            style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT);
            style.setWidth(220, Unit.PX);
            style.setMarginRight(Widgets.defaultSpacing, Unit.PX);
        }
        checkboxes.put(key, checkBox);
        panel.add(checkBox);
        inRow++;
        if (horizontal && inRow >= 3) {
            panel.add(new HTML("<br>"));
            inRow = 0;
        }
    }
    if (horizontal) {
        panel.add(Widgets.clear());
    }

    if (optionKeys.size() >= 10) {
        panel.add(new ActionButton(new SelectAllCheckboxesAction()));
        panel.add(new ActionButton(new DeselectAllCheckboxesAction()));
    }

    return panel;
}

From source file:ilarkesto.gwt.client.desktop.fields.AEditableTextBoxField.java

License:Open Source License

@Override
public AGoonTextBox createEditorWidget() {
    textBox = createTextBox();//from  w  w w. j av  a2 s  . c o  m
    Style style = textBox.getElement().getStyle();
    style.setWidth(getTextBoxWidth(), Unit.PX);
    style.setPadding(Widgets.defaultSpacing, Unit.PX);
    textBox.setMaxLength(getMaxLength());

    String value = getValue();
    if (value == null)
        value = getAlternateValueIfValueIsNull();
    textBox.setValue(value);

    textBox.getElement().setId(getId() + "_textBox");
    if (getEditVetoMessage() == null) {
        textBox.addKeyUpHandler(new EnterKeyUpHandler());
    } else {
        textBox.setEnabled(false);
        textBox.setTitle(getEditVetoMessage());
    }
    return textBox;
}

From source file:ilarkesto.gwt.client.desktop.Widgets.java

License:Open Source License

public static Widget verticalLine(int margin) {
    SimplePanel spacer = new SimplePanel();
    Style style = spacer.getElement().getStyle();
    style.setWidth(100, Unit.PCT);
    style.setHeight(1, Unit.PX);//from   w w w  . ja va  2 s.c om
    style.setBackgroundColor("#eeeeee");
    style.setMarginTop(margin, Unit.PX);
    style.setMarginBottom(margin, Unit.PX);
    return spacer;
}

From source file:ilarkesto.gwt.client.desktop.Widgets.java

License:Open Source License

public static Widget horizontalLine(int margin) {
    SimplePanel spacer = new SimplePanel();
    Style style = spacer.getElement().getStyle();
    style.setFloat(Float.LEFT);/*  w w  w  . j av a  2  s.  com*/
    style.setWidth(1, Unit.PX);
    style.setHeight(100, Unit.PCT);
    style.setBackgroundColor("#999999");
    style.setMarginLeft(margin, Unit.PX);
    style.setMarginRight(margin, Unit.PX);
    return spacer;
}

From source file:ilarkesto.gwt.client.desktop.Widgets.java

License:Open Source License

public static SimplePanel horizontalSpacer(int width) {
    SimplePanel spacer = new SimplePanel();
    Style style = spacer.getElement().getStyle();
    style.setWidth(width, Unit.PX);
    spacer.getElement().getStyle().setHeight(1, Unit.PX);
    spacer.getElement().getStyle().setFloat(Float.LEFT);
    return spacer;
}