Example usage for com.google.gwt.user.client.ui Widget setWidth

List of usage examples for com.google.gwt.user.client.ui Widget setWidth

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget setWidth.

Prototype

public void setWidth(String width) 

Source Link

Document

Sets the object's width.

Usage

From source file:org.kaaproject.avro.ui.gwt.client.widget.AbstractFieldWidget.java

License:Apache License

protected Widget constructWidget(FormField field, List<HandlerRegistration> handlerRegistrations) {
    Widget widget = null;

    if ((readOnly || field.isReadOnly()) && !field.getFieldType().isComplex()) {
        if (field.getFieldType() == FieldType.BOOLEAN) {
            widget = constructBooleanWidget((BooleanField) field, handlerRegistrations);
        } else {//from  w  ww  .j a  va 2  s  .com
            String text = extractStringValue(field);
            HTML textLabel = new HTML("&nbsp;");
            textLabel.setHeight(FULL_WIDTH);
            textLabel.setStyleName(style.secondaryLabel());
            if (!isBlank(text)) {
                textLabel.setText(text);
            }
            widget = textLabel;
        }
    } else {
        switch (field.getFieldType()) {
        case STRING:
            widget = constructStringWidget((StringField) field, handlerRegistrations);
            break;
        case BYTES:
            widget = constructBytesWidget((BytesField) field, handlerRegistrations);
            break;
        case FIXED:
            widget = constructFixedWidget((FixedField) field, handlerRegistrations);
            break;
        case INT:
            widget = constructIntegerWidget((IntegerField) field, handlerRegistrations);
            break;
        case FLOAT:
            widget = constructFloatWidget((FloatField) field, handlerRegistrations);
            break;
        case DOUBLE:
            widget = constructDoubleWidget((DoubleField) field, handlerRegistrations);
            break;
        case LONG:
            widget = constructLongWidget((LongField) field, handlerRegistrations);
            break;
        case ENUM:
            widget = constructEnumWidget((EnumField) field, handlerRegistrations);
            break;
        case BOOLEAN:
            widget = constructBooleanWidget((BooleanField) field, handlerRegistrations);
            break;
        case ARRAY:
            widget = constructArrayWidget((ArrayField) field, handlerRegistrations);
            break;
        case RECORD:
            throw new RuntimeException("Can't create record widget inside table.");
        case UNION:
            widget = constructUnionWidget((UnionField) field, handlerRegistrations);
            break;
        case TYPE_REFERENCE:
            widget = constructFqnReferenceWidget((FqnReferenceField) field, handlerRegistrations);
            break;
        case ALERT:
            widget = constructAlertWidget((AlertField) field, handlerRegistrations);
            break;
        case VERSION:
            widget = constructVersionWidget((VersionField) field, handlerRegistrations);
            break;
        case DEPENDENCIES:
            widget = constructDependenciesWidget((DependenciesField) field, handlerRegistrations);
            break;
        }
    }
    widget.setWidth(FULL_WIDTH);
    return widget;
}

From source file:org.kaaproject.avro.ui.gwt.client.widget.FormPopup.java

License:Apache License

void maybeUpdateSizeInternal() {
    Widget w = super.getWidget();
    if (w != null) {
        if (desiredHeight != null) {
            w.setHeight(desiredHeight);/*from  www  .  j a v a 2  s.c o  m*/
        }
        if (desiredWidth != null) {
            w.setWidth(desiredWidth);
        }
    }
}

From source file:org.kie.guvnor.guided.rule.client.widget.FromCompositeFactPatternWidget.java

License:Apache License

protected Widget addRemoveButton(Widget w, ClickHandler listener) {
    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();

    final Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
    remove.setAltText(Constants.INSTANCE.RemoveThisBlockOfData());
    remove.setTitle(Constants.INSTANCE.RemoveThisBlockOfData());
    remove.addClickHandler(listener);/*from  w w  w. java2  s . c  o  m*/

    horiz.setWidth("100%");
    w.setWidth("100%");

    horiz.add(w);
    if (!this.readOnly) {
        horiz.add(remove);
    }
    return horiz;
}

