Ejemplo n.º 1
0
 /**
  * Sets the currently selected row by key of its {@link UserItem}.
  *
  * @param key key of {@link UserItem}
  * @param forceExpand whether the selected row shall be expanded
  */
 public void setSelectedKey(Key key, boolean forceExpand) {
   if (key == null) {
     RowWidget old = rows.get(selected);
     old.collapse();
     old.removeStyleDependentName("selected");
     selected = null;
     SelectionChangeEvent.fire(this);
   } else if (key.equals(selected)) {
     // was selected and is selected
   } else {
     boolean expand = true;
     // selected changed
     if (selected != null) {
       RowWidget old = rows.get(selected);
       old.removeStyleDependentName("selected");
       if (old.isExpanded()) {
         old.collapse();
       } else {
         expand = false;
       }
     }
     RowWidget newly = rows.get(key);
     if (expand || forceExpand) {
       newly.expand();
     }
     selected = key;
     newly.addStyleDependentName("selected");
     SelectionChangeEvent.fire(this);
   }
 }
Ejemplo n.º 2
0
    private void makeSelectionOnTaskDataGrid(
        MultiSelectionModel<TaskDataDto> model, List<TaskDataDto> tests) {

      if (selectTests) {
        if (!previousSelectedSet.isEmpty()) {
          for (TaskDataDto taskDataDto : tests) {
            for (TaskDataDto taskDataPrevious : previousSelectedSet) {
              if (taskDataDto.getTaskName().equals(taskDataPrevious.getTaskName())) {
                model.setSelected(taskDataDto, true);
              }
            }
          }
          SelectionChangeEvent.fire(testDataGrid.getSelectionModel());
        }

      } else {
        Set<TestsMetrics> testsMetrics = place.getSelectedTestsMetrics();
        for (TaskDataDto taskDataDto : tests) {
          for (TestsMetrics testMetric : testsMetrics) {
            if (testMetric.getTestName().equals(taskDataDto.getTaskName())) {
              model.setSelected(taskDataDto, true);
            }
          }
        }
        model.addSelectionChangeHandler(new TestSelectChangeHandler());

        SelectionChangeEvent.fire(model);
      }
      previousSelectedSet.clear();
    }
Ejemplo n.º 3
0
    @Override
    public void onSelectionChange(SelectionChangeEvent event) {

      Set<PlotNameDto> selected =
          ((MultiSelectionModel<PlotNameDto>) event.getSource()).getSelectedSet();

      if (selected.isEmpty()) {
        // Remove plots from display which were unchecked
        removeUncheckedPlots(Collections.EMPTY_SET);
      } else {
        // Generate all id of plots which should be displayed
        Set<String> selectedTaskIds = generateTaskPlotIds(selected, chosenSessions.size());

        // Remove plots from display which were unchecked
        removeUncheckedPlots(selectedTaskIds);

        PlotProviderService.Async.getInstance()
            .getPlotDatas(
                selected,
                new AsyncCallback<Map<PlotNameDto, List<PlotSeriesDto>>>() {

                  @Override
                  public void onFailure(Throwable caught) {
                    caught.printStackTrace();
                  }

                  @Override
                  public void onSuccess(Map<PlotNameDto, List<PlotSeriesDto>> result) {
                    for (PlotNameDto plotNameDto : result.keySet()) {
                      if (isMaxPlotCountReached()) {
                        Window.alert("You are reached max count of plot on display");
                        break;
                      }

                      final String id;
                      // Generate DOM id for plot
                      if (chosenSessions.size() == 1) {
                        id = generateTaskScopePlotId(plotNameDto);
                      } else {
                        id = generateCrossSessionsTaskScopePlotId(plotNameDto);
                      }

                      // If plot has already displayed, then pass it
                      if (chosenPlots.containsKey(id)) {
                        continue;
                      }

                      chosenPlots.put(id, result.get(plotNameDto));
                    }
                    if (mainTabPanel.getSelectedIndex() == 2) {
                      onMetricsTabSelected();
                    }
                  }
                });
      }
    }
Ejemplo n.º 4
0
 public void update(final List<Property> models) {
   dataProvider.setList(models);
   if (models.isEmpty()) {
     selectionModel.clear();
   } else {
     table.selectDefaultEntity();
   }
   SelectionChangeEvent.fire(
       selectionModel); // updates ModelNodeForm's editedEntity with current value
 }
Ejemplo n.º 5
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);
                }
              });
    }
Ejemplo n.º 6
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();
    }
  void resolveChanges() {
    Set<Object> selectedKeys = selectedSet.keySet();
    List<Object> visibleKeys = new ArrayList<>();
    for (T visible : dataDisplay.getVisibleItems()) {
      visibleKeys.add(getKey(visible));
    }

    if (!visibleKeys.containsAll(selectedKeys)) {
      for (Map.Entry<Object, T> selectedEntry : selectedSet.entrySet()) {
        if (!visibleKeys.contains(selectedEntry.getKey())) {
          selectionChanges.put(selectedEntry.getValue(), false);
        }
      }
    }

    if (selectionChanges.isEmpty()) {
      return;
    }

    boolean changed = false;
    for (Map.Entry<T, Boolean> entry : selectionChanges.entrySet()) {
      T object = entry.getKey();
      boolean selected = entry.getValue();

      Object key = getKey(object);
      T oldValue = selectedSet.get(key);
      if (selected) {
        if (oldValue == null || !oldValue.equals(object)) {
          selectedSet.put(getKey(object), object);
          changed = true;
        }
      } else {
        if (oldValue != null) {
          selectedSet.remove(key);
          changed = true;
        }
      }
    }
    selectionChanges.clear();

    if (changed) {
      SelectionChangeEvent.fire(this);
    }
  }
Ejemplo n.º 8
0
 public HandlerRegistration addSelectionChangeHandler(
     com.google.gwt.view.client.SelectionChangeEvent.Handler handler) {
   return addHandler(handler, SelectionChangeEvent.getType());
 }
Ejemplo n.º 9
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);
                  }
                });
      }
    }
Ejemplo n.º 10
0
 private void fireSelectionChange() {
   if (manageSelection) setSelected(!selected);
   SelectionChangeEvent.fire(this);
 }
Ejemplo n.º 11
0
 @Override
 public HandlerRegistration addSelectionChangeHandler(Handler handler) {
   return handlerManager.addHandler(SelectionChangeEvent.getType(), handler);
 }