我在 eclipse 中使用 IRunnableWithProgress 对话框来显示当前的进度状态。每当我打开另一个对话框(例如属性页)时,进度对话框不会出现在前台。有没有办法强制 ProgressDialog 始终出现在顶层?
编辑1: 这是我用来获取此进度对话框的代码:
try {
IRunnableWithProgress process = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
monitor.beginTask(taskName, steps);
result = execution(monitor);
monitor.done();
}
};
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setActive();
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(process);
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
最佳答案
您无法控制进度服务显示的对话框。
如果您想从首选项页面(或其他一些对话框)显示进度,请使用 ProgressMonitorDialog
而不是进度服务。这也接受 IRunnableWithProgress
:
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()) {
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("Dialog title");
}
};
try {
dialog.run(true, true, progress);
}
... catches ...
关于java - 如何将 IRunnableWithProgress 始终带到前层?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38429709/