@Test
  public void click() {
    // Given
    final StringBuilder sb = new StringBuilder();

    // Add a selection model to handle user selection.
    final SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>();
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          public void onSelectionChange(SelectionChangeEvent event) {
            Contact selected = selectionModel.getSelectedObject();
            if (selected != null) {
              sb.append(selected.name).append(" : ").append(selected.address);
            }
          }
        });

    // When 1
    Browser.click(table, CONTACTS.get(0));

    // Then 1
    assertThat(sb.toString()).isEqualTo("Gael : 666 Evil");
    assertThat(table.getSelectionModel().isSelected(CONTACTS.get(0))).isTrue();

    // When 2 : deselect
    Browser.click(table, CONTACTS.get(0));

    // Then 2
    assertThat(sb.toString()).isEqualTo("Gael : 666 Evil");
    assertThat(table.getSelectionModel().isSelected(CONTACTS.get(0))).isFalse();
  }
 @Override
 protected void addColumns(DataGrid<DnsResolverServiceProxy> table) {
   Column<DnsResolverServiceProxy, String> dnsNameColumn =
       TextColumn.build(DnsResolverServiceProxy.DnsName);
   table.addColumn(dnsNameColumn, "Description");
   table.setColumnWidth(dnsNameColumn, "40ex");
 }
  @Override
  public void init(QuickNewJobPresenter p) {
    this.presenter = p;

    newParametersButton.setText(constants.Add_Parameter());
    createButton.setText(constants.Create());
    jobNameLabel.setText(constants.Name());
    jobDueLabel.setText(constants.Due_On());
    jobTypeLabel.setText(constants.Type());
    dataTriesLabel.setText(constants.Retries());

    myParametersGrid.setHeight("200px");

    // Set the message to display when the table is empty.
    myParametersGrid.setEmptyTableWidget(new Label(constants.No_Parameters_added_yet()));

    initGridColumns();

    long now = System.currentTimeMillis();
    jobDueDate.setEnabled(true);

    jobDueDate.setValue(now);

    jobDueDateTime.setValue(UTCDateBox.date2utc(new Date()));
  }
 protected void displayProblems(ProblemAndSubmissionReceipt[] result) {
   if (result != null) {
     grid.setRowCount(result.length);
     grid.setRowData(Arrays.asList(result));
     grid.setWidth("100%");
     grid.setHeight(result.length * 50 + "px");
   }
 }
Example #5
0
  /**
   * Constructor.
   *
   * @param page the {@link CloudCoderPage} that will contain this view
   */
  public ProblemListView3(CloudCoderPage page) {
    this.page = page;

    cellTable = new DataGrid<ProblemAndSubmissionReceipt>();

    // Configure the DataGrid that will show the problems
    cellTable.addColumn(new TestNameColumn(), "Name");
    cellTable.addColumn(new WhenDueColumn(), "Due");
    cellTable.addColumn(new SubmissionStatusColumn(), "Status");

    initWidget(cellTable);
  }
  private void initTable(
      DataGrid<KBWorkspaceObjectData> table, ListDataProvider<KBWorkspaceObjectData> dataProvider) {
    // populate the view with the current user's stuff.
    // columns: id, owner, command, mod date
    TextColumn<KBWorkspaceObjectData> idColumn =
        new TextColumn<KBWorkspaceObjectData>() {
          @Override
          public String getValue(KBWorkspaceObjectData metadata) {
            return metadata.getId();
          }
        };

    TextColumn<KBWorkspaceObjectData> workspaceColumn =
        new TextColumn<KBWorkspaceObjectData>() {
          @Override
          public String getValue(KBWorkspaceObjectData metadata) {
            return metadata.getWorkspace();
          }
        };

    TextColumn<KBWorkspaceObjectData> ownerColumn =
        new TextColumn<KBWorkspaceObjectData>() {
          @Override
          public String getValue(KBWorkspaceObjectData metadata) {
            return metadata.getOwner();
          }
        };

    TextColumn<KBWorkspaceObjectData> modDateColumn =
        new TextColumn<KBWorkspaceObjectData>() {
          @Override
          public String getValue(KBWorkspaceObjectData metadata) {
            return metadata.getModDate();
          }
        };

    // add columns to the table
    table.addColumn(idColumn, TEXT_ID_COL);
    table.addColumn(workspaceColumn, TEXT_WORKSPACE_COL);
    table.addColumn(ownerColumn, TEXT_OWNER_COL);
    table.addColumn(modDateColumn, TEXT_DATE_COL);

    // add data provider
    dataProvider.addDataDisplay(table);

    // add a selection model
    final SingleSelectionModel<KBWorkspaceObjectData> selectionModel =
        new SingleSelectionModel<KBWorkspaceObjectData>(KBWorkspaceObjectData.KEY_PROVIDER);
    table.setSelectionModel(selectionModel);
  }