From source file:org.kie.uberfirebootstrap.client.widgets.Popup.java

License:Apache License

@Override
public void show() {

    clear();/*from ww w.j av  a 2 s.  c  o m*/

    if (afterShowEvent != null) {
        afterShowEvent.execute();
    }

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);

    this.titleBar = new PopupTitleBar(getTitle());

    this.titleBar.closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            hide();
            if (afterCloseEvent != null) {
                afterCloseEvent.execute();
            }
        }
    });
    this.titleBar.addMouseDownHandler(new MouseDownHandler() {

        public void onMouseDown(MouseDownEvent event) {
            dragged = true;
            dragStartX = event.getRelativeX(getElement());
            dragStartY = event.getRelativeY(getElement());
            DOM.setCapture(titleBar.getElement());
        }
    });
    this.titleBar.addMouseMoveHandler(new MouseMoveHandler() {

        public void onMouseMove(MouseMoveEvent event) {
            if (dragged) {
                setPopupPosition(event.getClientX() - dragStartX, event.getClientY() - dragStartY);
            }
        }
    });
    this.titleBar.addMouseUpHandler(new MouseUpHandler() {

        public void onMouseUp(MouseUpEvent event) {
            dragged = false;
            DOM.releaseCapture(titleBar.getElement());
        }
    });

    verticalPanel.add(titleBar);

    Widget content = getContent();

    content.setWidth("100%");
    verticalPanel.add(content);
    add(verticalPanel);

    add(createKeyListeningFocusPanel(verticalPanel));

    super.show();

    focusFirstWidget(content);

    if (!fixedLocation) {
        center();
    }
}

From source file:org.kuali.student.core.statement.ui.client.widgets.table.SectionTable.java

License:Educational Community License

public void addColumn(Object columnHeading) {
    Widget widget = createCellWidget(columnHeading);
    int columnIndex = getColumnCount();

    widget.setWidth("100%");
    // widget.addStyleName("");

    setWidget(HEADER_ROW, columnIndex, widget);

    // getCellFormatter().addStyleName(HEADER_ROW, columnIndex, "ks-table-th");
    // getRowFormatter().addStyleName(HEADER_ROW, "ks-table-th");
    // getCellFormatter().setStyleName(HEADER_ROW, columnIndex, "");

}

From source file:org.mindinformatics.gwt.domeo.plugins.annotation.micropubs.ui.form.FMicroPublicationForm2.java

License:Apache License

