Example usage for org.apache.wicket.markup.html.list ListView ListView

List of usage examples for org.apache.wicket.markup.html.list ListView ListView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListView ListView.

Prototype

public ListView(final String id, final List<T> list) 

Source Link

Usage

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.charts.ChartsPanel.java

License:Apache License

private ListView getChartListViewComponent() {

    // update the content of the ListView container
    refreshDiagramContent();//from   ww w  .ja  v  a2s.co m

    final List<String> charts = new ArrayList<String>(diagramContent.keySet());

    return new ListView("chartsListView", charts) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem item) {

            String diagramName = charts.get(item.getIndex());
            List<ChartData> chartData = new ArrayList<ChartData>();
            for (DbStatisticDescription stat : diagramContent.get(diagramName)) {
                chartData.add(stat.getChartData());
            }

            Label chartTitle = new Label("chartTitle", diagramName);
            item.add(chartTitle);

            final String chartScript = getChartScript(chartData, chartId++);
            final Label chart = new Label("chartScriptContainer", chartScript);
            chart.setEscapeModelStrings(false);

            CsvWriter csvWriter = new CsvWriter(chartData);
            DownloadLink downloadChartDataLink = csvWriter.getDownloadChartDataLink();

            AjaxLink refreshButton = getRefreshChartLink(charts.get(item.getIndex()));

            item.add(chart);
            item.add(downloadChartDataLink);
            item.add(refreshButton);
        }
    };
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.charts.ChartsPanel.java

License:Apache License

/**
* @return statistic details component with all Min, Avg and Max values
*//*from   w ww  . j  a  v a 2  s  . co m*/
private Component getStatisticsDetailsComponent() {

    List<List<StatisticsTableCell>> rows = new ArrayList<List<StatisticsTableCell>>();
    List<StatisticsTableCell> columns = new ArrayList<StatisticsTableCell>();

    // add title
    columns.add(new StatisticsTableCell(
            "<img class=\"arrowUD\" src=\"images/up.png\"> System statistic details", false));

    // add machine value columns
    List<MachineDescription> mergedMachineDescriptions = getMergedMachineDescriptions();
    columns.add(new StatisticsTableCell(true, getMachineAliasModel("Values")));
    rows.add(columns);

    rows.addAll(systemStatisticsPanel.generateStatisticDetailRows(mergedMachineDescriptions, diagramContent));
    rows.addAll(userStatisticsPanel.generateStatisticDetailRows(mergedMachineDescriptions, diagramContent));
    rows.addAll(actionStatisticsPanel.generateStatisticDetailRows(mergedMachineDescriptions, diagramContent));

    ListView<List<StatisticsTableCell>> statisticDetailsTable = new ListView<List<StatisticsTableCell>>(
            "statDetailsRows", rows) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<List<StatisticsTableCell>> item) {

            // table TR
            if (item.getIndex() == 0) {
                item.add(AttributeModifier.replace("class", "statDetailsHeaderRow"));
                item.add(AttributeModifier.replace("onclick",
                        "showOrHideTableRows('statDetailsTable',1,false);"));
            } else if (item.getIndex() > 1 && item.getModelObject().get(0).labelText.contains("statUnit")) {
                item.add(AttributeModifier.replace("class", "statDetailsStatNameRow"));
            }
            item.add(new ListView<StatisticsTableCell>("statDetailsColumns", item.getModelObject()) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(ListItem<StatisticsTableCell> item) {

                    // table TD
                    if (item.getIndex() > 0) { // skip the first column
                        item.add(AttributeModifier.replace("class", "statDetailsCenCol"));
                    }
                    StatisticsTableCell cell = item.getModelObject();
                    Label label = null;
                    if (cell.isInputText) {
                        label = new Label("label", cell.getMachineLabelModel());
                        if (cell.getMachineLabelModel() != null) {
                            rememberMachineAliasLabel(label);
                        }
                    } else {
                        label = new Label("label", cell.labelText);
                    }
                    label.setEscapeModelStrings(false);
                    item.add(label);
                }
            });
        }
    };

    return statisticDetailsTable;
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.DataPanel.java

