Bug 160351

Summary: [Text] Setting the layout manager on a text flow after adding to parent leads to a NullPointerException
Product: [Tools] GEF Reporter: Eric Wasserman <ewasserman>
Component: GEF-Legacy Draw2dAssignee: gef-inbox <gef-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 3.2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Eric Wasserman CLA 2006-10-10 12:58:42 EDT
When a layout manager is set on a text flow it must be done before adding the text flow to its parent otherwise a NullPointerException may result.

Example Application:

public class OrderBug extends org.eclipse.draw2d.examples.AbstractExample {

  public static void main(String[] args) {
    new OrderBug().run();
  }

  protected void sizeShell() {
    shell.setSize(shell.computeSize(400, 200));
  }
  
  protected IFigure getContents() {
    Figure f = new Figure();
    f.setLayoutManager(new ToolbarLayout());
    f.add(orderBug());
    return f;
  }

  protected IFigure orderBug() {
    final boolean die = true;
    FlowPage fp = new FlowPage();
    TextFlow tf = new TextFlow();
    if (die) {
      fp.add(tf);
      tf.setLayoutManager(new ParagraphTextLayout(tf));
    } else {
      tf.setLayoutManager(new ParagraphTextLayout(tf));      
      fp.add(tf);
    }
    tf.setText("hello");
    return fp;
  }
  
}