private TableItem bindPublishEventAttribute(PublishEventMediatorAttribute attribute) {
    TableItem item = new TableItem(publishEventAttributeTable, SWT.NONE);
    if (attribute
        .getAttributeValueType()
        .getLiteral()
        .equals(AttributeValueType.STRING.getLiteral())) {
      item.setText(
          new String[] {
            attribute.getAttributeName(),
            attribute.getAttributeValue(),
            attribute.getAttributeValueType().getLiteral()
          });
    }
    if (attribute
        .getAttributeValueType()
        .getLiteral()
        .equals(AttributeValueType.EXPRESSION.getLiteral())) {
      item.setText(
          new String[] {
            attribute.getAttributeName(),
            attribute.getAttributeExpression().getPropertyValue(),
            attribute.getAttributeValueType().getLiteral()
          });
      item.setData(
          EXPRESSION_DATA,
          EsbFactory.eINSTANCE.copyNamespacedProperty(attribute.getAttributeExpression()));
    }

    item.setData(attribute);
    return item;
  }
 private void unbindpublishEventAttribute(int itemIndex) {
   TableItem item = publishEventAttributeTable.getItem(itemIndex);
   PublishEventMediatorAttribute attribute = (PublishEventMediatorAttribute) item.getData();
   if (null != attribute.eContainer()) {
     RemoveCommand removeCmd = null;
     if (attributeCategory.equals(PUBLISH_EVENT_META_CATEGORY)) {
       removeCmd =
           new RemoveCommand(
               editingDomain,
               publishEventMediator,
               EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__META_ATTRIBUTES,
               attribute);
     }
     if (attributeCategory.equals(PUBLISH_EVENT_CORRELATION_CATEGORY)) {
       removeCmd =
           new RemoveCommand(
               editingDomain,
               publishEventMediator,
               EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__CORRELATION_ATTRIBUTES,
               attribute);
     }
     if (attributeCategory.equals(PUBLISH_EVENT_PAYLOAD_CATEGORY)) {
       removeCmd =
           new RemoveCommand(
               editingDomain,
               publishEventMediator,
               EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__PAYLOAD_ATTRIBUTES,
               attribute);
     }
     if (attributeCategory.equals(PUBLISH_EVENT_ARBITRARY_CATEGORY)) {
       removeCmd =
           new RemoveCommand(
               editingDomain,
               publishEventMediator,
               EsbPackage.Literals.PUBLISH_EVENT_MEDIATOR__ARBITRARY_ATTRIBUTES,
               attribute);
     }
     getResultCommand().append(removeCmd);
   }
   publishEventAttributeTable.remove(publishEventAttributeTable.indexOf(item));
 }
  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();
  }