// Make a new Cell for ActionInsertFact columns
  private DecoratedGridCellValueAdaptor<? extends Comparable<?>> derieveCellFromAction(
      ActionInsertFactCol52 col) {

    // Check if the column has a "Value List" or an enumeration. Value List takes precedence
    final String factType = col.getFactType();
    final String fieldName = col.getFactField();
    if (model.hasValueList(col)) {
      return makeValueListCell(col);

    } else if (sce.hasEnums(factType, fieldName)) {
      return makeEnumCell(factType, fieldName);
    }

    return derieveCellFromModel(col);
  }
예제 #2
0
 private void doFieldLabel() {
   if (nil(this.editingCol.getFactField())) {
     fieldLabel.setText(constants.pleaseChooseFactType());
   } else {
     fieldLabel.setText(editingCol.getFactField());
   }
 }
예제 #3
0
 private void makeLimitedValueWidget() {
   if (!(editingCol instanceof LimitedEntryActionInsertFactCol52)) {
     setAttributeVisibility(limitedEntryValueAttributeIndex, false);
     return;
   }
   if (nil(editingCol.getFactField())) {
     setAttributeVisibility(limitedEntryValueAttributeIndex, false);
     return;
   }
   LimitedEntryActionInsertFactCol52 lea = (LimitedEntryActionInsertFactCol52) editingCol;
   setAttributeVisibility(limitedEntryValueAttributeIndex, true);
   if (lea.getValue() == null) {
     lea.setValue(factory.makeNewValue(editingCol));
   }
   limitedEntryValueWidgetContainer.setWidget(factory.getWidget(editingCol, lea.getValue()));
 }
예제 #4
0
  private Widget doInsertLogical() {
    HorizontalPanel hp = new HorizontalPanel();

    final CheckBox cb = new CheckBox();
    cb.setValue(editingCol.isInsertLogical());
    cb.setText("");
    cb.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            if (sce.isGlobalVariable(editingCol.getBoundName())) {
              cb.setEnabled(false);
              editingCol.setInsertLogical(false);
            } else {
              editingCol.setInsertLogical(cb.getValue());
            }
          }
        });
    hp.add(cb);
    hp.add(new InfoPopup(constants.UpdateFact(), constants.UpdateDescription()));
    return hp;
  }
예제 #5
0
  private ListBox loadPatterns() {
    Set<String> vars = new HashSet<String>();
    ListBox patterns = new ListBox();

    for (Object o : model.getActionCols()) {
      ActionCol52 col = (ActionCol52) o;
      if (col instanceof ActionInsertFactCol52) {
        ActionInsertFactCol52 c = (ActionInsertFactCol52) col;
        if (!vars.contains(c.getBoundName())) {
          patterns.addItem(
              c.getFactType() + " [" + c.getBoundName() + "]",
              c.getFactType() + " " + c.getBoundName());
          vars.add(c.getBoundName());
        }
      }
    }

    return patterns;
  }
예제 #6
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);
  }
예제 #7
0
 private void doPatternLabel() {
   if (this.editingCol.getFactType() != null) {
     this.patternLabel.setText(
         this.editingCol.getFactType() + " [" + editingCol.getBoundName() + "]");
   }
 }
예제 #8
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;
 }