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

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

Introduction

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

Prototype

public void addStyleName(String style) 

Source Link

Document

Adds a secondary or dependent style name to this object.

Usage

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

License:Open Source License

public void focusOrRemoveLastItem() {
    if (getWidgetCount() > 0) {
        Widget lastItem = getWidget(getWidgetCount() - 1);
        if (lastItem.getStyleName().contains("focus")) {
            removeItem((ListItem) lastItem);
        } else {// ww  w .ja v  a 2  s.com
            lastItem.addStyleName("focus");
        }
    }
}

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

License:Open Source License

public void addProperty(Widget key, Widget value, int column, int span) {
    int numRows = innerTable.getRowCount();
    int col = 2 * column;
    int row = col == 0 ? numRows : numRows - 1;
    if (key != null) {
        key.removeFromParent();//ww w  . jav  a2 s  .  c  om
        innerTable.setWidget(row, col, key);
        if (!Strings.isNullOrEmpty(keyStyleNames)) {
            innerTable.getFlexCellFormatter().setStyleName(row, col, keyStyleNames);
        }
        key.addStyleName("property-key");
    }

    if (value != null) {
        value.removeFromParent();
        innerTable.setWidget(row, col + 1, value);
        if (!Strings.isNullOrEmpty(valueStyleNames)) {
            innerTable.getFlexCellFormatter().setStyleName(row, col + 1, valueStyleNames);
        }
        if (span > 1) {
            innerTable.getFlexCellFormatter().setColSpan(row, col + 1, span + 1);
        }
        value.addStyleName("property-value");
    }
}

From source file:org.obiba.opal.web.gwt.app.client.view.ItemSelectorView.java

License:Open Source License

@Override
public void setItemInputDisplay(ItemInputDisplay itemInputDisplay) {
    this.itemInputDisplay = itemInputDisplay;

    // Add a row for the input widget.
    itemGrid.resize(1, 1);// w  ww.  j a  v a2 s  .  c om

    FlowPanel itemWidget = new FlowPanel();
    Widget itemInputWidget = itemInputDisplay.asWidget();
    itemInputWidget.addStyleName("inline-block");
    itemWidget.add(itemInputWidget);

    // Put an "add" button in the second column.
    Button addWidget = createAddWidget();
    addWidget.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            addItemAndClear();
        }
    });
    addWidget.addStyleName("small-indent neg-top-margin");
    itemWidget.add(addWidget);

    // Add the input widget in the first column.
    itemGrid.setWidget(itemGrid.getRowCount() - 1, 0, itemWidget);

    // Put the Grid in a FlowPanel (so that it doesn't expand to fill its parent) and set that as the widget.
    FlowPanel container = new FlowPanel();
    container.add(itemGrid);
    widget = container;

    setEnterKeyHandler();
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.ResultsTablePresenter.java

License:Apache License

private void constructItemNavigationPanel(List<TimedLocalSearchResult> entries) {

    int totalSize = _model.getTotalSize();
    int pageSize = _model.getPageSize();
    int pageIndex = _model.getPageIndex();
    int totalPages = (totalSize + 9) / pageSize;
    int fromIndex = pageIndex * pageSize + 1;
    int toIndex = fromIndex + entries.size() - 1;

    if (totalPages <= 1)
        return;//from   w  ww  .  j  a v a 2  s  .  co m

    Grid elements = new Grid(1, 3);
    elements.addStyleName(_css.ResultsTableWidgetNavigationWidget());
    String itemCountStyle = "ItemCount";
    DivWidget itemCount = new DivWidget("<span class=\"" + itemCountStyle + "\">" + fromIndex
            + "</span> to <span class=\"" + itemCountStyle + "\">" + toIndex + "</span> of <span class=\""
            + itemCountStyle + "\">" + totalSize + "</span>");
    itemCount.addStyleName(_css.ItemCountPanel());
    elements.setWidget(0, 0, itemCount);

    FlowPanel pagesPanel = new FlowPanel();
    pagesPanel.addStyleName(_css.PagesPanel());
    pagesPanel.add(new SpanWidget("Go to page "));

    int lastPage = -1;

    for (int i = 0; i < totalPages; i++) {
        final int pIndex = i;

        boolean display = (i == 0) || (i == totalPages - 1) || (Math.abs(i - pageIndex) < 3);

        if (display) {

            if (lastPage != -1) {
                String value = pIndex - lastPage == 1 ? "|" : "...";
                pagesPanel.add(new SpanWidget(value));
            }

            String label = Integer.toString(pIndex + 1);
            Widget page = (i == pageIndex) ? new SpanWidget(label) : new Anchor(label);
            pagesPanel.add(page);
            page.addStyleName(_css.PageCount());
            if (i == pageIndex) {
                page.addStyleName(_css.CurrentPage());
            } else {
                ((Anchor) page).addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent arg0) {
                        _model.setPageIndex(pIndex);
                    }
                });
            }

            lastPage = pIndex;
        }
    }
    elements.setWidget(0, 1, pagesPanel);

    FlowPanel prevNextPagePanel = new FlowPanel();
    prevNextPagePanel.addStyleName(_css.PrevNextPanel());

    if (pageIndex > 0) {
        Anchor prev = new Anchor("Previous");
        prevNextPagePanel.add(prev);
        if (pageIndex > 0) {
            prev.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent arg0) {
                    int pi = _model.getPageIndex();
                    _model.setPageIndex(pi - 1);
                }
            });
        }
    }

    if (pageIndex > 0 && pageIndex < totalPages - 1)
        prevNextPagePanel.add(new SpanWidget("|"));

    if (pageIndex < totalPages - 1) {
        Anchor next = new Anchor("Next");
        prevNextPagePanel.add(next);
        if (pageIndex + 1 < totalPages) {
            next.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent arg0) {
                    int pi = _model.getPageIndex();
                    _model.setPageIndex(pi + 1);
                }
            });
        }
    }

    elements.setWidget(0, 2, prevNextPagePanel);

    _tablePanel.add(elements);
}

