org.eclipse.ui.progress.WorkbenchJob Java Examples
The following examples show how to use
org.eclipse.ui.progress.WorkbenchJob.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Causes the view to re-sync its contents with the workspace. Note that changes will be scheduled * in a background job, and may not take effect immediately. */ protected final void refresh() { @SuppressWarnings("cast") final IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite() .getAdapter(IWorkbenchSiteProgressService.class); // rebuild statistics data CreateStatsJob job = new CreateStatsJob(getFilter(), getViewId()); job.setPriority(Job.DECORATE); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { mStats = ((CreateStatsJob) event.getJob()).getStats(); Job uiJob = new WorkbenchJob(Messages.AbstractStatsView_msgRefreshStats) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { handleStatsRebuilt(); return Status.OK_STATUS; } }; uiJob.setPriority(Job.DECORATE); uiJob.setSystem(true); uiJob.schedule(); } }); service.schedule(job, 0, true); }
Example #2
Source File: FilteredCheckboxTree.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override protected WorkbenchJob doCreateRefreshJob() { WorkbenchJob job = super.doCreateRefreshJob(); return new WorkbenchJob("Refresh Filter") {//$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (fCheckboxTreeViewer.getTree().isDisposed()) { return Status.CANCEL_STATUS; } // Save expanded elements before and after the filtering Set<Object> expandedElements = new HashSet<>(Arrays.asList(fCheckboxTreeViewer.getExpandedElements())); job.runInUIThread(monitor); expandedElements.addAll(Arrays.asList(fCheckboxTreeViewer.getExpandedElements())); fCheckboxTreeViewer.getTree().setRedraw(false); // Expand all to be able to store all checked elements fCheckboxTreeViewer.expandAll(); fCheckboxTreeViewer.setCheckedElements(getCheckedElements()); // Collapse all can change selection ISelection selection = fCheckboxTreeViewer.getSelection(); fCheckboxTreeViewer.collapseAll(); fCheckboxTreeViewer.getTree().setRedraw(true); // Expand tree according to the saved expanded elements fCheckboxTreeViewer.setExpandedElements(expandedElements.toArray()); // Restore the selection fCheckboxTreeViewer.setSelection(selection); return Status.OK_STATUS; } }; }
Example #3
Source File: TriStateFilteredCheckboxTree.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override protected WorkbenchJob doCreateRefreshJob() { WorkbenchJob job = super.doCreateRefreshJob(); job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { if (getCheckboxTreeViewer().getTree().isDisposed()) { return; } maintainAllCheckIntegrity(); } }); return job; }
Example #4
Source File: GwtCompilerTabGroup.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private void createUpdateJob() { new WorkbenchJob("GwtSuperDevModeCodeServerTabGroup") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { ILaunchConfigurationTab tab = launchConfigurationDialog.getActiveTab(); if (tab != null && !tab.getControl().isDisposed()) { launchConfigurationDialog.updateButtons(); launchConfigurationDialog.updateMessage(); } return Status.OK_STATUS; } }.schedule(); }
Example #5
Source File: WebAppTabGroup.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private void createUpdateJob() { new WorkbenchJob("WebAppTabGroup") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { ILaunchConfigurationTab tab = launchConfigurationDialog.getActiveTab(); if (tab != null && !tab.getControl().isDisposed()) { launchConfigurationDialog.updateButtons(); launchConfigurationDialog.updateMessage(); } return Status.OK_STATUS; } }.schedule(); }
Example #6
Source File: GwtSuperDevModeCodeServerTabGroup.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private void createUpdateJob() { new WorkbenchJob("GwtSuperDevModeCodeServerTabGroup") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { ILaunchConfigurationTab tab = launchConfigurationDialog.getActiveTab(); if (tab != null && !tab.getControl().isDisposed()) { launchConfigurationDialog.updateButtons(); launchConfigurationDialog.updateMessage(); } return Status.OK_STATUS; } }.schedule(); }
Example #7
Source File: KeybindingsManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void dispose() { WorkbenchJob job = new WorkbenchJob("Disposing KeybindingsManager") //$NON-NLS-1$ { @Override public IStatus runInUIThread(IProgressMonitor monitor) { workbench.getDisplay().removeFilter(SWT.KeyDown, listener); workbench.getDisplay().removeFilter(SWT.Traverse, listener); return Status.OK_STATUS; } }; EclipseUtil.setSystemForJob(job); job.schedule(); }
Example #8
Source File: CommonQuickOutlinePage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * createDelayedRefreshJob * * @return workbench job */ private WorkbenchJob createDelayedRefreshJob() { return new WorkbenchJob("Refresh Content") { //$NON-NLS-1$ /** * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { try { if (_treeViewer.getControl().isDisposed()) { return Status.CANCEL_STATUS; } _treeViewer.setSelection(null); _treeViewer.refresh(); } // SWT errors may be thrown here and will show as an error box since this is done on the UI thread // Catch everything and log it so that the dialog doesn't annoy the user since they may be typing into // the editor when this code throws errors and will impact them severely catch (Throwable e) { IdeLog.logError(CommonEditorPlugin.getDefault(), e); } return Status.OK_STATUS; } }; }
Example #9
Source File: OptionsConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private WorkbenchJob doCreateRefreshJob() { return new WorkbenchJob(PreferencesMessages.OptionsConfigurationBlock_RefreshFilter) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { updateUI(fRoot); fParentComposite.layout(true, true); //relayout if (fScrolledPageContent != null) { setVisible(fNoMatchFoundLabel, !fMatchFound); fScrolledPageContent.reflow(true); } return Status.OK_STATUS; } }; }
Example #10
Source File: KeybindingsManager.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private void initBindings() { WorkbenchJob workbenchJob = new WorkbenchJob("Installing KeybindingsManager") //$NON-NLS-1$ { @Override public IStatus runInUIThread(IProgressMonitor monitor) { loadbindings(); // Insert our key listener before the Eclipse's key listeners IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class); if (bindingService instanceof BindingService) { final BindingService theBindingService = (BindingService) bindingService; Display display = PlatformUI.getWorkbench().getDisplay(); final WorkbenchKeyboard keyboard = theBindingService.getKeyboard(); Listener keyDownFilter = keyboard.getKeyDownFilter(); try { if (keyDownFilter != null) { display.removeFilter(SWT.KeyDown, keyDownFilter); display.removeFilter(SWT.Traverse, keyDownFilter); } display.addFilter(SWT.KeyDown, listener); display.addFilter(SWT.Traverse, listener); } finally { if (keyDownFilter != null) { display.addFilter(SWT.KeyDown, keyDownFilter); display.addFilter(SWT.Traverse, keyDownFilter); } } } // Set the initial enabled state of KeybindingsManager IContextService contextService = (IContextService) workbench.getService(IContextService.class); contextService.addContextManagerListener(contextManagerListener); setEnabled(contextService.getActiveContextIds().contains(ScriptingUIPlugin.SCRIPTING_CONTEXT_ID)); return Status.OK_STATUS; } }; workbenchJob.setRule(MUTEX_RULE); EclipseUtil.setSystemForJob(workbenchJob); workbenchJob.setPriority(Job.LONG); workbenchJob.schedule(); }
Example #11
Source File: CommonQuickOutlinePage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * createRefreshJob * * @return Workbench job */ private WorkbenchJob createRefreshJob() { return new WorkbenchJob("Refresh Filter") {//$NON-NLS-1$ /** * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { if (_treeViewer.getControl().isDisposed()) { return Status.CANCEL_STATUS; } if (_pattern == null) { return Status.OK_STATUS; } _filter.setPattern(_pattern); try { // don't want the user to see updates that will be made to the tree _treeViewer.getControl().setRedraw(false); _treeViewer.refresh(true); if (_pattern.length() > 0) { /* * Expand elements one at a time. After each is expanded, check to see if the filter text has * been modified. If it has, then cancel the refresh job so the user doesn't have to endure * expansion of all the nodes. */ IStructuredContentProvider provider = (IStructuredContentProvider) _treeViewer .getContentProvider(); Object[] elements = provider.getElements(_treeViewer.getInput()); for (int i = 0; i < elements.length; i++) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } _treeViewer.expandToLevel(elements[i], AbstractTreeViewer.ALL_LEVELS); } TreeItem[] items = _treeViewer.getTree().getItems(); if (items.length > 0) { // to prevent scrolling _treeViewer.getTree().showItem(items[0]); } } } finally { // done updating the tree - set redraw back to true _treeViewer.getControl().setRedraw(true); } return Status.OK_STATUS; } }; }
Example #12
Source File: FilteredElementTreeSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected WorkbenchJob doCreateRefreshJob() { return new WorkbenchJob("Refresh Filter") {//$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (treeViewer.getControl().isDisposed()) { return Status.CANCEL_STATUS; } String text= getFilterString(); if (text == null) { return Status.OK_STATUS; } boolean initial= initialText != null && initialText.equals(text); if (initial) { getPatternFilter().setPattern(null); } else { getPatternFilter().setPattern(text); } Control redrawFalseControl= treeComposite != null ? treeComposite : treeViewer.getControl(); try { // don't want the user to see updates that will be made to // the tree // we are setting redraw(false) on the composite to avoid // dancing scrollbar redrawFalseControl.setRedraw(false); if (!narrowingDown) { // collapse all TreeItem[] is= treeViewer.getTree().getItems(); for (int i= 0; i < is.length; i++) { TreeItem item= is[i]; if (item.getExpanded()) { treeViewer.setExpandedState(item.getData(), false); } } } treeViewer.refresh(true); updateToolbar(text.length() > 0 && !initial); } finally { // done updating the tree - set redraw back to true TreeItem[] items= getViewer().getTree().getItems(); if (items.length > 0 && getViewer().getTree().getSelectionCount() == 0) { treeViewer.getTree().setTopItem(items[0]); } redrawFalseControl.setRedraw(true); } return Status.OK_STATUS; } }; }