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

The following examples show how to use org.eclipse.ui.progress.UIJob#setPriority() . 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: OpenThemePreferencesHandler.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	UIJob job = new UIJob("Open Theme Preferences") //$NON-NLS-1$
	{

		@Override
		public IStatus runInUIThread(IProgressMonitor monitor)
		{
			final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(UIUtils.getActiveShell(),
					ThemePreferencePage.ID, null, null);
			dialog.open();
			return Status.OK_STATUS;
		}
	};
	job.setPriority(Job.INTERACTIVE);
	job.setRule(PopupSchedulingRule.INSTANCE);
	job.schedule();
	return null;
}
 
Example 2
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 3
Source File: PerspectiveChangeResetListener.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void resetPerspective(final IWorkbenchPage page)
{
	UIJob job = new UIJob("Resetting Studio perspective...") //$NON-NLS-1$
	{

		@Override
		public IStatus runInUIThread(IProgressMonitor monitor)
		{
			if (MessageDialog.openQuestion(UIUtils.getActiveShell(),
					com.aptana.ui.Messages.UIPlugin_ResetPerspective_Title,
					com.aptana.ui.Messages.UIPlugin_ResetPerspective_Description))
			{
				page.resetPerspective();
			}
			return Status.OK_STATUS;
		}
	};
	EclipseUtil.setSystemForJob(job);
	job.setPriority(Job.INTERACTIVE);
	job.schedule();
}
 
Example 4
Source File: PyGoToDefinition.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Remove the editor from askReparse and if it's the last one, do the find.
 */
private void doFindIfLast() {
    synchronized (lock) {
        askReparse.remove(editToReparse);
        if (askReparse.size() > 0) {
            return; //not the last one (we'll only do the find when all are reparsed.
        }
    }
    /**
     * Create an ui job to actually make the find.
     */
    UIJob job = new UIJob("Find") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            try {
                findDefinitionsAndOpen(true);
            } catch (Throwable e) {
                Log.log(e);
            }
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
}
 
Example 5
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);
	}
}
 
Example 6
Source File: RenameRefactoringPopup.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void open() {
	
	// Must cache here, since editor context is not available in menu from popup shell:
	openDialogBinding = getOpenDialogBinding();
	Shell workbenchShell = editor.getSite().getShell();
	final Display display = workbenchShell.getDisplay();
	popup = new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
	popupLayout = new GridLayout(2, false);
	popupLayout.marginWidth = 1;
	popupLayout.marginHeight = 1;
	popupLayout.marginLeft = 4;
	popupLayout.horizontalSpacing = 0;
	popup.setLayout(popupLayout);
	createContent(popup);
	updatePopupLocation();
	new PopupVisibilityManager().start();

	// Leave linked mode when popup loses focus
	// (except when focus goes back to workbench window or menu is open):
	popup.addShellListener(new ShellAdapter() {
		@Override
		public void shellDeactivated(ShellEvent e) {
			if (iSMenuUp)
				return;

			final Shell editorShell = editor.getSite().getShell();
			display.asyncExec(new Runnable() {
				// post to UI thread since editor shell only gets activated after popup has lost focus
				@Override
				public void run() {
					Shell activeShell = display.getActiveShell();
					if (activeShell != editorShell) {
						controller.cancelLinkedMode();
					}
				}
			});
		}
	});

	if (!MAC) { // carbon and cocoa draw their own border...
		popup.addPaintListener(new PaintListener() {
			@Override
			public void paintControl(PaintEvent pe) {
				pe.gc.drawPolygon(getPolygon(true));
			}
		});
	}

	UIJob delayJob = new UIJob(display, "Delayed RenameInformationPopup") {
		@Override
		public IStatus runInUIThread(IProgressMonitor monitor) {
			delayJobFinished = true;
			if (popup != null && !popup.isDisposed()) {
				updateVisibility();
			}
			return Status.OK_STATUS;
		}
	};
	delayJob.setSystem(true);
	delayJob.setPriority(Job.INTERACTIVE);
	delayJob.schedule(POPUP_VISIBILITY_DELAY);
}
 
