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.cruxframework.mediamanager.client.controller.MenuController.java

License:Apache License

@Expose
public void toggleMenu() {
    Widget header = View.of(this).getWidget("mmHeader");
    if ((header.getStyleName()).indexOf("on") != -1) {
        header.removeStyleName("on");
    } else {//  w  ww . j  av a2s . co  m
        header.addStyleName("on");
    }
}

From source file:org.datacleaner.monitor.shared.widgets.WizardProgressBar.java

License:Open Source License

public void setSteps(final Integer steps, boolean indicateMore) {
    if (steps == null) {
        return;//  w  w w .  j a  v  a 2s. co  m
    }
    if (steps.intValue() == getSteps() && _indicatingMore == indicateMore) {
        return;
    }

    clear();

    Widget metaBefore = new Label();
    metaBefore.setStyleName("MetaItem");
    metaBefore.addStyleName("before");
    add(metaBefore);

    for (int i = 0; i < steps; i++) {
        Widget child = new Label("" + (i + 1));
        child.setStyleName("WizardProgressItem");
        if (i == 0) {
            child.addStyleName("first");
        } else if (i == steps - 1) {
            child.addStyleName("last");
        }
        add(child);
    }

    _indicatingMore = indicateMore;
    if (indicateMore) {
        Widget metaAfter = new Label("...");
        metaAfter.setStyleName("MetaItem");
        metaAfter.addStyleName("more");
        add(metaAfter);
    }

    Widget metaAfter = new Label();
    metaAfter.setStyleName("MetaItem");
    metaAfter.addStyleName("after");
    add(metaAfter);
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ConsumerView.java

License:Open Source License

/**
 * Sets the metric.//from ww  w  .  j  av  a 2s.  c  o  m
 * 
 * @param m
 *            the m
 * @param result
 *            the result
 * @see org.ebayopensource.turmeric.monitoring.client.presenter.ConsumerPresenter.Display#setMetric(org.ebayopensource.turmeric.monitoring.client.model.ConsumerMetric,
 *      org.ebayopensource.turmeric.monitoring.client.model.MetricData)
 */
public void setMetric(ConsumerMetric m, MetricData result) {

    // Fill in the appropriate table with the results
    SummaryPanel panel = null;
    String date1Header = "";
    String date2Header = "";

    if (result != null) {
        String d1 = ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date1));
        String d2 = ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date2));
        date1Header = d1 + " + " + (result.getMetricCriteria().durationSec / (60 * 60))
                + ConsoleUtil.constants.hr();
        date2Header = d2 + " + " + (result.getMetricCriteria().durationSec / (60 * 60))
                + ConsoleUtil.constants.hr();
    }

    switch (m) {
    /* Start tables for all consumers */
    case CallVolume: {
        String[] columns = { ConsoleUtil.constants.consumers(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                rowData[0] = new Label(rd.getCriteriaInfo().getConsumerName());
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(callVolumeTable, columns, rows);
        for (int i = 1; i < callVolumeTable.getRowCount(); i++) {
            Widget w = callVolumeTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = callVolumePanel;
        break;
    }
    case Performance: {
        String[] columns = { ConsoleUtil.constants.consumers(),
                (result == null ? ConsoleUtil.constants.average()
                        : date1Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                (result == null ? ConsoleUtil.constants.average()
                        : date2Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                "% " + ConsoleUtil.constants.change() };
        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                rowData[0] = new Label(rd.getCriteriaInfo().getConsumerName());
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(performanceTable, columns, rows);
        for (int i = 1; i < performanceTable.getRowCount(); i++) {
            Widget w = performanceTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = performancePanel;
        break;
    }
    case Errors: {
        String[] columns = { ConsoleUtil.constants.consumers(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                rowData[0] = new Label(rd.getCriteriaInfo().getConsumerName());
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(errorsTable, columns, rows);
        for (int i = 1; i < errorsTable.getRowCount(); i++) {
            Widget w = errorsTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = errorsPanel;
        break;
    }
    /* End tables for all consumers */
    /* Start tables for a particular consumer */
    case TopVolume: {
        // column 0 will either be Services or Operations of a Service
        String col0 = ConsoleUtil.constants.services();
        if (result != null
                && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
            col0 = ConsoleUtil.constants.operations();
        String[] columns = { col0,
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))
                    rowData[0] = new Label(rd.getCriteriaInfo().getServiceName());
                else if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
                    rowData[0] = new Label(rd.getCriteriaInfo().getOperationName());

                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(topVolumeTable, columns, rows);
        // style the column with the names of the consumers in it
        for (int i = 1; i < topVolumeTable.getRowCount(); i++) {
            Widget w = topVolumeTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = topVolumePanel;
        break;
    }
    case LeastPerformance: {
        // column 0 will either be Services or Operations of a Service
        String col0 = ConsoleUtil.constants.services();
        if (result != null
                && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
            col0 = ConsoleUtil.constants.operations();
        String[] columns = { col0,
                (result == null ? ConsoleUtil.constants.average()
                        : date1Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                (result == null ? ConsoleUtil.constants.average()
                        : date2Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                "% " + ConsoleUtil.constants.change() };
        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))
                    rowData[0] = new Label(rd.getCriteriaInfo().getServiceName());
                else if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
                    rowData[0] = new Label(rd.getCriteriaInfo().getOperationName());

                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(leastPerformanceTable, columns, rows);
        // style the column with the names of the consumers in it
        for (int i = 1; i < leastPerformanceTable.getRowCount(); i++) {
            Widget w = leastPerformanceTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = leastPerformancePanel;
        break;
    }
    case TopServiceErrors: {
        boolean isOperation = false;
        if (result != null && result.getMetricResourceCriteria() != null
                && result.getMetricResourceCriteria().resourceEntityRequests != null) {
            for (ResourceEntityRequest r : result.getMetricResourceCriteria().resourceEntityRequests) {
                if (r.resourceEntityType == Entity.Operation)
                    isOperation = true;
            }
        }
        String col0 = ConsoleUtil.constants.services();
        if (isOperation)
            col0 = ConsoleUtil.constants.operations();
        String[] columns = { col0, ConsoleUtil.constants.errors(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };
        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);

                Widget[] rowData = new Widget[5];

                if (isOperation) {
                    rowData[0] = new Label(rd.getCriteriaInfo().getOperationName());
                } else {
                    rowData[0] = new Label(rd.getCriteriaInfo().getServiceName());
                }
                String label = "undefined";
                label = (String) ConsoleUtil.constants.metricDefNamesMap()
                        .get(rd.getCriteriaInfo().getMetricName());
                rowData[1] = new Label(label);

                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[3] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[4] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(topServiceErrorsTable, columns, rows);
        // style the column with the names of the consumers in it
        for (int i = 1; i < topServiceErrorsTable.getRowCount(); i++) {
            Widget w = topServiceErrorsTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = topServiceErrorsPanel;
        break;
    }
    case TopConsumerErrors: {
        String[] columns = { ConsoleUtil.constants.errors(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);

                Widget[] rowData = new Widget[4];
                String label = "undefined";
                label = (String) ConsoleUtil.constants.metricDefNamesMap()
                        .get(rd.getCriteriaInfo().getMetricName());

                rowData[0] = new Label(label);
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(topConsumerErrorsTable, columns, rows);
        panel = topConsumerErrorsPanel;
        break;
    }
    /* End tables for particular Consumer */
    }
    if (result != null && result.getReturnData() != null && panel != null) {
        int rows = result.getReturnData().size() + 1;
        double height = 0;
        if (rows > 10)
            height = 10 * 2.5;
        else
            height = rows * 2.5;
        panel.setContentContainerHeight(String.valueOf(height) + "em");
    }

    if (panel != null) {
        if (result != null)
            panel.setInfo(result.getRestUrl());
        show(panel);
    }
}

From source file:org.eclipse.che.ide.ext.runner.client.manager.RunnerManagerViewImpl.java

License:Open Source License

private void changeSplitterStyle(@Nonnull SplitLayoutPanel panel, @Nonnull String style) {
    int widgetCount = panel.getWidgetCount();

    for (int i = 0; i < widgetCount; i++) {
        Widget widget = panel.getWidget(i);
        String styleName = widget.getStyleName();

        if (SPLITTER_STYLE_NAME.equals(styleName)) {
            this.splitter = widget;

            widget.removeStyleName(styleName);
            widget.addStyleName(style);
        }//from  w w w  . java 2  s .  com
    }
}

From source file:org.eclipse.che.ide.ext.runner.client.tabs.console.panel.ConsoleImpl.java

License:Open Source License

/** {@inheritDoc} */
@Override//from   w w w .jav a 2  s.  c om
public void changeWrapTextParam() {
    isWrappedText = !isWrappedText;
    String wrappedText = res.runnerCss().wrappedText();

    for (int i = 0; i < output.getWidgetCount(); i++) {
        Widget widget = output.getWidget(i);

        if (isWrappedText) {
            widget.addStyleName(wrappedText);
        } else {
            widget.removeStyleName(wrappedText);
        }
    }
}

From source file:org.eclipse.che.ide.extension.machine.client.outputspanel.OutputsContainerViewImpl.java

License:Open Source License

@Override
public void showConsole(int index) {
    for (int i = 0; i < tabsPanel.getWidgetCount(); i++) {
        final Widget widget = tabsPanel.getWidget(i);
        if (i == index) {
            widget.addStyleName(resources.getCss().outputsContainerConsoleTabSelected());
        } else {//w w  w . ja va 2 s.c  om
            widget.removeStyleName(resources.getCss().outputsContainerConsoleTabSelected());
        }
    }

    contentPanel.showWidget(index);
}

From source file:org.eclipse.che.ide.menu.MainMenuViewImpl.java

License:Open Source License

/**
 * Create a new widget and add it to panel menu.
 *//*from  w w  w  .  j  av  a 2  s  .  co m*/
private void addToPanel(FlowPanel panel, Action action, PresentationFactory presentationFactory) {
    Presentation presentation = presentationFactory.getPresentation(action);

    if (action instanceof Separator) {
        panel.add(new SeparatorItem(resources.menuCss().panelSeparator()));

        // todo find way to render non custom actions
    } else if (action instanceof CustomComponentAction) {
        CustomComponentAction customComponentAction = (CustomComponentAction) action;
        Widget component = customComponentAction.createCustomComponent(presentation);
        component.addStyleName(resources.menuCss().customComponent());
        panel.add(component);
    }
}

From source file:org.eclipse.che.ide.ui.dropdown.DropdownList.java

License:Open Source License

/**
 * Add the given {@code item} to the top of the list.
 *
 * @param item/*from   w w  w. j  a  v a  2  s.c om*/
 *         item to add to the list
 * @param renderer
 *         renderer provides widgets for representing the given {@code item} in the list
 */
public void addItem(DropdownListItem item, DropdownListItemRenderer renderer) {
    final Widget headerWidget = renderer.renderHeaderWidget();
    final Widget listWidget = new SimplePanel(renderer.renderListWidget());

    itemHeaderWidgets.put(item, headerWidget);
    itemListWidgets.put(item, listWidget);

    headerWidget.addHandler(e -> toggleListVisibility(), ClickEvent.getType());

    listWidget.addStyleName(RESOURCES.dropdownListCss().listItem());
    listWidget.addDomHandler(e -> {
        setSelectedItem(item);
        dropdownPopupPanel.hide();

        if (selectionHandler != null) {
            selectionHandler.onItemSelected(item);
        }
    }, ClickEvent.getType());

    dropdownContentPanel.insert(listWidget, 0);
    adaptDropDownPanelHeight();
    setSelectedItem(item);
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.collection.toc.AssessmentsPlayerTocView.java

License:Open Source License

@Override
public void setResourceActive(String collectionId, String collectionItemid, boolean isCollectionHome) {
    if (selectedWidgetIndex != -1) {
        Widget widget = navgationTocContainer.getWidget(selectedWidgetIndex);
        widget.removeStyleName(PlayerBundle.INSTANCE.getPlayerStyle().tocResourceSelected());
    }//from www.j a  v  a 2s .c  o m
    if (collectionItemid != null) {
        int widgetCount = navgationTocContainer.getWidgetCount();
        for (int i = 0; i < widgetCount; i++) {
            Widget widget = navgationTocContainer.getWidget(i);
            if (widget instanceof TocAssessmentsResourceView) {
                TocAssessmentsResourceView resourceView = (TocAssessmentsResourceView) widget;
                if (collectionItemid.equals(resourceView.getCollectionItemId())) {
                    selectedWidgetIndex = i;
                    resourceView.addStyleName(PlayerBundle.INSTANCE.getPlayerStyle().tocResourceSelected());
                    return;
                }
            }
        }
    } else if (isCollectionHome) {
        selectedWidgetIndex = 0;
        Widget widget = navgationTocContainer.getWidget(selectedWidgetIndex);
        widget.addStyleName(PlayerBundle.INSTANCE.getPlayerStyle().tocResourceSelected());
    } else {
        int widgetCount = navgationTocContainer.getWidgetCount();
        selectedWidgetIndex = widgetCount - 1;
        Widget widget = navgationTocContainer.getWidget(selectedWidgetIndex);
        widget.addStyleName(PlayerBundle.INSTANCE.getPlayerStyle().tocResourceSelected());
    }

}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.question.HTAnswerDropController.java

License:Open Source License

@Override
protected Widget newPositioner(DragContext context) {
    Widget widget = super.newPositioner(context);
    widget.removeStyleName(DragClientBundle.INSTANCE.css().positioner());
    widget.addStyleName("answerDragdropPositioner");
    positioner = widget;/*from www .ja  va 2s .com*/
    return widget;
}