public boolean isCurrentContextUI() { try { return PlatformUI.isWorkbenchRunning() || PlatformUI.getWorkbench().isClosing(); } catch (Exception e) { //Ignore, workbench must not be running return false; } }
private static Widget /* TaskItem */getApplicationTaskItem() { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench != null && workbench.getDisplay() != null && !workbench.isClosing()) { try { Class<?> taskBarClass = Class.forName("org.eclipse.swt.widgets.TaskBar"); //$NON-NLS-1$ Method getSystemTaskBarMethod = Display.class.getMethod("getSystemTaskBar"); //$NON-NLS-1$ Object systemTaskBar = getSystemTaskBarMethod.invoke(workbench.getDisplay()); if (systemTaskBar != null && systemTaskBar.getClass().equals(taskBarClass)) { Method getItemMethod = taskBarClass.getMethod("getItem", Shell.class); //$NON-NLS-1$ Object taskItem = getItemMethod.invoke(systemTaskBar, new Object[] { null }); if (taskItem instanceof Widget) { return (Widget) taskItem; } } } catch (Throwable t) { // ignore since class probably doesn't exist } } return null; }
private boolean isClosing(final IWorkbenchPage page) { IWorkbenchWindow pageWindow = page.getWorkbenchWindow(); boolean isWorkbenchClosing = pageWindow.getWorkbench().isClosing(); if (isWorkbenchClosing) { return true; } boolean isWorkbenchPageWindowClosing = pageWindow.isClosing(); if (isWorkbenchPageWindowClosing) { return true; } return false; }
/** * Return whether the viewer is closing or shutting down. * This method should be used in async execs to ensure that * the viewer is still alive. * @return a boolean indicating whether the viewer is closing */ protected boolean isClosing() { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench.isClosing()) return true; if (viewer.getControl().isDisposed()) return true; return false; } }
private boolean isOkToLoad() { if (PlatformUI.getWorkbench().isClosing()) return handler != null; if (configurationElement != null && handler == null) { final String bundleId = configurationElement.getContributor() .getName(); return BundleUtility.isActive(bundleId); } return true; }
public void run() { final TreeViewer treeViewer = filteredTree.getViewer(); final Tree tree = treeViewer.getTree(); IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench.isClosing()) return; if (tree != null && !tree.isDisposed()) { updateAvailableViewState(); } } };
protected void refreshViewer() { final TreeViewer treeViewer = filteredTree.getViewer(); final Tree tree = treeViewer.getTree(); IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench.isClosing()) return; if (tree != null && !tree.isDisposed()) { updateAvailableViewState(); } } };
private boolean updateTitleImage(final Image image) { if (!PlatformUI.getWorkbench().isClosing()) { if (image != null && !image.isDisposed()) { client.setImage(image); return true; } else { if (oldImage != null && !oldImage.isDisposed()) { client.setImage(oldImage); } } } return false; }
/** * Utility method to get the best parenting possible for a dialog. If there is a modal shell create it so as to * avoid two modal dialogs. If not then return the shell of the active workbench window. If neither can be found * return null. * <p> * <b>Note: Applied from patch on bug 99472.</b> * * @return Shell or <code>null</code> */ public static Shell getShell() { if (!PlatformUI.isWorkbenchRunning() || PlatformUI.getWorkbench().isClosing()) { return null; } Shell modal = getModalShellExcluding(null); if (modal != null) { return modal; } return getNonModalShell(); }
@Override public void run() { if (!display.isDisposed() && !configurer.getWorkbench().isClosing()) { int nextInterval; final long start = System.currentTimeMillis(); //don't garbage collect if background jobs are running if (!Job.getJobManager().isIdle()) { nextInterval = IDLE_INTERVAL; } else if ((start - lastGC) < nextGCInterval) { //don't garbage collect if we have collected within the specific interval nextInterval = nextGCInterval - (int) (start - lastGC); } else { gcJob.schedule(); nextInterval = minGCInterval; } display.timerExec(nextInterval, this); } } };
public void run() { if (PlatformUI.getWorkbench().isClosing()) return; int retCode = ApplyProfileChangesDialog.promptForRestart(ProvUI.getDefaultParentShell(), restartPolicy == Policy.RESTART_POLICY_PROMPT); if (retCode == ApplyProfileChangesDialog.PROFILE_APPLYCHANGES) { applyProfileChanges(); } else if (retCode == ApplyProfileChangesDialog.PROFILE_RESTART) { PlatformUI.getWorkbench().restart(); } } });
public void run() { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench.isClosing()) return; Shell shell = ProvUI.getDefaultParentShell();
@Override public void run() { IWorkbench workbench = PlatformUI.isWorkbenchRunning() ? PlatformUI.getWorkbench() : null; if (workbench != null && (workbench.getDisplay().isDisposed() || PlatformUI.getWorkbench().isClosing())) return; if (workbench == null || workbench.isStarting()) { Display.getCurrent().timerExec(PROBLEMS_VIEW_CREATION_DELAY, this); return; } IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); for (int i= 0; i < windows.length; i++) { IWorkbenchWindow window= windows[i]; IWorkbenchPage activePage= window.getActivePage(); if (activePage == null) continue; IViewReference[] refs= activePage.getViewReferences(); for (int j= 0; j < refs.length; j++) { IViewReference viewReference= refs[j]; if (IPageLayout.ID_PROBLEM_VIEW.equals(viewReference.getId())) try { activePage.showView(viewReference.getId(), viewReference.getSecondaryId(), IWorkbenchPage.VIEW_CREATE); } catch (PartInitException e) { log("Could not create Problems view", e.getStatus()); //$NON-NLS-1$ } } } } };
return; IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench.isClosing()) return;