Program: 66867
Project: 66867
Buggy source:
public Composite createArea(Composite parent){
  int numColumns=2;
  if (description != null && description.length() > 0) {
    numColumns++;
  }
  if ((style & BUTTON_AGGREGATION) == BUTTON_AGGREGATION) {
    numColumns++;
  }
  if ((style & BUTTON_GROUP) == BUTTON_GROUP) {
    numColumns++;
  }
  cmpTop=new Composite(parent,SWT.NONE);
{
    GridLayout glContent=new GridLayout();
    glContent.numColumns=numColumns;
    glContent.marginHeight=0;
    glContent.marginWidth=0;
    glContent.horizontalSpacing=2;
    cmpTop.setLayout(glContent);
    GridData gd=new GridData(GridData.FILL_HORIZONTAL);
    cmpTop.setLayoutData(gd);
  }
  Label lblDesc=null;
  if (description != null && description.length() > 0) {
    lblDesc=new Label(cmpTop,SWT.NONE);
    lblDesc.setText(description);
    lblDesc.setToolTipText(tooltipWhenBlank);
  }
  if ((style & BUTTON_AGGREGATION) == BUTTON_AGGREGATION) {
    createAggregationItem(cmpTop);
  }
  boolean isSharingChart=context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_CHART_QUERY);
  final Object[] predefinedQuery=context.getPredefinedQuery(queryType);
  sbHelper.reset(predefinedQuery);
  IDataServiceProvider provider=context.getDataServiceProvider();
  boolean needComboField=predefinedQuery != null && predefinedQuery.length > 0 && (provider.checkState(IDataServiceProvider.SHARE_QUERY) || provider.checkState(IDataServiceProvider.HAS_CUBE) || (provider.checkState(IDataServiceProvider.INHERIT_CUBE) && !provider.checkState(IDataServiceProvider.PART_CHART))|| provider.checkState(IDataServiceProvider.INHERIT_COLUMNS_GROUPS));
  needComboField&=!isSharingChart;
  boolean hasContentAssist=(!isSharingChart && predefinedQuery != null && predefinedQuery.length > 0);
  IAssistField assistField=null;
  if (needComboField) {
    Composite control=new Composite(cmpTop,SWT.NONE);
    GridData gd=new GridData(GridData.FILL_BOTH);
    gd.widthHint=80;
    control.setLayoutData(gd);
    GridLayout gl=new GridLayout();
    FieldAssistHelper.getInstance().initDecorationMargin(gl);
    control.setLayout(gl);
    cmbDefinition=new CCombo(control,context.getDataServiceProvider().checkState(IDataServiceProvider.PART_CHART) ? SWT.READ_ONLY | SWT.BORDER : SWT.BORDER);
    gd=new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace=true;
    cmbDefinition.setLayoutData(gd);
    if (hasContentAssist) {
      assistField=new CComboAssistField(cmbDefinition,null,null);
    }
    cmbDefinition.addListener(SWT.Selection,new Listener(){
      public void handleEvent(      Event event){
        String oldQuery=query.getDefinition() == null ? "String_Node_Str" : query.getDefinition();
        String text=btnBuilder.getExpression();
        if (!isTableSharedBinding() && !(isInXTabNonAggrCellAndInheritCube()) && text.equals(oldQuery)) {
          return;
        }
        if (!oldQuery.equals(text) && queryType == ChartUIConstants.QUERY_VALUE) {
          context.getDataServiceProvider().update(ChartUIConstants.QUERY_VALUE,text);
        }
        if (context.getDataServiceProvider().checkState(IDataServiceProvider.PART_CHART) && ChartUIConstants.QUERY_CATEGORY.equals(queryType) && context.getModel() instanceof ChartWithAxes) {
          ((ChartWithAxes)context.getModel()).setTransposed(cmbDefinition.getSelectionIndex() > 0);
        }
        if (predefinedQuery.length == 0 && (getQuery().getDefinition() == null || getQuery().getDefinition().equals("String_Node_Str"))) {
          cmbDefinition.setEnabled(false);
          btnBuilder.setEnabled(false);
        }
      }
    }
);
  }
 else {
    Composite control=cmpTop;
    if (hasContentAssist) {
      control=new Composite(cmpTop,SWT.NONE);
      GridData gd=new GridData(GridData.FILL_BOTH);
      gd.widthHint=80;
      control.setLayoutData(gd);
      GridLayout gl=new GridLayout();
      FieldAssistHelper.getInstance().initDecorationMargin(gl);
      control.setLayout(gl);
    }
    txtDefinition=new Text(control,SWT.BORDER | SWT.SINGLE);
    GridData gdTXTDefinition=new GridData(GridData.FILL_HORIZONTAL);
    gdTXTDefinition.widthHint=80;
    gdTXTDefinition.grabExcessHorizontalSpace=true;
    txtDefinition.setLayoutData(gdTXTDefinition);
    if (hasContentAssist) {
      assistField=new TextAssistField(txtDefinition,null,null);
    }
  }
  try {
    btnBuilder=(IExpressionButton)context.getUIServiceProvider().invoke(IUIServiceProvider.Command.EXPRESS_BUTTON_CREATE,cmpTop,getInputControl(),context.getExtendedItem(),IUIServiceProvider.COMMAND_EXPRESSION_DATA_BINDINGS,new Listener(){
      public void handleEvent(      Event event){
        onModifyExpression();
      }
    }
);
  }
 catch (  ChartException e) {
    WizardBase.displayException(e);
  }
  if (needComboField) {
    if (predefinedQuery.length == 0 && (getQuery().getDefinition() == null || getQuery().getDefinition().equals("String_Node_Str"))) {
      cmbDefinition.setEnabled(false);
      btnBuilder.setEnabled(false);
    }
  }
  btnBuilder.setPredefinedQuery(predefinedQuery);
  btnBuilder.setAssitField(assistField);
  if (query != null) {
    btnBuilder.setExpression(query.getDefinition());
  }
  Control dropControl=getInputControl();
  DropTarget target=new DropTarget(dropControl,DND.DROP_COPY);
  Transfer[] types=new Transfer[]{SimpleTextTransfer.getInstance()};
  target.setTransfer(types);
  target.addDropListener(new DataTextDropListener(dropControl,btnBuilder));
  DataDefinitionTextManager.getInstance().addDataDefinitionText(dropControl,this);
  if ((style & BUTTON_GROUP) == BUTTON_GROUP) {
    btnGroup=new Button(cmpTop,SWT.PUSH);
    GridData gdBTNGroup=new GridData();
    ChartUIUtil.setChartImageButtonSizeByPlatform(gdBTNGroup);
    btnGroup.setLayoutData(gdBTNGroup);
    btnGroup.setImage(UIHelper.getImage("String_Node_Str"));
    btnGroup.addSelectionListener(this);
    btnGroup.setToolTipText(Messages.getString("String_Node_Str"));
  }
  boolean isCubeNoMultiDimensions=(provider.checkState(IDataServiceProvider.HAS_CUBE) || provider.checkState(IDataServiceProvider.SHARE_CROSSTAB_QUERY)) && !provider.checkState(IDataServiceProvider.MULTI_CUBE_DIMENSIONS);
  if (context.getDataServiceProvider().checkState(IDataServiceProvider.PART_CHART) || context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_QUERY)) {
    if (txtDefinition != null && (!context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_CROSSTAB_QUERY) || isSharingChart)) {
      if (!ChartUIConstants.QUERY_OPTIONAL.equals(queryType) || !provider.checkState(IDataServiceProvider.SHARE_TABLE_QUERY) || getQuery().getDefinition() == null || getQuery().getDefinition().trim().length() == 0) {
        txtDefinition.setEnabled(false);
        btnBuilder.setEnabled(false);
      }
    }
    if (btnGroup != null) {
      btnGroup.setEnabled(false);
    }
  }
  if (cmbDefinition != null && ChartUIConstants.QUERY_OPTIONAL.equals(queryType) && isCubeNoMultiDimensions) {
    cmbDefinition.setEnabled(false);
    btnBuilder.setEnabled(false);
  }
  setTooltipForInputControl();
  boolean isRequiredField=(ChartUIConstants.QUERY_CATEGORY.equals(queryType));
  if (lblDesc != null && isRequiredField) {
    FieldAssistHelper.getInstance().addRequiredFieldIndicator(lblDesc);
  }
  return cmpTop;
}