Example #7
0
  private void setupSessionDataGrid() {
    sessionsDataGrid = new DataGrid<SessionDataDto>();
    sessionsDataGrid.setPageSize(15);
    sessionsDataGrid.setEmptyTableWidget(new Label("No Sessions"));

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

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

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getName();
          }
        },
        "Name");

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getStartDate();
          }
        },
        "Start Date");

    sessionsDataGrid.addColumn(
        new TextColumn<SessionDataDto>() {
          @Override
          public String getValue(SessionDataDto object) {
            return object.getEndDate();
          }
        },
        "End Date");

    sessionDataProvider.addDataDisplay(sessionsDataGrid);
  }
Example #8
0
 @UiHandler("showCheckedSessionsButton")
 void handleShowCheckedSessionsButtonClick(ClickEvent e) {
   Set<SessionDataDto> sessionDataDtoSet =
       ((MultiSelectionModel<SessionDataDto>) sessionsDataGrid.getSelectionModel())
           .getSelectedSet();
   filterSessions(sessionDataDtoSet);
 }
  /** Constructor. */
  public UserProgressListView(User myUser) {
    user = myUser;

    grid = new DataGrid<ProblemAndSubmissionReceipt>();
    TextColumn<ProblemAndSubmissionReceipt> colID =
        new TextColumn<ProblemAndSubmissionReceipt>() {
          @Override
          public String getValue(ProblemAndSubmissionReceipt problem) {
            return problem.getProblem().getProblemId() + "";
          }
        };
    grid.addColumn(colID, "ID");
    grid.setColumnWidth(colID, "50px");
    grid.addColumn(
        new TextColumn<ProblemAndSubmissionReceipt>() {
          @Override
          public String getValue(ProblemAndSubmissionReceipt problem) {
            return problem.getProblem().getTestname();
          }
        },
        "Problem name");
    grid.addColumn(
        new TextColumn<ProblemAndSubmissionReceipt>() {
          @Override
          public String getValue(ProblemAndSubmissionReceipt problem) {
            if (problem.getReceipt() == null) return "0/0";
            else
              return problem.getReceipt().getNumTestsPassed()
                  + "/"
                  + problem.getReceipt().getNumTestsAttempted();
          }
        },
        "Best score");
    grid.addColumn(
        new TextColumn<ProblemAndSubmissionReceipt>() {
          @Override
          public String getValue(ProblemAndSubmissionReceipt problem) {
            return problem.getProblem().getWhenDueAsDate().toString().substring(4, 19);
          }
        },
        "Due date");

    initWidget(grid);
  }
Example #10
0
  public void activate(final Session session, final SubscriptionRegistrar subscriptionRegistrar) {
    // Subscribe to session ADDED_OBJECT events (so we will see when a course is selected)
    session.subscribe(Session.Event.ADDED_OBJECT, this, subscriptionRegistrar);

    // When a problem is selected, add it to the session
    final SingleSelectionModel<ProblemAndSubmissionReceipt> selectionModel =
        new SingleSelectionModel<ProblemAndSubmissionReceipt>();
    cellTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            ProblemAndSubmissionReceipt selected = selectionModel.getSelectedObject();
            if (selected != null) {
              // Add the problem to the Session
              session.add(selected.getProblem());
            }
          }
        });

    // Load the exercise when the user double-clicks
    cellTable.addDomHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            Problem problem = session.get(Problem.class);
            if (problem != null) {
              // Switch to DevelopmentPage
              session.get(PageStack.class).push(PageId.DEVELOPMENT);
            }
          }
        },
        DoubleClickEvent.getType());

    // If there is already a Course selected, load its problems.
    // Otherwise, if there are problems already in the session, display them.
    CourseSelection courseSelection = session.get(CourseSelection.class);
    ProblemAndSubmissionReceipt[] problemList = session.get(ProblemAndSubmissionReceipt[].class);
    if (courseSelection != null) {
      loadProblemsForCourse(courseSelection);
    } else if (problemList != null) {
      displayLoadedProblems(problemList);
    }
  }
