Exemplo n.º 1
0
 public PhotoView() {
   initWidget(uiBinder.createAndBindUi(this));
   cellTable.setWidth("100%", true);
   pager.setDisplay(cellTable);
   initColumns();
   cellTable.addRangeChangeHandler(
       new RangeChangeEvent.Handler() {
         @Override
         public void onRangeChange(RangeChangeEvent event) {
           AppContext.getInstance()
               .getEventBus()
               .fireEvent(new ShowPhotoRange(event.getNewRange()));
         }
       });
 }
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
  private void setupTestDataGrid() {
    testDataGrid = new CellTable<TaskDataDto>();
    testDataGrid.setWidth("500px");
    testDataGrid.setEmptyTableWidget(new Label("No Tests"));

    // Add a selection model so we can select cells.
    final SelectionModel<TaskDataDto> selectionModel =
        new MultiSelectionModel<TaskDataDto>(
            new ProvidesKey<TaskDataDto>() {
              @Override
              public Object getKey(TaskDataDto item) {
                return item.getTaskName();
              }
            });
    testDataGrid.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<TaskDataDto>createCheckboxManager());

    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable mouse selection.
    Column<TaskDataDto, Boolean> checkColumn =
        new Column<TaskDataDto, Boolean>(new CheckboxCell(true, false)) {
          @Override
          public Boolean getValue(TaskDataDto object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };
    testDataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    testDataGrid.setColumnWidth(checkColumn, 40, Style.Unit.PX);

    testDataGrid.addColumn(
        new TextColumn<TaskDataDto>() {
          @Override
          public String getValue(TaskDataDto object) {
            return object.getTaskName();
          }
        },
        "Tests");
    testDataGrid.setRowData(Collections.EMPTY_LIST);
  }
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();
  }
Exemplo n.º 5
0
  public void initColumns() {
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return object.getTitle();
          }
        },
        "Title");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return object.getOwnerName();
          }
        },
        "Owner name");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return object.getViews();
          }
        },
        "Views");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return DateTimeFormat.getFormat("dd-MM-yyyy HH:mm").format(object.getDateupload());
          }
        },
        "Date Upload");
    cellTable.addColumn(
        new TextColumn<Photo>() {
          @Override
          public String getValue(Photo object) {
            return DateTimeFormat.getFormat("dd-MM-yyyy HH:mm").format(object.getLastupdate());
          }
        },
        "Last Update");
    cellTable.addColumn(
        new Column<Photo, String>(new ImageCell(75, 75)) {
          @Override
          public String getValue(Photo object) {
            return object.getUrl();
          }
        },
        "Photo");

    cellTable.addCellPreviewHandler(
        new CellPreviewEvent.Handler<Photo>() {
          @Override
          public void onCellPreview(CellPreviewEvent<Photo> event) {
            if (event.getNativeEvent().getType().equals("mousedown")) {
              Photo photo = event.getValue();
              AppContext.getInstance().getEventBus().fireEvent(new ShowPhotoDialog(photo));
            }
          }
        });
  }
Exemplo n.º 6
0
 public void setPhotoRange(int start, Photo[] photos) {
   cellTable.setRowData(start, Arrays.asList(photos));
 }
Exemplo n.º 7
0
 public void setPhotoCount(int photoCount) {
   cellTable.setRowCount(photoCount);
   AppContext.getInstance()
       .getEventBus()
       .fireEvent(new ShowPhotoRange(cellTable.getVisibleRange()));
 }