Fixed version (ground truth):
public Composite createArea(Composite parent){
  int numColumns=2;
  if (description != null && description.length() > 0) {
    numColumns++;
  }
  if ((style & BUTTON_AGGREGATION) == BUTTON_AGGREGATION) {
    numColumns++;
  }
  if ((style & BUTTON_GROUP) == BUTTON_GROUP) {
    numColumns++;
  }
  cmpTop=new Composite(parent,SWT.NONE);
{
    GridLayout glContent=new GridLayout();
    glContent.numColumns=numColumns;
    glContent.marginHeight=0;
    glContent.marginWidth=0;
    glContent.horizontalSpacing=2;
    cmpTop.setLayout(glContent);
    GridData gd=new GridData(GridData.FILL_HORIZONTAL);
    cmpTop.setLayoutData(gd);
  }
  Label lblDesc=null;
  if (description != null && description.length() > 0) {
    lblDesc=new Label(cmpTop,SWT.NONE);
    lblDesc.setText(description);
    lblDesc.setToolTipText(tooltipWhenBlank);
  }
  if ((style & BUTTON_AGGREGATION) == BUTTON_AGGREGATION) {
    createAggregationItem(cmpTop);
  }
  boolean isSharingChart=context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_CHART_QUERY);
  final Object[] predefinedQuery=context.getPredefinedQuery(queryType);
  sbHelper.reset(predefinedQuery);
  IDataServiceProvider provider=context.getDataServiceProvider();
  boolean needComboField=predefinedQuery != null && predefinedQuery.length > 0 && (provider.checkState(IDataServiceProvider.SHARE_QUERY) || provider.checkState(IDataServiceProvider.HAS_CUBE) || (provider.checkState(IDataServiceProvider.INHERIT_CUBE) && !provider.checkState(IDataServiceProvider.PART_CHART))|| provider.checkState(IDataServiceProvider.INHERIT_COLUMNS_GROUPS));
  needComboField&=!isSharingChart;
  boolean hasContentAssist=(!isSharingChart && predefinedQuery != null && predefinedQuery.length > 0);
  IAssistField assistField=null;
  if (needComboField) {
    Composite control=new Composite(cmpTop,SWT.NONE);
    GridData gd=new GridData(GridData.FILL_BOTH);
    gd.widthHint=80;
    control.setLayoutData(gd);
    GridLayout gl=new GridLayout();
    FieldAssistHelper.getInstance().initDecorationMargin(gl);
    control.setLayout(gl);
    cmbDefinition=new CCombo(control,context.getDataServiceProvider().checkState(IDataServiceProvider.PART_CHART) ? SWT.READ_ONLY | SWT.BORDER : SWT.BORDER);
    gd=new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace=true;
    cmbDefinition.setLayoutData(gd);
    if (hasContentAssist) {
      assistField=new CComboAssistField(cmbDefinition,null,null);
    }
    cmbDefinition.addListener(SWT.Selection,new Listener(){
      public void handleEvent(      Event event){
        String oldQuery=query.getDefinition() == null ? "String_Node_Str" : query.getDefinition();
        String text=btnBuilder.getExpression();
        if (!isTableSharedBinding() && !(isInXTabNonAggrCellAndInheritCube()) && text.equals(oldQuery)) {
          return;
        }
        if (!oldQuery.equals(text) && queryType == ChartUIConstants.QUERY_VALUE) {
          context.getDataServiceProvider().update(ChartUIConstants.QUERY_VALUE,text);
        }
        if (context.getDataServiceProvider().checkState(IDataServiceProvider.PART_CHART) && ChartUIConstants.QUERY_CATEGORY.equals(queryType) && context.getModel() instanceof ChartWithAxes) {
          ((ChartWithAxes)context.getModel()).setTransposed(cmbDefinition.getSelectionIndex() > 0);
        }
        if (predefinedQuery.length == 0 && (getQuery().getDefinition() == null || getQuery().getDefinition().equals("String_Node_Str"))) {
          cmbDefinition.setEnabled(false);
          btnBuilder.setEnabled(false);
        }
      }
    }
);
  }
 else {
    Composite control=cmpTop;
    if (hasContentAssist) {
      control=new Composite(cmpTop,SWT.NONE);
      GridData gd=new GridData(GridData.FILL_BOTH);
      gd.widthHint=80;
      control.setLayoutData(gd);
      GridLayout gl=new GridLayout();
      FieldAssistHelper.getInstance().initDecorationMargin(gl);
      control.setLayout(gl);
    }
    txtDefinition=new Text(control,SWT.BORDER | SWT.SINGLE);
    GridData gdTXTDefinition=new GridData(GridData.FILL_HORIZONTAL);
    gdTXTDefinition.widthHint=80;
    gdTXTDefinition.grabExcessHorizontalSpace=true;
    txtDefinition.setLayoutData(gdTXTDefinition);
    if (hasContentAssist) {
      assistField=new TextAssistField(txtDefinition,null,null);
    }
  }
  try {
    btnBuilder=(IExpressionButton)context.getUIServiceProvider().invoke(IUIServiceProvider.Command.EXPRESS_BUTTON_CREATE,cmpTop,getInputControl(),context.getExtendedItem(),IUIServiceProvider.COMMAND_EXPRESSION_DATA_BINDINGS,new Listener(){
      public void handleEvent(      Event event){
        onModifyExpression();
      }
    }
);
  }
 catch (  ChartException e) {
    WizardBase.displayException(e);
  }
  if (needComboField) {
    if (predefinedQuery.length == 0 && (getQuery().getDefinition() == null || getQuery().getDefinition().equals("String_Node_Str"))) {
      cmbDefinition.setEnabled(false);
      btnBuilder.setEnabled(false);
    }
  }
  btnBuilder.setPredefinedQuery(predefinedQuery);
  btnBuilder.setAssitField(assistField);
  if (query != null) {
    btnBuilder.setExpression(query.getDefinition());
  }
  Control dropControl=getInputControl();
  DropTarget target=new DropTarget(dropControl,DND.DROP_COPY);
  Transfer[] types=new Transfer[]{SimpleTextTransfer.getInstance()};
  target.setTransfer(types);
  target.addDropListener(new DataTextDropListener(dropControl,btnBuilder));
  DataDefinitionTextManager.getInstance().addDataDefinitionText(dropControl,this);
  if ((style & BUTTON_GROUP) == BUTTON_GROUP) {
    btnGroup=new Button(cmpTop,SWT.PUSH);
    GridData gdBTNGroup=new GridData();
    ChartUIUtil.setChartImageButtonSizeByPlatform(gdBTNGroup);
    btnGroup.setLayoutData(gdBTNGroup);
    btnGroup.setImage(UIHelper.getImage("String_Node_Str"));
    btnGroup.addSelectionListener(this);
    btnGroup.setToolTipText(Messages.getString("String_Node_Str"));
  }
  boolean isCubeNoMultiDimensions=(provider.checkState(IDataServiceProvider.HAS_CUBE) || provider.checkState(IDataServiceProvider.SHARE_CROSSTAB_QUERY)) && !provider.checkState(IDataServiceProvider.MULTI_CUBE_DIMENSIONS);
  if (context.getDataServiceProvider().checkState(IDataServiceProvider.PART_CHART) || context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_QUERY)) {
    if (txtDefinition != null && (!context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_CROSSTAB_QUERY) || isSharingChart)) {
      if (!ChartUIConstants.QUERY_OPTIONAL.equals(queryType) || !provider.checkState(IDataServiceProvider.SHARE_TABLE_QUERY) || getQuery().getDefinition() == null || getQuery().getDefinition().trim().length() == 0) {
        txtDefinition.setEnabled(false);
        btnBuilder.setEnabled(false);
      }
    }
    if (btnGroup != null) {
      btnGroup.setEnabled(false);
    }
  }
  if (cmbDefinition != null && ChartUIConstants.QUERY_OPTIONAL.equals(queryType) && (isCubeNoMultiDimensions || !ChartUIUtil.isGroupingSupported(context))) {
    cmbDefinition.setEnabled(false);
    btnBuilder.setEnabled(false);
  }
  setTooltipForInputControl();
  boolean isRequiredField=(ChartUIConstants.QUERY_CATEGORY.equals(queryType));
  if (lblDesc != null && isRequiredField) {
    FieldAssistHelper.getInstance().addRequiredFieldIndicator(lblDesc);
  }
  return cmpTop;
}