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(); }
@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(); } } }); } }
@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); } }); }
@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(); }
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); }
private void makeSelectionForMetricPanel( Set<MetricNameDto> metricTempSet, MetricPanel metricPanel, List<TaskDataDto> result) { if (!metricTempSet.isEmpty()) { for (MetricNameDto metricName : metricTempSet) { for (TaskDataDto mN : result) { if (metricName.getTests().getTaskName().equals(mN.getTaskName())) { metricPanel.setSelected(new MetricNameDto(mN, metricName.getName())); } } } } }
private void makeSelectionForTaskDetailsTree( Set<PlotNameDto> plotTempSet, SelectionModel<PlotNameDto> plotNameSelectionModel, List<TaskDataDto> result) { if (!plotTempSet.isEmpty()) { for (PlotNameDto plotName : plotTempSet) { for (TaskDataDto td : result) { if (plotName.getTest().getTaskName().equals(td.getTaskName())) { plotNameSelectionModel.setSelected(new PlotNameDto(td, plotName.getPlotName()), true); } } } } }
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()); } }
private void filterSessions(Set<SessionDataDto> sessionDataDtoSet) { if (sessionDataDtoSet == null || sessionDataDtoSet.isEmpty()) { sessionIdsTextBox.setText(null); stopTypingSessionIdsTimer.schedule(10); return; } final StringBuilder builder = new StringBuilder(); boolean first = true; for (SessionDataDto sessionDataDto : sessionDataDtoSet) { if (!first) { builder.append("/"); } builder.append(sessionDataDto.getSessionId()); first = false; } sessionIdsTextBox.setText(builder.toString()); stopTypingSessionIdsTimer.schedule(10); }
private void updateTests(List<TaskDataDto> tests) { MultiSelectionModel<TaskDataDto> model = (MultiSelectionModel) testDataGrid.getSelectionModel(); previousSelectedSet.addAll(model.getSelectedSet()); model.clear(); testDataGrid.redraw(); testDataGrid.setRowData(tests); if (chosenSessions.size() == 1) { metricPanel.getSelectionModel().clear(); final boolean selectTestsFinal = selectTests; final String sessionId = chosenSessions.get(0); PlotProviderService.Async.getInstance() .getSessionScopePlotList( sessionId, new AsyncCallback<Set<String>>() { @Override public void onFailure(Throwable throwable) { throwable.printStackTrace(); } @Override public void onSuccess(Set<String> plotNames) { sessionPlotPanel.update(sessionId, plotNames); if (!selectTestsFinal) { sessionPlotPanel.setSelected(place.getSessionTrends()); } sessionPlotPanel .getSelectionModel() .addSelectionChangeHandler(new SessionScopePlotSelectionChangedHandler()); SelectionChangeEvent.fire(sessionPlotPanel.getSelectionModel()); } }); } makeSelectionOnTaskDataGrid(model, tests); }
@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(); }
@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); } }); } }