Program: 92009
Project: 92009
Buggy source:
/** 
 * Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 * @param parent a widget which will be the parent of the new instance (cannot be null)
 * @param style the style of widget to construct
 * @param weights The relative weights of each side of the sash form
 * @since 2.1
 */
public TimeGraphCombo(Composite parent,int style,int[] weights){
  super(parent,style);
  setLayout(new FillLayout());
  final SashForm sash=new SashForm(this,SWT.NONE);
  fTreeViewer=new TreeViewer(sash,SWT.FULL_SELECTION | SWT.H_SCROLL);
  final Tree tree=fTreeViewer.getTree();
  tree.setHeaderVisible(true);
  tree.setLinesVisible(true);
  fTimeGraphViewer=new TimeGraphViewer(sash,SWT.NONE);
  fTimeGraphViewer.setItemHeight(getItemHeight(tree));
  fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());
  fTimeGraphViewer.setBorderWidth(tree.getBorderWidth());
  fTimeGraphViewer.setNameWidthPref(0);
  fFilter=new RawViewerFilter();
  addFilter(fFilter);
  fFilterDialog=new TimeGraphFilterDialog(getShell());
  tree.addControlListener(new ControlAdapter(){
    private int depth=0;
    @Override public void controlResized(    ControlEvent e){
      if (depth == 0) {
        depth++;
        tree.getVerticalBar().setEnabled(false);
        tree.getVerticalBar().setVisible(false);
        depth--;
      }
      fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());
    }
  }
);
  fTreeViewer.addTreeListener(new ITreeViewerListener(){
    @Override public void treeCollapsed(    TreeExpansionEvent event){
      fTimeGraphViewer.setExpandedState((ITimeGraphEntry)event.getElement(),false);
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        return;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
    }
    @Override public void treeExpanded(    TreeExpansionEvent event){
      ITimeGraphEntry entry=(ITimeGraphEntry)event.getElement();
      fTimeGraphViewer.setExpandedState(entry,true);
      for (      ITimeGraphEntry child : entry.getChildren()) {
        boolean expanded=fTreeViewer.getExpandedState(child);
        fTimeGraphViewer.setExpandedState(child,expanded);
      }
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        return;
      }
      final TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      getDisplay().asyncExec(new Runnable(){
        @Override public void run(){
          tree.setTopItem(treeItem);
        }
      }
);
    }
  }
);
  fTimeGraphViewer.addTreeListener(new ITimeGraphTreeListener(){
    @Override public void treeCollapsed(    TimeGraphTreeExpansionEvent event){
      fTreeViewer.setExpandedState(event.getEntry(),false);
    }
    @Override public void treeExpanded(    TimeGraphTreeExpansionEvent event){
      ITimeGraphEntry entry=event.getEntry();
      fTreeViewer.setExpandedState(entry,true);
      for (      ITimeGraphEntry child : entry.getChildren()) {
        boolean expanded=fTreeViewer.getExpandedState(child);
        fTimeGraphViewer.setExpandedState(child,expanded);
      }
    }
  }
);
  tree.addListener(SWT.MouseDown,new Listener(){
    @Override public void handleEvent(    Event event){
      TreeItem treeItem=tree.getItem(new Point(event.x,event.y));
      if (treeItem == null || treeItem.getData() == FILLER) {
        event.doit=false;
        List<TreeItem> treeItems=getVisibleExpandedItems(tree);
        if (treeItems.size() == 0) {
          fTreeViewer.setSelection(new StructuredSelection());
          fTimeGraphViewer.setSelection(null);
          return;
        }
        tree.select(treeItems.get(treeItems.size() - 1));
        fTreeViewer.setSelection(new StructuredSelection());
        fTimeGraphViewer.setSelection(null);
      }
    }
  }
);
  tree.addListener(SWT.MouseWheel,new Listener(){
    @Override public void handleEvent(    Event event){
      event.doit=false;
      Slider scrollBar=fTimeGraphViewer.getVerticalBar();
      fTimeGraphViewer.setTopIndex(scrollBar.getSelection() - event.count);
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        return;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
    }
  }
);
  tree.addListener(SWT.KeyDown,new Listener(){
    @Override public void handleEvent(    Event event){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        fTreeViewer.setSelection(new StructuredSelection());
        event.doit=false;
        return;
      }
      if (event.keyCode == SWT.ARROW_DOWN) {
        int index=Math.min(fTimeGraphViewer.getSelectionIndex() + 1,treeItems.size() - 1);
        fTimeGraphViewer.setSelection((ITimeGraphEntry)treeItems.get(index).getData());
        event.doit=false;
      }
 else       if (event.keyCode == SWT.PAGE_DOWN) {
        int height=tree.getSize().y - tree.getHeaderHeight() - tree.getHorizontalBar().getSize().y;
        int countPerPage=height / getItemHeight(tree);
        int index=Math.min(fTimeGraphViewer.getSelectionIndex() + countPerPage - 1,treeItems.size() - 1);
        fTimeGraphViewer.setSelection((ITimeGraphEntry)treeItems.get(index).getData());
        event.doit=false;
      }
 else       if (event.keyCode == SWT.END) {
        fTimeGraphViewer.setSelection((ITimeGraphEntry)treeItems.get(treeItems.size() - 1).getData());
        event.doit=false;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
      if (fTimeGraphViewer.getSelectionIndex() >= 0) {
        fTreeViewer.setSelection(new StructuredSelection(fTimeGraphViewer.getSelection()));
      }
 else {
        fTreeViewer.setSelection(new StructuredSelection());
      }
    }
  }
);
  fTimeGraphViewer.getTimeGraphControl().addControlListener(new ControlAdapter(){
    @Override public void controlResized(    ControlEvent e){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        return;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
    }
  }
);
  fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      if (fInhibitTreeSelection) {
        return;
      }
      if (event.getSelection() instanceof IStructuredSelection) {
        Object selection=((IStructuredSelection)event.getSelection()).getFirstElement();
        if (selection instanceof ITimeGraphEntry) {
          fTimeGraphViewer.setSelection((ITimeGraphEntry)selection);
        }
        List<TreeItem> treeItems=getVisibleExpandedItems(tree);
        if (treeItems.size() == 0) {
          return;
        }
        TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
        tree.setTopItem(treeItem);
      }
    }
  }
);
  fTimeGraphViewer.addSelectionListener(new ITimeGraphSelectionListener(){
    @Override public void selectionChanged(    TimeGraphSelectionEvent event){
      ITimeGraphEntry entry=fTimeGraphViewer.getSelection();
      fInhibitTreeSelection=true;
      if (entry != null) {
        StructuredSelection selection=new StructuredSelection(entry);
        fTreeViewer.setSelection(selection);
      }
 else {
        fTreeViewer.setSelection(new StructuredSelection());
      }
      fInhibitTreeSelection=false;
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        return;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
    }
  }
);
  fTimeGraphViewer.getVerticalBar().addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        return;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
    }
  }
);
  fTimeGraphViewer.getTimeGraphControl().addMouseWheelListener(new MouseWheelListener(){
    @Override public void mouseScrolled(    MouseEvent e){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        return;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
    }
  }
);
  fTreeViewer.getControl().addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseEnter(    MouseEvent e){
      if (fTimeGraphViewer.getTimeGraphControl().isFocusControl()) {
        fTreeViewer.getControl().setFocus();
      }
    }
  }
);
  fTimeGraphViewer.getTimeGraphControl().addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseEnter(    MouseEvent e){
      if (fTreeViewer.getControl().isFocusControl()) {
        fTimeGraphViewer.getTimeGraphControl().setFocus();
      }
    }
  }
);
  fTimeGraphViewer.getTimeGraphScale().addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseEnter(    MouseEvent e){
      if (fTreeViewer.getControl().isFocusControl()) {
        fTimeGraphViewer.getTimeGraphControl().setFocus();
      }
    }
  }
);
  tree.addPaintListener(new PaintListener(){
    @Override public void paintControl(    PaintEvent e){
      List<TreeItem> items=getVisibleExpandedItems(tree);
      for (int i=0; i < items.size() - 1; i++) {
        TreeItem item=items.get(i);
        Integer itemHeight=items.get(i + 1).getBounds().y - item.getBounds().y;
        if (!itemHeight.equals(item.getData(ITEM_HEIGHT))) {
          ITimeGraphEntry entry=(ITimeGraphEntry)item.getData();
          if (fTimeGraphViewer.getTimeGraphControl().setItemHeight(entry,itemHeight)) {
            item.setData(ITEM_HEIGHT,itemHeight);
          }
        }
      }
    }
  }
);
  fNumFillerRows=Display.getDefault().getBounds().height / getItemHeight(tree);
  sash.setWeights(weights);
}

