Program: 125441
Project: 125441
Buggy source:
@Override protected Object openDialogBox(Control cellEditorWindow){
  String schemaToEdit=(String)this.getValue();
  String oldValue=schemaToEdit;
  boolean metaReadonly=false;
  final List<IMetadataTable> metadatas=node.getMetadataList();
  IMetadataTable tableToEdit=null;
  if (schemaToEdit == null || "String_Node_Str".equals(schemaToEdit)) {
    SAPConnectionItem sapItem=getSAPRepositoryItem();
    if (sapItem != null) {
      boolean readonly=node.getProcess().isReadOnly();
      if (node.getJobletNode() != null) {
        readonly=node.isReadOnly();
      }
      SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,sapItem,EProcessType.CREATE,schemaToEdit,readonly);
      if (choiceDialog.open() == Window.OK) {
        if (choiceDialog.getSelctionType() == ESelectionCategory.REPOSITORY) {
          org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
          if (selectedMetadataTable != null) {
            final IMetadataTable metaTable=ConvertionHelper.convert(selectedMetadataTable);
            int index=0;
            if (getTableViewer() != null) {
              index=getTableViewer().getTable().getSelectionIndex();
            }
            SAPFunctionUnit functionUnit=null;
            if (selectedMetadataTable.eContainer() instanceof SAPFunctionUnit) {
              functionUnit=(SAPFunctionUnit)selectedMetadataTable.eContainer();
            }
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              node.getMetadataFromConnector(schemaToEdit);
              executeCommand(new RepositoryChangeMetadataForSAPBapi(node,functionUnit,metaTable,null,index));
            }
 else {
              executeCommand(new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,metaTable.getLabel(),metaTable,index));
            }
            if (getTableViewer() != null) {
              getTableViewer().refresh(true);
            }
            return selectedMetadataTable.getLabel();
          }
          return null;
        }
 else {
        }
      }
 else {
        this.setValue(oldValue);
        return oldValue;
      }
    }
    EbcdicConnectionItem repositoryItem=getRepositoryItem();
    if (repositoryItem != null) {
      SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,repositoryItem,EProcessType.CREATE,schemaToEdit,node.getProcess().isReadOnly());
      if (choiceDialog.open() == Window.OK) {
        if (choiceDialog.getSelctionType() == ESelectionCategory.REPOSITORY) {
          org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
          if (selectedMetadataTable != null) {
            final IMetadataTable metaTable=ConvertionHelper.convert(selectedMetadataTable);
            int index=0;
            if (getTableViewer() != null) {
              index=getTableViewer().getTable().getSelectionIndex();
            }
            SAPFunctionUnit functionUnit=null;
            if (selectedMetadataTable.eContainer() instanceof SAPFunctionUnit) {
              functionUnit=(SAPFunctionUnit)selectedMetadataTable.eContainer();
            }
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              executeCommand(new RepositoryChangeMetadataForSAPBapi(node,functionUnit,tableToEdit,metaTable));
            }
 else {
              executeCommand(new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,metaTable.getLabel(),metaTable,index));
            }
            if (getTableViewer() != null) {
              getTableViewer().refresh(true);
            }
            return selectedMetadataTable.getLabel();
          }
          return null;
        }
 else {
        }
      }
 else {
        return null;
      }
    }
    InputDialog dialogInput=new InputDialog(cellEditorWindow.getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),"String_Node_Str",new IInputValidator(){
      @Override public String isValid(      String newText){
        if ("String_Node_Str".equals(newText.trim())) {
          return Messages.getString("String_Node_Str");
        }
        if (MetadataToolHelper.getMetadataTableFromNodeTableName(node,newText) != null || !node.getProcess().checkValidConnectionName(newText)) {
          return Messages.getString("String_Node_Str");
        }
        return null;
      }
    }
);
    if (dialogInput.open() == InputDialog.OK) {
      Object newPropValue=dialogInput.getValue();
      if (!isRulesComponent(node)) {
        node.getProcess().addUniqueConnectionName(dialogInput.getValue());
        final MetadataTable table=new MetadataTable();
        table.setLabel(dialogInput.getValue());
        table.setTableName(dialogInput.getValue());
        tableToEdit=table;
        metadatas.add(table);
        executeCommand(new Command(){
          @Override public void execute(){
            if (getTableViewer() != null) {
              Table tTable=getTableViewer().getTable();
              Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
              if (data instanceof Map) {
                final Map<String,Object> valueMap=(Map<String,Object>)data;
                Object code=valueMap.get(IEbcdicConstant.FIELD_CODE);
                if (code == null || "String_Node_Str".equals(code)) {
                  valueMap.put(IEbcdicConstant.FIELD_CODE,table.getTableName());
                  valueMap.put(IEbcdicConstant.FIELD_SCHEMA,table.getTableName());
                }
              }
              getTableViewer().refresh();
            }
          }
        }
);
      }
 else {
        INode inputNode=null, outputNode=null;
        IMetadataTable originalInputTable=null, originalCurrentOutTable=null, finalOutTable=null, finalInputTable=null;
        MetadataDialog metaDialog=null;
        int index=getTableViewer().getTable().getSelectionIndex();
        if (node.getIncomingConnections().size() > 0) {
          if (node.getOutgoingConnections().size() > 0) {
            outputNode=node.getOutgoingConnections().get(0).getTarget();
          }
          originalInputTable=node.getIncomingConnections().get(0).getMetadataTable();
          inputNode=node.getIncomingConnections().get(0).getSource();
          if (outputNode == null) {
            outputNode=node;
          }
          List<IMetadataColumn> listColumns=new ArrayList<IMetadataColumn>();
          originalCurrentOutTable=new MetadataTable();
          originalCurrentOutTable.setListColumns(listColumns);
          metaDialog=new MetadataDialog(new Shell(),originalInputTable,inputNode,originalCurrentOutTable,outputNode,tableEditorView.getTableViewerCreator().getCommandStack());
          if (metaDialog.open() == Window.OK) {
            finalInputTable=metaDialog.getInputMetaData().clone();
            finalOutTable=metaDialog.getOutputMetaData().clone();
            ChangeRuleMetadataCommand changeRuleMetadataCommand=new ChangeRuleMetadataCommand(node,"String_Node_Str",newPropValue,finalOutTable,index);
            executeCommand(changeRuleMetadataCommand);
            if (getTableViewer() != null) {
              getTableViewer().refresh();
            }
          }
        }
 else {
          node.getProcess().addUniqueConnectionName(dialogInput.getValue());
          final MetadataTable table=new MetadataTable();
          table.setLabel(dialogInput.getValue());
          table.setTableName(dialogInput.getValue());
          tableToEdit=table;
          metadatas.add(table);
          executeCommand(new Command(){
            @Override public void execute(){
              if (getTableViewer() != null) {
                Table tTable=getTableViewer().getTable();
                Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
                if (data instanceof Map) {
                  final Map<String,Object> valueMap=(Map<String,Object>)data;
                  Object code=valueMap.get(IEbcdicConstant.FIELD_CODE);
                  if (code == null || "String_Node_Str".equals(code)) {
                    valueMap.put(IEbcdicConstant.FIELD_CODE,table.getTableName());
                    valueMap.put(IEbcdicConstant.FIELD_SCHEMA,table.getTableName());
                  }
                }
                getTableViewer().refresh();
              }
            }
          }
);
        }
      }
    }
  }
 else {
    if (isSAPNode(node) && getTableViewer() != null) {
      Table tTable=getTableViewer().getTable();
      Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
      if (data instanceof Map) {
        final Map<String,Object> valueMap=(Map<String,Object>)data;
        Object code=valueMap.get(IEbcdicConstant.FIELD_SCHEMA);
        tableToEdit=MetadataToolHelper.getMetadataTableFromNodeTableName(node,code.toString());
      }
    }
 else {
      tableToEdit=MetadataToolHelper.getMetadataTableFromNodeTableName(node,schemaToEdit);
    }
    if (getTableViewer() != null && tableToEdit != null && isEBCDICNode(node)) {
      Table tTable=getTableViewer().getTable();
      Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
      if (data instanceof Map) {
        final Map<String,Object> valueMap=(Map<String,Object>)data;
        final String key=IEbcdicConstant.FIELD_SCHEMA + IEbcdicConstant.REF_TYPE;
        Object repositoyType=valueMap.get(key);
        EbcdicConnectionItem repositoryItem=getRepositoryItem();
        EProcessType processType=EProcessType.BUILTIN;
        if (repositoryItem != null) {
          if (repositoyType != null && IEbcdicConstant.REF_ATTR_REPOSITORY.equals(repositoyType)) {
            processType=EProcessType.REPOSITORY;
          }
        }
        SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,repositoryItem,processType,schemaToEdit,node.getProcess().isReadOnly());
        if (choiceDialog.open() == Window.OK) {
          ESelectionCategory selctionType=choiceDialog.getSelctionType();
switch (selctionType) {
case SHOW_SCHEMA:
            if (processType == EProcessType.REPOSITORY) {
              metaReadonly=true;
            }
          break;
case REPOSITORY:
        final org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
      if (selectedMetadataTable != null) {
        String newSchema=selectedMetadataTable.getLabel();
        if (!schemaToEdit.equals(newSchema) || processType == EProcessType.BUILTIN) {
          RepositoryChangeMetadataForEBCDICCommand cmd=new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,newSchema,schemaToEdit,ConvertionHelper.convert(selectedMetadataTable),tableToEdit,tTable.getSelectionIndex());
          executeCommand(cmd);
          if (getTableViewer() != null) {
            getTableViewer().refresh();
          }
        }
        return newSchema;
      }
 else {
      }
case BUILDIN:
    executeCommand(new Command(){
      @Override public void execute(){
        valueMap.remove(key);
        if (getTableViewer() != null) {
          getTableViewer().refresh();
        }
      }
    }
);
  return schemaToEdit;
default :
}
}
 else {
return null;
}
}
}
if (getTableViewer() != null && tableToEdit != null && isSAPNode(node)) {
Table tTable=getTableViewer().getTable();
Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
if (data instanceof Map) {
final Map<String,Object> valueMap=(Map<String,Object>)data;
final String key=ISAPConstant.FIELD_SCHEMA + ISAPConstant.REF_TYPE;
Object repositoyType=valueMap.get(key);
SAPConnectionItem repositoryItem=getSAPRepositoryItem();
EProcessType processType=EProcessType.BUILTIN;
if (repositoryItem != null) {
if (repositoyType != null && ISAPConstant.REF_ATTR_REPOSITORY.equals(repositoyType)) {
processType=EProcessType.REPOSITORY;
}
}
Object type=valueMap.get(ISAPConstant.TYPE);
if (type != null && type.toString().equals(TABLE)) {
SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,repositoryItem,processType,schemaToEdit,node.getProcess().isReadOnly());
if (choiceDialog.open() == Window.OK) {
ESelectionCategory selctionType=choiceDialog.getSelctionType();
switch (selctionType) {
case SHOW_SCHEMA:
  if (processType == EProcessType.REPOSITORY) {
    metaReadonly=true;
  }
break;
case REPOSITORY:
final org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
if (selectedMetadataTable != null) {
String newSchema=selectedMetadataTable.getLabel();
if (!schemaToEdit.equals(newSchema) || processType == EProcessType.BUILTIN) {
RepositoryChangeMetadataForSAPCommand cmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,newSchema,schemaToEdit,ConvertionHelper.convert(selectedMetadataTable),tableToEdit,tTable.getSelectionIndex());
executeCommand(cmd);
if (getTableViewer() != null) {
  getTableViewer().refresh();
}
}
return newSchema;
}
 else {
}
case BUILDIN:
executeCommand(new Command(){
@Override public void execute(){
valueMap.remove(key);
if (getTableViewer() != null) {
getTableViewer().refresh();
}
}
}
);
return schemaToEdit;
default :
}
}
 else {
return null;
}
}
 else {
if (processType == EProcessType.REPOSITORY) {
metaReadonly=true;
}
}
}
}
}
Table tTable=getTableViewer().getTable();
boolean hasParentRow=false;
Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
Object type=null;
Object parent_row=null;
if (data instanceof Map) {
final Map<String,Object> valueMap=(Map<String,Object>)data;
if (valueMap.containsKey(PARENT_ROW)) {
hasParentRow=true;
}
final String key=ISAPConstant.TYPE;
type=valueMap.get(key);
parent_row=valueMap.get(PARENT_ROW);
if (isSAPNode(node) && type instanceof Integer) {
type=SINGLE;
valueMap.remove(key);
valueMap.put(key,SINGLE);
}
}
final boolean hasParentRowForExe=hasParentRow;
if (tableToEdit != null) {
if (isHL7OutputNode(node) && node.getIncomingConnections().size() > 0) {
copyHL7OutputMetadata(node,tableToEdit);
}
 else if (isSAPNode(node) && type != null && type.toString().equals(TABLE) && node.getIncomingConnections().size() > 0 && hasParentRow && (parent_row != null && !parent_row.equals("String_Node_Str") && !(parent_row instanceof Integer))) {
copySAPOutputMetadata(node,tableToEdit);
}
 else {
MetadataDialog dialog=new MetadataDialog(cellEditorWindow.getShell(),tableToEdit.clone(),node,null);
dialog.setSingleAndStruct(false);
dialog.setInputReadOnly(metaReadonly);
dialog.setOutputReadOnly(metaReadonly);
if (isSAPNode(node) && type != null && (type.equals(SINGLE) || type.equals(STRUCTURE)) && hasParentRow) {
dialog.setSingleAndStruct(true);
}
final IMetadataTable oldTable=tableToEdit;
if (dialog.open() == MetadataDialog.OK) {
final IMetadataTable newTable=dialog.getOutputMetaData();
if (!oldTable.sameMetadataAs(newTable,IMetadataColumn.OPTIONS_NONE)) {
executeCommand(new Command(){
@Override public void execute(){
oldTable.getListUsedColumns().clear();
oldTable.getListUnusedColumns().clear();
oldTable.setListColumns(newTable.getListColumns(true));
List<IMetadataColumn> columns=newTable.getListColumns(true);
if (node instanceof IGraphicalNode) {
IGraphicalNode gNode=(IGraphicalNode)node;
gNode.checkAndRefreshNode();
}
if (isSAPNode(node) && hasParentRowForExe) {
oldTable.getAdditionalProperties().put(ISINPUT,TRUE);
}
if (getTableViewer() != null) {
getTableViewer().refresh();
}
}
}
);
}
 else {
if (isSAPNode(node) && hasParentRowForExe) {
oldTable.getAdditionalProperties().put(ISINPUT,TRUE);
}
}
}
 else {
if (isSAPNode(node) && hasParentRowForExe) {
oldTable.getAdditionalProperties().put(ISINPUT,TRUE);
}
}
}
return schemaToEdit;
}
 else {
return "String_Node_Str";
}
}