License:Apache License

/**
 * Display the collected//from ww w .j av a  2 s.c o  m
 * @param statsForm
 */
public void displayStatisticDescriptions(Form<Object> statsForm) {

    boolean isDataPanelVisible = machineDescriptions.size() > 0;

    List<List<StatisticsTableCell>> rows = new ArrayList<List<StatisticsTableCell>>();
    List<StatisticsTableCell> columns = new ArrayList<StatisticsTableCell>();

    // add machine columns
    columns.add(new StatisticsTableCell("<img class=\"arrowUD\" src=\"images/up.png\">", false));
    columns.add(new StatisticsTableCell(this.name, false));
    for (MachineDescription machine : machineDescriptions) {
        String machineName = machine.getMachineAlias();
        if (SQLServerDbReadAccess.MACHINE_NAME_FOR_ATS_AGENTS.equals(machineName)) {
            machineName = "";
        }
        StatisticsTableCell cell = new StatisticsTableCell(
                "<b style=\"padding: 0 5px;\">" + machineName + "</b>", false, "centeredLabel");
        cell.cssClass = "fixTableColumn";
        columns.add(cell);
    }
    rows.add(columns);

    // add empty row
    columns = new ArrayList<StatisticsTableCell>();
    for (int i = 0; i < 2 + machineDescriptions.size(); i++) {
        columns.add(NBSP_EMPTY_CELL);
    }
    rows.add(columns);

    final Set<Integer> hiddenRowIndexes = new HashSet<Integer>();
    for (StatisticContainer statContainer : statContainers.values()) {

        List<DbStatisticDescription> statDescriptions = sortQueueItems(statContainer.getStatDescriptions());

        String lastStatParent = "";
        for (DbStatisticDescription statDescription : statDescriptions) {

            String statisticLabel = "<span class=\"statName\">" + statDescription.name
                    + "</span><span class=\"statUnit\">(" + statDescription.unit + ")</span>";

            // add parent table line if needed
            String statParent = statDescription.parentName;
            if (!StringUtils.isNullOrEmpty(statParent)
                    && !statParent.equals(StatisticsPanel.SYSTEM_STATISTIC_CONTAINER)
                    && !lastStatParent.equals(statParent)) {
                columns = new ArrayList<StatisticsTableCell>();
                columns.add(NBSP_EMPTY_CELL);
                if (statParent.startsWith(PROCESS_STAT_PREFIX)) {
                    // only Process parent element can hide its children (it is not a good idea to hide the User actions behind queue names)
                    columns.add(new StatisticsTableCell(
                            "<a href=\"#\" onclick=\"showHiddenStatChildren(this);return false;\">" + statParent
                                    + "</a>",
                            false, "parentStatTd"));
                } else {

                    columns.add(new StatisticsTableCell(statParent, false, "parentStatTd"));
                }
                for (int i = 0; i < machineDescriptions.size(); i++) {
                    columns.add(NBSP_EMPTY_CELL);
                }
                rows.add(columns);
            }

            lastStatParent = statParent;

            columns = new ArrayList<StatisticsTableCell>();
            columns.add(new StatisticsTableCell(true));
            StatisticsTableCell statName = new StatisticsTableCell(statisticLabel, true);
            statName.title = statDescription.params;
            columns.add(statName);

            for (MachineDescription machine : machineDescriptions) {
                Model<Boolean> selectionModel = machine.getStatDescriptionSelectionModel(statDescription);
                // selectionModel.getObject() should sometimes return
                // NULL - when comparing with other testcases
                if (selectionModel != null && selectionModel.getObject() != null) {
                    columns.add(new StatisticsTableCell(selectionModel));
                } else {
                    columns.add(EMPTY_CELL);
                }
            }

            // hide only the Process child elements
            if (!StringUtils.isNullOrEmpty(lastStatParent) && lastStatParent.startsWith(PROCESS_STAT_PREFIX)) {

                // add current row number as a child row which must be hidden
                hiddenRowIndexes.add(rows.size());
            }
            rows.add(columns);
        }
    }

    statisticsUIContainer = new ListView<List<StatisticsTableCell>>(uiPrefix + "StatsRows", rows) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<List<StatisticsTableCell>> item) {

            // table TR
            if (item.getIndex() == 0) {
                item.add(AttributeModifier.replace("class", "statisticsHeaderRow"));
                item.add(AttributeModifier.replace("onclick",
                        "showOrHideTableRows('" + uiPrefix + "StatsTable',1,true);"));
            } else if (item.getIndex() > 3) { // skip the machines,label and
                                              // measurement rows
                item.add(AttributeModifier.replace("class", "statisticRow"));
            }
            if (hiddenRowIndexes.contains(item.getIndex())) {
                item.add(new AttributeAppender("class", new Model<String>("hiddenStatRow"), " "));
            }

            item.add(new ListView<StatisticsTableCell>(uiPrefix + "StatsColumns", item.getModelObject()) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(ListItem<StatisticsTableCell> item) {

                    // table TD
                    if (item.getIndex() > 0) { // skip the first (CheckBox)
                                               // column
                        item.add(AttributeModifier.replace("class", "statisticColumn"));
                    }
                    StatisticsTableCell cell = item.getModelObject();
                    CheckBox checkBox = new CheckBox("checkbox", cell.checkboxModel);
                    if (cell.isCheckbox) {
                        if (item.getIndex() == 0) { // this is the first/main CheckBox

                            // binding onclick function which will (un)select all the CheckBoxes on that row
                            // and will change the line color if it is selected or not
                            checkBox.add(AttributeModifier.replace("onclick",
                                    "selectAllCheckboxes(this,'" + uiPrefix + "StatsTable');"));
                            checkBox.add(AttributeModifier.replace("class", "allMachinesCheckbox"));
                        } else {

                            // binding onclick function which will (un)select the main/first CheckBox on that row
                            // when all the CheckBoxes are selected or some are unselected.
                            // Also the row/cell color will be changed.
                            checkBox.add(AttributeModifier.replace("onclick",
                                    "unselectMainTrCheckbox(this,'" + uiPrefix + "StatsTable');"));
                            checkBox.add(AttributeModifier.replace("class", "machineCheckbox"));
                            item.add(AttributeModifier.replace("class", "statisticColumnWithCheckboxOnly"));
                        }
                    } else {
                        checkBox.setVisible(false);
                    }
                    item.add(checkBox);

                    Label label = new Label("label", cell.labelText);
                    label.setEscapeModelStrings(false).setVisible(!cell.isCheckbox && !cell.isInputText);
                    if (cell.isCheckboxLabel) {
                        // binding JavaScript function which will click on the first/main CheckBox of this statistic
                        label.add(AttributeModifier.replace("onclick", "clickSelectAllCheckbox(this);"));
                        label.add(AttributeModifier.replace("class", "checkboxLabel noselection"));
                        if (cell.title != null && !cell.title.isEmpty()) {
                            String title = cell.title;
                            int readingStartIndex = cell.title.indexOf(PARAMS_READING_UNIQUENESS_MAKRER);
                            if (readingStartIndex > 0) {

                                title = cell.title.substring(0, readingStartIndex)
                                        + cell.title.substring(cell.title.indexOf("_", readingStartIndex + 1));
                            }
                            label.add(AttributeModifier.replace("title", title.replace("_", ", ").trim()));
                        }
                    } else if (label.isVisible() && cell.cssClass != null) {
                        label.add(AttributeModifier.replace("class", cell.cssClass));
                    }
                    item.add(label);

                    Label machineAliasLabel = new Label("inputText", cell.getMachineLabelModel());
                    machineAliasLabel.setVisible(cell.isInputText);
                    if (cell.getMachineLabelModel() != null
                            && cell.getMachineLabelModel().getObject() != null) {
                        machineAliasLabel.setOutputMarkupId(true);
                        machineAliasLabel.add(
                                AttributeModifier.replace("title", cell.getMachineLabelModel().getObject()));
                        globalPanel.rememberMachineAliasLabel(machineAliasLabel);
                    }
                    item.add(machineAliasLabel);
                }
            });
        }
    };

    statisticsUIContainer.setVisible(isDataPanelVisible);
    statsForm.add(statisticsUIContainer);
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.StatisticsPanel.java