Example #11
0
  private void displayLoadedProblems(ProblemAndSubmissionReceipt[] problemList) {
    GWT.log("Displaying " + problemList.length + " problems/submission receipts");

    // Sort by due date
    ProblemAndSubmissionReceipt[] list = new ProblemAndSubmissionReceipt[problemList.length];
    System.arraycopy(problemList, 0, list, 0, problemList.length);
    ViewUtil.sortProblemsByDueDate(list);

    cellTable.setRowData(Arrays.asList(list));
  }
Example #12
0
 private void markChange(InputItem rec) {
   if (!changedRecs.containsKey(rec.getId())) {
     changedRecs.put(rec.getId(), rec);
     if (!separator.isVisible()) {
       md.info(
           MDS, "Some data has been changed. Click 'Save' or 'Cancel' when editing is finished.");
       editMode(true);
     }
     dataGrid.redraw();
   }
 }
Example #13
0
  public ExonDetailPanel() {
    dataGrid.setWidth("100%");
    initializeTable();
    dataProvider.addDataDisplay(dataGrid);
    dataGrid.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            if (selectionModel.getSelectedSet().isEmpty()) {
              exonEditContainer.setVisible(false);
            } else {
              exonEditContainer.setVisible(true);
              updateDetailData(selectionModel.getSelectedObject());
            }
          }
        });

    initWidget(ourUiBinder.createAndBindUi(this));
  }
Example #14
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);
  }
Example #15
0
  private <C> Column<RuleInfo, C> addColumn(
      Cell<C> cell,
      String headerText,
      final GetValue<C> getter,
      FieldUpdater<RuleInfo, C> fieldUpdater) {
    Column<RuleInfo, C> column =
        new Column<RuleInfo, C>(cell) {
          @Override
          public C getValue(RuleInfo object) {
            return getter.getValue(object);
          }
        };
    column.setFieldUpdater(fieldUpdater);

    dataGrid.addColumn(column, headerText);
    return column;
  }
Example #16
0
  private void onProblemSelected(Problem selectedProblem) {
    ProblemAndSubmissionReceipt[] data = page.getSession().get(ProblemAndSubmissionReceipt[].class);
    SingleSelectionModel<? super ProblemAndSubmissionReceipt> sm =
        (SingleSelectionModel<? super ProblemAndSubmissionReceipt>) cellTable.getSelectionModel();
    for (ProblemAndSubmissionReceipt p : data) {
      if (p.getProblem().getProblemId().equals(selectedProblem.getProblemId())) {
        // Found the selected problem, so change the selected row
        sm.clear();
        sm.setSelected(p, true);
        return;
      }
    }

    // The selected problem isn't being viewed currently,
    // so just clear the selection
    sm.clear();
  }
  private void initGrid() {
    Column<KeystoneTenant, Boolean> checkboxColumn =
        new Column<KeystoneTenant, Boolean>(new CheckboxCell()) {

          @Override
          public Boolean getValue(KeystoneTenant object) {
            return false;
          }
        };
    grid.setColumnWidth(checkboxColumn, "40px");
    grid.addColumn(checkboxColumn, "");
    TextColumn<KeystoneTenant> nameColumn =
        new TextColumn<KeystoneTenant>() {
          @Override
          public String getValue(KeystoneTenant object) {
            return object.getName();
          }
        };
    grid.setColumnWidth(nameColumn, "120px");
    grid.addColumn(nameColumn, "Name");
    TextColumn<KeystoneTenant> descriptionColumn =
        new TextColumn<KeystoneTenant>() {
          @Override
          public String getValue(KeystoneTenant object) {
            return object.getName();
          }
        };
    grid.setColumnWidth(descriptionColumn, "120px");
    grid.addColumn(descriptionColumn, "Description");
    TextColumn<KeystoneTenant> enabledColumn =
        new TextColumn<KeystoneTenant>() {
          @Override
          public String getValue(KeystoneTenant object) {
            return object.isEnabled() ? "ENABLED" : "DISABLED";
          }
        };
    grid.setColumnWidth(enabledColumn, "120px");
    grid.addColumn(enabledColumn, "STATUS");
  }
