Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [Solved] Not initialized class when content not visible.
[Solved] Not initialized class when content not visible. [message #906819] Sun, 02 September 2012 17:15 Go to next message
Hel Ral is currently offline Hel RalFriend
Messages: 2
Registered: September 2012
Junior Member
I've got a setup coded out which correctly created 2 window parts:
part 1 contains a treelist of items you can pick from,

part 2 contains several tabs with information.

When I click on something from the tree in part 1 I get a nullpointer exception.
When I click on something after opening all the pages from part 2, it works as expected.

The classes that I use for filling in the content of the tabs are singletons, which know for which window they are created. When you select something in part 1, I send a refresh call to the other 2 windows which tells them to recreate themselves with information about the newly selected element.

But since at least 1 page in part 2 hasn't been opened yet, it cannot create the controls that that page has because the container value hasn't been injected yet...

All pages from part 2 contain the following structure:
@Singleton
public class Page {
  public static Page instance;
  private Composite parent;

  public Page() {
    instance = this;
  }

  private void clear(){
    panel.dispose();
    createPanel();
  }

  @Inject
  public void init(Composite parent) {
    this.parent = parent;
    createPanel();
  }

  private void createPanel() {
    panel = new Composite(parent, SWT.NONE);
    // column creation code
  }

  private void register(RowProvider row){
    // row information code
  }

  public void update(InfoObject infoObject){
    clear();
    // register the RowProviders used on this page
  }


when something in part 1 is selected, the update method is called with the selected infoObject.

is there a way to always create the normally hidden tabs so that they do have their content containers at startup, and that they do call the inject method init?

[Updated on: Mon, 03 September 2012 16:37]

Report message to a moderator

Re: Not initialized class when content not visible. [message #907016 is a reply to message #906819] Mon, 03 September 2012 06:41 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
You should not create content which might never become visible. Therefore I would say that this is a design issue. You have a master detail type pattern in which the master must know something about the detail (namely the fact that the detail must have been created). You should think about designing it the other way around (child knows about master). Add a listenerList to part1 and let part2 register to that list upon creation. Then if selection changes in part1 only refresh registered listeners. When you create part2 it should request the current selection from master part1 so that it reflects the current selection.

Regards,
Thorsten
Re:[Solved] Not initialized class when content not visible. [message #907275 is a reply to message #907016] Mon, 03 September 2012 16:35 Go to previous message
Hel Ral is currently offline Hel RalFriend
Messages: 2
Registered: September 2012
Junior Member
Thanks for the info about the listener stuff. I've fixed it after reading your reply by using a Part1Observer Interface, which implements a notifySelectionChanged method and a register(Part1Observer observer) method on part1 itself, which is called when the classes finally get initialized.... even though you will almost always (99% of the time) check both tabs when you use the application.....
Previous Topic:Run ant files from RCP app
Next Topic:RCP product export customized ANT script
Goto Forum:
  


Current Time: Mon Oct 14 09:36:43 GMT 2024

Powered by FUDForum. Page generated in 0.06061 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top