@Override
public void resized() {
    if (_manager.getContainerWidth() > 0 && _manager.getContainerWidth() < 1290) {
        if (panelBelow.getWidget() == null) {
            panelBelow.setWidget(panelRight.getWidget());
        }/*from   ww  w.j a v a  2s .c o  m*/

        tabPanel.setWidth(Math.max(464, (Window.getClientWidth() - 174)) + "px");
        tabPanel.setHeight("120px");
        evidenceTabs.setWidth(Math.max(464, (Window.getClientWidth() - 174)) + "px");

        resizeEvidenceTab(true);

        statementBody.setWidth(Math.max(464, (Window.getClientWidth() - 190)) + "px");
        statementBody.setHeight("54px");

        scrollContainer.setSize(Math.max(740, (Window.getClientWidth() - 154)) + "px",
                (Window.getClientHeight() - 295) + "px");
        leftColumnPanel.setWidth(Math.max(464, (Window.getClientWidth() - 174)) + "px");
        leftColumnContainer.setCellWidth(leftColumnPanel,
                Math.max(464, (Window.getClientWidth() - 174)) + "px");

        tabBar.setWidth(Math.max(464, (Window.getClientWidth() - 174)) + "px");
        rightColumn.setWidth(Math.max(464, (Window.getClientWidth() - 174)) + "px");
        for (Widget tab : tabs) {
            //if(tab instanceof IResizable) ((IResizable)tab).resized();
            tab.setWidth(Math.max(464, (Window.getClientWidth() - 174)) + "px");
        }
    } else {
        if (panelRight.getWidget() == null) {
            panelRight.setWidget(panelBelow.getWidget());
        }

        tabPanel.setWidth("464px");
        tabPanel.setHeight("180px");

        resizeEvidenceTab(false);

        statementBody.setWidth("450px");
        statementBody.setHeight("110px");

        scrollContainer.setSize(Math.max(464, (Window.getClientWidth() - 154)) + "px",
                (Window.getClientHeight() - 295) + "px");
        leftColumnPanel.setWidth("464px");
        leftColumnContainer.setCellWidth(leftColumnPanel, "464px");

        tabBar.setWidth(Math.min(900, (Window.getClientWidth() - 616)) + "px");
        rightColumn.setWidth(Math.min(900, (Window.getClientWidth() - 616)) + "px");
        for (Widget tab : tabs) {
            //if(tab instanceof IResizable) ((IResizable)tab).resized();
            tab.setWidth(Math.min(900, (Window.getClientWidth() - 616)) + "px");
        }
    }

    buttonsPanelSpacer.setWidth(Math.max(0, (_manager.getContainerWidth() - 300)) + "px");
    buttonsPanel.setWidth(Math.max(0, (_manager.getContainerWidth() - 320)) + "px");
    headerPanel.setCellWidth(buttonsPanelSpacer, Math.max(0, (_manager.getContainerWidth() - 300)) + "px");
}

From source file:org.obiba.opal.web.gwt.app.client.ui.TabDeckPanel.java

License:Apache License

/**
 * Setup the container around the widget.
 *//*w  ww .j  a  va 2 s  . c om*/
private void finishWidgetInitialization(Element container, Widget w) {
    UIObject.setVisible(container, false);
    DOM.setStyleAttribute(container, "height", "100%");

    // Set 100% by default.
    Element element = w.getElement();
    if ("".equals(DOM.getStyleAttribute(element, "width"))) {
        w.setWidth("100%");
    }
    if ("".equals(DOM.getStyleAttribute(element, "height"))) {
        w.setHeight("100%");
    }

    // Issue 2510: Hiding the widget isn't necessary because we hide its
    // wrapper, but it's in here for legacy support.
    w.setVisible(false);
}

From source file:org.onecmdb.ui.gwt.toolkit.client.view.table.CITablePanel.java

License:Open Source License

protected void reload() {
    loadListenerCollection.fireOnLoadStart(this);

    this.control.getRows(new AsyncCallback() {

        public void onFailure(Throwable caught) {
            loadListenerCollection.fireOnLoadFailure(CITablePanel.this, caught);
        }//from ww w .j  a  v  a  2  s .co  m

        public void onSuccess(Object result) {
            if (result instanceof List) {
                List rows = (List) result;
                Integer firstItem = control.getFirstItem();
                int rowIndex = 1;
                if (firstItem != null) {
                    rowIndex = firstItem.intValue();
                    rowIndex++;
                }
                System.out.println("ROW COUNT=" + rows.size());
                for (int row = 0; row < rows.size(); row++) {
                    Object rowData = rows.get(row);
                    setText(row + 1, 0, "" + rowIndex);
                    rowIndex++;
                    if (((row + 1) % 2) == 0) {
                        getRowFormatter().setStyleName(row + 1, STYLE_ROW_EVEN);
                    } else {
                        getRowFormatter().setStyleName(row + 1, STYLE_ROW_ODD);
                    }
                    getCellFormatter().setStyleName(row + 1, 0, STYLE_HEADER);
                    if (rowData instanceof List) {
                        List cols = (List) rowData;
                        for (int col = 1; col < (cols.size() + 1); col++) {
                            Object colObject = cols.get(col - 1);
                            Widget widget = render.getColumnWidget(colObject);

                            if (widget != null) {
                                widget.setWidth("100%");
                                widget.setStyleName(STYLE_CELL);
                                if (widget instanceof IBaseField) {
                                    setWidget(row + 1, col, ((IBaseField) widget).getBaseField());
                                } else {
                                    setWidget(row + 1, col, widget);
                                }
                            } else {
                                setText(row + 1, col, "");
                            }
                        }
                    }
                }

                // Remove not visible rows.
                for (int row = (control.getMaxResult().intValue() + 1); row > rows.size(); row--) {
                    if (getRowCount() > row) {
                        removeRow(row);
                    }
                }
            }
            loadListenerCollection.fireOnLoadComplete(CITablePanel.this);
        }
    });

}

