.getWorkbench();
IWorkbenchWindow[] windows = workbench
.getWorkbenchWindows();
for (int i = 0; i < windows.length; i++) {
if (windows[i] instanceof WorkbenchWindow) {
final WorkbenchWindow window = (WorkbenchWindow) windows[i];
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(
window.getShell());
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
/**
* When this operation should open a dialog
*/
private long openTime;
/**
* Whether the dialog has been opened yet.
*/
private boolean dialogOpened = false;
/* (non-Javadoc)
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) {
openTime = System
.currentTimeMillis()
+ workbench
.getProgressService()
.getLongOperationTime();
//two work units - updating the window bars, and updating view bars
monitor
.beginTask(
ActivityMessages.ManagerTask, 2);
monitor
.subTask(ActivityMessages.ManagerWindowSubTask);
//update window managers...
updateWindowBars(window);
monitor.worked(1);
monitor
.subTask(ActivityMessages.ManagerViewsSubTask);
// update all of the (realized) views in all of the pages
IWorkbenchPage[] pages = window
.getPages();
for (int j = 0; j < pages.length; j++) {
IWorkbenchPage page = pages[j];
IViewReference[] refs = page
.getViewReferences();
for (int k = 0; k < refs.length; k++) {
IViewPart part = refs[k]
.getView(false);
if (part != null) {
updateViewBars(part);
}
}
}
monitor.worked(1);
monitor.done();
}
/**
* Update the managers on the given given view.
*
* @param part the view to update
*/
private void updateViewBars(
IViewPart part) {
IViewSite viewSite = part
.getViewSite();
// check for badly behaving or badly initialized views
if (viewSite == null) {
return;
}
IActionBars bars = viewSite
.getActionBars();
IContributionManager manager = bars
.getMenuManager();
if (manager != null) {
updateManager(manager);
}
manager = bars.getToolBarManager();
if (manager != null) {
updateManager(manager);
}
manager = bars
.getStatusLineManager();
if (manager != null) {
updateManager(manager);
}
}
/**
* Update the managers on the given window.
*
* @param window the window to update
*/
private void updateWindowBars(
final WorkbenchWindow window) {
IContributionManager manager = window
.getMenuBarManager();
if (manager != null) {
updateManager(manager);
}
manager = window
.getCoolBarManager2();
if (manager != null) {
updateManager(manager);
}
manager = window
.getToolBarManager2();
if (manager != null) {
updateManager(manager);
}
manager = window
.getStatusLineManager();
if (manager != null) {
updateManager(manager);
}
}