简体   繁体   中英

How do I make the "user operation is waiting" dialog invisible in Eclipse RCP?

I'm creating a web development framework with Eclipse RCP.

The wizard is creating a feature that creates a project when you press Finish.

I want to show Process Monitor at the bottom of the wizard

I wrote the code as below.

public abstract class CreateProjectWizard extends Wizard {
    
    public CreateProjectWizard () {
                
        ...
        
        setNeedsProgressMonitor(true);
    }
    
    ...
    
    @Override
    public boolean performFinish() {
    
        IRunnableWithProgress runnable= new IRunnableWithProgress() {
            
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    ...
                    
                 IStatus status = createProject(input, monitor);

                    ...
            }
        };
        
        try {
            getContainer().run(true, true, runnable);
        }   
        
        ...
        
        return true;
    }
}

图片1 图片2

How do I make the "user operation is waiting" dialog invisible?

I will let you know if you need additional information.

It looks like you should be able to call Dialog.setBlockedHandler with something that implements IDialogBlockedHandler to change this dialog (both in org.eclipse.jface.dialogs ).

The blocked handler does not have to display a dialog, the default JFace handler is just:

new IDialogBlockedHandler() {

        @Override
        public void clearBlocked() {
            // No default behavior
        }

        @Override
        public void showBlocked(IProgressMonitor blocking,
                IStatus blockingStatus, String blockedName) {
            // No default behavior
        }

        @Override
        public void showBlocked(Shell parentShell, IProgressMonitor blocking,
                IStatus blockingStatus, String blockedName) {
            // No default behavior
        }
    };

Eclipse normally replaces this with org.eclipse.ui.internal.dialogs.WorkbenchDialogBlockedHandler which shows the dialog you see ( BlockedJobsDialog ).

Note that this will not stop the operation waiting for the blocking jobs to finish it will just stop the dialog appearing.

Thank you for your kind reply.

When you write the code as below and click the finish button, the "user operation is waiting" dialog does not appear.

public abstract class CreateProjectWizard extends Wizard {
    
    public CreateProjectWizard () {
                
        ...
        
        setNeedsProgressMonitor(true);
    }
    
    ...
    
    @Override
    public boolean performFinish() {
    
        IRunnableWithProgress runnable= new IRunnableWithProgress() {
            
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    ...

                getShell().getDisplay()
                .asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        Dialog.getBlockedHandler().showBlocked(null, monitor, null, null);                  
                    }
                });     
               
                 IStatus status = createProject(input, monitor);

                 Dialog.getBlockedHandler().clearBlocked();
                    
                 ...
            }
        };
        
        try {
            getContainer().run(true, true, runnable);
        }   
        
        ...
        
        return true;
    }
}

image But very occasionally a "user operation is waiting" dialog appears, which is unstable.

Is it correct to write the code as above?

I'm not sure why the "user operation is waiting" dialog can be controlled by writing the code above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM