Program: 123915
Project: 123915
Buggy source:
/** 
 * Creates tab item. Changed by Marvin Wang on Feb. 24, 2012 for bug TDI-7643, for all SQLBuilderEditorComposite when using <code>editorComposite.getConnParam().getQueryObject()</code> to get the query object, the query every time get is the same object. Caz all <code>SQLBuilderEditorComposite</code>s use the same connection parameter.
 * @param node
 * @param connParam
 * @param isDefaultEditor
 */
private void createTabItem(RepositoryNode node,ConnectionParameters connParam,boolean isDefaultEditor){
  String queryStr="String_Node_Str";
  if (node != null) {
    CTabItem[] tabItems=tabFolder.getItems();
    for (int i=0; i < tabItems.length; i++) {
      SQLBuilderEditorComposite editorComposite=(SQLBuilderEditorComposite)(((CTabFolder)tabItems[i].getControl()).getItems()[0]).getControl();
      Query query2=editorComposite.getQueryObject();
      if ((RepositoryNodeType)node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.QUERY) {
        Query query=((QueryRepositoryObject)node.getObject()).getQuery();
        if (query2 == null && tabItems[i].getData() instanceof Query) {
          query2=(Query)tabItems[i].getData();
        }
        if (query2 != null && query.getLabel().equals(query2.getLabel())) {
          if ("String_Node_Str".equals(editorComposite.getEditorContent())) {
            editorComposite.setEditorContent(query.getValue());
          }
          tabFolder.setSelection(i);
          return;
        }
        connParam.setQueryObject(query);
        queryStr=query.getValue();
      }
    }
  }
  Object connectTypeObj=node.getProperties(EProperties.CONTENT_TYPE);
  RepositoryNodeType connectType=null;
  if (connectTypeObj instanceof RepositoryNodeType)   connectType=(RepositoryNodeType)connectTypeObj;
  if (RepositoryNodeType.QUERY != connectType) {
    connParam.setQueryObject(null);
    dialog.getConnParameters().setQueryObject(null);
  }
  CTabItem tabItem=null;
  if (connParam.isFromDBNode()) {
    tabItem=new CTabItem(tabFolder,SWT.NULL);
  }
 else {
    tabItem=new CTabItem(tabFolder,SWT.CLOSE);
  }
  node=SQLBuilderRepositoryNodeManager.getRoot(node);
  if (!"String_Node_Str".equals(queryStr)) {
    try {
      nodesSel=EMFRepositoryNodeManager.getInstance().parseSqlStatement(queryStr,node);
    }
 catch (    Exception e) {
      MessageDialog.openError(new Shell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
    }
  }
  MultiPageSqlBuilderEditor builderEditor=new MultiPageSqlBuilderEditor(nodesSel,tabItem,isDefaultEditor,connParam,node,dialog);
  builderEditor.setReadOnly(readOnly);
  try {
    builderEditor.init(new SQLBuilderEditorSite(),new SQLBuilderEditorInput());
  }
 catch (  PartInitException e) {
    ExceptionHandler.process(e);
  }
  builderEditor.createPartControl(tabFolder);
  tabItem.setControl(builderEditor.getContainer());
  tabItem.setData(TextUtil.KEY,builderEditor);
  if (connParam.isFromRepository() && connParam.getQueryObject() != null) {
    queryStr=connParam.getQueryObject().getValue();
  }
  builderEditor.setSqlText(queryStr);
  if (connParam.isShowDesignerPage()) {
    builderEditor.showDesignerPage();
  }
  tabFolder.setSelection(tabFolder.getItemCount() - 1);
  tabFolder.layout();
  tabFolder.redraw();
}

Fixed version (ground truth):
/** 
 * Creates tab item. Changed by Marvin Wang on Feb. 24, 2012 for bug TDI-7643, for all SQLBuilderEditorComposite when using <code>editorComposite.getConnParam().getQueryObject()</code> to get the query object, the query every time get is the same object. Caz all <code>SQLBuilderEditorComposite</code>s use the same connection parameter.
 * @param node
 * @param connParam
 * @param isDefaultEditor
 */
private void createTabItem(RepositoryNode node,ConnectionParameters connParam,boolean isDefaultEditor){
  String queryStr="String_Node_Str";
  if (node != null) {
    CTabItem[] tabItems=tabFolder.getItems();
    for (int i=0; i < tabItems.length; i++) {
      SQLBuilderEditorComposite editorComposite=(SQLBuilderEditorComposite)(((CTabFolder)tabItems[i].getControl()).getItems()[0]).getControl();
      Query query2=editorComposite.getQueryObject();
      if ((RepositoryNodeType)node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.QUERY) {
        Query query=((QueryRepositoryObject)node.getObject()).getQuery();
        if (query2 == null && tabItems[i].getData() instanceof Query) {
          query2=(Query)tabItems[i].getData();
        }
        if (query2 != null && query.getLabel().equals(query2.getLabel())) {
          if ("String_Node_Str".equals(editorComposite.getEditorContent())) {
            editorComposite.setEditorContent(query.getValue());
          }
          tabFolder.setSelection(i);
          return;
        }
        connParam.setQueryObject(query);
        queryStr=query.getValue();
      }
    }
  }
  Object connectTypeObj=node.getProperties(EProperties.CONTENT_TYPE);
  RepositoryNodeType connectType=null;
  if (connectTypeObj instanceof RepositoryNodeType)   connectType=(RepositoryNodeType)connectTypeObj;
  boolean flag=true;
  if (!("String_Node_Str").equals(connParam.getQuery()) && 0 == tabFolder.getItems().length && null == connParam.getQueryObject()) {
    flag=false;
  }
  if (flag) {
    if (RepositoryNodeType.QUERY == connectType) {
      connParam.setQueryObject(((QueryRepositoryObject)node.getObject()).getQuery());
      dialog.getConnParameters().setQueryObject(((QueryRepositoryObject)node.getObject()).getQuery());
    }
 else     if (RepositoryNodeType.DATABASE == connectType) {
      connParam.setQueryObject(null);
      dialog.getConnParameters().setQueryObject(null);
    }
  }
  CTabItem tabItem=null;
  if (connParam.isFromDBNode()) {
    tabItem=new CTabItem(tabFolder,SWT.NULL);
  }
 else {
    tabItem=new CTabItem(tabFolder,SWT.CLOSE);
  }
  node=SQLBuilderRepositoryNodeManager.getRoot(node);
  if (!"String_Node_Str".equals(queryStr)) {
    try {
      nodesSel=EMFRepositoryNodeManager.getInstance().parseSqlStatement(queryStr,node);
    }
 catch (    Exception e) {
      MessageDialog.openError(new Shell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
    }
  }
  MultiPageSqlBuilderEditor builderEditor=new MultiPageSqlBuilderEditor(nodesSel,tabItem,isDefaultEditor,connParam,node,dialog);
  builderEditor.setReadOnly(readOnly);
  try {
    builderEditor.init(new SQLBuilderEditorSite(),new SQLBuilderEditorInput());
  }
 catch (  PartInitException e) {
    ExceptionHandler.process(e);
  }
  builderEditor.createPartControl(tabFolder);
  tabItem.setControl(builderEditor.getContainer());
  tabItem.setData(TextUtil.KEY,builderEditor);
  if (connParam.isFromRepository() && connParam.getQueryObject() != null) {
    queryStr=connParam.getQueryObject().getValue();
  }
  builderEditor.setSqlText(queryStr);
  if (connParam.isShowDesignerPage()) {
    builderEditor.showDesignerPage();
  }
  tabFolder.setSelection(tabFolder.getItemCount() - 1);
  tabFolder.layout();
  tabFolder.redraw();
}