From source file:org.openelis.gwt.widget.table.TableColumn.java

License:Open Source License

public Widget getDisplayWidget(TableDataRow row) {
    TableDataCell cell = new TableDataCell(null);
    if (columnIndex < row.cells.size())
        cell = row.cells.get(columnIndex);
    Widget wid = null;
    Object val = null;
    if (colWidget instanceof CheckBox) {
        wid = new CheckBoxContainer();
        IconContainer icon = new IconContainer();
        if (CheckBox.CHECKED.equals(cell.getValue()))
            icon.setStyleName(CheckBox.CHECKED_STYLE);
        else if (controller.queryMode && cell.getValue() == null)
            icon.setStyleName(CheckBox.UNKNOWN_STYLE);
        else/*  w ww  .  ja  va2s. c  om*/
            icon.setStyleName(CheckBox.UNCHECKED_STYLE);
        setAlign(HasHorizontalAlignment.ALIGN_CENTER);
        ((AbsolutePanel) wid).add(icon);
        DOM.setStyleAttribute(wid.getElement(), "align", "center");
        wid.setWidth((currentWidth) + "px");
    } else if (colWidget instanceof PercentBar) {
        PercentBar newBar = new PercentBar();
        newBar.setColors(((PercentBar) colWidget).getColors());
        newBar.setWidth(currentWidth + "px");
        newBar.setBarWidth(((PercentBar) colWidget).getBarWidth());
        newBar.setPercent((Double) cell.getValue());
        return newBar;
    } else if (colWidget instanceof TableImage) {
        if (controller.queryMode)
            return new Label("");
        TableImage newImg = new TableImage();
        newImg.setStyleName((String) cell.getValue());
        setAlign(HasHorizontalAlignment.ALIGN_CENTER);
        return newImg;
    } else {
        if (colWidget instanceof AutoComplete) {
            if (controller.queryMode) {
                val = cell.getValue();
                if (val == null)
                    val = "";
            } else {
                TableDataRow vrow = (TableDataRow) cell.getValue();
                if (vrow != null)
                    ((AutoComplete) colWidget).setSelection(vrow);
                else
                    ((AutoComplete) colWidget).setSelection(null, "");
                val = ((AutoComplete) colWidget).getTextBoxDisplay();
            }
        } else if (colWidget instanceof Dropdown) {
            if (cell.getValue() instanceof ArrayList)
                ((Dropdown) colWidget).setSelectionKeys((ArrayList<Object>) cell.getValue());
            else
                ((Dropdown) colWidget).setSelection(cell.getValue());
            val = ((Dropdown) colWidget).getTextBoxDisplay();
        } else if (colWidget instanceof CalendarLookUp && ((CalendarLookUp) colWidget).getField().queryMode) {
            val = ((HasField) colWidget).getField().queryString;
        } else {
            if (cell.getValue() instanceof ArrayList) {
                if (((ArrayList) cell.getValue()).size() > 0)
                    ((HasField) colWidget).setFieldValue(((ArrayList) cell.getValue()).get(0).toString());
                else
                    ((HasField) colWidget).setFieldValue("");
            } else
                ((HasField) colWidget).setFieldValue(cell.getValue());
        }
        if (val == null) {
            if (((HasField) colWidget).getField().queryMode)
                val = ((HasField) colWidget).getField().queryString;
            else
                val = ((HasField) colWidget).getFieldValue();
        }
        Label label = new Label("");
        label.setStyleName("ScreenLabel");
        if (colWidget instanceof Label)
            label.setStyleName(colWidget.getStyleName());
        if (val != null) {
            if (colWidget instanceof CalendarLookUp) {
                if (((HasField) colWidget).getField().queryMode)
                    label.setText(((HasField) colWidget).getField().queryString);
                else
                    label.setText((((CalendarLookUp) colWidget).getField().format()));
            } else if (colWidget instanceof AutoComplete && controller.queryMode) {
                label.setText((String) val);
            } else if (colWidget instanceof DropdownWidget) {
                label.setText(((DropdownWidget) colWidget).getTextBoxDisplay());
            } else if (colWidget instanceof TextBoxBase) {
                if (((HasField) colWidget).getField().queryMode)
                    label.setText(((HasField) colWidget).getField().queryString);
                else
                    label.setText(((TextBoxBase) colWidget).getText());
            } else if (colWidget instanceof Label)
                label.setText(((Label) colWidget).getText());
        }
        label.setWordWrap(false);
        wid = label;
        wid.setWidth((currentWidth) + "px");
    }
    setExceptions(wid, cell.exceptions);
    wid.addStyleName("TableWidget");
    return wid;
}

