Obuli Sundar
Obuli Sundar

Reputation: 566

How to refresh multipage editor's page?

I have created a plugin,Where I have a multi page editor with two pages. Page1- Source Code Editor. Page2- For Manipulation.

My problem is if there is any compilation error in the code the second page must display another content like "Error". Otherwise it will show my manipulation form. For that I need to fill the composite with diffrent content each time the pageChanges. But it doesnt work.

How can achieve the scenario. While clicking the second page the content must be recreated or refreshed for the new content

  public void createPage1(){

    intializePage1Composite();

    updatePage1Content(this.page1Compostie);

    int index = addPage(this.page1Compostie);
    setPageText(index, "Service Behaviors ");
}
 public void updatePage1Content(Composite composite){

    boolean error=getPageStatus();


    if(!error){

        /**
         *Content of Normal Page
         */
    }

    /**
     * setting the page to error
     */
    else{
            /**
             *Content of Error Page
              */

        }
}


   protected void pageChange(int newPageIndex) {
    super.pageChange(newPageIndex);
    if (newPageIndex == 1) {


        updatePage1Content(this.page1Compostie);

        this.page1Compostie.redraw();


    }

}

Any advice ?

Upvotes: 0

Views: 428

Answers (1)

greg-449
greg-449

Reputation: 111216

To replace all the children of a composite you first call dispose() on each existing child control. Next add the new controls. Finally call

composite.layout(true, true);

on the parent composite to force it to update the layout.

If you just want to switch between two sets of controls you can use the GridData.exclude flag and Control.setVisible to include/exclude controls. Again call layout at the end.

Upvotes: 0

Related Questions