License:Apache License

/**
 * @return ListView containing all diagrams
 *//*from  w  w  w.  j a  v a2  s.  co m*/
private ListView<DbStatisticDescription> addChartGroupListView() {

    ListView<DbStatisticDescription> listViewChartGroup = new ListView<DbStatisticDescription>("chartGroupRows",
            listViewContent) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<DbStatisticDescription> item) {

            DbStatisticDescription statElement = listViewContent.get(item.getIndex());

            if (statElement.name.equals("HEADER")) { // add the header row for the diagram table
                item.add(AttributeModifier.replace("class", "chartGroupHeader"));
                Label removeIcon = new Label("removeIcon");
                removeIcon.add(AttributeModifier.append("style", ";display:none;"));
                item.add(removeIcon);
                item.add(addDiagramHeaderName("statName", "Name"));

                IModel<String> aliasModel = new Model<String>();
                aliasModel.setObject("Alias");
                TextField<String> alias = new TextField<String>("alias", aliasModel);
                alias.setOutputMarkupId(true);
                alias.add(AttributeModifier.append("style",
                        ";background-color:transparent;border:0px;pointer-events:none;text-align: center;font-family:\"Times New Roman\",Times,serif;"));
                alias.add(AttributeModifier.replace("class", "chartGroupHeader"));
                item.add(alias);
                item.add(addDiagramHeaderName("startDate", "Start Time"));
                item.add(addDiagramHeaderName("run", "Run"));
                item.add(addDiagramHeaderName("suite", "Suite"));
                item.add(addDiagramHeaderName("scenario", "Scenario"));
                item.add(addDiagramHeaderName("testcase", "Testcase"));

            } else if (statElement.unit == null) { // add diagram name row

                final AjaxButton deleteAllButton = new AjaxButton("removeIcon") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onSubmit(AjaxRequestTarget target, Form<?> form) {

                        String diagramName = listViewContent.get(item.getIndex()).name;
                        getTESession().getDiagramContainer().remove(diagramName);
                        updateDiagramTableContent();

                        target.add(statsForm);
                    }
                };
                deleteAllButton
                        .add(AttributeModifier.replace("class", "fixGroupTableColumn removeAllItemsIcon"));
                item.add(deleteAllButton);
                item.add(AttributeModifier.replace("class", "chartGroup"));

                item.add(new Label("statName", "").setEscapeModelStrings(false));
                Label alias = new Label("alias", "");
                // disable and change CSS of the input tag
                alias.add(AttributeModifier.append("style",
                        ";background-color:transparent;border:0px;pointer-events:none"));
                item.add(alias);
                item.add(new Label("startDate", statElement.name).setEscapeModelStrings(false));
                item.add(new Label("run", "").setEscapeModelStrings(false));
                item.add(new Label("suite", "").setEscapeModelStrings(false));
                item.add(new Label("scenario", "").setEscapeModelStrings(false));
                item.add(new Label("testcase", "").setEscapeModelStrings(false));

            } else { // add diagram content
                List<String> statNavigationTokens = getStatisticNavigation(statElement);
                final AjaxButton deleteButton = new AjaxButton("removeIcon") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onSubmit(AjaxRequestTarget target, Form<?> form) {

                        deleteSingleRowFromDiagramList(item);
                        updateDiagramTableContent();

                        target.add(statsForm);
                    }
                };
                item.add(deleteButton);
                item.add(new Label("statName", statElement.name).setEscapeModelStrings(false));
                IModel<String> aliasModel = null;
                DbStatisticDescription currentElement = listViewContent.get(item.getIndex());
                String currentElementKey = null;
                if (currentElement.getStatisticId() != 0 && currentElement.machineId != 0) {
                    currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime
                            + "_" + currentElement.getStatisticId() + "_" + currentElement.machineId;
                } else {
                    currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime
                            + "_" + currentElement.getName() + "_" + currentElement.getParentName();
                }
                // using diagramName+testcaseStartTime+statisticTypeId+machineId or testcaseStartTime+name+queueName for key
                IModel<String> alias = getTESession().getStatisticsAliasModels().get(currentElementKey);
                if (alias != null && alias.getObject() != null) {
                    aliasModel = alias;
                } else {
                    aliasModel = new Model<String>();
                }
                getTESession().getStatisticsAliasModels().put(currentElementKey, aliasModel);
                item.add(new TextField<String>("alias", aliasModel).setOutputMarkupId(true));
                item.add(new Label("startDate", statNavigationTokens.get(4)).setEscapeModelStrings(false));
                item.add(new Label("run", statNavigationTokens.get(0)).setEscapeModelStrings(false));
                item.add(new Label("suite", statNavigationTokens.get(1)).setEscapeModelStrings(false));
                item.add(new Label("scenario", statNavigationTokens.get(2)).setEscapeModelStrings(false));
                item.add(new Label("testcase", statNavigationTokens.get(3)).setEscapeModelStrings(false));
            }
        };
    };
    listViewChartGroup.setOutputMarkupId(true);

    return listViewChartGroup;
}

