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:com.puzzlebazar.client.ui.SquareGridLayoutPanel.java

License:Apache License

/**
 * Creates a standard cell widget and adds it at a specific cell.
 * (See {@link com.puzzlebazar.shared.util.Recti} for details on cells and vertices.)
 *
 * @param loc The location of this cell (a {@link Vec2i}).
 * @param styleNames A list of string containing all the desired style names. (The default cell style is added automatically.)
 * @return The newly created widget./*from  w w w .  j  a v a 2s . c  om*/
 */
public Widget createCell(Vec2i loc, String... styleNames) {
    Widget widget = GWT.create(FlowPanel.class);
    widget.addStyleName(resources.style().cell());
    for (String style : styleNames) {
        widget.addStyleName(style);
    }
    addCellWidget(loc, widget);
    return widget;
}

From source file:com.puzzlebazar.client.ui.SquareGridLayoutPanel.java

License:Apache License

/**
 * Creates a standard selected cell widget and adds it at a specific cell.
 * (See {@link com.puzzlebazar.shared.util.Recti} for details on cells and vertices.)
 *
 * @param loc The location of this cell (a {@link Vec2i}).
 * @param styleNames A list of string containing all the desired style names. (The default selected cell style is added automatically.)
 * @return The newly created widget.// w  w w.  j  av  a2s  . c  o  m
 */
public Widget createSelectedCell(Vec2i loc, String... styleNames) {
    Widget widget = GWT.create(FlowPanel.class);
    widget.addStyleName(resources.style().selectedCell());
    for (String style : styleNames) {
        widget.addStyleName(style);
    }
    addCellWidget(loc, widget);
    return widget;
}

From source file:com.qualogy.qafe.gwt.client.factory.WindowFactory.java

License:Apache License

public static void setWidgetToMainPanel(Widget w, WindowGVO windowGVO) {
    if (w != null) {
        clearWidgetFromMainPanel();/*  w  w w.j av  a2s  .c  o  m*/
        SimplePanel mainPanel = ClientApplicationContext.getInstance().getMainPanel();
        if (mainPanel == null) {
            mainPanel = new SimplePanel();
            mainPanel.setWidth(Window.getClientWidth() + "px");
            mainPanel.setHeight(Window.getClientHeight() + "px");

            ClientApplicationContext.getInstance().setMainPanel(mainPanel);
            MenuBar menuBar = ClientApplicationContext.getInstance().getApplicationsMenu();
            if (menuBar != null) {
                menuBar.addStyleName("SDIMenu");
                RootPanel.get().add((Widget) mainPanel, 0, 24);
            } else {
                RootPanel.get().add((Widget) mainPanel, 0, 0);
            }
        }

        w.setWidth(Window.getClientWidth() + "px");
        w.setHeight(Window.getClientHeight() + "px");
        mainPanel.addStyleName("SDIWrapper");
        mainPanel.setWidget(w);
        w.addStyleName("SDIPanel");
        if (windowGVO != null) {
            RendererHelper.addStyle(windowGVO.getRootPanel(), w);
        }
    }
}

From source file:com.risevision.ui.client.common.widgets.grid.DoubleRowFormGridWidget.java

License:Open Source License

private void addField(Widget widget, String styleName) {
    row++;/*from  w  w w  .j av  a2 s .c o m*/
    //      getCellFormatter().setStyleName(row, 0, "rdn-Column1");
    if (widget != null) {
        setWidget(row, 0, widget);

        if (styleName != null) {
            widget.setStyleName(styleName);
        }

        widget.addStyleName("rdn-Indent");
    }
}

From source file:com.sciencegadgets.client.algebra.EquationLayer.java

License:Open Source License

@Override
public void setVisible(boolean visible) {
    Visibility visibility = visible ? Visibility.VISIBLE : Visibility.HIDDEN;
    getElement().getStyle().setVisibility(visibility);

    if (visible) {
        Widget eqPanel = getParent();
        if (isExpression) {
            eqPanel.addStyleName(CSS.CAN_ZOOM_OUT);
        } else {//from w  w w . j  a va2 s  . co  m
            eqPanel.removeStyleName(CSS.CAN_ZOOM_OUT);
        }
    }
}

From source file:com.sciencegadgets.client.algebra.EquationWrapper.java

License:Open Source License

