示例#1
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);
  }
示例#2
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);
  }
 @Override
 protected void addColumns(DataGrid<DnsResolverServiceProxy> table) {
   Column<DnsResolverServiceProxy, String> dnsNameColumn =
       TextColumn.build(DnsResolverServiceProxy.DnsName);
   table.addColumn(dnsNameColumn, "Description");
   table.setColumnWidth(dnsNameColumn, "40ex");
 }
  /** 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);
  }
  @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 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");
  }
  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);
  }
示例#9
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;
  }
示例#10
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());
  }
  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();
  }
示例#12
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();
          }
        });
  }
示例#13
0
  private void initializeTable() {
    typeColumn =
        new TextColumn<AnnotationInfo>() {
          @Override
          public String getValue(AnnotationInfo annotationInfo) {
            String annotationTypeString = annotationInfo.getType();
            if (annotationTypeString.equals("non_canonical_five_prime_splice_site")) {
              annotationTypeString = "NC 5' splice";
            } else if (annotationTypeString.equals("non_canonical_three_prime_splice_site")) {
              annotationTypeString = "NC 3' splice";
            }
            return annotationTypeString;
          }
        };
    typeColumn.setSortable(true);

    startColumn =
        new Column<AnnotationInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(AnnotationInfo annotationInfo) {
            return getDisplayMin(annotationInfo.getMin());
          }
        };
    startColumn.setSortable(true);

    stopColumn =
        new Column<AnnotationInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(AnnotationInfo annotationInfo) {
            return annotationInfo.getMax();
          }
        };
    stopColumn.setSortable(true);

    lengthColumn =
        new Column<AnnotationInfo, Number>(new NumberCell()) {
          @Override
          public Integer getValue(AnnotationInfo annotationInfo) {
            return annotationInfo.getLength();
          }
        };
    lengthColumn.setSortable(true);

    dataGrid.addColumn(typeColumn, "Type");
    dataGrid.addColumn(startColumn, "Start");
    //        dataGrid.addColumn(stopColumn, "Stop");
    dataGrid.addColumn(lengthColumn, "Length");

    ColumnSortEvent.ListHandler<AnnotationInfo> sortHandler =
        new ColumnSortEvent.ListHandler<AnnotationInfo>(annotationInfoList);
    dataGrid.addColumnSortHandler(sortHandler);

    sortHandler.setComparator(
        typeColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getType().compareTo(o2.getType());
          }
        });

    sortHandler.setComparator(
        startColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getMin() - o2.getMin();
          }
        });

    sortHandler.setComparator(
        stopColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getMax() - o2.getMax();
          }
        });

    sortHandler.setComparator(
        lengthColumn,
        new Comparator<AnnotationInfo>() {
          @Override
          public int compare(AnnotationInfo o1, AnnotationInfo o2) {
            return o1.getLength() - o2.getLength();
          }
        });
  }
示例#14
0
 @Override
 public void addColumn(Column<T, ?> col, String headerString) {
   super.addColumn(col, new DataGridResizableHeader(headerString, col));
 }
  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);
  }
  @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");
  }
示例#17
0
  private void initTableColumns(
      SelectionModel<Supply> selectionModel, ListHandler<Supply> sortHandler) {

    // НОМЕР
    Column<Supply, String> supplyIdColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return Integer.toString(object.getSupplyId());
          }
        };
    supplyIdColumn.setSortable(true);
    sortHandler.setComparator(
        supplyIdColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            if (o1.getSupplyId() == o2.getSupplyId()) return 0;
            else if (o1.getSupplyId() > o2.getSupplyId()) return 1;
            else return -1;
          }
        });
    dataGrid.addColumn(supplyIdColumn, "Номер");
    dataGrid.setColumnWidth(supplyIdColumn, 30, Unit.PX);

    // ТИП
    Column<Supply, String> typeColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            if ("1".equals(object.getDeliveryDirection())) return "В филиал";
            else if ("0".equals(object.getDeliveryDirection())) return "На склад";
            else return "Ошибка!";
          }
        };
    typeColumn.setSortable(true);
    sortHandler.setComparator(
        typeColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getDeliveryDirection().compareTo(o2.getDeliveryDirection());
          }
        });
    dataGrid.addColumn(typeColumn, "Направление");
    dataGrid.setColumnWidth(typeColumn, 50, Unit.PX);

    // ДАТА ПОСТАВКИ
    // если сроки нарушены, то показывается актуальная дата!
    Column<Supply, String> dateColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
            if (object.getDateFact() != null) return dateFormat.format(object.getDateFact());
            else return dateFormat.format(object.getDateOk());
          }
        };
    dateColumn.setSortable(true);
    sortHandler.setComparator(
        dateColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getDateOk().compareTo(o2.getDateOk());
          }
        });
    dataGrid.addColumn(dateColumn, "Дата доставки");
    dataGrid.setColumnWidth(dateColumn, 70, Unit.PX);

    // СТАТУС
    Column<Supply, String> statusColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return StatusDict.getType(object.getStatus().getStatusCode());
          }
        };
    statusColumn.setSortable(true);
    sortHandler.setComparator(
        statusColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            if (o1.getStatus().getStatusCode() == o2.getStatus().getStatusCode()) return 0;
            else if (o1.getStatus().getStatusCode() == o2.getStatus().getStatusCode()) return -1;
            return 1;
          }
        });
    dataGrid.addColumn(statusColumn, "Статус доставки");
    dataGrid.setColumnWidth(statusColumn, 70, Unit.PX);

    // НОМЕР НАКЛАДНОЙ
    Column<Supply, String> nakladNumColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getNakladNum();
          }
        };
    nakladNumColumn.setSortable(true);
    sortHandler.setComparator(
        nakladNumColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getNakladNum().compareTo(o2.getNakladNum());
          }
        });
    dataGrid.addColumn(nakladNumColumn, "Накладная");
    dataGrid.setColumnWidth(nakladNumColumn, 50, Unit.PX);

    // АДРЕС
    Column<Supply, String> addressColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getAddress();
          }
        };
    addressColumn.setSortable(true);
    sortHandler.setComparator(
        addressColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getAddress().compareTo(o2.getAddress());
          }
        });
    dataGrid.addColumn(addressColumn, "Адрес");
    // если направление - со склада к филиалу, то Адрес кликабелен
    dataGrid.setColumnWidth(addressColumn, 70, Unit.PX);

    // КОНТРАГЕНТЫ
    Column<Supply, String> kontrName =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getKont().getName();
          }
        };
    kontrName.setSortable(true);
    sortHandler.setComparator(
        kontrName,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getKont().getName().compareTo(o2.getKont().getName());
          }
        });
    dataGrid.addColumn(kontrName, "Контрагент");
    // TODO: при нажании на название компании-контрагента - окошко с
    // информацией о т.к.
    dataGrid.setColumnWidth(kontrName, 50, Unit.PX);

    // ТРАНСПОРТНЫЕ КОМПАНИИ
    Column<Supply, String> transCompName =
        new Column<Supply, String>(new ClickableTextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getTk().getName();
          }
        };
    transCompName.setSortable(true);
    sortHandler.setComparator(
        transCompName,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getTk().getName().compareTo(o2.getTk().getName());
          }
        });
    transCompName.setFieldUpdater(
        new FieldUpdater<Supply, String>() {

          @Override
          public void update(int index, Supply object, String value) {
            final DialogBox dialogBox = new DialogBox();
            TKDetailed tkDetailed = new TKDetailed(object.getTk());

            tkDetailed
                .getCancel()
                .addClickHandler(
                    new ClickHandler() {
                      public void onClick(ClickEvent event) {
                        dialogBox.hide();
                      }
                    });

            dialogBox.setAnimationEnabled(true);
            dialogBox.setWidget(tkDetailed);

            dialogBox.center();
          }
        });
    dataGrid.addColumn(transCompName, "Транспортная компания");
    // TODO: при нажании на название ТК - окошко с информацией о ТК
    dataGrid.setColumnWidth(transCompName, 70, Unit.PX);

    // Кнопка редактиварония
    Column<Supply, String> buttonColumn =
        new Column<Supply, String>(new ButtonCell()) {
          @Override
          public String getValue(Supply object) {
            return " ... ";
          }
        };
    buttonColumn.setFieldUpdater(
        new FieldUpdater<Supply, String>() {

          @Override
          public void update(int index, Supply object, String value) {
            final DialogBox dialogBox = new DialogBox();
            FlowPanel flowPanel = new FlowPanel();
            flowPanel.setHeight("100px");
            flowPanel.setWidth("100px");
            flowPanel.add(new HTML("Id = " + object.getSupplyId()));
            final Button closeButton = new Button("Закрыть");
            flowPanel.add(closeButton);
            dialogBox.setAnimationEnabled(true);
            dialogBox.setWidget(flowPanel);

            // Add a handler to close the DialogBox
            closeButton.addClickHandler(
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    dialogBox.hide();
                  }
                });
            dialogBox.center();
          }
        });
    dataGrid.addColumn(buttonColumn, "");
    dataGrid.setColumnWidth(buttonColumn, 50, Unit.PX);
  }