From source file:com.chbase.applications.weight.WeightPage.java

License:Apache License

public WeightPage(final PageParameters parameters) {
    add(new BookmarkablePageLink("signoff", SignOff.class));
    add(new Label("message", "Enter weight data"));
    add(new WeightForm("weight"));
    //Add weights
    List<WeightInfo> weightList = getWeights();
    thingList = new ListView("weightList", weightList) {
        protected void populateItem(ListItem item) {
            WeightInfo wi = (WeightInfo) item.getModelObject();
            item.add(new Label("id", wi.getId()));
            item.add(new Label("weight", wi.getValue()));
            item.add(new DeleteForm("delete", wi.getId(), wi.getVersion()));
        }/*from   ww w  . ja va 2  s. c o m*/
    };
    add(thingList);
}

From source file:com.cloudera.recordbreaker.fisheye.FileContentsTable.java

License:Open Source License

void renderToPage(String label, List<DataTablePair> tablePairs, final boolean renderLinks) {
    final long localFid = this.fid;
    add(new ListView<DataTablePair>(label, tablePairs) {
        protected void populateItem(ListItem<DataTablePair> outerItem) {
            DataTablePair outerModelObj = outerItem.getModelObject();
            List<List<HeaderPair>> outputHeaderList = outerModelObj.getHeaderPairs();
            List<List<DataField>> outputTupleList = outerModelObj.getTupleList();

            outerItem.add(new ListView<List<HeaderPair>>("attributelabels", outputHeaderList) {
                protected void populateItem(ListItem<List<HeaderPair>> item) {
                    List<HeaderPair> myListOfFieldLabels = item.getModelObject();
                    ListView<HeaderPair> listOfFields = new ListView<HeaderPair>("fieldlist",
                            myListOfFieldLabels) {
                        protected void populateItem(ListItem<HeaderPair> item2) {
                            HeaderPair displayPair = item2.getModelObject();
                            item2.add(new Label("alabel", "" + displayPair.getString()));
                            item2.add(new AttributeModifier("colspan", true,
                                    new Model("" + displayPair.getColSpan())));
                            if (!displayPair.isBottom()) {
                                item2.add(new AttributeModifier("style", true, new Model("text-align:center")));
                            }//from w ww .  j  ava  2  s  .co m
                        }
                    };
                    item.add(listOfFields);
                }
            });

            outerItem.add(new ListView<List<DataField>>("schemalistview", outputTupleList) {
                protected void populateItem(ListItem<List<DataField>> item) {
                    List<DataField> myListOfSchemaElts = item.getModelObject();

                    ListView<DataField> listofTupleFields = new ListView<DataField>("tupleview",
                            myListOfSchemaElts) {
                        protected void populateItem(ListItem<DataField> item2) {
                            DataField dataField = item2.getModelObject();

                            //
                            // Build list of suggested queries for the HTML popover.
                            // 
                            // 1.  SELECT * FROM DATA WHERE ATTR = 'celltext'
                            // <others coming>
                            //
                            String totalHTML = "";
                            WebMarkupContainer popovercontent = new WebMarkupContainer("popovercontent");
                            Label celltextalone = new Label("celltextalone", "" + dataField.getDataStr());
                            item2.add(popovercontent);
                            item2.add(celltextalone);
                            if (renderLinks && dataField.getDataStr().length() > 0) {
                                String sqlQueryText = "SELECT * FROM <i>DATA</i> WHERE "
                                        + dataField.getDataFieldName() + " = "
                                        + (dataField.isStringVal() ? "'" : "") + dataField.getDataStr()
                                        + (dataField.isStringVal() ? "'" : "");
                                String selectionClause = dataField.getDataFieldName() + "+%3D+"
                                        + (dataField.isStringVal() ? "%27" : "") + dataField.getDataStr()
                                        + (dataField.isStringVal() ? "%27" : "");
                                String sqlHyperlink = "/QueryResults?fid=" + localFid + "&projectionclause=*"
                                        + "&selectionclause=" + selectionClause + "&filename="
                                        + dataField.getFilename();
                                totalHTML = "<ul><li><a href='" + sqlHyperlink + "'>" + sqlQueryText
                                        + "</a></ul>";

                                popovercontent
                                        .add(new AttributeModifier("data-content", true, new Model(totalHTML)));
                                popovercontent.add(new Label("celltext", "" + dataField.getDataStr()));
                                popovercontent.setVisibilityAllowed(true);
                                celltextalone.setVisibilityAllowed(false);
                            } else {
                                popovercontent.setVisibilityAllowed(false);
                                celltextalone.setVisibilityAllowed(true);
                            }
                        }
                    };
                    item.add(listofTupleFields);
                }
            });
        }
    });
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheDetailsPage.java

License:Apache License

public CacheDetailsPage(final String hostnameStr) {
    final Behavior updater = new MultiUpdatingTimerBehavior(Duration.seconds(1));
    final Label hostname = new Label("hostname", hostnameStr);
    hostname.add(updater);/*from  w  w  w  .j ava2 s . c  om*/
    add(hostname);

    List<KeyValue> jsonValues = null;
    try {
        final CacheState atsState = CacheState.getState(hostnameStr);
        jsonValues = atsState.getModelList();
    } catch (Exception e) {
        LOGGER.warn(e, e);
        jsonValues = new ArrayList<KeyValue>();
        jsonValues.add(new KeyValue("Error", e.toString()));
    }
    final ListView<KeyValue> servers = new ListView<KeyValue>("params", jsonValues) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<KeyValue> item) {
            final KeyValue keyval = (KeyValue) item.getModelObject();
            item.add(new Label("key", keyval.getKey()));
            final Label v = new Label("value", keyval);
            v.add(updater);
            item.add(v);
        }
    };
    add(servers);
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel.java

