<commit_before>package org.jboss.as.console.client.shared.runtime.web;

import com.google.gwt.cell.client.TextCell;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SingleSelectionModel;
import org.jboss.as.console.client.Console;
import org.jboss.as.console.client.core.DisposableViewImpl;
import org.jboss.as.console.client.shared.help.HelpSystem;
import org.jboss.as.console.client.shared.runtime.Metric;
import org.jboss.as.console.client.shared.runtime.RuntimeBaseAddress;
import org.jboss.as.console.client.shared.runtime.Sampler;
import org.jboss.as.console.client.shared.runtime.charts.Column;
import org.jboss.as.console.client.shared.runtime.charts.NumberColumn;
import org.jboss.as.console.client.shared.runtime.plain.PlainColumnView;
import org.jboss.as.console.client.shared.subsys.web.model.HttpConnector;
import org.jboss.as.console.client.layout.SimpleLayout;
import org.jboss.ballroom.client.widgets.tables.DefaultCellTable;
import org.jboss.ballroom.client.widgets.tools.ToolButton;
import org.jboss.ballroom.client.widgets.tools.ToolStrip;
import org.jboss.dmr.client.ModelDescriptionConstants;
import org.jboss.dmr.client.ModelNode;

import java.util.List;

/**
 * @author <NAME>
 * @date 12/10/11
 */
public class WebMetricView extends DisposableViewImpl implements WebMetricPresenter.MyView {

    private WebMetricPresenter presenter;
    private Sampler sampler;
    private DefaultCellTable<HttpConnector> connectorTable;
    private ListDataProvider<HttpConnector> connectorProvider;

    @Override
    public Widget createWidget() {


        final ToolStrip toolStrip = new ToolStrip();
        toolStrip.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_refresh(), new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                presenter.setSelectedConnector(getCurrentSelection());
            }
        }));

        // ----

        connectorTable = new DefaultCellTable<HttpConnector>(10);
        connectorTable.setSelectionModel(new SingleSelectionModel<HttpConnector>());

        connectorProvider = new ListDataProvider<HttpConnector>();
        connectorProvider.addDataDisplay(connectorTable);

        com.google.gwt.user.cellview.client.Column<HttpConnector, String> nameColumn = new com.google.gwt.user.cellview.client.Column<HttpConnector, String>(new TextCell()) {
            @Override
            public String getValue(HttpConnector object) {
                return object.getName();
            }
        };


        com.google.gwt.user.cellview.client.Column<HttpConnector, String> protocolColumn = new com.google.gwt.user.cellview.client.Column<HttpConnector, String>(new TextCell()) {
            @Override
            public String getValue(HttpConnector object) {
                return object.getProtocol();
            }
        };

        connectorTable.addColumn(nameColumn, "Name");
        connectorTable.addColumn(protocolColumn, "Protocol");

        connectorTable.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler(){
            @Override
            public void onSelectionChange(SelectionChangeEvent event) {
                HttpConnector connector = getCurrentSelection();
                presenter.setSelectedConnector(connector);

            }
        });
        connectorTable.getElement().setAttribute("style", "margin-top:15px;margin-bottom:15px;");

        // ----


        NumberColumn requestCount = new NumberColumn("requestCount","Request Count");

        Column[] cols = new Column[] {
                requestCount.setBaseline(true),
                new NumberColumn("errorCount","Error Count").setComparisonColumn(requestCount),
                new NumberColumn("processingTime","Processing Time"),
                new NumberColumn("maxTime", "Max Time")
        };

        String title = "Request per Connector";

        final HelpSystem.AddressCallback addressCallback = new HelpSystem.AddressCallback() {
            @Override
            public ModelNode getAddress() {
                ModelNode address = new ModelNode();
                address.get(ModelDescriptionConstants.ADDRESS).set(RuntimeBaseAddress.get());
                address.get(ModelDescriptionConstants.ADDRESS).add("subsystem", "web");
                address.get(ModelDescriptionConstants.ADDRESS).add("connector", "*");
                return address;
            }
        };

        sampler = new PlainColumnView(title, addressCallback)
                .setColumns(cols)
                .setWidth(100, Style.Unit.PCT);


        // ----

        SimpleLayout layout = new SimpleLayout()
                .setTitle("Web")
                .setTopLevelTools(toolStrip.asWidget())
                .setHeadline("Web Metrics")
                .setDescription(Console.CONSTANTS.subys_web_metric_desc())
                .addContent("Connector Selection", connectorTable)
                .addContent("Connector Metrics", sampler.asWidget());

        return layout.build();
    }

    private HttpConnector getCurrentSelection() {
        return ((SingleSelectionModel<HttpConnector>) connectorTable.getSelectionModel()).getSelectedObject();
    }

    @Override
    public void setPresenter(WebMetricPresenter presenter) {
        this.presenter = presenter;
    }
<commit_msg>Fix HAL-149: Bullet graphs for Web metrics<commit_after>package org.jboss.as.console.client.shared.runtime.web;

