Esempio n. 1
0
  /**
   * Constructor.
   *
   * @param name The field's name.
   * @param title The field's title.
   * @param desc The field's description.
   * @param options The options that can be selected.
   */
  public CCComboBoxField(
      final String name, final String title, final String desc, final List<Option> options) {
    super(name);

    final ComboBox<BaseModelData> cb = new ComboBox<BaseModelData>();
    cb.setTriggerAction(TriggerAction.ALL);
    cb.setFieldLabel(createLabel(name, title));
    cb.setToolTip(createTooltip(name, title, desc));
    cb.setDisplayField("title");
    cb.setValueField("value");
    cb.setEditable(false);

    final ListStore<BaseModelData> store = new ListStore<BaseModelData>();
    for (final Option o : options) {
      final BaseModelData model = new BaseModelData();

      model.set("title", o.getTitle());
      model.set("value", o.getValue());
      store.add(model);
      if (o.isDefault().booleanValue()) {
        cb.setValue(model);
      }
    }
    cb.setStore(store);

    _combobox = cb;
  }
  private ModelData modelData() {
    BaseModelData modelData = new BaseModelData();
    for (ConfigGroup groupEnum : ConfigGroup.values()) {
      for (Config config : groupEnum.configs) {
        modelData.set(config.name(), "");
      }
    }

    return modelData;
  }
Esempio n. 3
0
  /** {@inheritDoc} */
  @Override
  public void setValue(final Paragraph para) {

    final ComboBox<BaseModelData> cb = _combobox;
    final String value = para.getText();

    final ListStore<BaseModelData> store = cb.getStore();
    for (final BaseModelData model : store.getModels()) {
      if (model.get("value").equals(value)) {
        cb.setValue(model);
      }
    }
  }
Esempio n. 4
0
  private HashMap<String, Object> nominee2Period(BaseModelData fields) {
    HashMap<String, Object> retval = new HashMap<String, Object>();
    retval.put("handle", fields.get("sess_name") + " (" + fields.get("proj_name") + ")");
    retval.put(
        "date", DateTimeFormat.getFormat("yyyy-MM-dd").format(schedule.startVacancyDateTime));
    retval.put("time", DateTimeFormat.getFormat("HH:mm").format(schedule.startVacancyDateTime));
    retval.put("duration", (Double) fields.get("duration") / 60.0);

    Double score = (Double) fields.get("score");
    retval.put("sscore", score);
    retval.put("cscore", score);
    // retval.put("forecast", null);
    retval.put("backup", false);
    return retval;
  }
  public void draw(DoneDrawingCallback callback) {
    removeAll();

    final List<ColumnConfig> cols = getColumns();

    final Map<String, RowData> group = getGroupsForRows();
    final Map<String, String> groupIDToName = new HashMap<String, String>();
    final GroupingStore<BaseModelData> store = new GroupingStore<BaseModelData>();
    for (RowData row : getRows()) {
      final BaseModelData model = new BaseModelData();
      model.set("id", row.getField("id"));
      model.set("lockid", row.getField("lockid"));
      for (ColumnConfig col : cols) model.set(col.getId(), row.getField(col.getId()));
      RowData gID = group.get(row.getField("id"));
      if (gID == null) {
        model.set("groupid", "none");
        model.set("groupidentifier", null);
        groupIDToName.put("none", "No Group Defined");
      } else {
        model.set("groupid", gID.get("groupid"));
        model.set("groupidentifier", gID.get("id"));
        groupIDToName.put(gID.get("groupid"), "Working Set: " + gID.get("groupname"));
      }

      store.add(model);
    }
    store.groupBy("groupid");

    final GroupingView view = new GroupingView();
    view.setShowGroupedColumn(false);
    view.setGroupRenderer(
        new GridGroupRenderer() {
          public String render(GroupColumnData data) {
            return groupIDToName.get(data.group);
          }
        });

    final GridSelectionModel<BaseModelData> sel = new GridSelectionModel<BaseModelData>();
    sel.setSelectionMode(SelectionMode.SINGLE);

    grid = new Grid<BaseModelData>(store, new ColumnModel(cols));
    grid.setSelectionModel(sel);
    grid.setView(view);
    grid.addListener(
        Events.RowClick,
        new Listener<GridEvent>() {
          public void handleEvent(GridEvent be) {
            if (groupButton != null && be != null && be.getModel() != null)
              groupButton.setEnabled(be.getModel().get("groupidentifier") != null);
          }
        });
    // grid.setWidth(680);

    int size = 25;

    final LayoutContainer wrapper = new LayoutContainer();
    wrapper.setLayout(new FillLayout());
    // wrapper.setScrollMode(Scroll.ALWAYS);
    wrapper.add(grid);

    final LayoutContainer container = new LayoutContainer(new BorderLayout());
    container.setBorders(false);
    container.add(getToolBar(), new BorderLayoutData(LayoutRegion.SOUTH, size, size, size));
    container.add(wrapper, new BorderLayoutData(LayoutRegion.CENTER));

    add(container);

    callback.isDrawn();
  }