Example #18
0
  public void updateData(AnnotationInfo annotationInfo) {
    if (annotationInfo == null) return;
    // displayAnnotationInfo(annotationInfo);
    getAnnotationInfoWithTopLevelFeature(annotationInfo);
    annotationInfoList.clear();
    exonEditContainer.setVisible(false);
    GWT.log("sublist: " + annotationInfo.getAnnotationInfoSet().size());
    for (AnnotationInfo annotationInfo1 : annotationInfo.getAnnotationInfoSet()) {
      GWT.log("adding: " + annotationInfo1.getName());
      annotationInfoList.add(annotationInfo1);
    }

    // TODO: calculate phases
    //        calculatePhaseOnList(annotationInfoList);

    GWT.log("should be showing: " + annotationInfoList.size());

    if (annotationInfoList.size() > 0) {
      updateDetailData(annotationInfoList.get(0));
    }
    dataGrid.redraw();
  }
  @Before
  public void beforeCellTableTest() {
    // Create a CellTable.
    table = new DataGrid<Contact>();

    // Create name column.
    TextColumn<Contact> nameColumn =
        new TextColumn<Contact>() {
          @Override
          public String getValue(Contact contact) {
            return contact.name;
          }
        };

    // Create address column.
    TextColumn<Contact> addressColumn =
        new TextColumn<Contact>() {
          @Override
          public String getValue(Contact contact) {
            return contact.address;
          }
        };

    // Add the columns.
    table.addColumn(nameColumn, "Name");
    table.addColumn(addressColumn, "Address");

    // Set the total row count. This isn't strictly necessary, but it affects
    // paging calculations, so its good habit to keep the row count up to
    // date.
    table.setRowCount(CONTACTS.size(), true);

    // Push the data into the widget.
    table.setRowData(0, CONTACTS);

    table.setVisibleRange(0, 2);

    // Preconditions
    assertThat(table.getRowCount()).isEqualTo(3);
    assertThat(table.getVisibleItemCount()).isEqualTo(2);
  }
  private void initCellTable() {
    final PlaceRequest.Builder request =
        new PlaceRequest.Builder().nameToken(NameTokens.candidateGeneListDetail);
    dataGrid.addColumn(
        new IdentityColumn<CandidateGeneListProxy>(new TitleCell(request, placeManager)) {},
        "Name");

    dataGrid.addColumn(
        new Column<CandidateGeneListProxy, String>(new TextCell()) {
          @Override
          public String getValue(CandidateGeneListProxy object) {
            String retval = object.getDescription();
            return retval;
          }
        },
        "Description");
    dataGrid.addColumn(
        new Column<CandidateGeneListProxy, Number>(new NumberCell()) {
          @Override
          public Number getValue(CandidateGeneListProxy object) {
            return object.getGeneCount();
          }
        },
        "# Genes");
    dataGrid.addColumn(
        new Column<CandidateGeneListProxy, AppUserProxy>(avatarNameCell) {
          @Override
          public AppUserProxy getValue(CandidateGeneListProxy object) {
            return object.getOwnerUser();
          }
        },
        "Owner");
    dataGrid.addColumn(new AccessColumn(), "Access");
    dataGrid.setColumnWidth(3, 250, Style.Unit.PX);
    dataGrid.setColumnWidth(4, 150, Style.Unit.PX);
  }
