Пример #1
0
  /**
   * Creates columns configurations for jobs grid.
   *
   * @return columns configurations for jobs grid
   */
  private List<ColumnConfig<MyJobsModel, ?>> createColumnConfig() {
    List<ColumnConfig<MyJobsModel, ?>> configs = new ArrayList<ColumnConfig<MyJobsModel, ?>>();

    ColumnConfig<MyJobsModel, String> inputColumn =
        new ColumnConfig<MyJobsModel, String>(
            props.input(),
            Integer.parseInt(
                ApplicationContext.getSettings().getGridProperties().get("jobs_input_width")));
    inputColumn.setHeader(
        ApplicationContext.getSettings().getGridProperties().get("jobs_input_header"));
    inputColumn.setCell(new InputCell());
    inputColumn.setResizable(true);
    inputColumn.setColumnTextClassName("eppic-my-jobs-list-input");
    inputColumn.setColumnHeaderClassName("eppic-default-font");

    ColumnConfig<MyJobsModel, String> statusColumn =
        new ColumnConfig<MyJobsModel, String>(
            props.status(),
            Integer.parseInt(
                ApplicationContext.getSettings().getGridProperties().get("jobs_status_width")));
    statusColumn.setHeader(
        ApplicationContext.getSettings().getGridProperties().get("jobs_status_header"));
    statusColumn.setCell(new JobStatusCell());
    statusColumn.setResizable(false);
    statusColumn.setColumnHeaderClassName("eppic-default-font");

    configs.add(inputColumn);
    configs.add(statusColumn);

    return configs;
  }
Пример #2
0
  @Override
  public Widget asWidget() {
    // reduce the padding on text element as we have widgets in the cells
    SafeStyles textStyles = SafeStylesUtils.fromTrustedString("padding: 1px 3px;");

    ColumnConfig<Plant, String> cc1 =
        new ColumnConfig<Plant, String>(properties.name(), 100, "Name");
    // IMPORTANT we want the text element (cell parent) to only be as wide as the cell and not fill
    // the cell
    cc1.setColumnTextClassName(CommonStyles.get().inlineBlock());
    cc1.setColumnTextStyle(textStyles);

    TextButtonCell button = new TextButtonCell();
    button.addSelectHandler(
        new SelectHandler() {

          @Override
          public void onSelect(SelectEvent event) {
            Context c = event.getContext();
            int row = c.getIndex();
            Plant p = store.get(row);
            Info.display("Event", "The " + p.getName() + " was clicked.");
          }
        });
    cc1.setCell(button);

    DateCell dateCell = new DateCell();
    dateCell.setPropertyEditor(
        new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));

    ColumnConfig<Plant, Date> cc2 =
        new ColumnConfig<Plant, Date>(properties.available(), 100, "Date");
    cc2.setColumnTextStyle(textStyles);
    cc2.setCell(dateCell);

    List<ColumnConfig<Plant, ?>> l = new ArrayList<ColumnConfig<Plant, ?>>();
    l.add(cc1);
    l.add(cc2);
    ColumnModel<Plant> cm = new ColumnModel<Plant>(l);

    store = new ListStore<Plant>(properties.key());
    store.addAll(TestData.getPlants());

    Grid<Plant> grid = new Grid<Plant>(store, cm);
    grid.getView().setForceFit(true);

    ContentPanel cp = new ContentPanel();
    cp.setHeadingText("Cell Grid");
    cp.setWidget(grid);
    cp.setPixelSize(500, 400);
    cp.addStyleName("margin-10");
    return cp;
  }