Example 7
Source File: RenameInformationPopup.java    From typescript.java with MIT License 4 votes vote down vote up
public void open() {
		// Must cache here, since editor context is not available in menu from popup shell:
		fOpenDialogBinding= getOpenDialogBinding();

		Shell workbenchShell= fEditor.getSite().getShell();
		final Display display= workbenchShell.getDisplay();

		fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
		fPopupLayout= new GridLayout(3, false);
		fPopupLayout.marginWidth= 1;
		fPopupLayout.marginHeight= 1;
		fPopupLayout.marginLeft= 4;
		fPopupLayout.horizontalSpacing= 0;
		fPopup.setLayout(fPopupLayout);

		createContent(fPopup);
		updatePopupLocation(true);
		new PopupVisibilityManager().start();

		// Leave linked mode when popup loses focus
		// (except when focus goes back to workbench window or menu is open):
		fPopup.addShellListener(new ShellAdapter() {
			@Override
			public void shellDeactivated(ShellEvent e) {
				if (fIsMenuUp)
					return;

				final Shell editorShell= fEditor.getSite().getShell();
				display.asyncExec(new Runnable() {
					// post to UI thread since editor shell only gets activated after popup has lost focus
					@Override
					public void run() {
						Shell activeShell= display.getActiveShell();
						if (activeShell != editorShell) {
							fRenameLinkedMode.cancel();
						}
					}
				});
			}
		});

		if (! MAC) { // carbon and cocoa draw their own border...
			fPopup.addPaintListener(new PaintListener() {
				@Override
				public void paintControl(PaintEvent pe) {
					pe.gc.drawPolygon(getPolygon(true));
				}
			});
		}

//		fPopup.moveBelow(null); // make sure hovers are on top of the info popup
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
//		fPopup.moveBelow(workbenchShell.getShells()[0]);

		UIJob delayJob= new UIJob(display, RefactoringMessages.RenameInformationPopup_delayJobName) {
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor) {
				fDelayJobFinished= true;
				if (fPopup != null && ! fPopup.isDisposed()) {
					updateVisibility();
				}
				return Status.OK_STATUS;
			}
		};
		delayJob.setSystem(true);
		delayJob.setPriority(Job.INTERACTIVE);
		delayJob.schedule(POPUP_VISIBILITY_DELAY);
	}
 
Example 8
Source File: RenameInformationPopup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void open() {
		// Must cache here, since editor context is not available in menu from popup shell:
		fOpenDialogBinding= getOpenDialogBinding();

		Shell workbenchShell= fEditor.getSite().getShell();
		final Display display= workbenchShell.getDisplay();

		fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
		fPopupLayout= new GridLayout(2, false);
		fPopupLayout.marginWidth= 1;
		fPopupLayout.marginHeight= 1;
		fPopupLayout.marginLeft= 4;
		fPopupLayout.horizontalSpacing= 0;
		fPopup.setLayout(fPopupLayout);

		createContent(fPopup);
		updatePopupLocation(true);
		new PopupVisibilityManager().start();

		// Leave linked mode when popup loses focus
		// (except when focus goes back to workbench window or menu is open):
		fPopup.addShellListener(new ShellAdapter() {
			@Override
			public void shellDeactivated(ShellEvent e) {
				if (fIsMenuUp)
					return;

				final Shell editorShell= fEditor.getSite().getShell();
				display.asyncExec(new Runnable() {
					// post to UI thread since editor shell only gets activated after popup has lost focus
					public void run() {
						Shell activeShell= display.getActiveShell();
						if (activeShell != editorShell) {
							fRenameLinkedMode.cancel();
						}
					}
				});
			}
		});

		if (! MAC) { // carbon and cocoa draw their own border...
			fPopup.addPaintListener(new PaintListener() {
				public void paintControl(PaintEvent pe) {
					pe.gc.drawPolygon(getPolygon(true));
				}
			});
		}

//		fPopup.moveBelow(null); // make sure hovers are on top of the info popup
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
//		fPopup.moveBelow(workbenchShell.getShells()[0]);

		UIJob delayJob= new UIJob(display, ReorgMessages.RenameInformationPopup_delayJobName) {
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor) {
				fDelayJobFinished= true;
				if (fPopup != null && ! fPopup.isDisposed()) {
					updateVisibility();
				}
				return Status.OK_STATUS;
			}
		};
		delayJob.setSystem(true);
		delayJob.setPriority(Job.INTERACTIVE);
		delayJob.schedule(POPUP_VISIBILITY_DELAY);
	}