Example #21
0
  public OrganismPanel() {
    initWidget(ourUiBinder.createAndBindUi(this));
    loadingDialog = new LoadingDialog("Processing ...", null, false);

    TextColumn<OrganismInfo> organismNameColumn =
        new TextColumn<OrganismInfo>() {
          @Override
          public String getValue(OrganismInfo organism) {
            return organism.getName();
          }
        };
    Column<OrganismInfo, Number> annotationsNameColumn =
        new Column<OrganismInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(OrganismInfo object) {
            return object.getNumFeatures();
          }
        };
    Column<OrganismInfo, Number> sequenceColumn =
        new Column<OrganismInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(OrganismInfo object) {
            return object.getNumSequences();
          }
        };

    sequenceColumn.setSortable(true);
    organismNameColumn.setSortable(true);
    annotationsNameColumn.setSortable(true);

    Annotator.eventBus.addHandler(
        OrganismChangeEvent.TYPE,
        new OrganismChangeEventHandler() {
          @Override
          public void onOrganismChanged(OrganismChangeEvent organismChangeEvent) {
            organismInfoList.clear();
            organismInfoList.addAll(MainPanel.getInstance().getOrganismInfoList());
          }
        });

    dataGrid.setLoadingIndicator(new HTML("Calculating Annotations ... "));
    dataGrid.addColumn(organismNameColumn, "Name");
    dataGrid.addColumn(annotationsNameColumn, "Annotations");
    dataGrid.addColumn(sequenceColumn, "Ref Sequences");
    dataGrid.setEmptyTableWidget(
        new Label("No organisms available. Add new organisms using the form field."));

    singleSelectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            if (!creatingNewOrganism) {
              loadOrganismInfo();
              changeButtonSelection();
            } else {
              creatingNewOrganism = false;
            }
          }
        });
    dataGrid.setSelectionModel(singleSelectionModel);

    dataProvider.addDataDisplay(dataGrid);

    dataGrid.addDomHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            if (singleSelectionModel.getSelectedObject() != null) {
              String orgId = singleSelectionModel.getSelectedObject().getId();
              if (!MainPanel.getInstance().getCurrentOrganism().getId().equals(orgId)) {
                OrganismRestService.switchOrganismById(orgId);
              }
            }
          }
        },
        DoubleClickEvent.getType());

    List<OrganismInfo> trackInfoList = dataProvider.getList();

    ColumnSortEvent.ListHandler<OrganismInfo> sortHandler =
        new ColumnSortEvent.ListHandler<OrganismInfo>(trackInfoList);
    dataGrid.addColumnSortHandler(sortHandler);
    sortHandler.setComparator(
        organismNameColumn,
        new Comparator<OrganismInfo>() {
          @Override
          public int compare(OrganismInfo o1, OrganismInfo o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    sortHandler.setComparator(
        annotationsNameColumn,
        new Comparator<OrganismInfo>() {
          @Override
          public int compare(OrganismInfo o1, OrganismInfo o2) {
            return o1.getNumFeatures() - o2.getNumFeatures();
          }
        });
    sortHandler.setComparator(
        sequenceColumn,
        new Comparator<OrganismInfo>() {
          @Override
          public int compare(OrganismInfo o1, OrganismInfo o2) {
            return o1.getNumSequences() - o2.getNumSequences();
          }
        });
  }
  private void initGridColumns() {
    Column<RequestParameterSummary, String> paramKeyColumn =
        new Column<RequestParameterSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(RequestParameterSummary rowObject) {
            return rowObject.getKey();
          }
        };
    paramKeyColumn.setFieldUpdater(
        new FieldUpdater<RequestParameterSummary, String>() {
          @Override
          public void update(int index, RequestParameterSummary object, String value) {
            object.setKey(value);
            dataProvider.getList().set(index, object);
          }
        });
    myParametersGrid.addColumn(
        paramKeyColumn,
        new ResizableHeader<RequestParameterSummary>("Key", myParametersGrid, paramKeyColumn));

    Column<RequestParameterSummary, String> paramValueColumn =
        new Column<RequestParameterSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(RequestParameterSummary rowObject) {
            return rowObject.getValue();
          }
        };
    paramValueColumn.setFieldUpdater(
        new FieldUpdater<RequestParameterSummary, String>() {
          @Override
          public void update(int index, RequestParameterSummary object, String value) {
            object.setValue(value);
            dataProvider.getList().set(index, object);
          }
        });
    myParametersGrid.addColumn(
        paramValueColumn,
        new ResizableHeader<RequestParameterSummary>("Value", myParametersGrid, paramValueColumn));

    // actions (icons)
    List<HasCell<RequestParameterSummary, ?>> cells =
        new LinkedList<HasCell<RequestParameterSummary, ?>>();

    cells.add(
        new ActionHasCell(
            "Remove",
            new Delegate<RequestParameterSummary>() {
              @Override
              public void execute(RequestParameterSummary parameter) {
                presenter.removeParameter(parameter);
              }
            }));

    CompositeCell<RequestParameterSummary> cell = new CompositeCell<RequestParameterSummary>(cells);
    Column<RequestParameterSummary, RequestParameterSummary> actionsColumn =
        new Column<RequestParameterSummary, RequestParameterSummary>(cell) {
          @Override
          public RequestParameterSummary getValue(RequestParameterSummary object) {
            return object;
          }
        };
    myParametersGrid.addColumn(actionsColumn, "Actions");
    myParametersGrid.setColumnWidth(actionsColumn, "70px");

    dataProvider.addDataDisplay(myParametersGrid);
  }
 public void makeRowEditable(RequestParameterSummary parameter) {
   myParametersGrid.getSelectionModel().setSelected(parameter, true);
 }
Example #24
0
 @Override
 public void addColumn(Column<T, ?> col, String headerString) {
   super.addColumn(col, new DataGridResizableHeader(headerString, col));
 }
