Java Code Examples for org.eclipse.ui.progress.UIJob#setUser()

The following examples show how to use org.eclipse.ui.progress.UIJob#setUser() . 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: UIUtils.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private static void showErrorMessage(final String title, final String message, final Throwable exception)
{
	if (Display.getCurrent() == null || exception != null)
	{
		UIJob job = new UIJob(message)
		{
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor)
			{
				if (exception == null)
				{
					showErrorDialog(title, message);
					return Status.OK_STATUS;
				}
				return new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID, null, exception);
			}
		};
		job.setPriority(Job.INTERACTIVE);
		job.setUser(true);
		job.schedule();
	}
	else
	{
		showErrorDialog(title, message);
	}
}
 
Example 2
Source File: ControlView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void componentChanged(final ITraceControlComponent component) {
    if (fTreeViewer.getTree().isDisposed()) {
        return;
    }

    UIJob myJob = new UIJob("Refresh") { //$NON-NLS-1$
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            if (fTreeViewer.getTree().isDisposed()) {
                return Status.OK_STATUS;
            }

            fTreeViewer.refresh(component);

            // Change selection needed
            final ISelection sel = fTreeViewer.getSelection();
            fTreeViewer.setSelection(null);
            fTreeViewer.setSelection(sel);

            // Show component that was changed
            fTreeViewer.reveal(component);

            return Status.OK_STATUS;
        }
    };
    myJob.setUser(false);
    myJob.setSystem(true);
    myJob.schedule();
}
 
Example 3
Source File: ControlView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets the selected components in the tree
 * @param components - array of components to select
 */
public void setSelection(ITraceControlComponent[] components) {
    final StructuredSelection selection = new StructuredSelection(components);
    UIJob myJob = new UIJob("Select") { //$NON-NLS-1$
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            fTreeViewer.setSelection(selection);
            return Status.OK_STATUS;
        }
    };
    myJob.setUser(false);
    myJob.schedule();
}
 
Example 4
Source File: UIUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static boolean showPromptDialog(final String title, final String message)
{
	if (Display.getCurrent() == null)
	{
		UIJob job = new UIJob(title)
		{
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor)
			{
				if (showPromptDialogUI(title, message))
				{
					return Status.OK_STATUS;
				}
				return Status.CANCEL_STATUS;
			}
		};
		job.setPriority(Job.INTERACTIVE);
		job.setUser(true);
		job.schedule();
		try
		{
			job.join();
		}
		catch (InterruptedException e)
		{
		}
		return job.getResult() == Status.OK_STATUS;
	}
	else
	{
		return showPromptDialogUI(title, message);
	}
}