private void fillSelectionDetails() {
    LinkedList<Widget> detailsList = new LinkedList<Widget>();

    TypeSGET type = node.getType();//from ww w  .j a  v a 2s . co m
    TypeSGET operationType = null;
    // FitParentHTML typeLabel = new FitParentHTML(type.getIcon());
    HTML typeLabel = new HTML(type.toString());
    detailsList.add(typeLabel);

    switch (type) {
    case Number:
        String fullValue = node.getAttribute(MathAttribute.Value);
        if ("".equals(fullValue)) {
            fullValue = node.getAttribute(MathAttribute.Randomness);
        } else {
            try {
                new BigDecimal(fullValue);
                // FitParentHTML valueHTML = new
                // FitParentHTML(fullValue);
                final TextBox valueHTML = new TextBox();
                valueHTML.setText(fullValue);
                valueHTML.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        valueHTML.selectAll();
                    }
                });
                valueHTML.addStyleName(CSS.SELECTION_DETAILS_Value);
                valueHTML.getElement().getStyle().setProperty("textShadow", "inherit");
                detailsList.add(valueHTML);
            } catch (NumberFormatException ex) {
            }
        }

        UnitAttribute unit = node.getUnitAttribute();
        if (!"".equals(unit.toString())) {
            HTML unitHTML = new HTML();
            unitHTML.getElement().appendChild(UnitHTML.create(unit, false));
            detailsList.add(unitHTML);
        }

        break;
    case Variable:
        UnitAttribute qKind = node.getUnitAttribute();
        if (!"".equals(qKind.toString())) {
            // FitParentHTML qKindHTML = new FitParentHTML();
            HTML qKindHTML = new HTML();
            qKindHTML.getElement().appendChild(UnitHTML.create(qKind, false));
            detailsList.add(qKindHTML);
        }
        break;
    case Operation:
        operationType = node.getParentType();
        String[] parts = { node.getPrevSibling().getType().toString(), node.getSymbol(),
                node.getNextSibling().getType().toString() };

        typeLabel.setHTML("");
        Element typeEl = typeLabel.getElement();
        for (String part : parts) {
            Element partEl = new HTML(part).getElement();
            Style partSt = partEl.getStyle();
            partSt.setMargin(2, Unit.PX);
            partSt.setDisplay(Display.INLINE_BLOCK);
            partSt.setVerticalAlign(VerticalAlign.MIDDLE);
            typeEl.appendChild(partEl);
        }
    default:
        break;
    }

    FlowPanel detailsPanel = new FlowPanel();
    detailsPanel.addStyleName(CSS.SELECTION_DETAILS);
    for (Widget s : detailsList) {
        detailsPanel.add(s);
    }
    algebraActivity.detailsArea.clear();
    algebraActivity.detailsArea.add(detailsPanel);

    Widget typeParent = typeLabel.getParent();
    if (typeParent != null) {
        // typeParent.addStyleName(type.getCSSClassName());
        // typeParent.addStyleName(CSS.PARENT_WRAPPER);
        if (operationType != null) {
            typeParent.addStyleName(operationType.getCSSClassName());
        }
    }
}

From source file:com.sciencegadgets.client.ui.CommunistPanel.java

License:Open Source License

private void addComrade(Widget widget) {
    Widget container = widget;
    if (widget instanceof FitParentHTML) {
        FitParentHTML w = (FitParentHTML) widget;
        container = new HasFitParentHTML.FitParentContainer(w);
        w.setPanel(this);
    } else if (widget instanceof HasFitParentHTML) {
        HasFitParentHTML w = (HasFitParentHTML) widget;
        FitParentHTML fit = w.getFitParentHTML();
        fit.setPanel(this);
    }/*  w  w w  .j a v  a 2  s  . co m*/
    if (isHorizontal) {
        container.addStyleName(CSS.LAYOUT_ROW);
    }
    super.add(container);
}

From source file:com.seanchenxi.gwt.serenity.client.view.impl.DiscussionListViewImpl.java

License:Apache License

@Override
public void updateResponseViewPosition(int discussionId) {
    Widget respondWidget = Widget.asWidgetOrNull(respond);
    if (respondWidget == null)
        return;//from  w w  w. j a v a  2  s. com
    DiscussionViewImpl discussion = discussions.get(discussionId);
    if (discussion != null) {
        respond.setDiscussionId(discussion.getId());
        respondWidget.addStyleName(getLevelStyle(discussion.getLevel()));
        main.insert(respond, main.getWidgetIndex(discussion) + 1);
    } else {
        respond.setDiscussionId(0);
        respondWidget.setStyleName(StringPool.BLANK);
        main.add(respond);
    }
}

