简体   繁体   English

如何使“用户操作正在等待”对话框在 Eclipse RCP 中不可见?

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

I'm creating a web development framework with Eclipse RCP.我正在使用 Eclipse RCP 创建一个 web 开发框架。

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我想在向导底部显示 Process Monitor

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 ).看起来您应该能够使用实现IDialogBlockedHandler的东西来调用Dialog.setBlockedHandler来更改此对话框(都在org.eclipse.jface.dialogs中)。

The blocked handler does not have to display a dialog, the default JFace handler is just:阻塞的处理程序不必显示对话框,默认的 JFace 处理程序只是:

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 ). Eclipse 通常用org.eclipse.ui.internal.dialogs.WorkbenchDialogBlockedHandler替换它,它会显示您看到的对话框( 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. image但偶尔会出现“用户操作正在等待”对话框,不稳定。

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.我不确定为什么可以通过编写上面的代码来控制“用户操作正在等待”对话框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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