License:Apache License

private ListView<String> createServerListView(final Behavior updater, final ModalWindow modalWindow) {
    return new ListView<String>("servers", getServerList()) {
        private static final long serialVersionUID = 1L;

        @Override//w  ww . jav a  2s  .  c  o m
        protected void populateItem(final ListItem<String> item) {
            final String cacheName = item.getModelObject();

            item.add(new UpdatingAttributeAppender("class", new Model<String>("") {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    final CacheState cs = CacheState.getState(cacheName);

                    if (cs != null && !cs.isAvailable()) {
                        final String status = cs.getLastValue(HealthDeterminer.STATUS);

                        if (status != null) {
                            switch (HealthDeterminer.AdminStatus.valueOf(status)) {
                            case ADMIN_DOWN:
                            case OFFLINE:
                                return "warning";
                            default:
                                return "error";
                            }
                        } else {
                            return "error";
                        }
                    } else {
                        return " ";
                    }
                }
            }, " "));
            item.add(updater);

            Label label = new Label("status", new CacheStateModel(cacheName, "_status_string_"));
            label.add(updater);
            item.add(label);
            label = new Label("loadavg", new CacheStateModel(cacheName, "loadavg"));
            label.add(updater);
            item.add(label);
            label = new Label("queryTime", new CacheStateModel(cacheName, "queryTime"));
            label.add(updater);
            item.add(label);
            label = new Label("kbps", new CacheStateModel(cacheName, "kbps"));
            label.add(updater);
            item.add(label);
            label = new Label("maxKbps", new CacheStateModel(cacheName, "maxKbps"));
            label.add(updater);
            item.add(label);
            label = new Label("current_client_connections",
                    new CacheStateModel(cacheName, "ats.proxy.process.http.current_client_connections"));
            label.add(updater);
            item.add(label);

            //            final PageParameters pars = new PageParameters();
            //            pars.add("hostname", cacheName);
            //            final BookmarkablePageLink<Object> link 
            //               = new BookmarkablePageLink<Object>("fulldetails", FullDetailsPage.class, pars);
            final AjaxLink<Void> link = new AjaxLink<Void>("fulldetails") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    hostname = cacheName;
                    modalWindow.show(target);
                }
            };
            link.setBody(new Model<String>(cacheName));
            item.add(link);
        }
    };
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.ConfigPanel.java

