/** * Runs the dialog in headless mode. The dialog will run headless while the workflow can run. * * @param monitor * @param true if the workflow ran and completed correctly. False if it failed or the user * cancelled (because user interaction was required) */ public boolean runHeadless(IProgressMonitor monitor) { try { this.headless = true; int ticks = getWorkflowWizard().getWorkflow().getStates().length * 10; monitor.beginTask(Messages.WorkflowWizardDialog_importTask, ticks); // we must ensure that the contents of the dialog (shell) have been // creates, needed for wizard pages if (getShell() == null) { // do in ui thread PlatformGIS.syncInDisplayThread( new Runnable() { public void run() { create(); } }); } Workflow pipe = getWizard().getWorkflow(); pipe.run(new SubProgressMonitor(monitor, ticks)); final boolean[] result = new boolean[] {true}; if (!pipe.isFinished()) { // show the page corresponding to the current state final IWizardPage page = getWizard().getPage(pipe.getCurrentState()); if (page != null) { // ensure the page has a state if it is a DataPipelinePage if (page instanceof WorkflowWizardPage) { WorkflowWizardPage dpPage = (WorkflowWizardPage) page; if (dpPage.getState() == null) dpPage.setState(pipe.getCurrentState()); } PlatformGIS.syncInDisplayThread( new Runnable() { public void run() { headless = false; showPage(page); if (open() == Window.CANCEL) { result[0] = false; } }; }); } } this.headless = false; return result[0]; } finally { monitor.done(); } }
@Override public void showPage(IWizardPage page) { super.showPage(page); // let the page know that is is being shown in the wizard, lets page // do some lazy initalization of ui widgets, etc. ((WorkflowWizardPage) page).shown(); }