Program: 136797
Project: 136797
Buggy source:
private void setConnectionState(final AbstractAnalysisMetadataPage masterPage,final DataManager dataManager){
  DataManager newDataManager=dataManager;
  final DataManager fianlDataManager;
  if (newDataManager != null) {
    if (newDataManager.eIsProxy()) {
      newDataManager=(DataManager)EObjectHelper.resolveObject(newDataManager);
    }
    Property prop=PropertyHelper.getProperty(newDataManager);
    masterPage.reloadDataproviderAndFillConnCombo();
    fianlDataManager=newDataManager;
    Integer index=0;
    if (SwitchHelpers.CONNECTION_SWITCH.doSwitch(newDataManager) != null) {
      index=(Integer)masterPage.getConnCombo().getData(prop.getDisplayName() + RepositoryNodeHelper.getConnectionType(newDataManager));
    }
    if (index != null) {
      masterPage.getConnCombo().select(index);
    }
    if (prop != null && prop.getItem() != null && prop.getItem().getState() != null && prop.getItem().getState().isDeleted()) {
      masterPage.getLabelConnDeleted().setVisible(true);
      masterPage.getLabelConnDeleted().setText(DefaultMessagesImpl.getString("String_Node_Str",prop.getDisplayName()));
    }
 else {
      masterPage.getLabelConnDeleted().setVisible(false);
    }
    if (selectionListener == null) {
      selectionListener=new SelectionListener(){
        private int prevSelect=masterPage.getConnCombo().getSelectionIndex();
        private Connection dataProvider=(Connection)fianlDataManager;
        public void widgetDefaultSelected(        SelectionEvent e){
          widgetSelected(e);
        }
        public void widgetSelected(        SelectionEvent e){
          ReturnCode rc=selectedObjectAvailable();
          if (rc.isOk()) {
            if (dataProvider.eIsProxy()) {
              dataProvider=(Connection)EObjectHelper.resolveObject(dataProvider);
            }
            dataProvider=callChangeConnectionAction(masterPage,prevSelect,dataProvider);
            prevSelect=masterPage.getConnCombo().getSelectionIndex();
          }
 else {
            MessageDialogWithToggle.openError(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",rc.getMessage()));
            masterPage.reloadDataproviderAndFillConnCombo();
            masterPage.getConnCombo().removeSelectionListener(selectionListener);
            String uuid=ResourceHelper.getUUID(dataProvider);
            if (uuid != null) {
              int itemCount=masterPage.getConnCombo().getItemCount();
              for (int i=0; i < itemCount; i++) {
                Object connectionObj=masterPage.getConnCombo().getData(String.valueOf(i));
                RepositoryNode repoNode=(RepositoryNode)connectionObj;
                Connection connection=getConnectionFromRepositoryNode(repoNode);
                if (connection != null && uuid.endsWith(ResourceHelper.getUUID(connection))) {
                  masterPage.getConnCombo().select(i);
                  break;
                }
              }
            }
            masterPage.getConnCombo().addSelectionListener(selectionListener);
          }
        }
        /** 
 * check the connection is available or not(the connection is exist and not proxy, don't check the connection).
 * @return a ReturnCode, the message is the connection label
 */
        private ReturnCode selectedObjectAvailable(){
          ReturnCode rc=new ReturnCode("String_Node_Str",Boolean.FALSE);
          RepositoryNode repoNode=masterPage.getConnComboSelectNode();
          rc.setMessage(repoNode.getLabel());
          Connection connection=getConnectionFromRepositoryNode(repoNode);
          if (connection != null && !connection.eIsProxy()) {
            rc.setOk(true);
          }
          return rc;
        }
        /** 
 * DOC xqliu Comment method "getConnectionFromRepositoryNode".
 * @param repoNode
 * @return
 */
        private Connection getConnectionFromRepositoryNode(        RepositoryNode repoNode){
          Connection connection=null;
          IRepositoryViewObject repoViewObject=repoNode.getObject();
          if (repoViewObject != null) {
            Property property=repoViewObject.getProperty();
            if (property != null) {
              Item item=property.getItem();
              if (item != null && item instanceof ConnectionItem) {
                connection=((ConnectionItem)item).getConnection();
              }
            }
          }
          return connection;
        }
      }
;
      masterPage.getConnCombo().addSelectionListener(selectionListener);
    }
  }
 else {
    masterPage.getConnCombo().setText("String_Node_Str");
  }
}

Fixed version (ground truth):
private void setConnectionState(final AbstractAnalysisMetadataPage masterPage,final DataManager dataManager){
  DataManager newDataManager=dataManager;
  final DataManager fianlDataManager;
  if (newDataManager != null) {
    if (newDataManager.eIsProxy()) {
      newDataManager=(DataManager)EObjectHelper.resolveObject(newDataManager);
    }
    Property prop=PropertyHelper.getProperty(newDataManager);
    masterPage.reloadDataproviderAndFillConnCombo();
    fianlDataManager=newDataManager;
    Integer index=0;
    if (SwitchHelpers.CONNECTION_SWITCH.doSwitch(newDataManager) != null) {
      String displayName=prop.getDisplayName();
      DQRepositoryNode node=(DQRepositoryNode)RepositoryNodeHelper.recursiveFind(prop);
      if (!node.getProject().isMainProject()) {
        displayName+=node.getDisplayProjectName();
      }
      index=(Integer)masterPage.getConnCombo().getData(displayName + RepositoryNodeHelper.getConnectionType(newDataManager));
    }
    if (index != null) {
      masterPage.getConnCombo().select(index);
    }
    if (prop != null && prop.getItem() != null && prop.getItem().getState() != null && prop.getItem().getState().isDeleted()) {
      masterPage.getLabelConnDeleted().setVisible(true);
      masterPage.getLabelConnDeleted().setText(DefaultMessagesImpl.getString("String_Node_Str",prop.getDisplayName()));
    }
 else {
      masterPage.getLabelConnDeleted().setVisible(false);
    }
    if (selectionListener == null) {
      selectionListener=new SelectionListener(){
        private int prevSelect=masterPage.getConnCombo().getSelectionIndex();
        private Connection dataProvider=(Connection)fianlDataManager;
        public void widgetDefaultSelected(        SelectionEvent e){
          widgetSelected(e);
        }
        public void widgetSelected(        SelectionEvent e){
          ReturnCode rc=selectedObjectAvailable();
          if (rc.isOk()) {
            if (dataProvider.eIsProxy()) {
              dataProvider=(Connection)EObjectHelper.resolveObject(dataProvider);
            }
            dataProvider=callChangeConnectionAction(masterPage,prevSelect,dataProvider);
            prevSelect=masterPage.getConnCombo().getSelectionIndex();
          }
 else {
            MessageDialogWithToggle.openError(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",rc.getMessage()));
            masterPage.reloadDataproviderAndFillConnCombo();
            masterPage.getConnCombo().removeSelectionListener(selectionListener);
            String uuid=ResourceHelper.getUUID(dataProvider);
            if (uuid != null) {
              int itemCount=masterPage.getConnCombo().getItemCount();
              for (int i=0; i < itemCount; i++) {
                Object connectionObj=masterPage.getConnCombo().getData(String.valueOf(i));
                RepositoryNode repoNode=(RepositoryNode)connectionObj;
                Connection connection=getConnectionFromRepositoryNode(repoNode);
                if (connection != null && uuid.endsWith(ResourceHelper.getUUID(connection))) {
                  masterPage.getConnCombo().select(i);
                  break;
                }
              }
            }
            masterPage.getConnCombo().addSelectionListener(selectionListener);
          }
        }
        /** 
 * check the connection is available or not(the connection is exist and not proxy, don't check the connection).
 * @return a ReturnCode, the message is the connection label
 */
        private ReturnCode selectedObjectAvailable(){
          ReturnCode rc=new ReturnCode("String_Node_Str",Boolean.FALSE);
          RepositoryNode repoNode=masterPage.getConnComboSelectNode();
          rc.setMessage(repoNode.getLabel());
          Connection connection=getConnectionFromRepositoryNode(repoNode);
          if (connection != null && !connection.eIsProxy()) {
            rc.setOk(true);
          }
          return rc;
        }
        /** 
 * DOC xqliu Comment method "getConnectionFromRepositoryNode".
 * @param repoNode
 * @return
 */
        private Connection getConnectionFromRepositoryNode(        RepositoryNode repoNode){
          Connection connection=null;
          IRepositoryViewObject repoViewObject=repoNode.getObject();
          if (repoViewObject != null) {
            Property property=repoViewObject.getProperty();
            if (property != null) {
              Item item=property.getItem();
              if (item != null && item instanceof ConnectionItem) {
                connection=((ConnectionItem)item).getConnection();
              }
            }
          }
          return connection;
        }
      }
;
      masterPage.getConnCombo().addSelectionListener(selectionListener);
    }
  }
 else {
    masterPage.getConnCombo().setText("String_Node_Str");
  }
}