示例#1
0
 private ValueEditor<O> addValueEditor(boolean deleteVisible) {
   final ValueEditor<O> editor = getFreshValueEditor();
   currentEditors.add(editor);
   final int rowCount = tableField.getRowCount();
   tableField.setWidget(rowCount, 0, editor.asWidget());
   final DeleteButton deleteButton = new DeleteButton();
   deleteButton.addClickHandler(
       new ClickHandler() {
         @Override
         public void onClick(ClickEvent event) {
           handleDelete(editor);
         }
       });
   tableField.setWidget(rowCount, 1, deleteButton);
   final FlexTable.FlexCellFormatter formatter = tableField.getFlexCellFormatter();
   formatter.setWidth(rowCount, 0, "100%");
   formatter.setVerticalAlignment(rowCount, 0, HasVerticalAlignment.ALIGN_TOP);
   formatter.setWidth(rowCount, 1, "30px");
   formatter.getElement(rowCount, 1).getStyle().setPaddingLeft(1, Style.Unit.PX);
   formatter.setVerticalAlignment(rowCount, 1, HasVerticalAlignment.ALIGN_TOP);
   editor.addDirtyChangedHandler(dirtyChangedHandler);
   editor.addValueChangeHandler(valueChangeHandler);
   deleteButton.setVisible(deleteVisible);
   return editor;
 }
示例#2
0
 @Override
 public boolean isDirty() {
   for (ValueEditor<O> editor : currentEditors) {
     if (editor.isDirty()) {
       return true;
     }
   }
   return dirty;
 }
示例#3
0
 @Override
 public boolean isWellFormed() {
   for (ValueEditor<O> editor : currentEditors) {
     if (!editor.isWellFormed()) {
       return false;
     }
   }
   return true;
 }
示例#4
0
 @Override
 public void setValue(List<O> object) {
   clearInternal();
   for (O value : object) {
     ValueEditor<O> editor = addValueEditor(true);
     editor.setValue(value);
   }
   ensureBlank();
   dirty = false;
 }
示例#5
0
 @Override
 public Optional<List<O>> getValue() {
   List<O> editedValues = new ArrayList<O>();
   for (ValueEditor<O> editor : currentEditors) {
     Optional<O> value = editor.getValue();
     if (value.isPresent() && editor.isWellFormed()) {
       editedValues.add(value.get());
     }
   }
   return Optional.of(editedValues);
 }
  @Override
  public void commitValue() {

    IntellicutListEntry listEntry =
        (IntellicutListEntry) intellicutPanel.getIntellicutList().getSelectedValue();

    if (listEntry != null) {

      GemEntity gemEntity = (GemEntity) listEntry.getData();
      ModuleTypeInfo currentModuleInfo =
          valueEditorManager.getPerspective().getWorkingModuleTypeInfo();
      TypeExpr valueNodeType = getValueNode().getTypeExpr();
      TypeExpr functionType = gemEntity.getTypeExpr();
      TypeExpr unifiedType;

      try {
        unifiedType = TypeExpr.unify(valueNodeType, functionType, currentModuleInfo);
      } catch (TypeException e) {
        throw new IllegalStateException(e.getMessage());
      }

      GemEntityValueNode newValueNode = new GemEntityValueNode(gemEntity, unifiedType);
      replaceValueNode(newValueNode, true);
    }

    super.commitValue();
  }
 public void dispose() {
   super.dispose();
   if (cellEditor != null) cellEditor.dispose();
   cellEditor = null;
   if (fieldEditor != null) fieldEditor.dispose();
   fieldEditor = null;
   listContentProvider = null;
 }
    @Override
    public void valueCommitted(ValueEditorEvent e) {

      ValueEditor source = (ValueEditor) e.getSource();
      ValueNode oldChildValueNode = e.getOldValue();
      ValueNode newChildValueNode = source.getValueNode();

      if (!isEditable() || oldChildValueNode.sameValue(newChildValueNode)) {
        return;
      }

      // Get the commit value map and update the editor panel value nodes.
      Map<ValueNode, TypeExpr> valueNodeToUnconstrainedTypeMap =
          getValueNodeToUnconstrainedTypeMap();
      Map<ValueNode, ValueNode> commitValueMap =
          valueEditorManager
              .getValueNodeCommitHelper()
              .getCommitValues(
                  oldChildValueNode, newChildValueNode, valueNodeToUnconstrainedTypeMap);

      for (final DataConstructorEditorPanel editorPanel : editorPanelList) {
        editorPanel.updateValueNode(commitValueMap);
      }

      // Replace the current value node with the value node of the active panel.
      ValueNode newValueNode = null;
      if (editorPanelList.size() == 1) {
        newValueNode = editorPanelList.get(0).getValueNode().copyValueNode();
      } else {
        newValueNode = focusChangeListener.getFocusedPanel().getValueNode().copyValueNode();
      }

      replaceValueNode(newValueNode, true);

      refreshDisplay();
    }
 /**
  * Assert table contents.
  *
  * @param table WebElement of target table
  * @param expectedContents expected values of table content
  */
 protected void assertTableContents(
     WebElement table,
     int rowOffset,
     int cellIndex,
     ValueEditor valueEditor,
     String... expectedContents) {
   List<WebElement> tableRows = table.findElements(By.tagName("tr"));
   assertThat(tableRows.size(), is(expectedContents.length + rowOffset));
   for (int i = rowOffset; i < (tableRows.size() - rowOffset); i++) {
     WebElement row = tableRows.get(i);
     WebElement contentCell = row.findElements(By.tagName("td")).get(cellIndex);
     String text = contentCell.getText();
     if (valueEditor != null) {
       text = valueEditor.edit(text);
     }
     assertThat(text, is(expectedContents[i - rowOffset]));
   }
 }