Program: 72210
Project: 72210
Buggy source:
/** 
 * Creates the SWT control for this page under the given parent control. <p> Clients should not call this method (the workbench calls this method when it needs to, which may be never). </p>
 * @param parent the parent control
 */
public void createControl(Composite parent){
  super.createControl(parent);
  createContextMenu();
  ViewsTreeProvider provider=new ViewsTreeProvider();
  getTreeViewer().setContentProvider(provider);
  getTreeViewer().setLabelProvider(provider);
  getSelectionSynchronizer().setTreeViewer(getTreeViewer());
  new RenameListener(getTreeViewer()).apply();
  getTreeViewer().setSorter(new ItemSorter());
  addDragAndDropListener();
  init(reportHandle);
  getTreeViewer().expandToLevel(2);
  final Tree tree=getTreeViewer().getTree();
  tree.addListener(SWT.PaintItem,new Listener(){
    public void handleEvent(    Event event){
      TreeItem item=(TreeItem)event.item;
      if (event.item.getData() instanceof CssStyleSheetHandle || event.item.getData() instanceof CssSharedStyleHandle) {
        Color gray=Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
        if (!item.getForeground().equals(gray)) {
          item.setForeground(gray);
        }
      }
 else {
        Color black=Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
        if (!item.getForeground().equals(black)) {
          item.setForeground(black);
        }
      }
    }
  }
);
  tree.addMouseListener(new MouseAdapter(){
    public void mouseDown(    MouseEvent e){
      if ((e.stateMask & SWT.CTRL) != 0 || (e.stateMask & SWT.SHIFT) != 0) {
        setSingleSelection(e);
      }
    }
    private void setSingleSelection(    MouseEvent e){
      IStructuredSelection selection=(IStructuredSelection)getSelection();
      if (!selection.isEmpty() && selection.size() > 1) {
        boolean includeCell=false;
        for (Iterator iterator=selection.iterator(); iterator.hasNext(); ) {
          Object obj=iterator.next();
          if (obj instanceof CellHandle) {
            if (includeCell) {
              TreeItem item=getTreeViewer().getTree().getItem(new Point(e.x,e.y));
              if (item != null)               getTreeViewer().getTree().setSelection(new TreeItem[]{item});
              break;
            }
            includeCell=true;
          }
        }
      }
    }
  }
);
  tree.addSelectionListener(new SelectionListener(){
    public void widgetSelected(    SelectionEvent e){
    }
    public void widgetDefaultSelected(    SelectionEvent e){
      if (getSelection() instanceof StructuredSelection) {
        List list=new ArrayList();
        Object selectedObject=((StructuredSelection)getSelection()).getFirstElement();
        list.add(selectedObject);
        ReportRequest r=new ReportRequest();
        r.setType(ReportRequest.OPEN_EDITOR);
        r.setRequestConvert(new IRequestConvert(){
          public List convertSelectionToModelLisr(          List list){
            List lst=new ArrayList();
            for (Iterator itr=list.iterator(); itr.hasNext(); ) {
              Object obj=itr.next();
              lst.add(obj);
            }
            return lst;
          }
        }
);
        r.setSelectionObject(list);
        SessionHandleAdapter.getInstance().getMediator().notifyRequest(r);
        try {
          Tree tree=(Tree)e.getSource();
          TreeItem[] selectedItems=tree.getSelection();
          if (selectedItems.length > 0) {
            if (selectedItems[0].getExpanded()) {
              selectedItems[0].setExpanded(false);
            }
 else {
              getTreeViewer().expandToLevel(selectedObject,selectedItems[0].getExpanded() ? 0 : 1);
            }
          }
        }
 catch (        Exception e2) {
        }
      }
    }
  }
);
  tree.addMouseTrackListener(new MouseTrackAdapter(){
    public void mouseHover(    MouseEvent event){
      Widget widget=event.widget;
      if (widget == tree) {
        Point pt=new Point(event.x,event.y);
        TreeItem item=tree.getItem(pt);
        if (item == null || item.getData() == null) {
          tree.setToolTipText(null);
        }
 else {
          tree.setToolTipText(getTooltip(item.getData()));
        }
      }
    }
  }
);
  SessionHandleAdapter.getInstance().getMediator(reportHandle).addColleague(getSelectionSynchronizer());
  if (backup != null) {
    backup.restoreBackup(getTreeViewer());
    getTreeViewer().getTree().addTreeListener(new TreeListener(){
      public void treeCollapsed(      TreeEvent e){
        Item item=(Item)e.item;
        backup.updateCollapsedStatus(getTreeViewer(),item.getData());
      }
      public void treeExpanded(      TreeEvent e){
        Item item=(Item)e.item;
        backup.updateExpandedStatus(getTreeViewer(),item.getData());
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * Creates the SWT control for this page under the given parent control. <p> Clients should not call this method (the workbench calls this method when it needs to, which may be never). </p>
 * @param parent the parent control
 */
public void createControl(Composite parent){
  super.createControl(parent);
  createContextMenu();
  ViewsTreeProvider provider=new ViewsTreeProvider();
  getTreeViewer().setContentProvider(provider);
  getTreeViewer().setLabelProvider(provider);
  getSelectionSynchronizer().setTreeViewer(getTreeViewer());
  new RenameListener(getTreeViewer()).apply();
  getTreeViewer().setSorter(new ItemSorter());
  addDragAndDropListener();
  init(reportHandle);
  getTreeViewer().expandToLevel(2);
  final Tree tree=getTreeViewer().getTree();
  tree.addListener(SWT.PaintItem,new Listener(){
    public void handleEvent(    Event event){
      TreeItem item=(TreeItem)event.item;
      if (event.item.getData() instanceof CssStyleSheetHandle || event.item.getData() instanceof CssSharedStyleHandle) {
        Color gray=Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
        if (!item.getForeground().equals(gray)) {
          item.setForeground(gray);
        }
      }
 else {
        Color black=ReportColorConstants.ReportForeground;
        if (!item.getForeground().equals(black)) {
          item.setForeground(black);
        }
      }
    }
  }
);
  tree.addMouseListener(new MouseAdapter(){
    public void mouseDown(    MouseEvent e){
      if ((e.stateMask & SWT.CTRL) != 0 || (e.stateMask & SWT.SHIFT) != 0) {
        setSingleSelection(e);
      }
    }
    private void setSingleSelection(    MouseEvent e){
      IStructuredSelection selection=(IStructuredSelection)getSelection();
      if (!selection.isEmpty() && selection.size() > 1) {
        boolean includeCell=false;
        for (Iterator iterator=selection.iterator(); iterator.hasNext(); ) {
          Object obj=iterator.next();
          if (obj instanceof CellHandle) {
            if (includeCell) {
              TreeItem item=getTreeViewer().getTree().getItem(new Point(e.x,e.y));
              if (item != null)               getTreeViewer().getTree().setSelection(new TreeItem[]{item});
              break;
            }
            includeCell=true;
          }
        }
      }
    }
  }
);
  tree.addSelectionListener(new SelectionListener(){
    public void widgetSelected(    SelectionEvent e){
    }
    public void widgetDefaultSelected(    SelectionEvent e){
      if (getSelection() instanceof StructuredSelection) {
        List list=new ArrayList();
        Object selectedObject=((StructuredSelection)getSelection()).getFirstElement();
        list.add(selectedObject);
        ReportRequest r=new ReportRequest();
        r.setType(ReportRequest.OPEN_EDITOR);
        r.setRequestConvert(new IRequestConvert(){
          public List convertSelectionToModelLisr(          List list){
            List lst=new ArrayList();
            for (Iterator itr=list.iterator(); itr.hasNext(); ) {
              Object obj=itr.next();
              lst.add(obj);
            }
            return lst;
          }
        }
);
        r.setSelectionObject(list);
        SessionHandleAdapter.getInstance().getMediator().notifyRequest(r);
        try {
          Tree tree=(Tree)e.getSource();
          TreeItem[] selectedItems=tree.getSelection();
          if (selectedItems.length > 0) {
            if (selectedItems[0].getExpanded()) {
              selectedItems[0].setExpanded(false);
            }
 else {
              getTreeViewer().expandToLevel(selectedObject,selectedItems[0].getExpanded() ? 0 : 1);
            }
          }
        }
 catch (        Exception e2) {
        }
      }
    }
  }
);
  tree.addMouseTrackListener(new MouseTrackAdapter(){
    public void mouseHover(    MouseEvent event){
      Widget widget=event.widget;
      if (widget == tree) {
        Point pt=new Point(event.x,event.y);
        TreeItem item=tree.getItem(pt);
        if (item == null || item.getData() == null) {
          tree.setToolTipText(null);
        }
 else {
          tree.setToolTipText(getTooltip(item.getData()));
        }
      }
    }
  }
);
  SessionHandleAdapter.getInstance().getMediator(reportHandle).addColleague(getSelectionSynchronizer());
  if (backup != null) {
    backup.restoreBackup(getTreeViewer());
    getTreeViewer().getTree().addTreeListener(new TreeListener(){
      public void treeCollapsed(      TreeEvent e){
        Item item=(Item)e.item;
        backup.updateCollapsedStatus(getTreeViewer(),item.getData());
      }
      public void treeExpanded(      TreeEvent e){
        Item item=(Item)e.item;
        backup.updateExpandedStatus(getTreeViewer(),item.getData());
      }
    }
);
  }
}