Program: 75827
Project: 75827
Buggy source:
Composite createCustomControl(Composite parent){
  ScrolledComposite scrollContent=new ScrolledComposite(parent,SWT.H_SCROLL | SWT.V_SCROLL);
  scrollContent.setAlwaysShowScrollBars(false);
  scrollContent.setExpandHorizontal(true);
  scrollContent.setLayout(new FillLayout());
  Composite content=new Composite(scrollContent,SWT.NONE);
  GridLayout layout=new GridLayout();
  layout.numColumns=4;
  layout.verticalSpacing=10;
  layout.marginBottom=300;
  content.setLayout(layout);
  GridData gridData;
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  driverChooserCombo=new ComboViewer(content,SWT.DROP_DOWN);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  driverChooserCombo.getControl().setLayoutData(gridData);
  List driverListTmp1=JdbcToolKit.getJdbcDriversFromODADir(JDBC_EXTENSION_ID);
  JDBCDriverInformation[] driverListTmp2=JDBCDriverInfoManager.getDrivers();
  List driverList=new ArrayList();
  for (  Object driverInfo : driverListTmp1) {
    if (needCheckHide(driverListTmp2,(JDBCDriverInformation)driverInfo)) {
      if (!((JDBCDriverInformation)driverInfo).getHide()) {
        driverList.add(driverInfo);
      }
    }
 else {
      driverList.add(driverInfo);
    }
  }
  driverChooserCombo.setContentProvider(new IStructuredContentProvider(){
    public Object[] getElements(    Object inputElement){
      if (inputElement != null) {
        return ((ArrayList)inputElement).toArray();
      }
      return new JDBCDriverInformation[]{};
    }
    public void dispose(){
    }
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
  }
);
  driverChooserCombo.setLabelProvider(new LabelProvider(){
    public String getText(    Object inputElement){
      JDBCDriverInformation info=(JDBCDriverInformation)inputElement;
      return info.getDisplayString();
    }
  }
);
  driverChooserCombo.setInput(sortDriverList(driverList));
  driverChooserCombo.addSelectionChangedListener(new ISelectionChangedListener(){
    private String driverClassName;
    public void selectionChanged(    SelectionChangedEvent event){
      StructuredSelection selection=(StructuredSelection)event.getSelection();
      final JDBCDriverInformation info=(JDBCDriverInformation)selection.getFirstElement();
      String className=(info != null) ? info.getDriverClassName() : EMPTY_STRING;
      if (className.equalsIgnoreCase(driverClassName) == true)       return;
      driverClassName=className;
      if (info != null) {
        if (info.getUrlFormat() != null) {
          jdbcUrl.setText(info.getUrlFormat());
        }
 else {
          jdbcUrl.setText(EMPTY_STRING);
        }
        ((GridData)porpertyGroupComposite.getLayoutData()).exclude=true;
        porpertyGroupComposite.setVisible(false);
        porpertyGroupComposite.getParent().layout();
        Control[] children=porpertyGroupComposite.getChildren();
        for (int i=0; i < children.length; i++) {
          children[i].dispose();
        }
        if (info.hasProperty()) {
          drawPropertyGroups(info);
        }
        porpertyGroupComposite.getParent().layout();
      }
      jndiName.setText(EMPTY_STRING);
      userName.setText(EMPTY_STRING);
      password.setText(EMPTY_STRING);
      updateTestButton();
    }
    private void drawPropertyGroups(    final JDBCDriverInformation info){
      ((GridData)porpertyGroupComposite.getLayoutData()).exclude=false;
      porpertyGroupComposite.setVisible(true);
      ((GridData)porpertyGroupComposite.getLayoutData()).heightHint=SWT.DEFAULT;
      databaseProperties.clear();
      List<PropertyGroup> propertyGroups=info.getPropertyGroup();
      for (Iterator it=propertyGroups.iterator(); it.hasNext(); ) {
        PropertyGroup group=(PropertyGroup)(it.next());
        String propertyGroupName=group.getName();
        List<PropertyElement> propertyList=group.getProperties();
        Group propertyGroup=drawPropertyGroup(propertyGroupName == null ? EMPTY_STRING : propertyGroupName);
        for (int i=0; i < propertyList.size(); i++) {
          final String propertyName=propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_NAME);
          Label propertyParam=new Label(propertyGroup,SWT.NONE);
          String propertyParamDisplayName=propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_DISPLAYNAME);
          if (propertyParamDisplayName == null) {
            propertyParamDisplayName=propertyName;
          }
          propertyParam.setText(propertyParamDisplayName);
          propertyParam.setToolTipText(propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_DEC));
          GridData gd=new GridData();
          gd.horizontalSpan=2;
          propertyParam.setLayoutData(gd);
          String propertyContent=null;
          if (profileProperties != null && !profileProperties.isEmpty()) {
            propertyContent=getProfileproperty(propertyName);
          }
          if (Constants.DRIVER_INFO_PROPERTY_TYPE_BOOLEN.equalsIgnoreCase(propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_TYPE))) {
            drawPropertyCombo(propertyGroup,propertyName,propertyContent);
          }
 else {
            if (Boolean.valueOf(propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_ENCRYPT))) {
              drawPropertyText(propertyGroup,propertyName,propertyContent,true);
            }
 else             drawPropertyText(propertyGroup,propertyName,propertyContent,false);
          }
        }
        propertyGroup.getParent().layout();
      }
    }
    private void drawPropertyText(    Group propertyGroup,    final String propertyName,    String propertyContent,    boolean encrypt){
      GridData gd;
      final Text propertyText;
      if (encrypt) {
        propertyText=new Text(propertyGroup,SWT.BORDER | SWT.PASSWORD);
      }
 else {
        propertyText=new Text(propertyGroup,SWT.BORDER);
      }
      if (propertyContent != null) {
        propertyText.setText(propertyContent);
        databaseProperties.put(propertyName,propertyContent);
      }
      propertyText.addModifyListener(new ModifyListener(){
        public void modifyText(        ModifyEvent e){
          databaseProperties.put(propertyName,propertyText.getText());
        }
      }
);
      gd=new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan=3;
      gd.horizontalAlignment=SWT.FILL;
      propertyText.setLayoutData(gd);
      propertyText.getParent().layout();
    }
    private void drawPropertyCombo(    Group propertyGroup,    final String propertyName,    String propertyContent){
      GridData gd;
      final Combo propertyField=new Combo(propertyGroup,SWT.BORDER | SWT.READ_ONLY);
      propertyField.setItems(new String[]{EMPTY_STRING,"String_Node_Str","String_Node_Str"});
      if (propertyContent != null) {
        propertyField.setText(propertyContent);
        databaseProperties.put(propertyName,propertyContent);
      }
 else       propertyField.setText(EMPTY_STRING);
      propertyField.addSelectionListener(new SelectionListener(){
        @Override public void widgetSelected(        SelectionEvent arg0){
          if (propertyField.getSelectionIndex() == 1) {
            databaseProperties.put(propertyName,"String_Node_Str");
          }
 else           if (propertyField.getSelectionIndex() == 2) {
            databaseProperties.put(propertyName,"String_Node_Str");
          }
 else {
            databaseProperties.put(propertyName,EMPTY_STRING);
          }
        }
        @Override public void widgetDefaultSelected(        SelectionEvent arg0){
          databaseProperties.put(propertyName,EMPTY_STRING);
        }
      }
);
      gd=new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan=3;
      gd.horizontalAlignment=SWT.FILL;
      propertyField.setLayoutData(gd);
      propertyField.getParent().layout();
    }
    private Group drawPropertyGroup(    String propertyGroupName){
      GridData gridData;
      Group propertyGroup=new Group(porpertyGroupComposite,SWT.NONE);
      gridData=new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
      gridData.horizontalSpan=4;
      gridData.horizontalAlignment=SWT.FILL;
      propertyGroup.setText(propertyGroupName);
      propertyGroup.setLayoutData(gridData);
      GridLayout layout=new GridLayout();
      layout.marginWidth=layout.marginHeight=0;
      layout.numColumns=5;
      Layout parentLayout=porpertyGroupComposite.getParent().getLayout();
      if (parentLayout instanceof GridLayout)       layout.horizontalSpacing=((GridLayout)parentLayout).horizontalSpacing;
      propertyGroup.setLayout(layout);
      return propertyGroup;
    }
    private String getProfileproperty(    String propertyName){
      return profileProperties.getProperty(propertyName);
    }
  }
);
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  jdbcUrl=new Text(content,SWT.BORDER);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  gridData.grabExcessHorizontalSpace=true;
  jdbcUrl.setLayoutData(gridData);
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  userName=new Text(content,SWT.BORDER);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  userName.setLayoutData(gridData);
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  password=new Text(content,SWT.BORDER | SWT.PASSWORD);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  password.setLayoutData(gridData);
  String jndiLabel=JdbcPlugin.getResourceString("String_Node_Str");
  new Label(content,SWT.RIGHT).setText(jndiLabel);
  jndiName=new Text(content,SWT.BORDER);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  jndiName.setLayoutData(gridData);
  createPropertiesComposite(content);
  manageButton=new Button(content,SWT.PUSH);
  manageButton.setText(JdbcPlugin.getResourceString("String_Node_Str"));
  testButton=new Button(content,SWT.PUSH);
  testButton.setText(JdbcPlugin.getResourceString("String_Node_Str"));
  testButton.setLayoutData(new GridData(GridData.CENTER));
  Point size=content.computeSize(SWT.DEFAULT,SWT.DEFAULT);
  content.setSize(size.x,size.y);
  scrollContent.setMinWidth(size.x + 10);
  scrollContent.setContent(content);
  addControlListeners();
  updateTestButton();
  verifyJDBCProperties();
  Utility.setSystemHelp(getControl(),IHelpConstants.CONEXT_ID_DATASOURCE_JDBC);
  return content;
}