From source file:org.openelis.gwt.widget.table.TableColumn.java

License:Open Source License

public Widget getWidgetEditor(TableDataRow row) {
    TableDataCell cell = new TableDataCell(null);
    if (columnIndex < row.cells.size())
        cell = row.cells.get(columnIndex);
    Widget editor = colWidget;
    if (colWidget instanceof CheckBox) {
        CheckBoxContainer ap = new CheckBoxContainer();
        ((CheckBox) editor).setValue((String) cell.getValue());
        ap.setWidth((currentWidth) + "px");
        ap.add(editor);//w w  w .  j a va 2s. c o  m
        return ap;
    }
    if (colWidget instanceof PercentBar) {
        if (controller.queryMode)
            return new Label("");
        PercentBar newBar = (PercentBar) colWidget;
        newBar.setWidth(currentWidth + "px");
        newBar.setPercent((Double) cell.getValue());
        HTML html = new HTML(DOM.getInnerHTML(newBar.getElement()));
        html.setWidth(currentWidth + "px");
        return html;
    }
    if (colWidget instanceof TableImage) {
        if (controller.queryMode)
            return new Label("");
        TableImage newImg = new TableImage();
        newImg.setStyleName((String) cell.getValue());
        return newImg;
    }
    editor = colWidget;
    editor.setWidth((currentWidth) + "px");
    if (colWidget instanceof AutoComplete) {
        if (controller.queryMode) {
            ((AutoComplete) colWidget).textbox.setText((String) cell.getValue());
        } else {
            TableDataRow vrow = (TableDataRow) cell.getValue();
            if (vrow != null)
                ((AutoComplete) colWidget).setSelection(vrow);
            else
                ((AutoComplete) colWidget).setSelection(null, "");
        }
    } else if (colWidget instanceof Dropdown) {
        if (cell.getValue() instanceof ArrayList)
            ((Dropdown) colWidget).setSelectionKeys((ArrayList<Object>) cell.getValue());
        else
            ((Dropdown) colWidget).setSelection(cell.getValue());
    } else if (colWidget instanceof CalendarLookUp && ((CalendarLookUp) colWidget).getField().queryMode) {
        // do nothing;
    } else
        ((HasField) editor).setFieldValue(cell.getValue());

    ((HasField) editor).clearExceptions();
    setExceptions(editor, cell.exceptions);
    editor.addStyleName("TableWidget");
    return editor;
}