From source file:org.opencms.acacia.client.CmsButtonBarHandler.java

License:Open Source License

/**
 * Sets the button bar visibility.<p>
 *
 * @param buttonBar the button bar//from  w w  w .  j a v a  2  s  . com
 * @param visible <code>true</code> to show the button bar
 */
private void setButtonBarVisibility(Widget buttonBar, boolean visible) {

    String hoverStyle = I_CmsLayoutBundle.INSTANCE.form().hoverButton();
    if (visible) {
        buttonBar.addStyleName(hoverStyle);
    } else {
        buttonBar.removeStyleName(hoverStyle);
    }
    if (buttonBar instanceof CmsInlineEntityWidget) {
        ((CmsInlineEntityWidget) buttonBar).setContentHighlightingVisible(visible);
    }
    if (buttonBar.getParent() instanceof CmsInlineEntityWidget) {
        ((CmsInlineEntityWidget) buttonBar.getParent()).setContentHighlightingVisible(visible);
    }
}

From source file:org.opencms.acacia.client.CmsValueFocusHandler.java

License:Open Source License

/**
 * Hides all help bubbles.<p>//  ww w  .j a v a2s .  c o m
 *
 * @param formPanel the form panel
 * @param hide <code>true</code> to hide the help bubbles
 */
public void hideHelpBubbles(Widget formPanel, boolean hide) {

    if (hide) {
        formPanel.addStyleName(I_CmsLayoutBundle.INSTANCE.form().hideHelpBubbles());
    } else {
        formPanel.removeStyleName(I_CmsLayoutBundle.INSTANCE.form().hideHelpBubbles());
    }
}

From source file:org.opencms.ade.containerpage.client.ui.CmsSmallElementsHandler.java

License:Open Source License

/**
 * Prepares a small element.<p>//  ww w  . ja  v  a2s  .c  o  m
 *
 * @param widget the small element
 */
public void prepareSmallElement(Widget widget) {

    m_hasSmallElements = true;
    widget.addStyleName(org.opencms.ade.containerpage.client.ui.css.I_CmsLayoutBundle.INSTANCE
            .containerpageCss().smallElement());

}

From source file:org.opencms.ade.containerpage.client.ui.groupeditor.A_CmsGroupEditor.java

License:Open Source License

/**
 * Adds an input field with the given label to the dialog.<p>
 *
 * @param label the label//from w w w  . j ava  2 s  . c o m
 * @param inputWidget the input widget
 */
protected void addInputField(String label, Widget inputWidget) {

    FlowPanel row = new FlowPanel();
    row.setStyleName(I_CmsLayoutBundle.INSTANCE.groupcontainerCss().inputRow());
    CmsLabel labelWidget = new CmsLabel(label);
    labelWidget.setStyleName(I_CmsLayoutBundle.INSTANCE.groupcontainerCss().inputLabel());
    row.add(labelWidget);
    inputWidget.addStyleName(I_CmsLayoutBundle.INSTANCE.groupcontainerCss().inputBox());
    row.add(inputWidget);
    m_dialogContent.add(row);
}

From source file:org.opencms.ade.sitemap.client.CmsModelPageTreeItem.java

License:Open Source License

/**
 * Creates the list item widget for the given folder.<p>
 *
 * @param modelPage the model page bean/*from ww  w.  j  a v a2s  .c o m*/
 *
 * @return the list item widget
 */
private CmsListItemWidget createListWidget(final CmsModelPageEntry modelPage) {

    CmsListItemWidget result = new CmsModelPageListItemWidget(modelPage.getListInfoBean());
    if (modelPage.isDefault()) {
        Widget label = result.getShortExtraInfoLabel();
        label.addStyleName(I_CmsInputLayoutBundle.INSTANCE.inputCss().subtitleSuffix());
        result.setExtraInfo("(*)");
    }
    result.setIcon(CmsIconUtil.getResourceIconClasses(
            m_isModelGroup ? CmsGwtConstants.TYPE_MODELGROUP_PAGE : CmsGwtConstants.TYPE_MODELPAGE,
            modelPage.getRootPath(), false));
    if (m_isModelGroup || CmsEditModelPageMenuEntry.checkVisible(modelPage.getStructureId())) {
        result.addIconClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {

                CmsEditModelPageMenuEntry.editModelPage(modelPage.getSitePath(), isModelGroup());
            }
        });
    }
    return result;
}

From source file:org.opencms.ade.sitemap.client.ui.A_CmsNewModelPageDialog.java

License:Open Source License

/**
 * Adds a row to the form.<p>//  www. j  a  va2 s  . c  om
 *
 * @param label the label
 * @param inputWidget the input widget
 */
private void addInputRow(String label, Widget inputWidget) {

    FlowPanel row = new FlowPanel();
    row.setStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormRow());
    CmsLabel labelWidget = new CmsLabel(label);
    labelWidget.setStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormLabel());
    row.add(labelWidget);
    inputWidget.addStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormInputBox());
    row.add(inputWidget);
    m_dialogContent.getFieldSet().add(row);
}