Exemplo n.º 1
0
    private void ifItWasLink(
        List<TaskDataDto> result,
        MetricPanel metricPanel,
        TaskDataTreeViewModel taskDataTreeViewModel) {

      Set<MetricNameDto> metricsToSelect = new HashSet<MetricNameDto>();
      Set<PlotNameDto> trendsToSelect = new HashSet<PlotNameDto>();

      for (TaskDataDto taskDataDto : result) {
        for (TestsMetrics testMetric : place.getSelectedTestsMetrics()) {
          if (testMetric.getTestName().equals(taskDataDto.getTaskName())) {
            // add metrics
            for (String metricName : testMetric.getMetrics()) {
              MetricNameDto meticDto = new MetricNameDto();
              meticDto.setName(metricName);
              meticDto.setTests(taskDataDto);
              metricsToSelect.add(meticDto);
            }

            // add plots
            for (String trendsName : testMetric.getTrends()) {
              PlotNameDto plotNameDto = new PlotNameDto(taskDataDto, trendsName);
              trendsToSelect.add(plotNameDto);
            }
          }
        }
      }

      MetricNameDto fireMetric = null;
      if (!metricsToSelect.isEmpty()) fireMetric = metricsToSelect.iterator().next();

      for (MetricNameDto metric : metricsToSelect) {
        metricPanel.setSelected(metric);
      }
      metricPanel.addSelectionListener(new MetricsSelectionChangedHandler());

      if (fireMetric != null) metricPanel.setSelected(fireMetric);

      PlotNameDto firePlot = null;
      if (!trendsToSelect.isEmpty()) firePlot = trendsToSelect.iterator().next();

      for (PlotNameDto plotNameDto : trendsToSelect) {
        taskDataTreeViewModel.getSelectionModel().setSelected(plotNameDto, true);
      }
      taskDataTreeViewModel
          .getSelectionModel()
          .addSelectionChangeHandler(new TaskPlotSelectionChangedHandler());

      if (firePlot != null) taskDataTreeViewModel.getSelectionModel().setSelected(firePlot, true);
    }
Exemplo n.º 2
0
    @Override
    public void onSelectionChange(SelectionChangeEvent event) {
      // Currently selection model for sessions is a single selection model
      Set<SessionDataDto> selected =
          ((MultiSelectionModel<SessionDataDto>) event.getSource()).getSelectedSet();

      // Refresh summary
      chosenMetrics.clear();
      chosenPlots.clear();
      summaryPanel.updateSessions(selected);
      // Clear plots display
      plotPanel.clear();
      plotTrendsPanel.clear();
      // Clear markings dto map
      markingsMap.clear();
      testDataGrid.setRowData(Collections.EMPTY_LIST);
      chosenSessions.clear();
      sessionPlotPanel.clearPlots();

      if (selected.isEmpty()) {
        ((MultiSelectionModel) testDataGrid.getSelectionModel()).clear();
        return;
      }

      final Set<String> sessionIds = new HashSet<String>();
      for (SessionDataDto sessionDataDto : selected) {
        sessionIds.add(sessionDataDto.getSessionId());
        chosenSessions.add(sessionDataDto.getSessionId());
      }
      Collections.sort(
          chosenSessions,
          new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
              return (Long.parseLong(o2) - Long.parseLong(o1)) > 0 ? 0 : 1;
            }
          });

      TaskDataService.Async.getInstance()
          .getTaskDataForSessions(
              sessionIds,
              new AsyncCallback<List<TaskDataDto>>() {
                @Override
                public void onFailure(Throwable caught) {
                  caught.printStackTrace();
                }

                @Override
                public void onSuccess(List<TaskDataDto> result) {
                  updateTests(result);
                }
              });
    }
Exemplo n.º 3
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);
                  }
                });
      }
    }