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
  public void updatePlace(TrendsPlace place) {
    if (this.place != null) return;

    this.place = place;
    final TrendsPlace finalPlace = this.place;
    if (place.getSelectedSessionIds().isEmpty()) {

      sessionsDataGrid
          .getSelectionModel()
          .addSelectionChangeHandler(new SessionSelectChangeHandler());

      selectTests = true;
      testDataGrid.getSelectionModel().addSelectionChangeHandler(new TestSelectChangeHandler());

      TaskDataTreeViewModel viewModel = (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
      viewModel
          .getSelectionModel()
          .addSelectionChangeHandler(new TaskPlotSelectionChangedHandler());

      metricPanel.addSelectionListener(new MetricsSelectionChangedHandler());

      chooseTab(place.getToken());
      return;
    }

    SessionDataService.Async.getInstance()
        .getBySessionIds(
            0,
            place.getSelectedSessionIds().size(),
            place.getSelectedSessionIds(),
            new AsyncCallback<PagedSessionDataDto>() {
              @Override
              public void onFailure(Throwable caught) {
                caught.printStackTrace();
              }

              @Override
              public void onSuccess(PagedSessionDataDto result) {
                for (SessionDataDto session : result.getSessionDataDtoList()) {
                  sessionsDataGrid.getSelectionModel().setSelected(session, true);
                }
                sessionsDataGrid
                    .getSelectionModel()
                    .addSelectionChangeHandler(new SessionSelectChangeHandler());
                sessionsDataGrid
                    .getSelectionModel()
                    .setSelected(result.getSessionDataDtoList().iterator().next(), true);
                chooseTab(finalPlace.getToken());
              }
            });
    History.newItem(NameTokens.EMPTY);
  }
Exemplo n.º 3
0
    @Override
    public void onSelectionChange(SelectionChangeEvent event) {

      Set<TaskDataDto> selected =
          ((MultiSelectionModel<TaskDataDto>) event.getSource()).getSelectedSet();
      List<TaskDataDto> result = new ArrayList<TaskDataDto>(selected);

      TaskDataTreeViewModel taskDataTreeViewModel =
          (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
      MultiSelectionModel<PlotNameDto> plotNameSelectionModel =
          taskDataTreeViewModel.getSelectionModel();

      // chosen plots
      Set<PlotNameDto> plotTempSet = plotNameSelectionModel.getSelectedSet();
      // chosen metrics
      Set<MetricNameDto> metricTempSet = metricPanel.getSelected();

      chosenPlots.clear();
      // Clear markings dto map
      markingsMap.clear();
      taskDataTreeViewModel.clear();
      plotNameSelectionModel.clear();
      metricPanel.updateTests(result);
      taskDataTreeViewModel.populateTaskList(result);
      // Populate available plots tree level for each task for selected session
      for (TaskDataDto taskDataDto : result) {
        taskDataTreeViewModel
            .getPlotNameDataProviders()
            .put(
                taskDataDto,
                new TaskPlotNamesAsyncDataProvider(taskDataDto, summaryPanel.getSessionIds()));
      }
      summaryPanel.updateTests(result);

      if (selectTests) {
        makeSelectionForMetricPanel(metricTempSet, metricPanel, result);
        makeSelectionForTaskDetailsTree(plotTempSet, plotNameSelectionModel, result);
      } else {
        selectTests = true;
        ifItWasLink(result, metricPanel, taskDataTreeViewModel);
      }

      metricTempSet.clear();
      plotTempSet.clear();
    }
Exemplo n.º 4
0
  @UiHandler("getHyperlink")
  void getHyperlink(ClickEvent event) {
    MultiSelectionModel<SessionDataDto> sessionModel =
        (MultiSelectionModel) sessionsDataGrid.getSelectionModel();
    MultiSelectionModel<TaskDataDto> testModel =
        (MultiSelectionModel) testDataGrid.getSelectionModel();

    Set<SessionDataDto> sessions = sessionModel.getSelectedSet();

    Set<TaskDataDto> tests = testModel.getSelectedSet();

    Set<MetricNameDto> metrics = metricPanel.getSelected();

    TaskDataTreeViewModel taskDataTreeViewModel =
        (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
    Set<PlotNameDto> trends = taskDataTreeViewModel.getSelectionModel().getSelectedSet();

    HashSet<String> sessionsIds = new HashSet<String>();
    HashSet<TestsMetrics> testsMetricses = new HashSet<TestsMetrics>(tests.size());
    HashMap<String, TestsMetrics> map = new HashMap<String, TestsMetrics>(tests.size());

    for (SessionDataDto session : sessions) {
      sessionsIds.add(session.getSessionId());
    }

    for (TaskDataDto taskDataDto : tests) {
      TestsMetrics testsMetrics =
          new TestsMetrics(taskDataDto.getTaskName(), new HashSet<String>(), new HashSet<String>());
      testsMetricses.add(testsMetrics);
      map.put(taskDataDto.getTaskName(), testsMetrics);
    }

    for (MetricNameDto metricNameDto : metrics) {
      map.get(metricNameDto.getTests().getTaskName()).getMetrics().add(metricNameDto.getName());
    }

    for (PlotNameDto plotNameDto : trends) {
      map.get(plotNameDto.getTest().getTaskName()).getTrends().add(plotNameDto.getPlotName());
    }

    TrendsPlace newPlace =
        new TrendsPlace(
            mainTabPanel.getSelectedIndex() == 0
                ? NameTokens.SUMMARY
                : mainTabPanel.getSelectedIndex() == 1 ? NameTokens.TRENDS : NameTokens.METRICS);

    newPlace.setSelectedSessionIds(sessionsIds);
    newPlace.setSelectedTestsMetrics(testsMetricses);
    newPlace.setSessionTrends(sessionPlotPanel.getSelected());

    String linkText =
        Window.Location.getHost()
            + Window.Location.getPath()
            + Window.Location.getQueryString()
            + "#"
            + new JaggerPlaceHistoryMapper().getToken(newPlace);
    linkText = URL.encode(linkText);

    // create a dialog for copy link
    final DialogBox dialog = new DialogBox(false, true);
    dialog.setText("Share link");
    dialog.setModal(true);
    dialog.setAutoHideEnabled(true);
    dialog.setPopupPosition(event.getClientX(), event.getClientY());

    final TextArea textArea = new TextArea();
    textArea.setText(linkText);
    textArea.setWidth("300px");
    textArea.setHeight("40px");
    // select text
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {
                textArea.setVisible(true);
                textArea.setFocus(true);
                textArea.selectAll();
              }
            });

    dialog.add(textArea);

    dialog.show();
  }