Fixed version (ground truth):
@Override protected Object openDialogBox(Control cellEditorWindow){
  String schemaToEdit=(String)this.getValue();
  String oldValue=schemaToEdit;
  boolean metaReadonly=false;
  final List<IMetadataTable> metadatas=node.getMetadataList();
  IMetadataTable tableToEdit=null;
  if (schemaToEdit == null || "String_Node_Str".equals(schemaToEdit)) {
    SAPConnectionItem sapItem=getSAPRepositoryItem();
    if (sapItem != null) {
      boolean readonly=node.getProcess().isReadOnly();
      if (node.getJobletNode() != null) {
        readonly=node.isReadOnly();
      }
      SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,sapItem,EProcessType.CREATE,schemaToEdit,readonly);
      if (choiceDialog.open() == Window.OK) {
        if (choiceDialog.getSelctionType() == ESelectionCategory.REPOSITORY) {
          org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
          if (selectedMetadataTable != null) {
            final IMetadataTable metaTable=ConvertionHelper.convert(selectedMetadataTable);
            int index=0;
            if (getTableViewer() != null) {
              index=getTableViewer().getTable().getSelectionIndex();
            }
            SAPFunctionUnit functionUnit=null;
            if (selectedMetadataTable.eContainer() instanceof SAPFunctionUnit) {
              functionUnit=(SAPFunctionUnit)selectedMetadataTable.eContainer();
            }
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              node.getMetadataFromConnector(schemaToEdit);
              executeCommand(new RepositoryChangeMetadataForSAPBapi(node,functionUnit,metaTable,null,index));
            }
 else {
              executeCommand(new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,metaTable.getLabel(),metaTable,index));
            }
            if (getTableViewer() != null) {
              getTableViewer().refresh(true);
            }
            return selectedMetadataTable.getLabel();
          }
          return null;
        }
 else {
        }
      }
 else {
        this.setValue(oldValue);
        return oldValue;
      }
    }
    EbcdicConnectionItem repositoryItem=getRepositoryItem();
    if (repositoryItem != null) {
      SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,repositoryItem,EProcessType.CREATE,schemaToEdit,node.getProcess().isReadOnly());
      if (choiceDialog.open() == Window.OK) {
        if (choiceDialog.getSelctionType() == ESelectionCategory.REPOSITORY) {
          org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
          if (selectedMetadataTable != null) {
            final IMetadataTable metaTable=ConvertionHelper.convert(selectedMetadataTable);
            int index=0;
            if (getTableViewer() != null) {
              index=getTableViewer().getTable().getSelectionIndex();
            }
            SAPFunctionUnit functionUnit=null;
            if (selectedMetadataTable.eContainer() instanceof SAPFunctionUnit) {
              functionUnit=(SAPFunctionUnit)selectedMetadataTable.eContainer();
            }
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              executeCommand(new RepositoryChangeMetadataForSAPBapi(node,functionUnit,tableToEdit,metaTable));
            }
 else {
              executeCommand(new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,metaTable.getLabel(),metaTable,index));
            }
            if (getTableViewer() != null) {
              getTableViewer().refresh(true);
            }
            return selectedMetadataTable.getLabel();
          }
          return null;
        }
 else {
        }
      }
 else {
        return null;
      }
    }
    InputDialog dialogInput=new InputDialog(cellEditorWindow.getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),"String_Node_Str",new IInputValidator(){
      @Override public String isValid(      String newText){
        if ("String_Node_Str".equals(newText.trim())) {
          return Messages.getString("String_Node_Str");
        }
        if (MetadataToolHelper.getMetadataTableFromNodeTableName(node,newText) != null || !node.getProcess().checkValidConnectionName(newText)) {
          return Messages.getString("String_Node_Str");
        }
        return null;
      }
    }
);
    if (dialogInput.open() == InputDialog.OK) {
      Object newPropValue=dialogInput.getValue();
      if (!isRulesComponent(node)) {
        node.getProcess().addUniqueConnectionName(dialogInput.getValue());
        final MetadataTable table=new MetadataTable();
        table.setLabel(dialogInput.getValue());
        table.setTableName(dialogInput.getValue());
        tableToEdit=table;
        metadatas.add(table);
        executeCommand(new Command(){
          @Override public void execute(){
            if (getTableViewer() != null) {
              Table tTable=getTableViewer().getTable();
              Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
              if (data instanceof Map) {
                final Map<String,Object> valueMap=(Map<String,Object>)data;
                Object code=valueMap.get(IEbcdicConstant.FIELD_CODE);
                if (code == null || "String_Node_Str".equals(code)) {
                  valueMap.put(IEbcdicConstant.FIELD_CODE,table.getTableName());
                  valueMap.put(IEbcdicConstant.FIELD_SCHEMA,table.getTableName());
                }
              }
              getTableViewer().refresh();
            }
          }
        }
);
      }
 else {
        INode inputNode=null, outputNode=null;
        IMetadataTable originalInputTable=null, originalCurrentOutTable=null, finalOutTable=null, finalInputTable=null;
        MetadataDialog metaDialog=null;
        int index=getTableViewer().getTable().getSelectionIndex();
        if (node.getIncomingConnections().size() > 0) {
          if (node.getOutgoingConnections().size() > 0) {
            outputNode=node.getOutgoingConnections().get(0).getTarget();
          }
          originalInputTable=node.getIncomingConnections().get(0).getMetadataTable();
          inputNode=node.getIncomingConnections().get(0).getSource();
          if (outputNode == null) {
            outputNode=node;
          }
          List<IMetadataColumn> listColumns=new ArrayList<IMetadataColumn>();
          originalCurrentOutTable=new MetadataTable();
          originalCurrentOutTable.setListColumns(listColumns);
          metaDialog=new MetadataDialog(new Shell(),originalInputTable,inputNode,originalCurrentOutTable,outputNode,tableEditorView.getTableViewerCreator().getCommandStack());
          if (metaDialog.open() == Window.OK) {
            finalInputTable=metaDialog.getInputMetaData().clone();
            finalOutTable=metaDialog.getOutputMetaData().clone();
            ChangeRuleMetadataCommand changeRuleMetadataCommand=new ChangeRuleMetadataCommand(node,"String_Node_Str",newPropValue,finalOutTable,index);
            executeCommand(changeRuleMetadataCommand);
            if (getTableViewer() != null) {
              getTableViewer().refresh();
            }
          }
        }
 else {
          node.getProcess().addUniqueConnectionName(dialogInput.getValue());
          final MetadataTable table=new MetadataTable();
          table.setLabel(dialogInput.getValue());
          table.setTableName(dialogInput.getValue());
          tableToEdit=table;
          metadatas.add(table);
          executeCommand(new Command(){
            @Override public void execute(){
              if (getTableViewer() != null) {
                Table tTable=getTableViewer().getTable();
                Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
                if (data instanceof Map) {
                  final Map<String,Object> valueMap=(Map<String,Object>)data;
                  Object code=valueMap.get(IEbcdicConstant.FIELD_CODE);
                  if (code == null || "String_Node_Str".equals(code)) {
                    valueMap.put(IEbcdicConstant.FIELD_CODE,table.getTableName());
                    valueMap.put(IEbcdicConstant.FIELD_SCHEMA,table.getTableName());
                  }
                }
                getTableViewer().refresh();
              }
            }
          }
);
        }
      }
    }
  }
 else {
    if (isSAPNode(node) && getTableViewer() != null) {
      Table tTable=getTableViewer().getTable();
      Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
      if (data instanceof Map) {
        final Map<String,Object> valueMap=(Map<String,Object>)data;
        Object code=valueMap.get(IEbcdicConstant.FIELD_SCHEMA);
        tableToEdit=MetadataToolHelper.getMetadataTableFromNodeTableName(node,code.toString());
      }
    }
 else {
      tableToEdit=MetadataToolHelper.getMetadataTableFromNodeTableName(node,schemaToEdit);
    }
    if (getTableViewer() != null && tableToEdit != null && isEBCDICNode(node)) {
      Table tTable=getTableViewer().getTable();
      Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
      if (data instanceof Map) {
        final Map<String,Object> valueMap=(Map<String,Object>)data;
        final String key=IEbcdicConstant.FIELD_SCHEMA + IEbcdicConstant.REF_TYPE;
        Object repositoyType=valueMap.get(key);
        EbcdicConnectionItem repositoryItem=getRepositoryItem();
        EProcessType processType=EProcessType.BUILTIN;
        if (repositoryItem != null) {
          if (repositoyType != null && IEbcdicConstant.REF_ATTR_REPOSITORY.equals(repositoyType)) {
            processType=EProcessType.REPOSITORY;
          }
        }
        SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,repositoryItem,processType,schemaToEdit,node.getProcess().isReadOnly());
        if (choiceDialog.open() == Window.OK) {
          ESelectionCategory selctionType=choiceDialog.getSelctionType();
switch (selctionType) {
case SHOW_SCHEMA:
            if (processType == EProcessType.REPOSITORY) {
              metaReadonly=true;
            }
          break;
case REPOSITORY:
        final org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
      if (selectedMetadataTable != null) {
        String newSchema=selectedMetadataTable.getLabel();
        if (!schemaToEdit.equals(newSchema) || processType == EProcessType.BUILTIN) {
          RepositoryChangeMetadataForEBCDICCommand cmd=new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,newSchema,schemaToEdit,ConvertionHelper.convert(selectedMetadataTable),tableToEdit,tTable.getSelectionIndex());
          executeCommand(cmd);
          if (getTableViewer() != null) {
            getTableViewer().refresh();
          }
        }
        return newSchema;
      }
 else {
      }
case BUILDIN:
    executeCommand(new Command(){
      @Override public void execute(){
        valueMap.remove(key);
        if (getTableViewer() != null) {
          getTableViewer().refresh();
        }
      }
    }
);
  return schemaToEdit;
default :
}
}
 else {
return null;
}
}
}
if (getTableViewer() != null && tableToEdit != null && isSAPNode(node)) {
Table tTable=getTableViewer().getTable();
Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
if (data instanceof Map) {
final Map<String,Object> valueMap=(Map<String,Object>)data;
final String key=ISAPConstant.FIELD_SCHEMA + ISAPConstant.REF_TYPE;
Object repositoyType=valueMap.get(key);
SAPConnectionItem repositoryItem=getSAPRepositoryItem();
EProcessType processType=EProcessType.BUILTIN;
if (repositoryItem != null) {
if (repositoyType != null && ISAPConstant.REF_ATTR_REPOSITORY.equals(repositoyType)) {
processType=EProcessType.REPOSITORY;
}
}
Object type=valueMap.get(ISAPConstant.TYPE);
if (type != null && type.toString().equals(TABLE)) {
SchemaOperationChoiceDialog choiceDialog=new SchemaOperationChoiceDialog(cellEditorWindow.getShell(),node,repositoryItem,processType,schemaToEdit,node.getProcess().isReadOnly());
if (choiceDialog.open() == Window.OK) {
ESelectionCategory selctionType=choiceDialog.getSelctionType();
switch (selctionType) {
case SHOW_SCHEMA:
  if (processType == EProcessType.REPOSITORY) {
    metaReadonly=true;
  }
break;
case REPOSITORY:
final org.talend.core.model.metadata.builder.connection.MetadataTable selectedMetadataTable=choiceDialog.getSelectedMetadataTable();
if (selectedMetadataTable != null) {
String newSchema=selectedMetadataTable.getLabel();
if (!schemaToEdit.equals(newSchema) || processType == EProcessType.BUILTIN) {
RepositoryChangeMetadataForSAPCommand cmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,newSchema,schemaToEdit,ConvertionHelper.convert(selectedMetadataTable),tableToEdit,tTable.getSelectionIndex());
executeCommand(cmd);
if (getTableViewer() != null) {
  getTableViewer().refresh();
}
}
return newSchema;
}
 else {
}
case BUILDIN:
executeCommand(new Command(){
@Override public void execute(){
valueMap.remove(key);
if (getTableViewer() != null) {
getTableViewer().refresh();
}
}
}
);
return schemaToEdit;
default :
}
}
 else {
return null;
}
}
 else {
if (processType == EProcessType.REPOSITORY) {
metaReadonly=true;
}
}
}
}
}
Table tTable=getTableViewer().getTable();
boolean hasParentRow=false;
Object data=tTable.getItem(tTable.getSelectionIndex()).getData();
Object type=null;
Object parent_row=null;
if (data instanceof Map) {
final Map<String,Object> valueMap=(Map<String,Object>)data;
if (valueMap.containsKey(PARENT_ROW)) {
hasParentRow=true;
}
final String key=ISAPConstant.TYPE;
type=valueMap.get(key);
parent_row=valueMap.get(PARENT_ROW);
if (isSAPNode(node) && type instanceof Integer) {
type=SINGLE;
valueMap.remove(key);
valueMap.put(key,SINGLE);
}
}
final boolean hasParentRowForExe=hasParentRow;
if (tableToEdit != null) {
if (isHL7OutputNode(node) && node.getIncomingConnections().size() > 0) {
copyHL7OutputMetadata(node,tableToEdit);
}
 else if (isSAPNode(node) && type != null && type.toString().equals(TABLE) && node.getIncomingConnections().size() > 0 && hasParentRow && (parent_row != null && !parent_row.equals("String_Node_Str") && !(parent_row instanceof Integer))) {
copySAPOutputMetadata(node,tableToEdit);
}
 else {
MetadataDialog dialog=new MetadataDialog(cellEditorWindow.getShell(),tableToEdit.clone(),node,null);
dialog.setInputReadOnly(metaReadonly);
dialog.setOutputReadOnly(metaReadonly);
if (isSAPNode(node) && type != null && (type.equals(SINGLE) || type.equals(STRUCTURE)) && hasParentRow) {
MetadataDialog.setSingleAndStruct(true);
}
final IMetadataTable oldTable=tableToEdit;
if (dialog.open() == MetadataDialog.OK) {
final IMetadataTable newTable=dialog.getOutputMetaData();
if (!oldTable.sameMetadataAs(newTable,IMetadataColumn.OPTIONS_NONE)) {
executeCommand(new Command(){
@Override public void execute(){
oldTable.getListUsedColumns().clear();
oldTable.getListUnusedColumns().clear();
oldTable.setListColumns(newTable.getListColumns(true));
List<IMetadataColumn> columns=newTable.getListColumns(true);
if (node instanceof IGraphicalNode) {
IGraphicalNode gNode=(IGraphicalNode)node;
gNode.checkAndRefreshNode();
}
if (isSAPNode(node) && hasParentRowForExe) {
oldTable.getAdditionalProperties().put(ISINPUT,TRUE);
}
if (getTableViewer() != null) {
getTableViewer().refresh();
}
}
}
);
}
 else {
if (isSAPNode(node) && hasParentRowForExe) {
oldTable.getAdditionalProperties().put(ISINPUT,TRUE);
}
}
}
 else {
if (isSAPNode(node) && hasParentRowForExe) {
oldTable.getAdditionalProperties().put(ISINPUT,TRUE);
}
}
}
return schemaToEdit;
}
 else {
return "String_Node_Str";
}
}