Morpheus
Morpheus

Reputation: 113

Using SWT ScrolledComposite with Eclipse JFace WizardPage

I would like to add scrolledComposite to wizard page in Eclipse plug-in. Everything works fine on the FirstPage where I implemented scrolledComposite. The problem is, the SecondPage which is to display after that, is blank.

Initialization code for FirstPage:

    public void createControl(Composite parent) {

        ScrolledComposite scroll = new ScrolledComposite(parent,  SWT.NULL | SWT.V_SCROLL); 
        scroll.setLayoutData(new GridData(GridData.FILL_VERTICAL)); 

        scroll.setAlwaysShowScrollBars(false);   
        scroll.setExpandVertical(true); 
        scroll.setExpandHorizontal(true); 

        scroll.setMinHeight(500);  
        scroll.setLayout(new GridLayout(1, false)); 

        Composite container = new Composite(scroll, SWT.NULL);      
        GridLayout layout = new GridLayout();
        container.setLayout(layout); 
        scroll.setContent(container); 


    setControl(container);
    setPageComplete(false);
}

SecondPage createControl code is standard, but I also tried, to locate a parent, which would be a scroll - I supposed it would be issue of "nested" ScrolledComposite - like that:

    ScrolledComposite scroll = null;
 if(parent.getChildren() != null && parent.getChildren().length > 1 && parent.getChildren()[1] instanceof ScrolledComposite) { 
  scroll = (ScrolledComposite)parent.getChildren()[1]; 

 } 

    scroll.setLayoutData(new GridData(GridData.FILL_VERTICAL)); 
    Composite container = new Composite(scroll, SWT.NULL); 
    scroll.setContent(container);
    scroll.setAlwaysShowScrollBars(false);   
    scroll.setExpandVertical(true); 
    scroll.setExpandHorizontal(true); 

    scroll.setMinHeight(500);  
    scroll.setLayout(new GridLayout(1, false)); 


    GridLayout layout = new GridLayout();
    container.setLayout(layout); 
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

but such approach doesn't work.

Has anyone some experience with integrating with ScrolledComposites and multi-page JFace wizards?

Upvotes: 0

Views: 348

Answers (2)

Morpheus
Morpheus

Reputation: 113

I found solution, but - I must admit it - it was very stupid error. It is enough to change setControl(container); to setControl(scroll); . Now every page is displayed properly. Please, take care on such things in the future :)

Upvotes: 1

prashanth
prashanth

Reputation: 36

If you see the class hierarchy IDialogPage --> DialogPage --> WizardPage --> YourCustomPage. So for every page you need to create the custom content in under the parent Composite which is shared across the WizardPages by a Wizard.

But you are adding ScollableComposite on top of this root composite which is the content element in your case, specific to the first page and which should not shareable to the second wizard page.

So you need to create a new ScollableComposite for the second page and add your contents separately. If you try to update the contents of the same ScollableComposite in the second page then your content won't be updated to first page when you click on the back button. Because the createContent() won't be called when getPreviousPage() is called.

Upvotes: 0

Related Questions