License:Apache License

public ConfigPanel(final String id, final Behavior updater) {
    super(id);/* w ww . ja  v  a  2  s .c o m*/

    this.setOutputMarkupId(true);

    final WebMarkupContainer c = new WebMarkupContainer("configpanel");
    add(c);

    this.setOutputMarkupId(true);
    final MonitorConfig config = ConfigHandler.getConfig();

    final Map<String, String> effectiveProps = config.getEffectiveProps();
    final ListView<String> propView2 = new ListView<String>("propList", sort(effectiveProps.keySet())) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<String> item) {
            final String key = item.getModelObject();

            Label label = new Label("key", key);
            item.add(label);
            label = new Label("value", new ConfigModel(key));
            label.add(updater);
            item.add(label);
        }
    };

    c.add(propView2);

}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsDetailsPage.java

License:Apache License

public DsDetailsPage(final String idStr) {
    final Behavior updater = new MultiUpdatingTimerBehavior(Duration.seconds(1));
    final Label hostname = new Label("id", idStr);
    hostname.add(updater);//from w  w w.j a va2s . com
    add(hostname);

    List<KeyValue> jsonValues = null;
    try {
        final DsState state = DsState.getState(idStr);
        jsonValues = state.getModelList();
    } catch (Exception e) {
        LOGGER.warn(e, e);
        jsonValues = new ArrayList<KeyValue>();
        jsonValues.add(new KeyValue("Error", e.toString()));
    }
    final ListView<KeyValue> servers = new ListView<KeyValue>("params", jsonValues) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<KeyValue> item) {
            final KeyValue keyval = (KeyValue) item.getModelObject();
            item.add(new Label("key", keyval.getKey()));
            final Label v = new Label("value", keyval);
            v.add(updater);
            item.add(v);
        }
    };
    add(servers);
}