import com.google.gwt.cell.client.TextCell;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SingleSelectionModel;
import org.jboss.as.console.client.Console;
import org.jboss.as.console.client.core.DisposableViewImpl;
import org.jboss.as.console.client.shared.help.HelpSystem;
import org.jboss.as.console.client.shared.runtime.Metric;
import org.jboss.as.console.client.shared.runtime.RuntimeBaseAddress;
import org.jboss.as.console.client.shared.runtime.Sampler;
import org.jboss.as.console.client.shared.runtime.charts.BulletGraphView;
import org.jboss.as.console.client.shared.runtime.charts.Column;
import org.jboss.as.console.client.shared.runtime.charts.NumberColumn;
import org.jboss.as.console.client.shared.runtime.plain.PlainColumnView;
import org.jboss.as.console.client.shared.subsys.web.model.HttpConnector;
import org.jboss.as.console.client.layout.SimpleLayout;
import org.jboss.ballroom.client.widgets.tables.DefaultCellTable;
import org.jboss.ballroom.client.widgets.tools.ToolButton;
import org.jboss.ballroom.client.widgets.tools.ToolStrip;
import org.jboss.dmr.client.ModelDescriptionConstants;
import org.jboss.dmr.client.ModelNode;

import java.util.List;

/**
 * @author <NAME>
 * @date 12/10/11
 */
public class WebMetricView extends DisposableViewImpl implements WebMetricPresenter.MyView {

    private WebMetricPresenter presenter;
    private Sampler sampler;
    private DefaultCellTable<HttpConnector> connectorTable;
    private ListDataProvider<HttpConnector> connectorProvider;

    @Override
    public Widget createWidget() {


        final ToolStrip toolStrip = new ToolStrip();
        toolStrip.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_refresh(), new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                presenter.setSelectedConnector(getCurrentSelection());
            }
        }));

        // ----

        connectorTable = new DefaultCellTable<HttpConnector>(10);
        connectorTable.setSelectionModel(new SingleSelectionModel<HttpConnector>());

        connectorProvider = new ListDataProvider<HttpConnector>();
        connectorProvider.addDataDisplay(connectorTable);

        com.google.gwt.user.cellview.client.Column<HttpConnector, String> nameColumn = new com.google.gwt.user.cellview.client.Column<HttpConnector, String>(new TextCell()) {
            @Override
            public String getValue(HttpConnector object) {
                return object.getName();
            }
        };


        com.google.gwt.user.cellview.client.Column<HttpConnector, String> protocolColumn = new com.google.gwt.user.cellview.client.Column<HttpConnector, String>(new TextCell()) {
            @Override
            public String getValue(HttpConnector object) {
                return object.getProtocol();
            }
        };

        connectorTable.addColumn(nameColumn, "Name");
        connectorTable.addColumn(protocolColumn, "Protocol");

        connectorTable.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler(){
            @Override
            public void onSelectionChange(SelectionChangeEvent event) {
                HttpConnector connector = getCurrentSelection();
                presenter.setSelectedConnector(connector);

            }
        });
        connectorTable.getElement().setAttribute("style", "margin-top:15px;margin-bottom:15px;");

        // ----


        NumberColumn requestCount = new NumberColumn("requestCount","Requests");

        Column[] cols = new Column[] {
                requestCount.setBaseline(true),
                new NumberColumn("errorCount","Errors").setComparisonColumn(requestCount),
                new NumberColumn("processingTime","Processing Time"),
                new NumberColumn("maxTime", "Max Time")
        };

        String title = "Request per Connector";

        final HelpSystem.AddressCallback addressCallback = new HelpSystem.AddressCallback() {
            @Override
            public ModelNode getAddress() {
                ModelNode address = new ModelNode();
                address.get(ModelDescriptionConstants.ADDRESS).set(RuntimeBaseAddress.get());
                address.get(ModelDescriptionConstants.ADDRESS).add("subsystem", "web");
                address.get(ModelDescriptionConstants.ADDRESS).add("connector", "*");
                return address;
            }
        };


        if(Console.protovisAvailable())
        {
            sampler = new BulletGraphView(title, "count")
                    .setColumns(cols);
        }
        else
        {
            sampler = new PlainColumnView(title, addressCallback)
                    .setColumns(cols)
                    .setWidth(100, Style.Unit.PCT);
        }

        // ----

        SimpleLayout layout = new SimpleLayout()
                .setTitle("Web")
                .setTopLevelTools(toolStrip.asWidget())
                .setHeadline("Web Metrics")
                .setDescription(Console.CONSTANTS.subys_web_metric_desc())
                .addContent("Connector Selection", connectorTable)
                .addContent("Connector Metrics", sampler.asWidget());

        return layout.build();
    }

    private HttpConnector getCurrentSelection() {
        return ((SingleSelectionModel<HttpConnector>) connectorTable.getSelectionModel()).getSelectedObject();
    }

    @Override
    public void setPresenter(WebMetricPresenter presenter) {
        this.presenter = presenter;
    }

{'fraction_non_alphanumeric': 0.10754930066892537, 'fraction_numerical': 0.0028668230388324213, 'mean_word_length': 2.9751381215469612, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6206398', 'n_tokens_mistral': 3145, 'n_tokens_neox': 2999, 'n_words': 471}