Fixed version (ground truth):
Composite createCustomControl(Composite parent){
  ScrolledComposite scrollContent=new ScrolledComposite(parent,SWT.H_SCROLL | SWT.V_SCROLL);
  scrollContent.setAlwaysShowScrollBars(false);
  scrollContent.setExpandHorizontal(true);
  scrollContent.setLayout(new FillLayout());
  Composite content=new Composite(scrollContent,SWT.NONE);
  GridLayout layout=new GridLayout();
  layout.numColumns=4;
  layout.verticalSpacing=10;
  layout.marginBottom=300;
  content.setLayout(layout);
  GridData gridData;
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  driverChooserCombo=new ComboViewer(content,SWT.DROP_DOWN);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  driverChooserCombo.getControl().setLayoutData(gridData);
  List driverListTmp1=JdbcToolKit.getJdbcDriversFromODADir(JDBC_EXTENSION_ID);
  JDBCDriverInformation[] driverListTmp2=JDBCDriverInfoManager.getDrivers();
  List driverList=new ArrayList();
  for (  Object driverInfo : driverListTmp1) {
    if (needCheckHide(driverListTmp2,(JDBCDriverInformation)driverInfo)) {
      if (!((JDBCDriverInformation)driverInfo).getHide()) {
        driverList.add(driverInfo);
      }
    }
 else {
      driverList.add(driverInfo);
    }
  }
  driverChooserCombo.setContentProvider(new IStructuredContentProvider(){
    public Object[] getElements(    Object inputElement){
      if (inputElement != null) {
        return ((ArrayList)inputElement).toArray();
      }
      return new JDBCDriverInformation[]{};
    }
    public void dispose(){
    }
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
  }
);
  driverChooserCombo.setLabelProvider(new LabelProvider(){
    public String getText(    Object inputElement){
      JDBCDriverInformation info=(JDBCDriverInformation)inputElement;
      return info.getDisplayString();
    }
  }
);
  driverChooserCombo.setInput(sortDriverList(driverList));
  driverChooserCombo.addSelectionChangedListener(new ISelectionChangedListener(){
    private String driverClassName;
    public void selectionChanged(    SelectionChangedEvent event){
      StructuredSelection selection=(StructuredSelection)event.getSelection();
      final JDBCDriverInformation info=(JDBCDriverInformation)selection.getFirstElement();
      String className=(info != null) ? info.getDriverClassName() : EMPTY_STRING;
      if (className.equalsIgnoreCase(driverClassName) == true)       return;
      driverClassName=className;
      if (info != null) {
        if (info.getUrlFormat() != null) {
          jdbcUrl.setText(info.getUrlFormat());
        }
 else {
          jdbcUrl.setText(EMPTY_STRING);
        }
        ((GridData)porpertyGroupComposite.getLayoutData()).exclude=true;
        porpertyGroupComposite.setVisible(false);
        porpertyGroupComposite.getParent().layout();
        Control[] children=porpertyGroupComposite.getChildren();
        for (int i=0; i < children.length; i++) {
          children[i].dispose();
        }
        if (info.hasProperty()) {
          drawPropertyGroups(info);
        }
        porpertyGroupComposite.getParent().layout();
      }
      jndiName.setText(EMPTY_STRING);
      userName.setText(EMPTY_STRING);
      password.setText(EMPTY_STRING);
      updateTestButton();
    }
    private void drawPropertyGroups(    final JDBCDriverInformation info){
      ((GridData)porpertyGroupComposite.getLayoutData()).exclude=false;
      porpertyGroupComposite.setVisible(true);
      ((GridData)porpertyGroupComposite.getLayoutData()).heightHint=SWT.DEFAULT;
      databaseProperties.clear();
      List<PropertyGroup> propertyGroups=info.getPropertyGroup();
      for (Iterator it=propertyGroups.iterator(); it.hasNext(); ) {
        PropertyGroup group=(PropertyGroup)(it.next());
        String propertyGroupName=group.getName();
        List<PropertyElement> propertyList=group.getProperties();
        Group propertyGroup=drawPropertyGroup(propertyGroupName == null ? EMPTY_STRING : propertyGroupName);
        for (int i=0; i < propertyList.size(); i++) {
          final String propertyName=propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_NAME);
          Label propertyParam=new Label(propertyGroup,SWT.NONE);
          String propertyParamDisplayName=propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_DISPLAYNAME);
          if (propertyParamDisplayName == null) {
            propertyParamDisplayName=propertyName;
          }
          propertyParam.setText(propertyParamDisplayName);
          propertyParam.setToolTipText(propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_DEC));
          GridData gd=new GridData();
          gd.horizontalSpan=2;
          propertyParam.setLayoutData(gd);
          String propertyContent=null;
          if (profileProperties != null && !profileProperties.isEmpty()) {
            propertyContent=getProfileproperty(propertyName);
          }
          if (Constants.DRIVER_INFO_PROPERTY_TYPE_BOOLEN.equalsIgnoreCase(propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_TYPE))) {
            drawPropertyCombo(propertyGroup,propertyName,propertyContent);
          }
 else {
            if (Boolean.valueOf(propertyList.get(i).getAttribute(Constants.DRIVER_INFO_PROPERTY_ENCRYPT))) {
              drawPropertyText(propertyGroup,propertyName,propertyContent,true);
            }
 else             drawPropertyText(propertyGroup,propertyName,propertyContent,false);
          }
        }
        propertyGroup.getParent().layout();
      }
    }
    private void drawPropertyText(    Group propertyGroup,    final String propertyName,    String propertyContent,    boolean encrypt){
      GridData gd;
      final Text propertyText;
      if (encrypt) {
        propertyText=new Text(propertyGroup,SWT.BORDER | SWT.PASSWORD);
      }
 else {
        propertyText=new Text(propertyGroup,SWT.BORDER);
      }
      if (propertyContent != null) {
        propertyText.setText(propertyContent);
        databaseProperties.put(propertyName,propertyContent);
      }
      propertyText.addModifyListener(new ModifyListener(){
        public void modifyText(        ModifyEvent e){
          databaseProperties.put(propertyName,propertyText.getText());
        }
      }
);
      gd=new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan=3;
      gd.horizontalAlignment=SWT.FILL;
      propertyText.setLayoutData(gd);
      propertyText.getParent().layout();
    }
    private void drawPropertyCombo(    Group propertyGroup,    final String propertyName,    String propertyContent){
      GridData gd;
      final Combo propertyField=new Combo(propertyGroup,SWT.BORDER | SWT.READ_ONLY);
      propertyField.setItems(new String[]{EMPTY_STRING,"String_Node_Str","String_Node_Str"});
      if (propertyContent != null) {
        propertyField.setText(propertyContent);
        databaseProperties.put(propertyName,propertyContent);
      }
 else       propertyField.setText(EMPTY_STRING);
      propertyField.addSelectionListener(new SelectionListener(){
        public void widgetSelected(        SelectionEvent arg0){
          if (propertyField.getSelectionIndex() == 1) {
            databaseProperties.put(propertyName,"String_Node_Str");
          }
 else           if (propertyField.getSelectionIndex() == 2) {
            databaseProperties.put(propertyName,"String_Node_Str");
          }
 else {
            databaseProperties.put(propertyName,EMPTY_STRING);
          }
        }
        public void widgetDefaultSelected(        SelectionEvent arg0){
          databaseProperties.put(propertyName,EMPTY_STRING);
        }
      }
);
      gd=new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan=3;
      gd.horizontalAlignment=SWT.FILL;
      propertyField.setLayoutData(gd);
      propertyField.getParent().layout();
    }
    private Group drawPropertyGroup(    String propertyGroupName){
      GridData gridData;
      Group propertyGroup=new Group(porpertyGroupComposite,SWT.NONE);
      gridData=new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
      gridData.horizontalSpan=4;
      gridData.horizontalAlignment=SWT.FILL;
      propertyGroup.setText(propertyGroupName);
      propertyGroup.setLayoutData(gridData);
      GridLayout layout=new GridLayout();
      layout.marginWidth=layout.marginHeight=0;
      layout.numColumns=5;
      Layout parentLayout=porpertyGroupComposite.getParent().getLayout();
      if (parentLayout instanceof GridLayout)       layout.horizontalSpacing=((GridLayout)parentLayout).horizontalSpacing;
      propertyGroup.setLayout(layout);
      return propertyGroup;
    }
    private String getProfileproperty(    String propertyName){
      return profileProperties.getProperty(propertyName);
    }
  }
);
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  jdbcUrl=new Text(content,SWT.BORDER);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  gridData.grabExcessHorizontalSpace=true;
  jdbcUrl.setLayoutData(gridData);
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  userName=new Text(content,SWT.BORDER);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  userName.setLayoutData(gridData);
  new Label(content,SWT.RIGHT).setText(JdbcPlugin.getResourceString("String_Node_Str"));
  password=new Text(content,SWT.BORDER | SWT.PASSWORD);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  password.setLayoutData(gridData);
  String jndiLabel=JdbcPlugin.getResourceString("String_Node_Str");
  new Label(content,SWT.RIGHT).setText(jndiLabel);
  jndiName=new Text(content,SWT.BORDER);
  gridData=new GridData();
  gridData.horizontalSpan=3;
  gridData.horizontalAlignment=SWT.FILL;
  jndiName.setLayoutData(gridData);
  createPropertiesComposite(content);
  manageButton=new Button(content,SWT.PUSH);
  manageButton.setText(JdbcPlugin.getResourceString("String_Node_Str"));
  testButton=new Button(content,SWT.PUSH);
  testButton.setText(JdbcPlugin.getResourceString("String_Node_Str"));
  testButton.setLayoutData(new GridData(GridData.CENTER));
  Point size=content.computeSize(SWT.DEFAULT,SWT.DEFAULT);
  content.setSize(size.x,size.y);
  scrollContent.setMinWidth(size.x + 10);
  scrollContent.setContent(content);
  addControlListeners();
  updateTestButton();
  verifyJDBCProperties();
  Utility.setSystemHelp(getControl(),IHelpConstants.CONEXT_ID_DATASOURCE_JDBC);
  return content;
}