From source file:com.sencha.gxt.theme.base.client.container.BorderLayoutBaseAppearance.java

License:sencha.com license

@Override
public void onInsert(Widget child) {
    child.addStyleName(style.child());
}

From source file:com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.java

License:sencha.com license

@Override
protected void onInsert(int index, Widget child) {
    child.addStyleName(CommonStyles.get().positionable());

    appearance.onInsert(child);// w  w w . j  av  a2  s  . c om

    if (!(child instanceof Component)) {
        return;
    }

    final Component c = (Component) child;

    if (c == getWidget()) {
        return;
    }

    final BorderLayoutData data = getLayoutData(c);

    if (c instanceof CollapsePanel) {
        final CollapsePanel collapse = (CollapsePanel) c;
        final BorderLayoutData panelData = (BorderLayoutData) collapse.getContentPanel().getLayoutData();
        SplitBar bar = collapse.getData("splitBar");
        if (bar == null || bar.getTargetWidget() != c) {
            bar = collapse.getSplitBar();
            bar.setCollapsible(panelData.isCollapseMini());

            c.setData("splitBar", bar);

            if (panelData.isCollapseHidden()) {
                collapse.collapseHidden();
            }

            bar.addSelectHandler(new SelectHandler() {
                @Override
                public void onSelect(SelectEvent event) {
                    onExpandClick((CollapsePanel) c);
                }
            });
        }
    }

    if (data.isCollapsible() && c instanceof ContentPanel && !c.isRendered()) {
        final ContentPanel cp = (ContentPanel) c;
        cp.setCollapsible(true);
        cp.setHideCollapseTool(true);

        IconConfig config = ToolButton.DOUBLELEFT;

        switch (getRegion(cp)) {
        case NORTH:
            config = ToolButton.DOUBLEUP;
            break;
        case SOUTH:
            config = ToolButton.DOUBLEDOWN;
            break;
        case EAST:
            config = ToolButton.DOUBLERIGHT;
            break;
        case WEST:
        case CENTER:
            // do nothing
        }

        cp.getHeader().addTool(new ToolButton(config, new SelectHandler() {

            @Override
            public void onSelect(SelectEvent event) {
                cp.collapse();
            }
        }));
        cp.addBeforeCollapseHandler(collapseHandler);
        cp.addBeforeExpandHandler(collapseHandler);
    }

    if (data.isSplit()) {
        SplitBar bar = c.getData("splitBar");
        if (bar == null || bar.getTargetWidget() != c) {
            bar = createSplitBar(c);
            final SplitBar fbar = bar;
            bar.setCollapsible(data.isCollapseMini());
            if (data.isCollapseMini()) {
                switch (getRegion(c)) {
                case EAST:
                    bar.updateMini(Direction.RIGHT);
                    break;
                case WEST:
                    bar.updateMini(Direction.LEFT);
                    break;
                case NORTH:
                    bar.updateMini(Direction.UP);
                    break;
                case SOUTH:
                    bar.updateMini(Direction.DOWN);
                    break;
                case CENTER:
                    // do nothing
                }
                bar.addSelectHandler(new SelectHandler() {
                    @Override
                    public void onSelect(SelectEvent event) {
                        if (c instanceof Collapsible) {
                            ((Collapsible) c).collapse();
                        }
                    }
                });
            }

            bar.addSplitBarDragHandler(new SplitBarDragHandler() {

                @Override
                public void onDragEvent(SplitBarDragEvent event) {
                    LayoutRegion region = getRegion(c);
                    if (event.isStart()) {
                        fbar.setMinSize(data.getMinSize());
                        boolean side = region == LayoutRegion.WEST || region == LayoutRegion.EAST;
                        int size = side ? c.getOffsetWidth() : c.getOffsetHeight();
                        if (lastCenter != null) {
                            int centerSize = side ? lastCenter.getWidth() : lastCenter.getHeight();
                            fbar.setMaxSize(Math.min(size + centerSize, data.getMaxSize()));
                        }
                    } else {
                        if (event.getSize() < 1) {
                            return;
                        }
                        data.setSize(event.getSize());
                        doLayout();
                    }
                }
            });

        }
        bar.getElement().getStyle().setVisibility(Visibility.HIDDEN);
        c.setData("splitBar", bar);

        bar.setMinSize(data.getMinSize());
        bar.setMaxSize(data.getMaxSize() == 0 ? bar.getMaxSize() : data.getMaxSize());
        bar.setAutoSize(false);
    }
}