Пример #1
0
    private void removeUncheckedPlots(Set<String> selectedTaskIds) {

      List<Widget> toRemove = new ArrayList<Widget>();
      for (int i = 0; i < plotPanel.getWidgetCount(); i++) {
        Widget widget = plotPanel.getWidget(i);
        String widgetId = widget.getElement().getId();
        if ((!isSessionScopePlotId(widgetId)) || selectedTaskIds.contains(widgetId)) {
          continue;
        }
        toRemove.add(widget);
      }
      for (Widget widget : toRemove) {
        plotPanel.remove(widget);
        chosenPlots.remove(widget.getElement().getId());
      }
    }
Пример #2
0
    @Override
    public void onSelectionChange(SelectionChangeEvent event) {

      hasChanged = true;
      if (summaryPanel.getSessionComparisonPanel() == null) {
        plotTrendsPanel.clear();
        chosenMetrics.clear();
        return;
      }
      Set<MetricNameDto> metrics =
          ((MultiSelectionModel<MetricNameDto>) event.getSource()).getSelectedSet();

      if (metrics.isEmpty()) {
        // Remove plots from display which were unchecked
        chosenMetrics.clear();
        plotTrendsPanel.clear();
        summaryPanel.getSessionComparisonPanel().clearTreeStore();
      } else {

        final ArrayList<MetricNameDto> notLoaded = new ArrayList<MetricNameDto>();
        final ArrayList<MetricDto> loaded = new ArrayList<MetricDto>();

        for (MetricNameDto metricName : metrics) {
          if (!summaryPanel.getCachedMetrics().containsKey(metricName)) {
            notLoaded.add(metricName);
          } else {
            MetricDto metric = summaryPanel.getCachedMetrics().get(metricName);

            // if we have not checked it on previous selection, but already cached it some time
            if (!chosenMetrics.values().contains(metric)) {
              summaryPanel.getSessionComparisonPanel().addMetricRecord(metric);
            }

            loaded.add(metric);
          }
        }

        // Generate all id of plots which should be displayed
        Set<String> selectedMetricsIds = new HashSet<String>();
        for (MetricNameDto plotNameDto : metrics) {
          selectedMetricsIds.add(generateMetricPlotId(plotNameDto));
        }

        List<MetricDto> toRemoveFromTable = new ArrayList<MetricDto>();
        // Remove plots from display which were unchecked
        Set<String> metricIdsSet = new HashSet<String>(chosenMetrics.keySet());
        for (String plotId : metricIdsSet) {
          if (!selectedMetricsIds.contains(plotId)) {
            toRemoveFromTable.add(chosenMetrics.get(plotId));
            chosenMetrics.remove(plotId);
          }
        }
        metricIdsSet = chosenMetrics.keySet();
        List<Widget> toRemove = new ArrayList<Widget>();
        for (int i = 0; i < plotTrendsPanel.getWidgetCount(); i++) {
          Widget widget = plotTrendsPanel.getWidget(i);
          String wId = widget.getElement().getId();
          if (!metricIdsSet.contains(wId)) {
            toRemove.add(widget);
          }
        }
        for (Widget widget : toRemove) {
          plotTrendsPanel.remove(widget);
        }
        summaryPanel.getSessionComparisonPanel().removeRecords(toRemoveFromTable);

        MetricDataService.Async.getInstance()
            .getMetrics(
                notLoaded,
                new AsyncCallback<List<MetricDto>>() {
                  @Override
                  public void onFailure(Throwable caught) {
                    caught.printStackTrace();
                  }

                  @Override
                  public void onSuccess(List<MetricDto> result) {
                    loaded.addAll(result);
                    MetricRankingProvider.sortMetrics(loaded);

                    summaryPanel.getSessionComparisonPanel().addMetricRecords(result);

                    renderMetricPlots(loaded);
                  }
                });
      }
    }