コード例 #1
0
 private ActionInsertFactCol52 cloneActionInsertColumn(ActionInsertFactCol52 col) {
   ActionInsertFactCol52 clone = null;
   if (col instanceof LimitedEntryActionInsertFactCol52) {
     clone = new LimitedEntryActionInsertFactCol52();
     DTCellValue52 dcv = cloneLimitedEntryValue(((LimitedEntryCol) col).getValue());
     ((LimitedEntryCol) clone).setValue(dcv);
   } else {
     clone = new ActionInsertFactCol52();
   }
   clone.setBoundName(col.getBoundName());
   clone.setType(col.getType());
   clone.setFactField(col.getFactField());
   clone.setFactType(col.getFactType());
   clone.setHeader(col.getHeader());
   clone.setValueList(col.getValueList());
   clone.setDefaultValue(col.getDefaultValue());
   clone.setHideColumn(col.isHideColumn());
   clone.setInsertLogical(col.isInsertLogical());
   return clone;
 }
コード例 #2
0
  public ActionInsertColumnPopup(
      SuggestionCompletionEngine sce,
      final GuidedDecisionTable52 model,
      final GenericColumnCommand refreshGrid,
      final ActionInsertFactCol52 col,
      final boolean isNew) {
    this.editingCol = cloneActionInsertColumn(col);
    this.model = model;
    this.sce = sce;

    // Set-up factory for common widgets
    factory = new DTCellValueWidgetFactory(model, sce);

    setTitle(constants.ActionColumnConfigurationInsertingANewFact());
    setModal(false);

    // Fact being inserted
    HorizontalPanel pattern = new HorizontalPanel();
    pattern.add(patternLabel);
    doPatternLabel();

    Image changePattern =
        new ImageButton(
            images.edit(),
            constants.ChooseAPatternThatThisColumnAddsDataTo(),
            new ClickHandler() {
              public void onClick(ClickEvent w) {
                showChangePattern(w);
              }
            });
    pattern.add(changePattern);
    addAttribute(constants.Pattern(), pattern);

    // Fact field being set
    HorizontalPanel field = new HorizontalPanel();
    field.add(fieldLabel);
    Image editField =
        new ImageButton(
            images.edit(),
            constants.EditTheFieldThatThisColumnOperatesOn(),
            new ClickHandler() {
              public void onClick(ClickEvent w) {
                showFieldChange();
              }
            });
    field.add(editField);
    addAttribute(constants.Field(), field);
    doFieldLabel();

    // Column header
    final TextBox header = new TextBox();
    header.setText(col.getHeader());
    header.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            editingCol.setHeader(header.getText());
          }
        });
    addAttribute(constants.ColumnHeaderDescription(), header);

    // Optional value list
    if (model.getTableFormat() == TableFormat.EXTENDED_ENTRY) {
      final TextBox valueList = new TextBox();
      valueList.setText(editingCol.getValueList());
      valueList.addChangeHandler(
          new ChangeHandler() {
            public void onChange(ChangeEvent event) {
              editingCol.setValueList(valueList.getText());
            }
          });
      HorizontalPanel vl = new HorizontalPanel();
      vl.add(valueList);
      vl.add(new InfoPopup(constants.ValueList(), constants.ValueListsExplanation()));
      addAttribute(constants.optionalValueList(), vl);
    }

    // Default Value
    if (model.getTableFormat() == TableFormat.EXTENDED_ENTRY) {
      addAttribute(constants.DefaultValue(), DTCellValueWidgetFactory.getDefaultEditor(editingCol));
    }

    // Limited entry value widget
    limitedEntryValueAttributeIndex =
        addAttribute(constants.LimitedEntryValue(), limitedEntryValueWidgetContainer);
    makeLimitedValueWidget();

    // Logical insertion
    addAttribute(
        constants.LogicallyAssertAFactTheFactWillBeRetractedWhenTheSupportingEvidenceIsRemoved(),
        doInsertLogical());

    // Hide column tick-box
    addAttribute(
        constants.HideThisColumn(), DTCellValueWidgetFactory.getHideColumnIndicator(editingCol));

    Button apply = new Button(constants.ApplyChanges());
    apply.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (null == editingCol.getHeader() || "".equals(editingCol.getHeader())) {
              Window.alert(constants.YouMustEnterAColumnHeaderValueDescription());
              return;
            }
            if (isNew) {
              if (!unique(editingCol.getHeader())) {
                Window.alert(constants.ThatColumnNameIsAlreadyInUsePleasePickAnother());
                return;
              }

            } else {
              if (!col.getHeader().equals(editingCol.getHeader())) {
                if (!unique(editingCol.getHeader())) {
                  Window.alert(constants.ThatColumnNameIsAlreadyInUsePleasePickAnother());
                  return;
                }
              }
            }

            // Pass new\modified column back for handling
            refreshGrid.execute(editingCol);
            hide();
          }
        });
    addAttribute("", apply);
  }