Pages

Tuesday, 23 November 2010

Remove the Progress Monitor Part from Jface Wizard

Many a times the Jface wizards have posed an annoying problem to me... Even after setting the needsProgressMonitor attribute to false, there is some extra space left at the bottom of the wizard dialog which contains the invisible progress monitor part.

I finally managed a hack that removes that part, here is the code that you need to use -

WizardDialog dialog = new WizardDialog(null, wizard) {
           
            @Override
            protected Control createDialogArea(Composite parent) {
                Control ctrl = super.createDialogArea(parent);
                getProgressMonitor();
                return ctrl;
            }
           
            @Override
            protected IProgressMonitor getProgressMonitor() {
                ProgressMonitorPart monitor = (ProgressMonitorPart) super.getProgressMonitor();
                GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
                gridData.heightHint = 0;
                monitor.setLayoutData(gridData);
                monitor.setVisible(false);
                return monitor;
            }
   };

This safely removes the extra space from the bottom of the wizard. Though you will not be able to use the progress monitor from this point onwards in the wizard where this code is placed.

4 comments:

Tomasz Werszko said...

Great tip. You've just save me a lot of time :).

Rajesh Nair said...

Thank you so much for sharing this. :)

Anonymous said...

Awesome.. Worked Smoothly

Unknown said...

Oh god! Thank you :)

Post a Comment