Fixed version (ground truth):
/** 
 * Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 * @param parent a widget which will be the parent of the new instance (cannot be null)
 * @param style the style of widget to construct
 * @param weights The relative weights of each side of the sash form
 * @since 2.1
 */
public TimeGraphCombo(Composite parent,int style,int[] weights){
  super(parent,style);
  setLayout(new FillLayout());
  final SashForm sash=new SashForm(this,SWT.NONE);
  fTreeViewer=new TreeViewer(sash,SWT.FULL_SELECTION | SWT.H_SCROLL);
  final Tree tree=fTreeViewer.getTree();
  tree.setHeaderVisible(true);
  tree.setLinesVisible(true);
  fTimeGraphViewer=new TimeGraphViewer(sash,SWT.NONE);
  fTimeGraphViewer.setItemHeight(getItemHeight(tree));
  fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());
  fTimeGraphViewer.setBorderWidth(tree.getBorderWidth());
  fTimeGraphViewer.setNameWidthPref(0);
  fFilter=new RawViewerFilter();
  addFilter(fFilter);
  fFilterDialog=new TimeGraphFilterDialog(getShell());
  tree.addControlListener(new ControlAdapter(){
    private int depth=0;
    @Override public void controlResized(    ControlEvent e){
      if (depth == 0) {
        depth++;
        tree.getVerticalBar().setEnabled(false);
        tree.getVerticalBar().setVisible(false);
        depth--;
      }
      fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());
    }
  }
);
  fTreeViewer.addTreeListener(new ITreeViewerListener(){
    @Override public void treeCollapsed(    TreeExpansionEvent event){
      fTimeGraphViewer.setExpandedState((ITimeGraphEntry)event.getElement(),false);
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      int topIndex=fTimeGraphViewer.getTopIndex();
      if (topIndex >= treeItems.size()) {
        return;
      }
      TreeItem treeItem=treeItems.get(topIndex);
      tree.setTopItem(treeItem);
    }
    @Override public void treeExpanded(    TreeExpansionEvent event){
      ITimeGraphEntry entry=(ITimeGraphEntry)event.getElement();
      fTimeGraphViewer.setExpandedState(entry,true);
      for (      ITimeGraphEntry child : entry.getChildren()) {
        boolean expanded=fTreeViewer.getExpandedState(child);
        fTimeGraphViewer.setExpandedState(child,expanded);
      }
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      int topIndex=fTimeGraphViewer.getTopIndex();
      if (topIndex >= treeItems.size()) {
        return;
      }
      final TreeItem treeItem=treeItems.get(topIndex);
      getDisplay().asyncExec(new Runnable(){
        @Override public void run(){
          tree.setTopItem(treeItem);
        }
      }
);
    }
  }
);
  fTimeGraphViewer.addTreeListener(new ITimeGraphTreeListener(){
    @Override public void treeCollapsed(    TimeGraphTreeExpansionEvent event){
      fTreeViewer.setExpandedState(event.getEntry(),false);
    }
    @Override public void treeExpanded(    TimeGraphTreeExpansionEvent event){
      ITimeGraphEntry entry=event.getEntry();
      fTreeViewer.setExpandedState(entry,true);
      for (      ITimeGraphEntry child : entry.getChildren()) {
        boolean expanded=fTreeViewer.getExpandedState(child);
        fTimeGraphViewer.setExpandedState(child,expanded);
      }
    }
  }
);
  tree.addListener(SWT.MouseDown,new Listener(){
    @Override public void handleEvent(    Event event){
      TreeItem treeItem=tree.getItem(new Point(event.x,event.y));
      if (treeItem == null || treeItem.getData() == FILLER) {
        event.doit=false;
        List<TreeItem> treeItems=getVisibleExpandedItems(tree);
        if (treeItems.size() == 0) {
          fTreeViewer.setSelection(new StructuredSelection());
          fTimeGraphViewer.setSelection(null);
          return;
        }
        tree.select(treeItems.get(treeItems.size() - 1));
        fTreeViewer.setSelection(new StructuredSelection());
        fTimeGraphViewer.setSelection(null);
      }
    }
  }
);
  tree.addListener(SWT.MouseWheel,new Listener(){
    @Override public void handleEvent(    Event event){
      event.doit=false;
      Slider scrollBar=fTimeGraphViewer.getVerticalBar();
      fTimeGraphViewer.setTopIndex(scrollBar.getSelection() - event.count);
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      int topIndex=fTimeGraphViewer.getTopIndex();
      if (topIndex >= treeItems.size()) {
        return;
      }
      TreeItem treeItem=treeItems.get(topIndex);
      tree.setTopItem(treeItem);
    }
  }
);
  tree.addListener(SWT.KeyDown,new Listener(){
    @Override public void handleEvent(    Event event){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      if (treeItems.size() == 0) {
        fTreeViewer.setSelection(new StructuredSelection());
        event.doit=false;
        return;
      }
      if (event.keyCode == SWT.ARROW_DOWN) {
        int index=Math.min(fTimeGraphViewer.getSelectionIndex() + 1,treeItems.size() - 1);
        fTimeGraphViewer.setSelection((ITimeGraphEntry)treeItems.get(index).getData());
        event.doit=false;
      }
 else       if (event.keyCode == SWT.PAGE_DOWN) {
        int height=tree.getSize().y - tree.getHeaderHeight() - tree.getHorizontalBar().getSize().y;
        int countPerPage=height / getItemHeight(tree);
        int index=Math.min(fTimeGraphViewer.getSelectionIndex() + countPerPage - 1,treeItems.size() - 1);
        fTimeGraphViewer.setSelection((ITimeGraphEntry)treeItems.get(index).getData());
        event.doit=false;
      }
 else       if (event.keyCode == SWT.END) {
        fTimeGraphViewer.setSelection((ITimeGraphEntry)treeItems.get(treeItems.size() - 1).getData());
        event.doit=false;
      }
      TreeItem treeItem=treeItems.get(fTimeGraphViewer.getTopIndex());
      tree.setTopItem(treeItem);
      if (fTimeGraphViewer.getSelectionIndex() >= 0) {
        fTreeViewer.setSelection(new StructuredSelection(fTimeGraphViewer.getSelection()));
      }
 else {
        fTreeViewer.setSelection(new StructuredSelection());
      }
    }
  }
);
  fTimeGraphViewer.getTimeGraphControl().addControlListener(new ControlAdapter(){
    @Override public void controlResized(    ControlEvent e){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      int topIndex=fTimeGraphViewer.getTopIndex();
      if (topIndex >= treeItems.size()) {
        return;
      }
      TreeItem treeItem=treeItems.get(topIndex);
      tree.setTopItem(treeItem);
    }
  }
);
  fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      if (fInhibitTreeSelection) {
        return;
      }
      if (event.getSelection() instanceof IStructuredSelection) {
        Object selection=((IStructuredSelection)event.getSelection()).getFirstElement();
        if (selection instanceof ITimeGraphEntry) {
          fTimeGraphViewer.setSelection((ITimeGraphEntry)selection);
        }
        List<TreeItem> treeItems=getVisibleExpandedItems(tree);
        int topIndex=fTimeGraphViewer.getTopIndex();
        if (topIndex >= treeItems.size()) {
          return;
        }
        TreeItem treeItem=treeItems.get(topIndex);
        tree.setTopItem(treeItem);
      }
    }
  }
);
  fTimeGraphViewer.addSelectionListener(new ITimeGraphSelectionListener(){
    @Override public void selectionChanged(    TimeGraphSelectionEvent event){
      ITimeGraphEntry entry=fTimeGraphViewer.getSelection();
      fInhibitTreeSelection=true;
      if (entry != null) {
        StructuredSelection selection=new StructuredSelection(entry);
        fTreeViewer.setSelection(selection);
      }
 else {
        fTreeViewer.setSelection(new StructuredSelection());
      }
      fInhibitTreeSelection=false;
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      int topIndex=fTimeGraphViewer.getTopIndex();
      if (topIndex >= treeItems.size()) {
        return;
      }
      TreeItem treeItem=treeItems.get(topIndex);
      tree.setTopItem(treeItem);
    }
  }
);
  fTimeGraphViewer.getVerticalBar().addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      int topIndex=fTimeGraphViewer.getTopIndex();
      if (topIndex >= treeItems.size()) {
        return;
      }
      TreeItem treeItem=treeItems.get(topIndex);
      tree.setTopItem(treeItem);
    }
  }
);
  fTimeGraphViewer.getTimeGraphControl().addMouseWheelListener(new MouseWheelListener(){
    @Override public void mouseScrolled(    MouseEvent e){
      List<TreeItem> treeItems=getVisibleExpandedItems(tree);
      int topIndex=fTimeGraphViewer.getTopIndex();
      if (topIndex >= treeItems.size()) {
        return;
      }
      TreeItem treeItem=treeItems.get(topIndex);
      tree.setTopItem(treeItem);
    }
  }
);
  fTreeViewer.getControl().addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseEnter(    MouseEvent e){
      if (fTimeGraphViewer.getTimeGraphControl().isFocusControl()) {
        fTreeViewer.getControl().setFocus();
      }
    }
  }
);
  fTimeGraphViewer.getTimeGraphControl().addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseEnter(    MouseEvent e){
      if (fTreeViewer.getControl().isFocusControl()) {
        fTimeGraphViewer.getTimeGraphControl().setFocus();
      }
    }
  }
);
  fTimeGraphViewer.getTimeGraphScale().addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseEnter(    MouseEvent e){
      if (fTreeViewer.getControl().isFocusControl()) {
        fTimeGraphViewer.getTimeGraphControl().setFocus();
      }
    }
  }
);
  tree.addPaintListener(new PaintListener(){
    @Override public void paintControl(    PaintEvent e){
      List<TreeItem> items=getVisibleExpandedItems(tree);
      for (int i=0; i < items.size() - 1; i++) {
        TreeItem item=items.get(i);
        Integer itemHeight=items.get(i + 1).getBounds().y - item.getBounds().y;
        if (!itemHeight.equals(item.getData(ITEM_HEIGHT))) {
          ITimeGraphEntry entry=(ITimeGraphEntry)item.getData();
          if (fTimeGraphViewer.getTimeGraphControl().setItemHeight(entry,itemHeight)) {
            item.setData(ITEM_HEIGHT,itemHeight);
          }
        }
      }
    }
  }
);
  fNumFillerRows=Display.getDefault().getBounds().height / getItemHeight(tree);
  sash.setWeights(weights);
}