Пример #1
0
  public ActionRetractFactPopup(
      final GuidedDecisionTable52 model,
      final GenericColumnCommand refreshGrid,
      final ActionRetractFactCol52 col,
      final boolean isNew,
      final boolean isReadOnly) {
    this.rm = new BRLRuleModel(model);
    this.editingCol = cloneActionRetractColumn(col);
    this.model = model;

    setTitle(GuidedDecisionTableConstants.INSTANCE.ColumnConfigurationDeleteAFact());
    setModal(false);

    // Show available pattern bindings, if Limited Entry
    if (model.getTableFormat() == TableFormat.LIMITED_ENTRY) {
      final LimitedEntryActionRetractFactCol52 ler =
          (LimitedEntryActionRetractFactCol52) editingCol;
      final ListBox patterns = loadBoundFacts(ler.getValue().getStringValue());
      patterns.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        patterns.addClickHandler(
            new ClickHandler() {

              public void onClick(ClickEvent event) {
                int index = patterns.getSelectedIndex();
                if (index > -1) {
                  ler.getValue().setStringValue(patterns.getValue(index));
                }
              }
            });
      }
      addAttribute(GuidedDecisionTableConstants.INSTANCE.FactToDeleteColon(), patterns);
    }

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

    // Hide column tick-box
    addAttribute(
        new StringBuilder(GuidedDecisionTableConstants.INSTANCE.HideThisColumn())
            .append(GuidedDecisionTableConstants.COLON)
            .toString(),
        DTCellValueWidgetFactory.getHideColumnIndicator(editingCol));

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

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

            // Pass new\modified column back for handling
            refreshGrid.execute(editingCol);
            hide();
          }
        });
    addAttribute("", apply);
  }
  public ActionRetractFactPopup(
      final GuidedDecisionTable52 model,
      final GenericColumnCommand refreshGrid,
      final ActionRetractFactCol52 col,
      final boolean isNew,
      final boolean isReadOnly) {
    super(GuidedDecisionTableConstants.INSTANCE.ColumnConfigurationDeleteAFact());
    this.rm = new BRLRuleModel(model);
    this.editingCol = cloneActionRetractColumn(col);
    this.model = model;

    // Show available pattern bindings, if Limited Entry
    if (model.getTableFormat() == TableFormat.LIMITED_ENTRY) {
      final LimitedEntryActionRetractFactCol52 ler =
          (LimitedEntryActionRetractFactCol52) editingCol;
      final ListBox patterns = loadBoundFacts(ler.getValue().getStringValue());
      patterns.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        patterns.addClickHandler(
            new ClickHandler() {

              public void onClick(ClickEvent event) {
                int index = patterns.getSelectedIndex();
                if (index > -1) {
                  ler.getValue().setStringValue(patterns.getValue(index));
                }
              }
            });
      }
      addAttribute(GuidedDecisionTableConstants.INSTANCE.FactToDeleteColon(), patterns);
    }

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

    // Hide column tick-box
    addAttribute(
        new StringBuilder(GuidedDecisionTableConstants.INSTANCE.HideThisColumn())
            .append(GuidedDecisionTableConstants.COLON)
            .toString(),
        DTCellValueWidgetFactory.getHideColumnIndicator(editingCol));

    // Apply button
    add(
        new ModalFooterOKCancelButtons(
            new Command() {
              @Override
              public void execute() {
                applyChanges(refreshGrid, col, isNew);
              }
            },
            new Command() {
              @Override
              public void execute() {
                hide();
              }
            }));
  }