Program: 122132
Project: 122132
Buggy source:
@Override protected Command createButtonCommand(Button button){
  if (checkForRepositoryShema(button)) {
    return null;
  }
  Button inputButton=button;
  IElementParameter switchParam=elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
  if (inputButton.getData(NAME).equals(SCHEMA)) {
    Map<INode,Map<IMetadataTable,Boolean>> inputInfos=new HashMap<INode,Map<IMetadataTable,Boolean>>();
    INode node;
    if (elem instanceof Node) {
      node=(INode)elem;
    }
 else {
      node=((IConnection)elem).getSource();
    }
    IMetadataTable inputMetadata=null, inputMetaCopy=null;
    Connection inputConec=null;
    String propertyName=(String)inputButton.getData(PARAMETER_NAME);
    IElementParameter param=node.getElementParameter(propertyName);
    IElementParameter connectionParam=param.getChildParameters().get(EParameterName.CONNECTION.getName());
    String connectionName=null;
    if (connectionParam != null) {
      connectionName=(String)connectionParam.getValue();
    }
    Object obj=button.getData(FORCE_READ_ONLY);
    boolean forceReadOnly=false;
    if (obj != null) {
      forceReadOnly=(Boolean)obj;
    }
    boolean inputReadOnly=false, outputReadOnly=false, inputReadOnlyNode=false, inputReadOnlyParam=false;
    for (    Connection connec : (List<Connection>)node.getIncomingConnections()) {
      if (connec.isActivate() && (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE) || connec.getLineStyle().equals(EConnectionType.FLOW_MERGE)|| connec.getLineStyle() == EConnectionType.FLOW_REF)) {
        if (connectionName != null && !connec.getName().equals(connectionName)) {
          continue;
        }
        inputMetadata=connec.getMetadataTable();
        inputMetaCopy=inputMetadata.clone();
        inputConec=connec;
        if (connec.getSource().isReadOnly()) {
          inputReadOnlyNode=true;
        }
 else {
          for (          IElementParameter curParam : connec.getSource().getElementParameters()) {
            if (curParam.getFieldType() == EParameterFieldType.SCHEMA_TYPE) {
              if (curParam.isReadOnly()) {
                inputReadOnlyParam=true;
              }
            }
          }
        }
        if (inputMetadata != null) {
          for (          IMetadataColumn column : inputMetadata.getListColumns()) {
            IMetadataColumn columnCopied=inputMetaCopy.getColumn(column.getLabel());
            columnCopied.setCustom(column.isCustom());
            columnCopied.setReadOnly(column.isReadOnly());
          }
          inputMetaCopy.setReadOnly(inputMetadata.isReadOnly());
          inputReadOnly=prepareReadOnlyTable(inputMetaCopy,inputReadOnlyParam,inputReadOnlyNode);
        }
        Map<IMetadataTable,Boolean> oneInput=new HashMap<IMetadataTable,Boolean>();
        oneInput.put(inputMetaCopy,inputReadOnly);
        inputInfos.put(connec.getSource(),oneInput);
      }
    }
    if (connectionParam != null && inputMetadata == null) {
      MessageDialog.openError(button.getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
      return null;
    }
    IMetadataTable originaleMetadataTable=getMetadataTableFromXml(node);
    IMetadataTable originaleOutputTable=node.getMetadataFromConnector(param.getContext());
    if ("String_Node_Str".equals(node.getComponent().getName())) {
      originaleOutputTable=node.getMetadataTable("String_Node_Str");
    }
    IMetadataTable outputMetaCopy=originaleOutputTable.clone(true);
    for (    IMetadataColumn column : originaleOutputTable.getListColumns()) {
      IMetadataColumn columnCopied=outputMetaCopy.getColumn(column.getLabel());
      columnCopied.setCustom(column.isCustom());
      columnCopied.setReadOnly(column.isReadOnly());
      if (("String_Node_Str".equals(node.getComponent().getName()) || "String_Node_Str".equals(node.getComponent().getName())) && !outputMetaCopy.sameMetadataAs(originaleMetadataTable,IMetadataColumn.OPTIONS_NONE)) {
        columnCopied.setReadOnly(false);
      }
    }
    outputMetaCopy.setReadOnly(originaleOutputTable.isReadOnly() || param.isReadOnly(node.getElementParametersWithChildrens()));
    if (("String_Node_Str".equals(node.getComponent().getName()) || "String_Node_Str".equals(node.getComponent().getName())) && !outputMetaCopy.sameMetadataAs(originaleMetadataTable,IMetadataColumn.OPTIONS_NONE)) {
      outputMetaCopy.setReadOnly(false);
    }
    IElementParameter schemaTypeParam=param.getChildParameters().get("String_Node_Str");
    List<IElementParameterDefaultValue> defaultValues=schemaTypeParam.getDefaultValues();
    for (    IElementParameterDefaultValue elementParameterDefaultValue : defaultValues) {
      if (elementParameterDefaultValue.getDefaultValue() instanceof MetadataTable) {
        MetadataTable table=(MetadataTable)elementParameterDefaultValue.getDefaultValue();
        outputMetaCopy.setReadOnlyColumnPosition(table.getReadOnlyColumnPosition());
        break;
      }
    }
    outputMetaCopy.sortCustomColumns();
    if (!forceReadOnly) {
      outputReadOnly=prepareReadOnlyTable(outputMetaCopy,param.isReadOnly(),node.isReadOnly());
    }
 else {
      outputReadOnly=true;
    }
    MetadataDialog metaDialog=null;
    if (inputMetadata != null) {
      if (inputInfos != null && inputInfos.size() > 1 && connectionName == null) {
        MetadataDialogForMerge metaDialogForMerge=new MetadataDialogForMerge(composite.getShell(),inputInfos,outputMetaCopy,node,getCommandStack());
        metaDialogForMerge.setText(Messages.getString("String_Node_Str") + node.getLabel());
        metaDialogForMerge.setInputReadOnly(inputReadOnly);
        metaDialogForMerge.setOutputReadOnly(outputReadOnly);
        if (metaDialogForMerge.open() == MetadataDialogForMerge.OK) {
          outputMetaCopy=metaDialogForMerge.getOutputMetaData();
          boolean modified=false;
          if (!outputMetaCopy.sameMetadataAs(originaleOutputTable,IMetadataColumn.OPTIONS_NONE)) {
            modified=true;
          }
 else {
            if (inputMetadata != null) {
              Set<INode> inputNodes=inputInfos.keySet();
              for (              INode inputNode : inputNodes) {
                Map<IMetadataTable,Boolean> oneInput=inputInfos.get(inputNode);
                inputMetaCopy=(IMetadataTable)oneInput.keySet().toArray()[0];
                if (!inputMetaCopy.sameMetadataAs(inputNode.getMetadataList().get(0),IMetadataColumn.OPTIONS_NONE)) {
                  modified=true;
                }
              }
            }
          }
          if (modified) {
            if (switchParam != null) {
              switchParam.setValue(Boolean.FALSE);
            }
            Command changeMetadataCommand=null;
            if (inputInfos.isEmpty()) {
              changeMetadataCommand=new ChangeMetadataCommand(node,param,null,null,null,originaleOutputTable,outputMetaCopy);
            }
 else {
              Set<INode> inputNodes=inputInfos.keySet();
              int count=0;
              for (              INode inputNode : inputNodes) {
                Map<IMetadataTable,Boolean> oneInput=inputInfos.get(inputNode);
                inputMetaCopy=(IMetadataTable)oneInput.keySet().toArray()[0];
                if (count == 0) {
                  changeMetadataCommand=new ChangeMetadataCommand(node,param,inputNode,inputNode.getMetadataList().get(0),inputMetaCopy,originaleOutputTable,outputMetaCopy);
                }
 else {
                  changeMetadataCommand=changeMetadataCommand.chain(new ChangeMetadataCommand(node,param,inputNode,inputNode.getMetadataList().get(0),inputMetaCopy,originaleOutputTable,outputMetaCopy));
                }
                count++;
              }
            }
            return changeMetadataCommand;
          }
        }
      }
 else {
        INode inputNode=(inputConec.getSource());
        if (inputMetaCopy.getAttachedConnector() == null) {
          INodeConnector mainConnector;
          if (inputNode.isELTComponent()) {
            mainConnector=inputNode.getConnectorFromType(EConnectionType.TABLE);
          }
 else {
            mainConnector=inputNode.getConnectorFromType(EConnectionType.FLOW_MAIN);
          }
          inputMetaCopy.setAttachedConnector(mainConnector.getName());
        }
        metaDialog=new MetadataDialog(composite.getShell(),inputMetaCopy,inputNode,outputMetaCopy,node,getCommandStack());
      }
    }
 else {
      metaDialog=new MetadataDialog(composite.getShell(),outputMetaCopy,node,getCommandStack());
    }
    if (metaDialog != null) {
      metaDialog.setText(Messages.getString("String_Node_Str") + node.getLabel());
      metaDialog.setInputReadOnly(inputReadOnly);
      metaDialog.setOutputReadOnly(outputReadOnly);
      if (metaDialog.open() == MetadataDialog.OK) {
        inputMetaCopy=metaDialog.getInputMetaData();
        outputMetaCopy=metaDialog.getOutputMetaData();
        boolean modified=false;
        if (!outputMetaCopy.sameMetadataAs(originaleOutputTable,IMetadataColumn.OPTIONS_NONE)) {
          modified=true;
        }
 else {
          if (inputMetadata != null) {
            if (!inputMetaCopy.sameMetadataAs(inputMetadata,IMetadataColumn.OPTIONS_NONE)) {
              modified=true;
            }
          }
        }
        if (modified) {
          if (switchParam != null) {
            switchParam.setValue(Boolean.FALSE);
          }
          INode inputNode=null;
          if (inputConec != null) {
            inputNode=inputConec.getSource();
          }
          ChangeMetadataCommand changeMetadataCommand=new ChangeMetadataCommand(node,param,inputNode,inputMetadata,inputMetaCopy,originaleOutputTable,outputMetaCopy);
          return changeMetadataCommand;
        }
      }
    }
  }
 else   if (inputButton.getData(NAME).equals(RETRIEVE_SCHEMA)) {
    Node node=(Node)elem;
    final Command cmd=RetrieveSchemaHelper.retrieveSchemasCommand(node);
    if (switchParam != null) {
      switchParam.setValue(Boolean.FALSE);
    }
    return cmd;
  }
 else   if (inputButton.getData(NAME).equals(RESET_COLUMNS)) {
    Node node=(Node)elem;
    String propertyName=(String)inputButton.getData(PARAMETER_NAME);
    IElementParameter param=node.getElementParameter(propertyName);
    final Command cmd=SynchronizeSchemaHelper.createCommand(node,param);
    if (switchParam != null) {
      switchParam.setValue(Boolean.FALSE);
    }
    return cmd;
  }
 else   if (button.getData(NAME).equals(REPOSITORY_CHOICE)) {
    String paramName=(String)button.getData(PARAMETER_NAME);
    IElementParameter schemaParam=elem.getElementParameter(paramName);
    ERepositoryObjectType type=ERepositoryObjectType.METADATA_CON_TABLE;
    String filter=schemaParam.getFilter();
    if (elem instanceof Node) {
      Node sapNode=(Node)elem;
      if (sapNode.getComponent().getName().startsWith("String_Node_Str")) {
        type=ERepositoryObjectType.METADATA_SAP_FUNCTION;
      }
 else       if (sapNode.getComponent().getName().startsWith("String_Node_Str")) {
        filter=ERepositoryObjectType.SERVICESOPERATION.getType();
      }
    }
    RepositoryReviewDialog dialog=new RepositoryReviewDialog(button.getShell(),type,filter);
    if (dialog.open() == RepositoryReviewDialog.OK) {
      RepositoryNode node=dialog.getResult();
      while (node.getObject().getProperty().getItem() == null || (!(node.getObject().getProperty().getItem() instanceof ConnectionItem))) {
        node=node.getParent();
      }
      String id=dialog.getResult().getObject().getProperty().getId();
      String name=dialog.getResult().getObject().getLabel();
      String value=id + "String_Node_Str" + name;
      String fullParamName=paramName + "String_Node_Str" + getRepositoryChoiceParamName();
      org.talend.core.model.metadata.builder.connection.Connection connection=null;
      if (elem instanceof Node) {
        IMetadataTable repositoryMetadata=MetadataToolHelper.getMetadataFromRepository(value);
        connection=MetadataToolHelper.getConnectionFromRepository(value);
        if (((Node)elem).getUniqueName().startsWith("String_Node_Str")) {
          Node sapNode=(Node)elem;
          String functionId=node.getParent().getId();
          repositoryMetadata=getMetadataFromRepository(id,functionId,name);
          String tableName=repositoryMetadata.getLabel();
          String functionName=node.getParent().getObject().getLabel();
          for (          IElementParameter param : sapNode.getElementParameters()) {
            SAPParametersUtils.retrieveSAPParams(elem,connection,param,functionName);
          }
        }
 else {
          repositoryMetadata=MetadataToolHelper.getMetadataFromRepository(value);
        }
        boolean isValRulesLost=false;
        IRepositoryViewObject currentValRuleObj=ValidationRulesUtil.getCurrentValidationRuleObjs(elem);
        if (currentValRuleObj != null) {
          List<IRepositoryViewObject> valRuleObjs=ValidationRulesUtil.getRelatedValidationRuleObjs(value);
          if (!ValidationRulesUtil.isCurrentValRuleObjInList(valRuleObjs,currentValRuleObj)) {
            if (!MessageDialog.openConfirm(button.getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
              return null;
            }
 else {
              isValRulesLost=true;
            }
          }
        }
        if (repositoryMetadata == null) {
          repositoryMetadata=new MetadataTable();
        }
        if (switchParam != null) {
          switchParam.setValue(Boolean.FALSE);
        }
        CompoundCommand cc=new CompoundCommand();
        RepositoryChangeMetadataCommand changeMetadataCommand=new RepositoryChangeMetadataCommand((Node)elem,fullParamName,value,repositoryMetadata,null,null);
        changeMetadataCommand.setConnection(connection);
        cc.add(changeMetadataCommand);
        if (isValRulesLost) {
          ValidationRulesUtil.appendRemoveValidationRuleCommands(cc,elem);
        }
        return cc;
      }
    }
  }
 else   if (button.getData(NAME).equals(COPY_CHILD_COLUMNS)) {
    String paramName=(String)button.getData(PARAMETER_NAME);
    IElementParameter param=elem.getElementParameter(paramName);
    IElementParameter processParam=elem.getElementParameterFromField(EParameterFieldType.PROCESS_TYPE);
    IElementParameter processIdParam=processParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
    String id=(String)processIdParam.getValue();
    Item item=ItemCacheManager.getProcessItem(id);
    Node node=(Node)elem;
    copySchemaFromChildJob(node,item);
    MetadataDialog metaDialog=new MetadataDialog(composite.getShell(),node.getMetadataList().get(0),node,getCommandStack());
    metaDialog.setText(Messages.getString("String_Node_Str") + node.getLabel());
    if (metaDialog.open() == MetadataDialog.OK) {
      IMetadataTable outputMetaData=metaDialog.getOutputMetaData();
      return new ChangeMetadataCommand(node,param,null,outputMetaData);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected Command createButtonCommand(Button button){
  if (checkForRepositoryShema(button)) {
    return null;
  }
  Button inputButton=button;
  IElementParameter switchParam=elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
  if (inputButton.getData(NAME).equals(SCHEMA)) {
    Map<INode,Map<IMetadataTable,Boolean>> inputInfos=new HashMap<INode,Map<IMetadataTable,Boolean>>();
    INode node;
    if (elem instanceof Node) {
      node=(INode)elem;
    }
 else {
      node=((IConnection)elem).getSource();
    }
    IMetadataTable inputMetadata=null, inputMetaCopy=null;
    Connection inputConec=null;
    String propertyName=(String)inputButton.getData(PARAMETER_NAME);
    IElementParameter param=node.getElementParameter(propertyName);
    IElementParameter connectionParam=param.getChildParameters().get(EParameterName.CONNECTION.getName());
    String connectionName=null;
    if (connectionParam != null) {
      connectionName=(String)connectionParam.getValue();
    }
    Object obj=button.getData(FORCE_READ_ONLY);
    boolean forceReadOnly=false;
    if (obj != null) {
      forceReadOnly=(Boolean)obj;
    }
    boolean inputReadOnly=false, outputReadOnly=false, inputReadOnlyNode=false, inputReadOnlyParam=false;
    for (    Connection connec : (List<Connection>)node.getIncomingConnections()) {
      if (connec.isActivate() && (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE) || connec.getLineStyle().equals(EConnectionType.FLOW_MERGE)|| connec.getLineStyle() == EConnectionType.FLOW_REF)) {
        if (connectionName != null && !connec.getName().equals(connectionName)) {
          continue;
        }
        inputMetadata=connec.getMetadataTable();
        inputMetaCopy=inputMetadata.clone();
        inputConec=connec;
        if (connec.getSource().isReadOnly()) {
          inputReadOnlyNode=true;
        }
 else {
          for (          IElementParameter curParam : connec.getSource().getElementParameters()) {
            if (curParam.getFieldType() == EParameterFieldType.SCHEMA_TYPE) {
              if (curParam.isReadOnly()) {
                inputReadOnlyParam=true;
              }
            }
          }
        }
        if (inputMetadata != null) {
          for (          IMetadataColumn column : inputMetadata.getListColumns()) {
            IMetadataColumn columnCopied=inputMetaCopy.getColumn(column.getLabel());
            columnCopied.setCustom(column.isCustom());
            columnCopied.setReadOnly(column.isReadOnly());
          }
          inputMetaCopy.setReadOnly(inputMetadata.isReadOnly());
          inputReadOnly=prepareReadOnlyTable(inputMetaCopy,inputReadOnlyParam,inputReadOnlyNode);
        }
        Map<IMetadataTable,Boolean> oneInput=new HashMap<IMetadataTable,Boolean>();
        oneInput.put(inputMetaCopy,inputReadOnly);
        inputInfos.put(connec.getSource(),oneInput);
      }
    }
    if (connectionParam != null && inputMetadata == null) {
      MessageDialog.openError(button.getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
      return null;
    }
    IMetadataTable originaleMetadataTable=getMetadataTableFromXml(node);
    IMetadataTable originaleOutputTable=node.getMetadataFromConnector(param.getContext());
    if ("String_Node_Str".equals(node.getComponent().getName())) {
      originaleOutputTable=node.getMetadataTable("String_Node_Str");
    }
    IMetadataTable outputMetaCopy=originaleOutputTable.clone(true);
    for (    IMetadataColumn column : originaleOutputTable.getListColumns()) {
      IMetadataColumn columnCopied=outputMetaCopy.getColumn(column.getLabel());
      columnCopied.setCustom(column.isCustom());
      columnCopied.setReadOnly(column.isReadOnly());
      if (("String_Node_Str".equals(node.getComponent().getName()) || "String_Node_Str".equals(node.getComponent().getName())) && !outputMetaCopy.sameMetadataAs(originaleMetadataTable,IMetadataColumn.OPTIONS_NONE)) {
        columnCopied.setReadOnly(false);
      }
    }
    outputMetaCopy.setReadOnly(originaleOutputTable.isReadOnly() || param.isReadOnly(node.getElementParametersWithChildrens()));
    if (("String_Node_Str".equals(node.getComponent().getName()) || "String_Node_Str".equals(node.getComponent().getName())) && !outputMetaCopy.sameMetadataAs(originaleMetadataTable,IMetadataColumn.OPTIONS_NONE)) {
      outputMetaCopy.setReadOnly(false);
    }
    IElementParameter schemaTypeParam=param.getChildParameters().get("String_Node_Str");
    List<IElementParameterDefaultValue> defaultValues=schemaTypeParam.getDefaultValues();
    for (    IElementParameterDefaultValue elementParameterDefaultValue : defaultValues) {
      if (elementParameterDefaultValue.getDefaultValue() instanceof MetadataTable) {
        MetadataTable table=(MetadataTable)elementParameterDefaultValue.getDefaultValue();
        outputMetaCopy.setReadOnlyColumnPosition(table.getReadOnlyColumnPosition());
        break;
      }
    }
    outputMetaCopy.sortCustomColumns();
    if (!forceReadOnly) {
      outputReadOnly=prepareReadOnlyTable(outputMetaCopy,param.isReadOnly(),node.isReadOnly());
    }
 else {
      outputReadOnly=true;
    }
    MetadataDialog metaDialog=null;
    if (inputMetadata != null) {
      if (inputInfos != null && inputInfos.size() > 1 && connectionName == null) {
        MetadataDialogForMerge metaDialogForMerge=new MetadataDialogForMerge(composite.getShell(),inputInfos,outputMetaCopy,node,getCommandStack());
        metaDialogForMerge.setText(Messages.getString("String_Node_Str") + node.getLabel());
        metaDialogForMerge.setInputReadOnly(inputReadOnly);
        metaDialogForMerge.setOutputReadOnly(outputReadOnly);
        if (metaDialogForMerge.open() == MetadataDialogForMerge.OK) {
          outputMetaCopy=metaDialogForMerge.getOutputMetaData();
          boolean modified=false;
          if (!outputMetaCopy.sameMetadataAs(originaleOutputTable,IMetadataColumn.OPTIONS_NONE)) {
            modified=true;
          }
 else {
            if (inputMetadata != null) {
              Set<INode> inputNodes=inputInfos.keySet();
              for (              INode inputNode : inputNodes) {
                Map<IMetadataTable,Boolean> oneInput=inputInfos.get(inputNode);
                inputMetaCopy=(IMetadataTable)oneInput.keySet().toArray()[0];
                if (!inputMetaCopy.sameMetadataAs(inputNode.getMetadataList().get(0),IMetadataColumn.OPTIONS_NONE)) {
                  modified=true;
                }
              }
            }
          }
          if (modified) {
            if (switchParam != null) {
              switchParam.setValue(Boolean.FALSE);
            }
            Command changeMetadataCommand=null;
            if (inputInfos.isEmpty()) {
              changeMetadataCommand=new ChangeMetadataCommand(node,param,null,null,null,originaleOutputTable,outputMetaCopy);
            }
 else {
              Set<INode> inputNodes=inputInfos.keySet();
              int count=0;
              for (              INode inputNode : inputNodes) {
                Map<IMetadataTable,Boolean> oneInput=inputInfos.get(inputNode);
                inputMetaCopy=(IMetadataTable)oneInput.keySet().toArray()[0];
                if (count == 0) {
                  changeMetadataCommand=new ChangeMetadataCommand(node,param,inputNode,inputNode.getMetadataList().get(0),inputMetaCopy,originaleOutputTable,outputMetaCopy);
                }
 else {
                  changeMetadataCommand=changeMetadataCommand.chain(new ChangeMetadataCommand(node,param,inputNode,inputNode.getMetadataList().get(0),inputMetaCopy,originaleOutputTable,outputMetaCopy));
                }
                count++;
              }
            }
            return changeMetadataCommand;
          }
        }
      }
 else {
        INode inputNode=(inputConec.getSource());
        if (inputMetaCopy.getAttachedConnector() == null) {
          INodeConnector mainConnector;
          if (inputNode.isELTComponent()) {
            mainConnector=inputNode.getConnectorFromType(EConnectionType.TABLE);
          }
 else {
            mainConnector=inputNode.getConnectorFromType(EConnectionType.FLOW_MAIN);
          }
          inputMetaCopy.setAttachedConnector(mainConnector.getName());
        }
        metaDialog=new MetadataDialog(composite.getShell(),inputMetaCopy,inputNode,outputMetaCopy,node,getCommandStack());
      }
    }
 else {
      metaDialog=new MetadataDialog(composite.getShell(),outputMetaCopy,node,getCommandStack());
    }
    if (metaDialog != null) {
      metaDialog.setText(Messages.getString("String_Node_Str") + node.getLabel());
      metaDialog.setInputReadOnly(inputReadOnly);
      metaDialog.setOutputReadOnly(outputReadOnly);
      if (metaDialog.open() == MetadataDialog.OK) {
        inputMetaCopy=metaDialog.getInputMetaData();
        outputMetaCopy=metaDialog.getOutputMetaData();
        boolean modified=false;
        if (!outputMetaCopy.sameMetadataAs(originaleOutputTable,IMetadataColumn.OPTIONS_NONE)) {
          modified=true;
        }
 else {
          if (inputMetadata != null) {
            if (!inputMetaCopy.sameMetadataAs(inputMetadata,IMetadataColumn.OPTIONS_NONE)) {
              modified=true;
            }
          }
        }
        if (modified) {
          if (switchParam != null) {
            switchParam.setValue(Boolean.FALSE);
          }
          INode inputNode=null;
          if (inputConec != null) {
            inputNode=inputConec.getSource();
          }
          ChangeMetadataCommand changeMetadataCommand=new ChangeMetadataCommand(node,param,inputNode,inputMetadata,inputMetaCopy,originaleOutputTable,outputMetaCopy);
          return changeMetadataCommand;
        }
      }
    }
  }
 else   if (inputButton.getData(NAME).equals(RETRIEVE_SCHEMA)) {
    Node node=(Node)elem;
    final Command cmd=RetrieveSchemaHelper.retrieveSchemasCommand(node);
    if (switchParam != null) {
      switchParam.setValue(Boolean.FALSE);
    }
    return cmd;
  }
 else   if (inputButton.getData(NAME).equals(RESET_COLUMNS)) {
    Node node=(Node)elem;
    String propertyName=(String)inputButton.getData(PARAMETER_NAME);
    IElementParameter param=node.getElementParameter(propertyName);
    final Command cmd=SynchronizeSchemaHelper.createCommand(node,param);
    if (switchParam != null) {
      switchParam.setValue(Boolean.FALSE);
    }
    return cmd;
  }
 else   if (button.getData(NAME).equals(REPOSITORY_CHOICE)) {
    String paramName=(String)button.getData(PARAMETER_NAME);
    IElementParameter schemaParam=elem.getElementParameter(paramName);
    ERepositoryObjectType type=ERepositoryObjectType.METADATA_CON_TABLE;
    String filter=schemaParam.getFilter();
    if (elem instanceof Node) {
      Node sapNode=(Node)elem;
      if (sapNode.getComponent().getName().startsWith("String_Node_Str")) {
        type=ERepositoryObjectType.METADATA_SAP_FUNCTION;
      }
 else       if (sapNode.getComponent().getName().startsWith("String_Node_Str")) {
        filter=ERepositoryObjectType.SERVICESOPERATION.getType();
      }
    }
    RepositoryReviewDialog dialog=new RepositoryReviewDialog(button.getShell(),type,filter);
    if (dialog.open() == RepositoryReviewDialog.OK) {
      RepositoryNode node=dialog.getResult();
      while (node.getObject().getProperty().getItem() == null || (!(node.getObject().getProperty().getItem() instanceof ConnectionItem))) {
        node=node.getParent();
      }
      String id=dialog.getResult().getObject().getProperty().getId();
      String name=dialog.getResult().getObject().getLabel();
      if (name != null) {
        if (elem instanceof Node) {
          Node nodeElement=(Node)elem;
          String value=id + "String_Node_Str" + name;
          IMetadataTable repositoryMetadata=MetadataToolHelper.getMetadataFromRepository(value);
          if (nodeElement.getComponent().getName().equals("String_Node_Str")) {
            if (paramName.equals("String_Node_Str")) {
              paramName="String_Node_Str";
              Command dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              executeCommand(dbSelectorCommand);
              Text labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              paramName="String_Node_Str";
              dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(name));
              executeCommand(dbSelectorCommand);
              labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(name));
              paramName="String_Node_Str";
            }
 else             if (paramName.equals("String_Node_Str")) {
              paramName="String_Node_Str";
              Command dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              executeCommand(dbSelectorCommand);
              Text labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              paramName="String_Node_Str";
              dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(name));
              executeCommand(dbSelectorCommand);
              labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(name));
              paramName="String_Node_Str";
            }
          }
 else           if (nodeElement.getComponent().getName().startsWith("String_Node_Str")) {
            if (paramName.equals("String_Node_Str")) {
              paramName="String_Node_Str";
              Command dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              executeCommand(dbSelectorCommand);
              Text labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              paramName="String_Node_Str";
              dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(name));
              executeCommand(dbSelectorCommand);
              labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(name));
              paramName="String_Node_Str";
            }
 else             if (paramName.equals("String_Node_Str")) {
              paramName="String_Node_Str";
              Command dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              executeCommand(dbSelectorCommand);
              Text labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
              paramName="String_Node_Str";
              dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(name));
              executeCommand(dbSelectorCommand);
              labelText=(Text)hashCurControls.get(paramName);
              labelText.setText(TalendTextUtils.addQuotes(name));
              paramName="String_Node_Str";
            }
          }
 else {
            Command dbSelectorCommand=new PropertyChangeCommand(elem,paramName,TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
            executeCommand(dbSelectorCommand);
            Text labelText=(Text)hashCurControls.get(paramName);
            if (labelText != null) {
              labelText.setText(TalendTextUtils.addQuotes(repositoryMetadata.getTableName()));
            }
          }
        }
      }
      String value=id + "String_Node_Str" + name;
      String fullParamName=paramName + "String_Node_Str" + getRepositoryChoiceParamName();
      org.talend.core.model.metadata.builder.connection.Connection connection=null;
      if (elem instanceof Node) {
        IMetadataTable repositoryMetadata=MetadataToolHelper.getMetadataFromRepository(value);
        connection=MetadataToolHelper.getConnectionFromRepository(value);
        if (((Node)elem).getUniqueName().startsWith("String_Node_Str")) {
          Node sapNode=(Node)elem;
          String functionId=node.getParent().getId();
          repositoryMetadata=getMetadataFromRepository(id,functionId,name);
          String tableName=repositoryMetadata.getLabel();
          String functionName=node.getParent().getObject().getLabel();
          for (          IElementParameter param : sapNode.getElementParameters()) {
            SAPParametersUtils.retrieveSAPParams(elem,connection,param,functionName);
          }
        }
 else {
          repositoryMetadata=MetadataToolHelper.getMetadataFromRepository(value);
        }
        boolean isValRulesLost=false;
        IRepositoryViewObject currentValRuleObj=ValidationRulesUtil.getCurrentValidationRuleObjs(elem);
        if (currentValRuleObj != null) {
          List<IRepositoryViewObject> valRuleObjs=ValidationRulesUtil.getRelatedValidationRuleObjs(value);
          if (!ValidationRulesUtil.isCurrentValRuleObjInList(valRuleObjs,currentValRuleObj)) {
            if (!MessageDialog.openConfirm(button.getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
              return null;
            }
 else {
              isValRulesLost=true;
            }
          }
        }
        if (repositoryMetadata == null) {
          repositoryMetadata=new MetadataTable();
        }
        if (switchParam != null) {
          switchParam.setValue(Boolean.FALSE);
        }
        CompoundCommand cc=new CompoundCommand();
        RepositoryChangeMetadataCommand changeMetadataCommand=new RepositoryChangeMetadataCommand((Node)elem,fullParamName,value,repositoryMetadata,null,null);
        changeMetadataCommand.setConnection(connection);
        cc.add(changeMetadataCommand);
        if (isValRulesLost) {
          ValidationRulesUtil.appendRemoveValidationRuleCommands(cc,elem);
        }
        return cc;
      }
    }
  }
 else   if (button.getData(NAME).equals(COPY_CHILD_COLUMNS)) {
    String paramName=(String)button.getData(PARAMETER_NAME);
    IElementParameter param=elem.getElementParameter(paramName);
    IElementParameter processParam=elem.getElementParameterFromField(EParameterFieldType.PROCESS_TYPE);
    IElementParameter processIdParam=processParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
    String id=(String)processIdParam.getValue();
    Item item=ItemCacheManager.getProcessItem(id);
    Node node=(Node)elem;
    copySchemaFromChildJob(node,item);
    MetadataDialog metaDialog=new MetadataDialog(composite.getShell(),node.getMetadataList().get(0),node,getCommandStack());
    metaDialog.setText(Messages.getString("String_Node_Str") + node.getLabel());
    if (metaDialog.open() == MetadataDialog.OK) {
      IMetadataTable outputMetaData=metaDialog.getOutputMetaData();
      return new ChangeMetadataCommand(node,param,null,outputMetaData);
    }
  }
  return null;
}