Example #25
0
  private void createDataGrid() {
    dataGrid = new DataGrid<InputItem>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selectionModel = new SingleSelectionModel<InputItem>(KEY_PROVIDER);
    dataGrid.setSelectionModel(selectionModel);

    recordStore = new ListDataProvider<InputItem>(KEY_PROVIDER);
    recordStore.addDataDisplay(dataGrid);

    sortHandler = new ColumnSortEvent.ListHandler<InputItem>(recordStore.getList());

    Column<InputItem, InputItem> colId = new IdentityColumn<InputItem>(ID_CELL);
    dataGrid.addColumn(colId, new ResizableHeader<InputItem>("#", dataGrid, colId));
    dataGrid.setColumnWidth(colId, 35, Style.Unit.PX);

    final EditTextCell cellName = new EditTextCell();
    Column<InputItem, String> colName =
        new Column<InputItem, String>(cellName) {
          @Override
          public String getValue(InputItem rec) {
            return rec.getName();
          }
        };
    colName.setFieldUpdater(
        new FieldUpdater<InputItem, String>() {
          @Override
          public void update(int index, InputItem rec, String value) {
            if (!value.equals(rec.getName())) {
              markChange(rec);
              rec.setName(value);
              cellName.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colName, new ResizableHeader<InputItem>("Name", dataGrid, colName));
    dataGrid.setColumnWidth(colName, 128, Style.Unit.PX);

    colName.setSortable(true);
    sortHandler.setComparator(
        colName,
        new Comparator<InputItem>() {
          @Override
          public int compare(InputItem o1, InputItem o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });

    //        final SelectCell<String,Integer> cellActive = new SelectCell<String,Integer>(
    //                ZicoWidgets.<String,Integer>map("NO",0,"YES",1));
    //        Column<InputItem,Integer> colActive = new Column<InputItem, Integer>(cellActive) {
    //            @Override
    //            public Integer getValue(InputItem rec) {
    //                return rec.getActive();
    //            }
    //        };
    //        colActive.setFieldUpdater(new FieldUpdater<InputItem, Integer>() {
    //            @Override
    //            public void update(int index, InputItem rec, Integer value) {
    //                if (rec.getActive() != value) {
    //                    markChange(rec);
    //                    rec.setActive(value);
    //                    cellActive.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        dataGrid.addColumn(colActive, new ResizableHeader<InputItem>("Active", dataGrid,
    // colActive));
    //        dataGrid.setColumnWidth(colActive, 128, Style.Unit.PX);

    //        final DatePickerCell cellTstart = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0);
    //        Column<InputItem,Date> colTstart = new Column<InputItem, Date>(cellTstart) {
    //            @Override
    //            public Date getValue(InputItem rec) {
    //                return ClientUtil.unix2date(rec.getTstart());
    //            }
    //        };
    //        colTstart.setFieldUpdater(new FieldUpdater<InputItem, Date>() {
    //            @Override
    //            public void update(int index, InputItem rec, Date value) {
    //                long t = ClientUtil.date2unix(value);
    //                if (t != rec.getTstart()) {
    //                    markChange(rec);
    //                    rec.setTstart(t);
    //                    cellTstart.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        colTstart.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    //        dataGrid.addColumn(colTstart, new ResizableHeader<InputItem>("TStart", dataGrid,
    // colTstart));
    //        dataGrid.setColumnWidth(colTstart, 100, Style.Unit.PX);

    //        final DatePickerCell cellTstop = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0);
    //        Column<InputItem,Date> colTstop = new Column<InputItem, Date>(cellTstop) {
    //            @Override
    //            public Date getValue(InputItem rec) {
    //                return ClientUtil.unix2date(rec.getTstop());
    //            }
    //        };
    //        colTstop.setFieldUpdater(new FieldUpdater<InputItem, Date>() {
    //            @Override
    //            public void update(int index, InputItem rec, Date value) {
    //                long t = ClientUtil.date2unix(value);
    //                if (t != rec.getTstop()) {
    //                    markChange(rec);
    //                    rec.setTstop(t);
    //                    cellTstop.clearViewData(rec.getId());
    //                }
    //            }
    //        });
    //        colTstop.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    //        dataGrid.addColumn(colTstop, new ResizableHeader<InputItem>("TStop", dataGrid,
    // colTstop));
    //        dataGrid.setColumnWidth(colTstop, 100, Style.Unit.PX);

    Column<InputItem, Integer> colInput =
        new Column<InputItem, Integer>(cellInput) {
          @Override
          public Integer getValue(InputItem iitem) {
            return iitem.getInputId();
          }
        };
    colInput.setFieldUpdater(
        new FieldUpdater<InputItem, Integer>() {
          @Override
          public void update(int index, InputItem rec, Integer value) {
            if (rec.getInputId() != value) {
              markChange(rec);
              rec.setInputId(value);
              cellInput.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colInput, new ResizableHeader<InputItem>("Input", dataGrid, colInput));
    dataGrid.setColumnWidth(colInput, 128, Style.Unit.PX);

    Column<InputItem, Integer> colTxForm =
        new Column<InputItem, Integer>(cellTxForm) {
          @Override
          public Integer getValue(InputItem rec) {
            return rec.getTxFormid();
          }
        };
    colTxForm.setFieldUpdater(
        new FieldUpdater<InputItem, Integer>() {
          @Override
          public void update(int index, InputItem iitem, Integer value) {
            if (iitem.getTxFormid() != value) {
              markChange(iitem);
              iitem.setTxFormid(value);
              cellTxForm.clearViewData(iitem.getId());
            }
          }
        });
    dataGrid.addColumn(colTxForm, new ResizableHeader<InputItem>("TxForm", dataGrid, colTxForm));
    dataGrid.setColumnWidth(colTxForm, 128, Style.Unit.PX);

    final EditTextCell cellComment = new EditTextCell();
    Column<InputItem, String> colComment =
        new Column<InputItem, String>(cellComment) {
          @Override
          public String getValue(InputItem rec) {
            return rec.getComment();
          }
        };
    colComment.setFieldUpdater(
        new FieldUpdater<InputItem, String>() {
          @Override
          public void update(int index, InputItem rec, String value) {
            if (!value.equals(rec.getComment())) {
              markChange(rec);
              rec.setComment(value);
              cellComment.clearViewData(rec.getId());
            }
          }
        });
    dataGrid.addColumn(colComment, new ResizableHeader<InputItem>("Comment", dataGrid, colComment));

    colComment.setSortable(true);
    sortHandler.setComparator(
        colComment,
        new Comparator<InputItem>() {
          @Override
          public int compare(InputItem o1, InputItem o2) {
            return o1.getComment().compareTo(o2.getComment());
          }
        });

    dataGrid.addCellPreviewHandler(
        new CellPreviewEvent.Handler<InputItem>() {
          @Override
          public void onCellPreview(CellPreviewEvent<InputItem> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
              selectionModel.setSelected(event.getValue(), true);
              if (event.getValue() != null) {
                contextMenu.setPopupPosition(
                    event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
                contextMenu.show();
              }
            }
          }
        });

    dataGrid.setKeyboardSelectionPolicy(
        HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);
    dataGrid.addDomHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
          }
        },
        DoubleClickEvent.getType());
    dataGrid.addDomHandler(
        new ContextMenuHandler() {
          @Override
          public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
          }
        },
        ContextMenuEvent.getType());
  }
Example #26
0
 public void reload() {
   dataGrid.redraw();
 }
Example #27
0
 @UiHandler("uncheckSessionsButton")
 void handleUncheckSessionsButtonClick(ClickEvent e) {
   MultiSelectionModel model = (MultiSelectionModel<?>) sessionsDataGrid.getSelectionModel();
   model.clear();
 }
Example #28
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();
  }
  @Override
  public void initTableColumns(DataGrid<T> dataGrid, ListHandler<T> sortHandler) {

    // ------------------------- Last Name ----------------------------------
    final Column<T, String> lastNameColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getLastName();
          }
        };
    lastNameColumn.setSortable(true);
    sortHandler.setComparator(
        lastNameColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getLastName().compareTo(((UserInfoGwt) o2).getLastName());
          }
        });
    dataGrid.addColumn(lastNameColumn, "Last Name");
    dataGrid.setColumnWidth(lastNameColumn, "50px");

    // ------------------------- First Name ---------------------------------
    final Column<T, String> firstNameColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getFirstName();
          }
        };
    firstNameColumn.setSortable(true);
    sortHandler.setComparator(
        firstNameColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getFirstName().compareTo(((UserInfoGwt) o2).getFirstName());
          }
        });
    dataGrid.addColumn(firstNameColumn, "First Name");
    dataGrid.setColumnWidth(firstNameColumn, "50px");

    // --------------------------- User ID ----------------------------------
    final Column<T, String> userIdColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getUserName();
          }
        };
    userIdColumn.setSortable(true);
    sortHandler.setComparator(
        userIdColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getUserName().compareTo(((UserInfoGwt) o2).getUserName());
          }
        });
    dataGrid.addColumn(userIdColumn, "User ID");
    dataGrid.setColumnWidth(userIdColumn, "50px");
  }
  public Widget draw() {

    // contentWidget.setSize("100%", "100%");

    DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
    contentWidget.setWidget(ft);

    final DataGrid gridTable = new DataGrid();
    gridTable.setSize("100%", "100%");

    final ArrayList<Attribute> vosList = new ArrayList<Attribute>();
    final GetAttributesV2 getVos =
        new GetAttributesV2(
            new JsonCallbackEvents() {
              public void onFinished(JavaScriptObject jso) {
                vosList.addAll(
                    new TableSorter<Attribute>()
                        .sortByAttrNameTranslation(JsonUtils.<Attribute>jsoAsList(jso)));
                gridTable.setRowData(vosList);
                gridTable.redraw();
              }
            });
    getVos.getUserAttributes(3411);
    getVos.retrieveData();

    gridTable.setSelectionModel(
        new MultiSelectionModel<Attribute>(new GeneralKeyProvider<Attribute>()));
    final SelectionModel<Attribute> selectionModel = gridTable.getSelectionModel();
    gridTable.setKeyboardSelectionPolicy(
        HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);

    Column<Attribute, Boolean> checkBoxColumn =
        new Column<Attribute, Boolean>(new CheckboxCell(true, true)) {
          @Override
          public Boolean getValue(Attribute object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };
    checkBoxColumn.setFieldUpdater(
        new FieldUpdater<Attribute, Boolean>() {
          @Override
          public void update(int i, Attribute Attribute, Boolean aBoolean) {
            selectionModel.setSelected(Attribute, aBoolean);
          }
        });

    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader =
        new Header<Boolean>(cb) {
          public Boolean getValue() {
            return false; // return true to see a checked checkbox.
          }
        };
    checkBoxHeader.setUpdater(
        new ValueUpdater<Boolean>() {
          public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (Attribute obj : vosList) {
              selectionModel.setSelected(obj, value);
            }
          }
        });

    gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
    gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);

    TextColumn<Attribute> idColumn =
        new TextColumn<Attribute>() {
          @Override
          public String getValue(Attribute object) {
            return String.valueOf(object.getId());
          }
        };

    if (JsonUtils.isExtendedInfoVisible()) {
      gridTable.addColumn(idColumn, "Id", "Id");
      gridTable.setColumnWidth(idColumn, "90px");
    }

    // Name column
    Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());

    // Description column
    Column<Attribute, Attribute> descriptionColumn =
        JsonUtils.addColumn(new PerunAttributeDescriptionCell());

    // Value column
    Column<Attribute, Attribute> valueColumn =
        JsonUtils.addColumn(
            new PerunAttributeValueCell(),
            new FieldUpdater<Attribute, Attribute>() {
              public void update(int index, Attribute object, Attribute value) {
                object = value;
                selectionModel.setSelected(object, object.isAttributeValid());
              }
            });

    ColumnSortEvent.ListHandler<Attribute> columnSortHandler =
        new ColumnSortEvent.ListHandler<Attribute>(vosList);
    gridTable.addColumnSortHandler(columnSortHandler);

    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(
        nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));

    // Sorting description column
    descriptionColumn.setSortable(true);
    columnSortHandler.setComparator(
        descriptionColumn,
        new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));

    // Add sorting
    gridTable.addColumnSortHandler(columnSortHandler);

    // updates the columns size
    gridTable.setColumnWidth(nameColumn, 200.0, Style.Unit.PX);
    gridTable.setColumnWidth(valueColumn, 420.0, Style.Unit.PX);

    gridTable.addColumn(nameColumn, "Name");
    gridTable.addColumn(valueColumn, "Value");
    gridTable.addColumn(descriptionColumn, "Description");

    TabMenu tabMenu = new TabMenu();

    tabMenu.addWidget(
        TabMenu.getPredefinedButton(
            ButtonType.ADD,
            "",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                session.getTabManager().addTabToCurrentTab(new TestDataGridTabItem(), true);
              }
            }));

    ft.addNorth(tabMenu, 50);
    ft.add(gridTable);

    return getWidget();
  }