Bug 160351 - [Text] Setting the layout manager on a text flow after adding to parent leads to a NullPointerException
Summary: [Text] Setting the layout manager on a text flow after adding to parent leads...
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.2.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-10 12:58 EDT by Eric Wasserman CLA
Modified: 2010-11-04 17:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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;
  }
  
}