protected void okPressed() {

    for (TableItem item : publishEventAttributeTable.getItems()) {
      PublishEventMediatorAttribute attribute = (PublishEventMediatorAttribute) item.getData();
      NamespacedProperty expression =
          ((PublishEventMediatorAttributeImpl) item.getData()).getAttributeExpression();

      // If the attribute is a new one, add it to the model.
      if (null == attribute.eContainer()) {
        // Update the publishEvent attribute with the latest data from
        // table row.
        attribute.setAttributeName(item.getText(0));

        if (item.getText(2).equals(AttributeValueType.STRING.getLiteral())) {
          attribute.setAttributeValueType(AttributeValueType.STRING);
          attribute.setAttributeValue(item.getText(1));
        }

        if (item.getText(2).equals(AttributeValueType.EXPRESSION.getLiteral())) {
          attribute.setAttributeValueType(AttributeValueType.EXPRESSION);
          NamespacedProperty namespaceProperty =
              EsbFactoryImpl.eINSTANCE.createNamespacedProperty();
          namespaceProperty.setPropertyValue(item.getText(1));
          namespaceProperty.setNamespaces(expression.getNamespaces());
          attribute.setAttributeExpression(namespaceProperty);
        }

        // Record the add operation.
        AddCommand addCmd = null;
        if (attributeCategory.equals(PUBLISH_EVENT_META_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__META_ATTRIBUTES,
                  attribute);
        }
        if (attributeCategory.equals(PUBLISH_EVENT_CORRELATION_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__CORRELATION_ATTRIBUTES,
                  attribute);
        }
        if (attributeCategory.equals(PUBLISH_EVENT_PAYLOAD_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__PAYLOAD_ATTRIBUTES,
                  attribute);
        }
        if (attributeCategory.equals(PUBLISH_EVENT_ARBITRARY_CATEGORY)) {
          addCmd =
              new AddCommand(
                  editingDomain,
                  publishEventMediator,
                  EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__ARBITRARY_ATTRIBUTES,
                  attribute);
        }
        getResultCommand().append(addCmd);
      }
    }

    // Apply changes.
    if (getResultCommand().canExecute()) {
      editingDomain.getCommandStack().execute(getResultCommand());
    }

    super.okPressed();
  }