Java Examples for org.eclipse.ui.progress.UIJob
The following java examples will help you to understand the usage of org.eclipse.ui.progress.UIJob. These source code samples are taken from different open source projects.
Example 1
| Project: cdt-master File: ImportMemoryDialog.java View source code |
public void scrollRenderings(final BigInteger address) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"repositionRenderings") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
for (IMemoryRenderingContainer container : fMemoryView.getMemoryRenderingContainers()) {
IMemoryRendering rendering = container.getActiveRendering();
if (rendering instanceof IRepositionableMemoryRendering) {
try {
((IRepositionableMemoryRendering) rendering).goToAddress(address);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, MessageFormat.format(Messages.getString("ImportMemoryDialog.ErrRepositioningRendering"), address.toString(16)), ex));
}
}
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.setThread(Display.getDefault().getThread());
job.schedule();
}Example 2
| Project: cdt-tests-runner-master File: ImportMemoryDialog.java View source code |
public void scrollRenderings(final BigInteger address) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"repositionRenderings") {
public IStatus runInUIThread(IProgressMonitor monitor) {
for (IMemoryRenderingContainer container : fMemoryView.getMemoryRenderingContainers()) {
IMemoryRendering rendering = container.getActiveRendering();
if (rendering instanceof IRepositionableMemoryRendering) {
try {
((IRepositionableMemoryRendering) rendering).goToAddress(address);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, MessageFormat.format(Messages.getString("ImportMemoryDialog.ErrRepositioningRendering"), address.toString(16)), ex));
}
}
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.setThread(Display.getDefault().getThread());
job.schedule();
}Example 3
| Project: as-spacebar-master File: DropIndex.java View source code |
protected void handle(ExecutionEvent event, final Index index) {
Shell shell = HandlerUtil.getActiveShell(event);
MessageDialog dialog = new MessageDialog(shell, "Confirm Index Drop", null, NLS.bind("Are you sure you want to drop index ''{0}''?", index), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, // yes is the default
IDialogConstants.NO_LABEL }, // yes is the default
0);
int code = dialog.open();
if (code == MessageDialog.OK) {
new UIJob(shell.getDisplay(), "DropIndex") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
monitor.beginTask(NLS.bind("Dropping index ''{0}''", index), 1);
Space space = index.getParent().getParent();
Metaspace metaspace = space.getParent().getParent().getConnection().getMetaspace();
SpaceDef spaceDef = metaspace.getSpaceDef(space.getName());
spaceDef.removeIndexDef(index.getName());
metaspace.alterSpace(spaceDef);
monitor.worked(1);
} catch (com.tibco.as.space.ASException e) {
return SpaceBarPlugin.createStatus(e, "Could not drop index ''{0}''", index);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
}.schedule();
}
}Example 4
| Project: elexis-3-base-master File: Activator.java View source code |
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
UIJob job = new UIJob("InitCommandsWorkaround") {
public IStatus runInUIThread(@SuppressWarnings("unused") IProgressMonitor monitor) {
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
Command command = commandService.getCommand(LoadESRFileHandler.COMMAND_ID);
command.isEnabled();
return new Status(IStatus.OK, "my.plugin.id", "Init commands workaround performed succesfully");
}
};
job.schedule();
}Example 5
| Project: erlide-master File: ReportPreferencePage.java View source code |
@Override
public IStatus run(final IProgressMonitor monitor) {
final String location = LogUtil.getReportFile();
final ProblemData data = gatherProblemData(attach, title, contact, body);
sendToDisk(location, data);
final Job inner = new UIJob("update report ui") {
@Override
public IStatus runInUIThread(final IProgressMonitor amonitor) {
sendButton.setText("Done!");
responseLabel.setVisible(true);
locationLabel.setText(location);
locationLabel.setVisible(true);
responseLabel_1.setVisible(true);
return Status.OK_STATUS;
}
};
inner.setPriority(Job.INTERACTIVE);
inner.setSystem(true);
inner.schedule();
return Status.OK_STATUS;
}Example 6
| Project: erlide_eclipse-master File: ReportPreferencePage.java View source code |
@Override
public IStatus run(final IProgressMonitor monitor) {
final String location = LogUtil.getReportFile();
final ProblemData data = gatherProblemData(attach, title, contact, body);
sendToDisk(location, data);
final Job inner = new UIJob("update report ui") {
@Override
public IStatus runInUIThread(final IProgressMonitor amonitor) {
sendButton.setText("Done!");
responseLabel.setVisible(true);
locationLabel.setText(location);
locationLabel.setVisible(true);
responseLabel_1.setVisible(true);
return Status.OK_STATUS;
}
};
inner.setPriority(Job.INTERACTIVE);
inner.setSystem(true);
inner.schedule();
return Status.OK_STATUS;
}Example 7
| Project: spring-ide-master File: ColumnViewerAnimator.java View source code |
private void ensureJob() {
if (job == null) {
job = new UIJob("Animate table icons") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!tv.getControl().isDisposed()) {
animationCounter++;
for (CellAnimation a : getAnimations()) {
Image[] imgs = a.imgs;
if (a.item.isDisposed()) {
//See bug: https://www.pivotaltracker.com/story/show/100608788
stopAnimation(a);
} else {
a.item.setImage(imgs[animationCounter % imgs.length]);
}
}
if (job != null && animatedElements.size() > 0) {
job.schedule(INTERVAL);
}
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
}
}Example 8
| Project: Arcum-master File: EclipseUtil.java View source code |
public static void refreshPackageExplorer() {
UIJob job = new UIJob("Refresh Package Explorer") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
PackageExplorerPart explorer;
explorer = PackageExplorerPart.getFromActivePerspective();
if (explorer != null) {
explorer.getTreeViewer().refresh();
}
return Status.OK_STATUS;
}
};
job.schedule();
}Example 9
| Project: eclipse-integration-gradle-master File: DisableGradleNatureAction.java View source code |
@Override
public void run(IAction action) {
new UIJob("Removing Gradle Nature") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
monitor.beginTask("Removing Gradle Natures", getProjects().size());
try {
for (IProject project : getProjects()) {
NatureUtils.remove(project, GradleNature.NATURE_ID, monitor);
monitor.worked(1);
}
} catch (CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
}
}.schedule();
}Example 10
| Project: eclipse-pmd-master File: ValidationJob.java View source code |
@Override
protected IStatus run(final IProgressMonitor monitor) {
monitor.beginTask("Validating...", IProgressMonitor.UNKNOWN);
try {
final ValidationResult result = new ValidationResult();
model.validate(propertyName, result);
final UIJob uijob = new UIJob("ValidationJob") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
model.setValidationResult(result);
return Status.OK_STATUS;
}
};
uijob.schedule();
} finally {
monitor.done();
}
return Status.OK_STATUS;
}Example 11
| Project: jbosstools-base-master File: ConfigureProblemSeverityMarkerResolution.java View source code |
public void run(IMarker marker) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"") {
public IStatus runInUIThread(IProgressMonitor monitor) {
IEclipsePreferences projectPreferences = preferences.getProjectPreferences(project);
String projectValue = null;
if (projectPreferences != null) {
projectValue = projectPreferences.get(preferenceKey, null);
}
if (projectValue != null) {
PreferencesUtil.createPropertyDialogOn(DebugUIPlugin.getShell(), project, ConfigureProblemSeverityMarkerResolution.this.propertyPageId, new String[] { ConfigureProblemSeverityMarkerResolution.this.preferencePageId }, ConfigureProblemSeverityMarkerResolution.this.preferenceKey).open();
} else {
PreferencesUtil.createPreferenceDialogOn(DebugUIPlugin.getShell(), ConfigureProblemSeverityMarkerResolution.this.preferencePageId, new String[] { ConfigureProblemSeverityMarkerResolution.this.preferencePageId }, ConfigureProblemSeverityMarkerResolution.this.preferenceKey).open();
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.setPriority(Job.INTERACTIVE);
job.schedule();
}Example 12
| Project: mylyn.builds-master File: BuildsStartup.java View source code |
public void earlyStartup() {
UIJob job = new UIJob("Initializing Builds View") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage != null) {
for (IViewReference view : activePage.getViewReferences()) {
if (view.getId().equals(BuildsUiConstants.ID_VIEW_BUILDS)) {
// ensure that build view decoration is accurate
activePage.showView(BuildsUiConstants.ID_VIEW_BUILDS, null, IWorkbenchPage.VIEW_CREATE);
}
}
}
}
// FIXME trigger refresh job
} catch (PartInitException e) {
StatusHandler.log(new Status(IStatus.ERROR, BuildsUiPlugin.ID_PLUGIN, "Unexpected error during initialization of Builds View", e));
}
return Status.OK_STATUS;
}
};
job.schedule();
}Example 13
| Project: rdt-master File: BrowserView.java View source code |
@Override
public void createPartControl(Composite parent) {
try {
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser = browserSupport.getExternalBrowser();
browser.openURL(new URL(getURL()));
} catch (PartInitException e) {
RubyCore.log(e);
} catch (MalformedURLException e) {
RubyCore.log(e);
}
final ViewPart self = this;
Job job = new UIJob("") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
self.getSite().getPage().hideView(self);
self.dispose();
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.setPriority(Job.INTERACTIVE);
job.schedule();
}Example 14
| Project: statecharts-master File: SCTPerspectiveManager.java View source code |
protected void schedulePerspectiveSwitchJob(final String perspectiveID) {
Job switchJob = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
DebugUIPlugin.getStandardDisplay(), //$NON-NLS-1$
"Perspective Switch Job") {
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
if (window != null && !(isCurrentPerspective(window, perspectiveID))) {
switchToPerspective(window, perspectiveID);
}
// Force the debug view to open
if (window != null) {
try {
window.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DEBUG_VIEW_ID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
return Status.OK_STATUS;
}
};
switchJob.setSystem(true);
switchJob.setPriority(Job.INTERACTIVE);
switchJob.setRule(AsynchronousSchedulingRuleFactory.getDefault().newSerialPerObjectRule(this));
switchJob.schedule();
}Example 15
| Project: studio2-master File: TestSelectionFormattingAction.java View source code |
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
try {
IProject project = ProjectTestUtils.createProject("test format");
Path path = //$NON-NLS-1$
ProjectTestUtils.findFileInPlugin(//$NON-NLS-1$
"com.aptana.ide.editors.junit", "format/dojo.js");
IFile file = ProjectTestUtils.addFileToProject(path, project);
final JSEditor editor = (JSEditor) ProjectTestUtils.openInEditor(file, ProjectTestUtils.JS_EDITOR_ID);
final StyledText text = editor.getViewer().getTextWidget();
final IDocument document = editor.getViewer().getDocument();
UIJob cpJob = new UIJob("Copy Pasting") {
int currentIndex = 0;
int currentLenght = 1;
int errors = 0;
public IStatus runInUIThread(IProgressMonitor monitor) {
final String original = document.get();
CodeFormatAction action = new CodeFormatAction();
action.setActiveEditor(null, editor);
try {
String finalString = null;
if (currentIndex < document.getLength()) {
text.setSelection(currentIndex, currentLenght);
action.run();
finalString = text.getText();
if (!finalString.equals(original)) {
document.set(original);
System.out.println("Selection Formatting Error:" + errors + " Position:" + currentIndex + " Length:" + currentLenght);
errors++;
}
if (currentLenght < document.getLength()) {
currentLenght++;
} else {
currentIndex++;
currentLenght = 1;
}
}
} catch (Exception e) {
}
this.schedule(100);
return Status.OK_STATUS;
}
};
cpJob.schedule();
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Error formatting", e.getMessage());
}
}Example 16
| Project: virgo.ide-master File: RuntimeListener.java View source code |
public void runtimeRemoved(IRuntime runtime) {
if (runtime.getRuntimeType().getId().startsWith(VirgoRuntimeProvider.SERVER_VIRGO_BASE)) {
final String name = runtime.getName();
UIJob job = new //$NON-NLS-1$
WorkbenchJob(//$NON-NLS-1$
"RemoveVirgoTargetPlatform") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (PDEHelper.existsTargetDefinition(name)) {
boolean delete = MessageDialog.openQuestion(getDisplay().getActiveShell(), "Delete target platform?", "A Virgo Runtime has been deleted. Do you also want to delete the associated PDE Target Platform?");
if (delete) {
PDEHelper.deleteTargetDefinition(name);
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}
}Example 17
| Project: org.eclipse.rap-master File: DeferredTreeContentManager.java View source code |
/** * Create a UIJob to add the children to the parent in the tree viewer. * * @param parent * @param children * @param monitor */ protected void addChildren(final Object parent, final Object[] children, IProgressMonitor monitor) { WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.get().DeferredTreeContentManager_AddingChildren) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor updateMonitor) { // Cancel the job if the tree viewer got closed if (treeViewer.getControl().isDisposed() || updateMonitor.isCanceled()) { return Status.CANCEL_STATUS; } treeViewer.add(parent, children); return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(); }
Example 18
| Project: rap-master File: DeferredTreeContentManager.java View source code |
/** * Create a UIJob to add the children to the parent in the tree viewer. * * @param parent * @param children * @param monitor */ protected void addChildren(final Object parent, final Object[] children, IProgressMonitor monitor) { WorkbenchJob updateJob = new WorkbenchJob(display, ProgressMessages.get(display).DeferredTreeContentManager_AddingChildren) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor updateMonitor) { // Cancel the job if the tree viewer got closed if (treeViewer.getControl().isDisposed() || updateMonitor.isCanceled()) { return Status.CANCEL_STATUS; } treeViewer.add(parent, children); return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(); }
Example 19
| Project: yoursway-sunrise-master File: DeferredTreeContentManager.java View source code |
/** * Create a UIJob to add the children to the parent in the tree viewer. * * @param parent * @param children * @param monitor */ protected void addChildren(final Object parent, final Object[] children, IProgressMonitor monitor) { WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.DeferredTreeContentManager_AddingChildren) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor updateMonitor) { // Cancel the job if the tree viewer got closed if (treeViewer.getControl().isDisposed() || updateMonitor.isCanceled()) { return Status.CANCEL_STATUS; } treeViewer.add(parent, children); return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(); }
Example 20
| Project: arduino-eclipse-plugin-master File: Activator.java View source code |
private static void runGUIRegistration() {
UIJob installJob = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Gui Registration") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
ProjectExplorerListener.registerListener();
return Status.OK_STATUS;
}
};
installJob.setPriority(Job.BUILD);
installJob.setUser(true);
installJob.schedule();
}Example 21
| Project: earthsci-master File: EditorLineSupport.java View source code |
private UIJob getRefreshJob() { if (refreshJob == null) { refreshJob = new UIJob(Display.getDefault(), "Refersh Editor Line") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { doRefresh(); return Status.OK_STATUS; } }; refreshJob.setUser(false); refreshJob.setSystem(true); } return refreshJob; }
Example 22
| Project: eclipse-gov.redhawk.core-master File: Activator.java View source code |
public void playPorts(final List<ScaUsesPort> portList) {
final UIJob job = new UIJob("Starting Play Port") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
monitor.beginTask("Opening Play Port View", IProgressMonitor.UNKNOWN);
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page != null) {
PlayAudioView view;
try {
view = (PlayAudioView) page.showView(PlayAudioView.ID);
for (ScaUsesPort port : portList) {
view.playPort(port);
}
PortHelper.refreshPorts(portList, monitor);
} catch (final PartInitException e) {
getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error finding Play Port View", e));
}
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}Example 23
| Project: eclipse.jdt.debug-master File: JavaObjectValueEditor.java View source code |
/**
* Evaluates the given expression and sets the given variable's value
* using the result.
*
* @param variable the variable whose value should be set
* @param expression the expression to evaluate
* @throws DebugException if an exception occurs evaluating the expression
* or setting the variable's value
*/
protected void setValue(final IVariable variable, final String expression) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Setting Variable Value") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
IValue newValue = evaluate(expression);
if (newValue != null) {
variable.setValue(newValue);
} else {
variable.setValue(expression);
}
} catch (DebugException de) {
handleException(de);
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}Example 24
| Project: eclipse.platform.ui-master File: UIJobTest.java View source code |
/**
* Test to ensure that calling join() on a UIJob will block the calling
* thread until the job has finished.
*
* @throws Exception
* @since 3.1
*/
public void testJoin() throws Exception {
uiJobFinished = false;
backgroundThreadStarted = false;
backgroundThreadFinished = false;
backgroundThreadInterrupted = false;
uiJobFinishedBeforeBackgroundThread = false;
final UIJob testJob = new UIJob("blah blah blah") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
backgroundThreadFinishedBeforeUIJob = backgroundThreadFinished;
uiJobFinished = true;
return Status.OK_STATUS;
}
};
testJob.setPriority(Job.INTERACTIVE);
// Background thread that will try to schedule and join a UIJob. If all goes well
// it should lock up since we're intentionally blocking the UI thread, preventing
// it from running.
Thread testThread = new Thread() {
@Override
public void run() {
testJob.schedule();
backgroundThreadStarted = true;
try {
testJob.join();
uiJobFinishedBeforeBackgroundThread = uiJobFinished;
backgroundThreadFinished = true;
} catch (InterruptedException e) {
backgroundThreadInterrupted = true;
}
}
};
// This job does nothing. We use a bogus low-priority job instead of a simple
// sleep(xxxx) in order to ensure that we don't wake up before the test job was
// scheduled.
Job delayJob = new Job("blah") {
@Override
protected IStatus run(IProgressMonitor monitor) {
return Status.OK_STATUS;
}
};
delayJob.setPriority(Job.LONG);
try {
// Schedule the test thread
testThread.start();
// Measure current time
long currentTime = System.currentTimeMillis();
// We need to create a situation in which the run() method of the UIJob will have
// been called and exited, but the runInUIThread() method will not have been called.
// We then put everything else to sleep, making a high probability that the background
// thread would wake up if there was nothing blocking it. Note: it is possible that the
// test would still pass if there was a problem and the background thread failed to
// wake up for reasons other than its join()... but it creates a high probability of
// things failing if something goes wrong.
//
// The point of this join() is to block the UI thread, making it impossible to
// run *syncExecs. Joining a low priority job means that the UIJob should get
// scheduled first (meaning its run(...) method will be called). The fact that we're
// in the UI thread right now means that the UIJob's runInUIThread method shouldn't
// be called.
// Block the UI thread until the UIJob's run() method is called.
delayJob.schedule(200);
delayJob.join();
long finalTime = System.currentTimeMillis();
// Ensure that we slept for at least 200ms
Assert.assertTrue("We tried to sleep the UI thread, but it woke up too early. ", finalTime - currentTime >= 200);
Assert.assertTrue("Background thread did not start, so there was no possibility " + "of testing whether its behavior was correct. This is not a test failure. " + "It means we were unable to run the test. ", backgroundThreadStarted);
Assert.assertFalse("A UI job somehow ran to completion while the UI thread was blocked", uiJobFinished);
Assert.assertFalse("Background job managed to run to completion, even though it joined a UI thread that still hasn't finished", backgroundThreadFinished);
Assert.assertFalse("Background thread was interrupted", backgroundThreadInterrupted);
// Now run the event loop. Give the asyncExec a chance to run.
//Use the display provided by the shell if possible
Display display = fWindow.getShell().getDisplay();
// probably deadlocked.
while (!(uiJobFinished && backgroundThreadFinished)) {
// If we've waited more than 3s for the test job to run, then something is wrong.
if (finalTime - System.currentTimeMillis() > 3000) {
break;
}
if (!display.readAndDispatch()) {
display.sleep();
}
}
// Now that the event queue is empty, check that our final state is okay.
Assert.assertTrue("Background thread did not finish (possible deadlock)", backgroundThreadFinished);
Assert.assertTrue("Test job did not finish (possible deadlock)", uiJobFinished);
Assert.assertFalse("Background thread was interrupted ", backgroundThreadInterrupted);
Assert.assertFalse("Background thread finished before the UIJob, even though the background thread was supposed to be waiting for the UIJob", backgroundThreadFinishedBeforeUIJob);
// This is the whole point of the test: ensure that the background job actually waited for the UI job
// to run to completion.
Assert.assertFalse("Background thread finished before the UIJob, even though the background thread was supposed to be waiting for the UIJob", backgroundThreadFinishedBeforeUIJob);
// Paranoia check: this is really the same test as above, but it confirms that both
// threads agreed on the answer.
Assert.assertTrue("Background thread finished before the UIJob, even though the background thread was supposed to be waiting for the UIJob", uiJobFinishedBeforeBackgroundThread);
} finally {
}
}Example 25
| Project: groovy-eclipse-master File: DebuggerPreferencesPage.java View source code |
@Override
public boolean performOk() {
if (doForceOptions) {
// ensures that this runs after the preference page closes
// otherwise the forcing might be overridden by the actual Java Step
// Filter preferences page
UIJob job = new UIJob(this.getShell().getDisplay(), "Setting Groovy debug options") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
new GroovyDebugOptionsEnforcer().force();
return Status.OK_STATUS;
}
};
job.schedule();
}
return super.performOk();
}Example 26
| Project: jbosstools-openshift-master File: RestoreSnapshotWizard.java View source code |
@Override
public boolean performFinish() {
final IApplication application = getModel().getApplication();
final String applicationName = application.getName();
try {
final RestoreJob restoreJob = new RestoreJob(application);
Job jobChain = new JobChainBuilder(restoreJob).runWhenDone(new UIJob(NLS.bind("Show Snapshot Restore/Deploy Output for application {0}...", applicationName)) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
MessageConsole console = ConsoleUtils.displayConsoleView(application);
if (console == null) {
return ExpressUIActivator.createCancelStatus(NLS.bind("Cound not open console for application {0}", applicationName));
}
printResponse(restoreJob.getResponse(), console);
return Status.OK_STATUS;
}
private void printResponse(String response, MessageConsole console) {
MessageConsoleStream messageStream = console.newMessageStream();
if (StringUtils.isEmpty(response)) {
messageStream.print("Done");
} else {
messageStream.print(response);
}
}
}).build();
WizardUtils.runInWizard(jobChain, getContainer());
return restoreJob.getResult().isOK();
} catch (InvocationTargetException e) {
IStatus status = ExpressUIActivator.createErrorStatus(e.getMessage(), e);
new ErrorDialog(getShell(), "Error", NLS.bind("Could not restore snapshot for application {0}", applicationName), status, IStatus.ERROR).open();
return false;
} catch (InterruptedException e) {
IStatus status = ExpressUIActivator.createErrorStatus(e.getMessage(), e);
new ErrorDialog(getShell(), "Error", NLS.bind("Could not restore snapshot for application {0}", applicationName), status, IStatus.ERROR).open();
return false;
}
}Example 27
| Project: mylyn-reviews-master File: ReviewsUiPlugin.java View source code |
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
reviewManager = new ActiveReviewManager();
//We need to schedule initialization otherwise TasksUiPlugin hasn't finished initialization.
UIJob job = new UIJob(Messages.ReviewsUiPlugin_Updating_task_review_mapping) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
taskReviewsMappingStore = new TaskReviewsMappingsStore(TasksUiPlugin.getTaskList(), TasksUiPlugin.getRepositoryManager());
TaskReviewsMappingsStore.setInstance(taskReviewsMappingStore);
TasksUiPlugin.getTaskList().addChangeListener(taskReviewsMappingStore);
Job job = new Job(Messages.ReviewsUiPlugin_Updating_task_review_mapping) {
@Override
protected IStatus run(IProgressMonitor monitor) {
taskReviewsMappingStore.readFromTaskList();
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.setUser(false);
job.schedule();
return Status.OK_STATUS;
}
};
job.schedule();
}Example 28
| Project: mylyn.incubator-master File: DefaultResourceHyperlink.java View source code |
private void openEditor(final IFile file) {
UIJob job = new UIJob("Opening resource") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
return Status.OK_STATUS;
} catch (PartInitException e) {
MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Open Resource", "Failed to open resource.");
}
return Status.CANCEL_STATUS;
}
};
job.setSystem(true);
job.schedule();
}Example 29
| Project: radrails-master File: LaunchBrowser.java View source code |
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
if (sel == null || sel.getFirstElement() == null) {
return;
}
final Server server = (Server) ((RailsServer) sel.getFirstElement()).getServer();
UIJob job = new UIJob("Opening browser") {
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
if (server == null) {
return Status.CANCEL_STATUS;
}
String port = String.valueOf(server.getPort());
BrowserUtil.openBrowser("http://" + server.getBrowserHost() + ":" + port);
} catch (Exception e) {
return new Status(Status.ERROR, "com.aptana.radrails.server.bridge", -1, e.getMessage(), e);
}
return Status.OK_STATUS;
}
};
job.schedule();
}Example 30
| Project: windup-eclipse-plugin-master File: ShowGettingStartedAction.java View source code |
/**
* Closes the intro view, opens the Windup perspective, and opens the 'getting started' editor.
*/
public static void doRun(IWorkbenchWindow window) {
UIJob job = new UIJob(Messages.showWindupGettingStarted) {
public IStatus runInUIThread(IProgressMonitor monitor) {
monitor.beginTask(Messages.showWindupGettingStarted, 1);
try {
try {
IIntroManager introMgr = window.getWorkbench().getIntroManager();
IIntroPart intro = introMgr.getIntro();
if (intro != null) {
introMgr.closeIntro(intro);
}
PlatformUI.getWorkbench().showPerspective(WindupPerspective.ID, window);
monitor.worked(1);
window.getActivePage().openEditor(EditorInput.INSTANCE, GettingStartedEditor.VIEW_ID);
return Status.OK_STATUS;
} catch (Throwable e) {
WindupUIPlugin.log(e);
}
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
job.schedule();
}Example 31
| Project: yang-ide-master File: DiagramModelMergeAdapter.java View source code |
@Override
public void notifyChanged(final Notification notification) {
if (notification.getEventType() != Notification.REMOVING_ADAPTER && notification.getFeature() != ModelPackage.Literals.NODE__PARENT) {
switch(notification.getEventType()) {
case Notification.ADD:
if (notification.getFeature() == ModelPackage.Literals.CONTAINING_NODE__CHILDREN) {
final Node node = (Node) notification.getNewValue();
final Node parent = (Node) notification.getNotifier();
new UIJob("Update diagram from source") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
modelChangeHandler.nodeAdded(parent, node, notification.getPosition());
return Status.OK_STATUS;
}
}.schedule();
}
break;
case Notification.REMOVE:
if (notification.getOldValue() instanceof Node && notification.getOldValue() != null) {
final Node node = (Node) notification.getOldValue();
new UIJob("Update diagram from source") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
modelChangeHandler.nodeRemoved(node);
return Status.OK_STATUS;
}
}.schedule();
}
break;
case Notification.SET:
if (notification.getNotifier() instanceof Node && notification.getFeature() instanceof EAttribute) {
final Node node = (Node) notification.getNotifier();
new UIJob("Update diagram from source") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
modelChangeHandler.nodeChanged(node, (EAttribute) notification.getFeature(), notification.getNewValue());
return Status.OK_STATUS;
}
}.schedule();
}
break;
default:
break;
}
}
super.notifyChanged(notification);
}Example 32
| Project: ArchStudio5-master File: AbstractToggleNatureObjectActionDelegate.java View source code |
@Override
public void earlyStartup() {
// Necessary to initialize toggle state
// see: http://wiki.eclipse.org/Menu_Contributions/Radio_Button_Command#Initializing_the_Handler
UIJob job = new UIJob("InitCommandsWorkaround") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
Command command = commandService.getCommand(commandID);
// force initialization of command
command.isEnabled();
System.err.println(commandID + " " + natureID + " " + command.isDefined() + " " + command.isEnabled());
return new Status(IStatus.OK, commandID, "Init commands workaround performed succesfully");
} catch (Throwable t) {
return new Status(IStatus.ERROR, commandID, "Init commands workaround failed", t);
}
}
};
job.schedule();
}Example 33
| Project: bpmn2-modeler-master File: Bpmn2PropertyPageRedrawHandler.java View source code |
/** * Schedule a redraw. If the UIJob is already running but in a WAIT * state, cancel and reschedule it. */ private synchronized void scheduleRedrawPage() { if (job == null) { job = new //$NON-NLS-1$ UIJob(//$NON-NLS-1$ "BPMN2 Property Page redraw") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { try { doRedrawPage(); } catch (Exception e) { } return Status.OK_STATUS; } }; } if (job.getState() == Job.WAITING) job.cancel(); job.schedule(UIJOB_INTERRUPT_INTERVAL); }
Example 34
| Project: ch.hsr.ifs.cdttesting-master File: OutlinePage.java View source code |
public void update() {
new UIJob("UpdateOutline") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
final OutlineTreeViewer viewer = (OutlineTreeViewer) OutlinePage.this.getTreeViewer();
if (viewer != null) {
viewer.saveExpandedState();
final Control control = viewer.getControl();
if (control != null && !control.isDisposed()) {
control.setRedraw(false);
viewer.setInput(OutlinePage.this.input);
viewer.loadExpandedState();
control.setRedraw(true);
}
}
return new Status(0, Activator.PLUGIN_ID, 0, "ok", (Throwable) null);
}
}.schedule();
}Example 35
| Project: dawn-isenciaui-master File: PasserellePreferencePage.java View source code |
@Override
public boolean performOk() {
boolean result = super.performOk();
if (result) {
String newSubmodelRoot = Activator.getDefault().getPreferenceStore().getString(RepositoryService.SUBMODEL_ROOT);
if (submodelPath != null && !submodelPath.equalsIgnoreCase(newSubmodelRoot)) {
if (getContainer() instanceof IWorkbenchPreferenceContainer) {
IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
UIJob job = new UIJob("Restart request") {
public IStatus runInUIThread(IProgressMonitor monitor) {
// make sure they really want to do this
int really = new MessageDialog(null, "Submodel configuration change", null, "Changing the submodel root will require restarting the workbench to complete the change. Restart now?", MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1).open();
if (really == Window.OK) {
PlatformUI.getWorkbench().restart();
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
container.registerUpdateJob(job);
}
}
}
return result;
}Example 36
| Project: Eclipse-EGit-master File: EditHandler.java View source code |
private void openStagingAndRebaseInteractiveViews(final Repository repository) {
Job job = new UIJob(UIText.EditHandler_OpenStagingAndRebaseInteractiveViews) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
final StagingView stagingView = (StagingView) workbenchPage.showView(StagingView.VIEW_ID);
stagingView.reload(repository);
stagingView.setAmending(true);
RebaseInteractiveView rebaseView = (RebaseInteractiveView) workbenchPage.showView(RebaseInteractiveView.VIEW_ID);
rebaseView.setInput(repository);
} catch (PartInitException e) {
Activator.logError(e.getMessage(), e);
}
return Status.OK_STATUS;
}
};
job.setRule(RuleUtil.getRule(repository));
job.setUser(true);
job.schedule();
}Example 37
| Project: eclipse-integration-cloudfoundry-master File: PartsWizardPage.java View source code |
/**
* Runs the specified runnable asynchronously in a worker thread. Caller is
* responsible for ensuring that any UI behaviour in the runnable is
* executed in the UI thread, either synchronously (synch exec through
* {@link Display} or asynch through {@link Display} or {@link UIJob}).
* @param runnable
* @param operationLabel
*/
protected void runAsynchWithWizardProgress(final ICoreRunnable runnable, String operationLabel) {
if (runnable == null) {
return;
}
if (operationLabel == null) {
//$NON-NLS-1$
operationLabel = "";
}
// Asynch launch as a UI job, as the wizard messages get updated before
// and after the forked operation
UIJob job = new UIJob(operationLabel) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
CoreException cex = null;
try {
// Fork in a worker thread.
CloudUiUtil.runForked(runnable, getWizard().getContainer());
} catch (OperationCanceledException e) {
} catch (CoreException ce) {
cex = ce;
}
// complete the wizard with manual values.
if (cex != null) {
CloudFoundryPlugin.logError(cex);
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}Example 38
| Project: eclipse-integration-commons-master File: IdeUiPlugin.java View source code |
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// avoid cyclic startup dependency on org.eclipse.mylyn.tasks.ui
Job startupJob = new UIJob("Spring Tool Suite Initialization") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
migrateBlogFeeds();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
// prevent loading if already opened by workspace
// restore
IEditorReference[] references = window.getActivePage().getEditorReferences();
for (IEditorReference reference : references) {
if (DashboardEditorInputFactory.FACTORY_ID.equals(reference.getFactoryId())) {
return;
}
}
if (getPreferenceStore().getBoolean(IIdeUiConstants.PREF_OPEN_DASHBOARD_STARTUP)) {
// don't show if welcome page is visible
if (window.getWorkbench().getIntroManager().getIntro() != null) {
// scheduleUpdateJob();
return;
}
ShowDashboardAction showDashboard = new ShowDashboardAction();
showDashboard.init(window);
showDashboard.run(null);
return;
}
}
// scheduleUpdateJob();
}
});
return Status.OK_STATUS;
}
};
startupJob.setSystem(true);
startupJob.schedule();
}Example 39
| Project: eclipse-mpc-master File: MarketplaceDropAdapter.java View source code |
public void earlyStartup() {
UIJob registerJob = new UIJob(Display.getDefault(), Messages.MarketplaceDropAdapter_0) {
{
setPriority(Job.DECORATE);
}
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow window : workbenchWindows) {
Shell shell = window.getShell();
installDropTarget(shell);
}
return Status.OK_STATUS;
}
};
registerJob.schedule();
}Example 40
| Project: eclipsefp-master File: ReferencesWorkspaceHandler.java View source code |
@Override
public void handle(final EditorThing thing) {
if (thing != null) {
final UsageQuery uq = getUsageQuery(haskellEditor, project, thing.getThing());
new UIJob(UITexts.openDefinition_select_job) {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
NewSearchUI.runQueryInBackground(uq, p);
return Status.OK_STATUS;
}
}.schedule();
}
}Example 41
| Project: ecoretools-master File: EClassHierarchyView.java View source code |
private Job createRefreshHierarchyJob(final EClass selection) {
Job job = new WorkbenchJob(Messages.EClassHierarchyView_RefreshHierarchy) {
/**
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (hierarchyTree.getControl().isDisposed()) {
return Status.CANCEL_STATUS;
}
try {
hierarchyTree.getControl().setRedraw(false);
hierarchyTree.setInput(new EClass[] { selection });
hierarchyTree.refresh();
hierarchyTree.expandToLevel(2);
hierarchyTree.setSelection(new StructuredSelection(selection), true);
} finally {
// done updating the tree - set redraw back to true
hierarchyTree.getControl().setRedraw(true);
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
return job;
}Example 42
| Project: EGit-master File: EditHandler.java View source code |
private void openStagingAndRebaseInteractiveViews(final Repository repository) {
Job job = new UIJob(UIText.EditHandler_OpenStagingAndRebaseInteractiveViews) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
final StagingView stagingView = (StagingView) workbenchPage.showView(StagingView.VIEW_ID);
stagingView.reload(repository);
stagingView.setAmending(true);
RebaseInteractiveView rebaseView = (RebaseInteractiveView) workbenchPage.showView(RebaseInteractiveView.VIEW_ID);
rebaseView.setInput(repository);
} catch (PartInitException e) {
Activator.logError(e.getMessage(), e);
}
return Status.OK_STATUS;
}
};
job.setRule(RuleUtil.getRule(repository));
job.setUser(true);
job.schedule();
}Example 43
| Project: emf-compare-master File: E4DeferredTreeContentManager.java View source code |
@Override
protected void addChildren(final Object parent, final Object[] children, final IProgressMonitor monitor) {
UIJob updateJob = new UIJob(Display.getDefault(), ProgressMessages.DeferredTreeContentManager_AddingChildren) {
@Override
public IStatus runInUIThread(IProgressMonitor updateMonitor) {
// Cancel the job if the tree viewer got closed
if (treeViewer.getControl().isDisposed() || updateMonitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
treeViewer.add(parent, children);
return Status.OK_STATUS;
}
};
updateJob.setSystem(true);
updateJob.schedule();
}Example 44
| Project: emf.compare-master File: E4DeferredTreeContentManager.java View source code |
@Override
protected void addChildren(final Object parent, final Object[] children, final IProgressMonitor monitor) {
UIJob updateJob = new UIJob(Display.getDefault(), ProgressMessages.DeferredTreeContentManager_AddingChildren) {
@Override
public IStatus runInUIThread(IProgressMonitor updateMonitor) {
// Cancel the job if the tree viewer got closed
if (treeViewer.getControl().isDisposed() || updateMonitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
treeViewer.add(parent, children);
return Status.OK_STATUS;
}
};
updateJob.setSystem(true);
updateJob.schedule();
}Example 45
| Project: epp.mpc-master File: DiscoverFileSupportJob.java View source code |
private IStatus run(IMarketplaceService marketplaceService, IProgressMonitor monitor) {
final String fileExtension = getFileExtension(fileName);
String fileExtensionTag = getFileExtensionTag(fileExtension);
final List<? extends INode> nodes;
try {
ISearchResult searchResult = marketplaceService.tagged(fileExtensionTag, monitor);
nodes = searchResult.getNodes();
} catch (CoreException ex) {
return new Status(IStatus.ERROR, MarketplaceClientUiPlugin.getInstance().getBundle().getSymbolicName(), ex.getMessage(), ex);
}
if (nodes.isEmpty()) {
return Status.OK_STATUS;
}
UIJob openDialog = new ShowFileSupportProposalsJob(fileName, nodes, editorRegistry, defaultDescriptor, display);
openDialog.setPriority(Job.INTERACTIVE);
openDialog.setSystem(true);
openDialog.schedule();
return Status.OK_STATUS;
}Example 46
| Project: FURCAS-master File: PreferenceInitializer.java View source code |
public void initializeDefaultPreferences() {
if (Display.getCurrent() == null) {
// This isn't the UI thread, so schedule a job to do the initialization later.
UIJob job = new UIJob("IMP Preference Initializer") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (// this should never be false, but let's be safe
Display.getCurrent() != null) {
new PreferenceInitializer().initializeDefaultPreferences();
}
return Status.OK_STATUS;
}
};
job.schedule(0);
return;
}
IPreferenceStore store = RuntimePlugin.getInstance().getPreferenceStore();
FontData fontData = findSuitableFont();
if (fontData != null) {
// System.out.println("Using font " + fontData.getName() + " at height " + fontData.getHeight());
PreferenceConverter.setDefault(store, PreferenceConstants.P_SOURCE_FONT, new FontData[] { fontData });
}
store.setDefault(PreferenceConstants.P_EMIT_MESSAGES, false);
store.setDefault(PreferenceConstants.P_EMIT_BUILDER_DIAGNOSTICS, false);
store.setDefault(PreferenceConstants.P_TAB_WIDTH, 8);
store.setDefault(PreferenceConstants.P_SPACES_FOR_TABS, false);
store.setDefault(PreferenceConstants.P_DUMP_TOKENS, false);
store.setDefault(PreferenceConstants.EDITOR_MATCHING_BRACKETS, true);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, false);
String colorKey = RuntimePlugin.IMP_RUNTIME + "." + PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
ColorRegistry registry = null;
if (PlatformUI.isWorkbenchRunning()) {
registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
}
PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, findRGB(registry, colorKey, new RGB(192, 192, 192)));
}Example 47
| Project: gda-dal-master File: SimpleSliderEditPart.java View source code |
@Override
public void sliderValueChanged(final double newValue) {
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
model.setPropertyManualValue(SimpleSliderModel.PROP_VALUE, newValue);
slider.setManualValue(newValue);
if (_resetManualValueDisplayJob == null) {
_resetManualValueDisplayJob = new UIJob("reset") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
slider.setManualValue(model.getValue());
slider.setValue(model.getValue());
return Status.OK_STATUS;
}
};
}
_resetManualValueDisplayJob.schedule(5000);
} else {
LOG.info("Slider value changed");
}
}Example 48
| Project: HBuilder-opensource-master File: PyRenameInFileAction.java View source code |
/**
* As soon as the reparse is done, this method is called to actually make the rename.
*/
public void parserChanged(ISimpleNode root, IAdaptable file, IDocument doc) {
//we'll only listen for this single parse
pyEdit.getParser().removeParseListener(this);
/**
* Create an ui job to actually make the rename (otherwise we can't make ui.enter() nor create a PySelection.)
*/
UIJob job = new UIJob("Rename") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
ISourceViewer viewer = pyEdit.getPySourceViewer();
IDocument document = viewer.getDocument();
PySelection ps = new PySelection(pyEdit);
LinkedPositionGroup group = new LinkedPositionGroup();
if (!fillWithOccurrences(document, group, new NullProgressMonitor(), ps)) {
return Status.OK_STATUS;
}
if (group.isEmpty()) {
return Status.OK_STATUS;
}
LinkedModeModel model = new LinkedModeModel();
model.addGroup(group);
if (model.tryInstall() && model.getTabStopSequence().size() > 0) {
final LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
Tuple<String, Integer> currToken = ps.getCurrToken();
ui.setCyclingMode(LinkedModeUI.CYCLE_ALWAYS);
ui.setExitPosition(viewer, currToken.o2 + currToken.o1.length(), 0, 0);
ui.enter();
}
} catch (BadLocationException e) {
Log.log(e);
} catch (Throwable e) {
Log.log(e);
}
return Status.OK_STATUS;
}
};
job.setPriority(Job.INTERACTIVE);
job.schedule();
}Example 49
| Project: jbosstools-javaee-master File: CreateJSF2CompositeMenuTest.java View source code |
public void testMenu() {
fileName = PAGE_NAME;
IFile testfile = project.getFile(fileName);
assertTrue("Test file doesn't exist: " + project.getName() + "/" + fileName, (testfile.exists() && testfile.isAccessible()));
//$NON-NLS-1$
editorPart = WorkbenchUtils.openEditor(project.getName() + "/" + fileName);
obtainTextEditor(editorPart);
UIJob registerJob = new UIJob(Display.getDefault(), "JBoss Central DND initialization") {
{
setPriority(Job.DECORATE);
}
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
viewer = getTextViewer();
Menu menu = viewer.getTextWidget().getMenu();
Listener[] listeners = menu.getListeners(SWT.Show);
assertTrue("No listeners found in context menu", listeners.length > 0);
for (Listener listener : listeners) {
if (listener instanceof TypedListener) {
TypedListener tl = (TypedListener) listener;
if (tl.getEventListener() instanceof MenuListener) {
MenuListener ml = (MenuListener) tl.getEventListener();
Event event = new Event();
event.widget = viewer.getTextWidget();
event.display = viewer.getTextWidget().getDisplay();
event.time = (int) System.currentTimeMillis();
ml.menuShown(new MenuEvent(event));
} else {
fail("Event listener should be instance of MenuListener");
}
} else {
fail("listener should be instance of TypedListener");
}
}
menu.setVisible(true);
MenuItem[] items = menu.getItems();
assertTrue("No items found in context menu", items.length > 0);
for (MenuItem item : items) {
if ("Create JSF2 composite...".equals(item.getText())) {
// found
return null;
}
}
fail("Create JSF2 composite... menu item not found");
return null;
}
};
}Example 50
| Project: jenkow-plugin-master File: ProjectTreeContentProvider.java View source code |
@Override
public boolean visit(final IResourceDelta delta) throws CoreException {
IResource source = delta.getResource();
switch(source.getType()) {
case IResource.ROOT:
case IResource.PROJECT:
final IProject project = (IProject) source;
if (isActivitiProject(project)) {
updateModel(project);
new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Update Project Model in CommonViewer") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (getStructuredViewer() != null && !getStructuredViewer().getControl().isDisposed()) {
getStructuredViewer().refresh(project);
}
return Status.OK_STATUS;
}
}.schedule();
}
return false;
case IResource.FOLDER:
return true;
case IResource.FILE:
}
return false;
}Example 51
| Project: makegood-master File: TestOutlineViewController.java View source code |
private void updateTestOutline() {
Job job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"MakeGood Test Outline View Updated") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
TestOutlineView view = (TestOutlineView) ViewOpener.find(TestOutlineView.ID);
if (view != null) {
view.updateTestOutline();
}
return Status.OK_STATUS;
}
};
job.schedule();
}Example 52
| Project: Neo4EMF-master File: OpenNeo4emfDbCommand.java View source code |
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
ISelectionService service = window.getSelectionService();
ISelection selection = service.getSelection();
folder = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object elt = structuredSelection.getFirstElement();
if (elt instanceof IFolder) {
folder = (IFolder) elt;
}
}
if (folder == null)
return null;
new UIJob(window.getShell().getDisplay(), "Create Dynamic Instance") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
URI uri = URI.createURI("neo4emf:" + folder.getLocationURI().getRawSchemeSpecificPart());
URIEditorInput editorInput = new URIEditorInput(uri);
if (editorInput != null) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
page.openEditor(editorInput, Neo4emfEditor.EDITOR_ID);
} catch (PartInitException e) {
return new Status(IStatus.ERROR, Neo4emfUiPlugin.PLUGIN_ID, "Unable to open editor", e);
}
}
return Status.OK_STATUS;
}
}.schedule();
return null;
}Example 53
| Project: olca-app-master File: Popup.java View source code |
public void show() {
UIJob job = new UIJob("Open popup") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
Display display = getDisplay();
if (display == null || display.isDisposed())
return Status.CANCEL_STATUS;
new PopupImpl(display).open();
return Status.OK_STATUS;
}
};
job.schedule();
}Example 54
| Project: overture-master File: OpenVdmToolsProjectCommandHandler.java View source code |
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
final IContainer c = (IContainer) selection.getFirstElement();
final IProject project = c.getProject();
final IVdmProject vdmProject = (IVdmProject) project.getAdapter(IVdmProject.class);
if (vdmProject != null) {
final List<File> files = new Vector<File>();
try {
for (IVdmSourceUnit source : vdmProject.getSpecFiles()) {
files.add(source.getSystemFile());
}
UIJob job = new UIJob("Create VDM Tools Project") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
new VdmTools().createProject(this.getDisplay().getActiveShell(), vdmProject, files);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (IOException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to open VDM Tools", e);
} catch (CoreException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to open VDM Tools", e);
}
return Status.OK_STATUS;
}
};
job.schedule();
} catch (CoreException e) {
e.printStackTrace();
}
}
return null;
}Example 55
| Project: tracecompass-master File: BaseAddContextHandler.java View source code |
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
fLock.lock();
try {
CommandParameter tmpParam = fParam;
if (tmpParam == null) {
return null;
}
// Make a copy for thread safety
final CommandParameter param = tmpParam.clone();
UIJob getJob = new UIJob(Messages.TraceControl_GetContextJob) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
final List<String> availableContexts = param.getSession().getContextList(monitor);
final IAddContextDialog dialog = TraceControlDialogFactory.getInstance().getAddContextDialog();
dialog.setAvalibleContexts(availableContexts);
if ((dialog.open() != Window.OK) || (dialog.getContexts().isEmpty())) {
return Status.OK_STATUS;
}
Job addJob = new Job(Messages.TraceControl_AddContextJob) {
@Override
protected IStatus run(IProgressMonitor monitor2) {
Exception error = null;
try {
List<String> contextNames = dialog.getContexts();
addContexts(param, contextNames, monitor2);
} catch (ExecutionException e) {
error = e;
}
// get session configuration in all cases
refresh(param);
if (error != null) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_AddContextFailure, error);
}
return Status.OK_STATUS;
}
};
addJob.setUser(true);
addJob.schedule();
} catch (ExecutionException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_GetContextFailure, e);
}
return Status.OK_STATUS;
}
};
getJob.setUser(false);
getJob.schedule();
} finally {
fLock.unlock();
}
return null;
}Example 56
| Project: turmeric-eclipse-master File: SOABaseWizard.java View source code |
/**
* Change perspective.
*/
protected void changePerspective() {
UIJob fNotifierJob = new UIJob("Change to Turmeric Development Perspective") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
BasicNewProjectResourceWizard.updatePerspective(fConfig);
return Status.OK_STATUS;
}
};
fNotifierJob.setSystem(true);
fNotifierJob.schedule();
}Example 57
| Project: org.eclipse.ui.ide.format.extension.patch-master File: IDEWorkbenchErrorHandler.java View source code |
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.statushandlers.WorkbenchErrorHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter,
* int)
*/
public void handle(final StatusAdapter statusAdapter, int style) {
// if fatal error occurs, we will show the blocking error dialog anyway
if (isFatal(statusAdapter)) {
// StatusManager
if (!map.containsKey(statusAdapter.getStatus())) {
map.put(statusAdapter.getStatus(), null);
} else {
return;
}
if (statusAdapter.getProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY) == Boolean.TRUE) {
statusAdapter.setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.FALSE);
}
super.handle(statusAdapter, style | StatusManager.BLOCK);
} else {
super.handle(statusAdapter, style);
}
// if fatal error occurs, we will ask to close the workbench
if (isFatal(statusAdapter)) {
UIJob handlingExceptionJob = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"IDE Exception Handler") {
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus runInUIThread(IProgressMonitor monitor) {
handleException(statusAdapter.getStatus().getException());
return new Status(IStatus.OK, IDEWorkbenchPlugin.IDE_WORKBENCH, IDEWorkbenchMessages.IDEExceptionHandler_ExceptionHandledMessage);
}
};
handlingExceptionJob.setSystem(true);
handlingExceptionJob.schedule();
}
}Example 58
| Project: archiv-editor-master File: UpdateAllDataHandler.java View source code |
@Override
public void run(final IProgressMonitor monitor) {
// Activator.getDefault().getPreferenceStore().getString("REPOSITORY_URL"));
if (monitor.isCanceled()) {
monitor.setCanceled(true);
}
final User user = Facade.getInstanz().getCurrentUser();
IUpdateManager[] updateManagers = Facade.getInstanz().getUpdateManagers();
for (IUpdateManager manager : updateManagers) {
try {
if (user != null) {
_updateStatus = manager.updateAllData(user.getPdrId().toString(), user.getAuthentication().getPassword(), monitor);
}
} catch (final XMLStreamException e) {
e.printStackTrace();
UIJob job = new UIJob("Feedbackup") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
IWorkbench workbench = PlatformUI.getWorkbench();
Display display = workbench.getDisplay();
Shell shell = new Shell(display);
String info = NLMessages.getString("Command_update_error") + "\n\n" + e.getMessage();
MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Command_update_error"), null, info, MessageDialog.ERROR, new String[] { "OK" }, 0);
infoDialog.open();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
} catch (final UnsupportedEncodingException e) {
e.printStackTrace();
UIJob job = new UIJob("Feedbackup") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
IWorkbench workbench = PlatformUI.getWorkbench();
Display display = workbench.getDisplay();
Shell shell = new Shell(display);
String info = NLMessages.getString("Command_update_error") + "\n\n" + e.getMessage();
MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Command_update_error"), null, info, MessageDialog.ERROR, new String[] { "OK" }, 0);
infoDialog.open();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
} catch (final Exception e) {
e.printStackTrace();
UIJob job = new UIJob("Feedbackup") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
IWorkbench workbench = PlatformUI.getWorkbench();
Display display = workbench.getDisplay();
Shell shell = new Shell(display);
String info = NLMessages.getString("Command_update_error") + "\n\n" + e.getMessage();
MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Command_update_error"), null, info, MessageDialog.ERROR, new String[] { "OK" }, 0);
infoDialog.open();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}
// for-loop
}
UIJob job = new UIJob("Feedbackup") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
Facade.getInstanz().refreshAllData();
IWorkbench workbench = PlatformUI.getWorkbench();
Display display = workbench.getDisplay();
Shell shell = new Shell(display);
String info = null;
if (_updateStatus != null && _updateStatus.equals(Status.OK_STATUS)) {
info = NLMessages.getString("Command_update_successful");
} else {
info = NLMessages.getString("Command_update_error");
}
MessageDialog infoDialog = new MessageDialog(shell, info, null, info, MessageDialog.INFORMATION, new String[] //$NON-NLS-1$
{ "OK" }, 0);
infoDialog.open();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
monitor.done();
}Example 59
| Project: carrot2-master File: AttributeInfoTooltip.java View source code |
@Override
protected boolean shouldCreateToolTip(Event event) {
boolean value = super.shouldCreateToolTip(event);
if (value && isSynchronizedWithView()) {
final Job job = new UIJob("Show attribute info") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
showInView();
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.setPriority(Job.DECORATE);
job.schedule();
value = false;
}
return value;
}Example 60
| Project: CodingSpectator-master File: ProblemMarkerManager.java View source code |
private void postAsyncUpdate(final Display display) {
if (fNotifierJob == null) {
fNotifierJob = new UIJob(display, JavaUIMessages.ProblemMarkerManager_problem_marker_update_job_description) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
runPendingUpdates();
return Status.OK_STATUS;
}
};
fNotifierJob.setSystem(true);
}
fNotifierJob.schedule();
}Example 61
| Project: Curators-Workbench-master File: Activator.java View source code |
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext )
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
UIJob job = new UIJob("InitCommandsWorkaround") {
@Override
public IStatus runInUIThread(@SuppressWarnings("unused") IProgressMonitor monitor) {
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
Command command = commandService.getCommand("workbench_plugin.commandSetDivType");
command.isEnabled();
return new Status(IStatus.OK, PLUGIN_ID, "Init commands workaround performed succesfully");
}
};
job.schedule();
LOG.info("SLF4J is logging here.");
}Example 62
| Project: dawn-third-master File: UsageDataCaptureActivator.java View source code |
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
this.context = context;
settings = new UsageDataCaptureSettings();
final UsageDataService service = new UsageDataService();
getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (UsageDataCaptureSettings.CAPTURE_ENABLED_KEY.equals(event.getProperty())) {
if (isTrue(event.getNewValue())) {
service.startMonitoring();
} else {
service.stopMonitoring();
}
}
}
private boolean isTrue(Object newValue) {
if (newValue instanceof Boolean)
return ((Boolean) newValue).booleanValue();
if (newValue instanceof String)
return Boolean.valueOf((String) newValue);
return false;
}
});
// TODO There is basically no value to having this as a service at this point.
// In fact, there is potential for some weirdness with this as a service. For
// example, if the service is shut down it will just keep running anyway.
registration = context.registerService(UsageDataService.class.getName(), service, null);
usageDataServiceTracker = new ServiceTracker(context, UsageDataService.class.getName(), null);
usageDataServiceTracker.open();
/*
* Create a job that starts the UsageDataService in the UI Thread. This
* should happen well after this method has exited and the bundle is
* done activating and is in the "started" state. This was initially
* done to overcome a problem in which some of the monitors spun off
* jobs that resulted in multiple threads inadvertently trying to
* activate this bundle concurrently. The conditions that caused this
* problem have been rectified.
*
* In spite of the fact that the problem no longer exists, we're keeping
* the UIJob as this is a potentially expensive operation.
*/
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Usage Data Service Starter") {
public IStatus runInUIThread(IProgressMonitor monitor) {
if (settings.isEnabled()) {
service.startMonitoring();
}
return Status.OK_STATUS;
}
};
job.schedule(1000);
}Example 63
| Project: dbeaver-master File: ScriptPositionColumn.java View source code |
@Override
public void columnCreated() {
visible = true;
new UIJob("Update script ruler") {
{
setSystem(true);
}
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (DBeaverCore.isClosing()) {
return Status.CANCEL_STATUS;
}
BaseTextEditor editor = (BaseTextEditor) getEditor();
if (editor == null || editor.getTextViewer() == null)
return Status.CANCEL_STATUS;
StyledText textWidget = editor.getTextViewer().getTextWidget();
if (textWidget == null || textWidget.isDisposed())
return Status.CANCEL_STATUS;
if (textWidget.isVisible()) {
int[] newCurrentLines = editor.getCurrentLines();
if (!Arrays.equals(newCurrentLines, currentLines)) {
currentLines = newCurrentLines;
redraw();
}
}
if (visible) {
schedule(100);
}
return Status.OK_STATUS;
}
}.schedule(100);
}Example 64
| Project: Disco-Build-System-master File: ImportEaAnno.java View source code |
/* the background job starts here... */
@Override
public IStatus run(final IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
ElectricAnnoScanner eas = new ElectricAnnoScanner(importBuildStore);
try {
/*
* Create a listener that will monitor/display our progress in parsing the file.
* This listener reports the percentage of work completed so far (as a percentage
* of the size of file it's reading). On the first call to "progress()", we
* start our progress monitor, then we call worked() on that monitor whenever
* the percentage increases.
*/
ProgressFileInputStreamListener listener = new ProgressFileInputStreamListener() {
/** first time we've been called? */
private boolean firstReport = true;
/** the percentage complete, last time we were called */
private int lastPercentage = 0;
/**
* Progress has been made by the ElectricAnnoScanner.
*/
@Override
public void progress(long current, long total, int percentage) {
if (firstReport) {
monitor.beginTask("Importing Annotation File...", 0);
firstReport = false;
}
if (percentage != lastPercentage) {
monitor.worked(percentage - lastPercentage);
lastPercentage = percentage;
}
}
/** the import is completely done */
@Override
public void done() {
/* empty */
}
};
/*
* Start the parse - the listener will update us as we go.
*/
eas.parse(inputXmlFilePath, listener);
} catch (FileNotFoundException e) {
AlertDialog.displayErrorDialog("Error During Import", "ElectricAccelerator annotation file " + inputXmlFilePath + " not found.");
status = Status.CANCEL_STATUS;
} catch (IOException e) {
AlertDialog.displayErrorDialog("Error During Import", "I/O error while reading ElectricAccelerator annotation file " + inputXmlFilePath + ".");
status = Status.CANCEL_STATUS;
} catch (SAXException e) {
AlertDialog.displayErrorDialog("Error During Import", "Unexpected syntax in ElectricAccelerator annotation file " + inputXmlFilePath + ".");
status = Status.CANCEL_STATUS;
} catch (FatalBuildScannerError e) {
AlertDialog.displayErrorDialog("Error During Import", "Logic problem while scanning ElectricAccelerator annotation file " + inputXmlFilePath + "\n" + e.getMessage());
status = Status.CANCEL_STATUS;
}
/* we're done - close the BuildStore */
monitor.done();
try {
importBuildStore.save();
} catch (IOException e) {
AlertDialog.displayErrorDialog("Import Failed", "The build database could not be closed. " + e.getMessage());
}
importBuildStore.close();
/*
* Open the BuildStore in an editor (this must be done
* in the UI thread) so that the user can see what was just
* imported.
*/
UIJob openEditorJob = new UIJob("Open Editor") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
EclipsePartUtils.openNewEditor(outputBmlFilePath);
return Status.OK_STATUS;
}
};
openEditorJob.schedule();
return status;
}Example 65
| Project: dltk.core-master File: DLTKUiBridgePlugin.java View source code |
/**
* Startup order is critical.
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
INSTANCE = this;
IPreferenceStore dltkPrefs = DLTKUIPlugin.getDefault().getPreferenceStore();
// NOTE: moved out of wizard and first task activation to avoid bug
// 194766
int count = getPreferenceStore().getInt(MYLYN_RUN_COUNT);
if (count < 1) {
getPreferenceStore().setValue(MYLYN_RUN_COUNT, count + 1);
// to avoid prevent JDT from displaying a warning dialog
if (count == 0 && getPreferenceStore().contains(MYLYN_PREVIOUS_RUN)) {
if (dltkPrefs.contains(NUM_COMPUTERS_PREF_KEY)) {
int lastNumberOfComputers = dltkPrefs.getInt(NUM_COMPUTERS_PREF_KEY);
if (lastNumberOfComputers > 0) {
dltkPrefs.putValue(NUM_COMPUTERS_PREF_KEY, Integer.toString(lastNumberOfComputers - 2));
}
}
}
// try installing Task-Focused content assist twice
new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Initialize Content Assist") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
DLTKUiUtil.installContentAssist(store, false);
return Status.OK_STATUS;
}
}.schedule();
}
// the Task-Focused category should be disabled if the user reverts to
// the default
String defaultValue = dltkPrefs.getDefaultString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
dltkPrefs.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, defaultValue + DLTKUiUtil.ASSIST_MYLYN_ALL + DLTKUiUtil.SEPARATOR_CODEASSIST);
}Example 66
| Project: ecf-master File: Activator.java View source code |
public IStatus runInUIThread(IProgressMonitor monitor) {
final IncomingSharedTaskNotificationPopup popup = new IncomingSharedTaskNotificationPopup(shell);
popup.setTask(task);
popup.open();
new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
shell.getDisplay(), //$NON-NLS-1$
"Close Popup Job") {
public IStatus runInUIThread(IProgressMonitor monitor) {
Shell shell = popup.getShell();
if (shell != null && !shell.isDisposed()) {
popup.close();
}
monitor.done();
return Status.OK_STATUS;
}
}.schedule(5000);
return Status.OK_STATUS;
}Example 67
| Project: eclipse-gov.redhawk.ide-master File: LocalComponentContentProvider.java View source code |
public void notifyChanged(org.eclipse.emf.common.notify.Notification notification) {
super.notifyChanged(notification);
if (notification.getNotifier() instanceof LocalScaWaveform) {
switch(notification.getFeatureID(LocalScaWaveform.class)) {
case ScaDebugPackage.LOCAL_SCA_WAVEFORM__COMPONENTS:
final ScaWaveform domainWaveform = findDomainWaveform((ScaWaveform) notification.getNotifier());
if (domainWaveform != null && !viewer.getControl().isDisposed()) {
UIJob job = new UIJob("Refresh...") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (viewer.getControl().isDisposed()) {
return Status.CANCEL_STATUS;
}
((TreeViewer) viewer).refresh(domainWaveform);
return Status.OK_STATUS;
}
};
job.schedule();
}
break;
default:
break;
}
}
}Example 68
| Project: eclipse-themes-master File: EditorLineSupport.java View source code |
private UIJob getRefreshJob() { if (refreshJob == null) { refreshJob = new UIJob(Display.getDefault(), "Refersh Editor Line") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { doRefresh(); return Status.OK_STATUS; } }; refreshJob.setUser(false); refreshJob.setSystem(true); } return refreshJob; }
Example 69
| Project: eclipse.jdt.ui-master File: ProblemMarkerManager.java View source code |
private void postAsyncUpdate(final Display display) {
if (fNotifierJob == null) {
fNotifierJob = new UIJob(display, JavaUIMessages.ProblemMarkerManager_problem_marker_update_job_description) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
runPendingUpdates();
return Status.OK_STATUS;
}
};
fNotifierJob.setSystem(true);
}
fNotifierJob.schedule();
}Example 70
| Project: eclipse.platform.debug-master File: MemoryViewUtil.java View source code |
/**
* Helper function to open an error dialog.
*
* @param title
* @param message
* @param e
*/
public static void openError(final String title, final String message, final Exception e) {
UIJob uiJob = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"open error") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
// open error for the exception
String detail = IInternalDebugCoreConstants.EMPTY_STRING;
if (e != null)
detail = e.getMessage();
Shell shell = DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
shell, //$NON-NLS-1$
title, //$NON-NLS-1$
message + "\n" + detail);
return Status.OK_STATUS;
}
};
uiJob.setSystem(true);
uiJob.schedule();
}Example 71
| Project: eclipse3-master File: TextSearchPage.java View source code |
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
ISearchQuery searchQuery = newQuery();
searchQuery.run(monitor);
searchResult = (FileSearchResult) searchQuery.getSearchResult();
removeWrongPackageFolders();
} catch (Throwable e) {
DartToolsPlugin.log(e);
return Status.CANCEL_STATUS;
}
// schedule UI update
new UIJob("Displaying search results...") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
searchView.setContentDescription(MessageFormat.format("''{0}'' - {1} text occurrences in workspace", searchText, searchResult.getMatchCount()));
if (fileSearchPage != null) {
fileSearchPage.setInput(searchResult, fileSearchPage);
fileSearchPage.setViewPart(searchView);
}
return Status.OK_STATUS;
}
}.schedule();
// done
return Status.OK_STATUS;
}Example 72
| Project: gmp.graphiti-master File: GFEmfTreeContentProvider.java View source code |
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
if (resource == null)
return false;
switch(resource.getType()) {
case IResource.ROOT:
return true;
case IResource.PROJECT:
IProject p = (IProject) resource;
try {
boolean hasNature = p.hasNature(ExampleProjectNature.NATURE_ID);
return hasNature;
} catch (CoreException e) {
}
return false;
case IResource.FOLDER:
return true;
case IResource.FILE:
final IFile file = (IFile) resource;
if (//$NON-NLS-1$ //$NON-NLS-2$
file.getName().endsWith(".diagram") || file.getName().equals("Predefined.data")) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Update Viewer") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (viewer != null && !viewer.getControl().isDisposed()) {
EClassesNode classesNode = projectToEClassesNode.get(file.getProject());
if (viewer instanceof StructuredViewer && classesNode != null) {
((StructuredViewer) viewer).refresh(classesNode, true);
} else {
viewer.refresh();
}
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}
return false;
}
return false;
}Example 73
| Project: grails-ide-master File: GrailsLaunchUtils.java View source code |
/**
* Special handling for run-app and run-war, see https://issuetracker.springsource.com/browse/STS-3155
* https://issuetracker.springsource.com/browse/STS-3299
*
* @throws CoreException
*/
private static void launchNoTimeout(final IJavaProject javaProject, final String script) {
final String title = "Launching " + javaProject.getElementName() + ": " + script;
new UIJob(title) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
monitor.beginTask(title, 3);
try {
try {
ILaunchConfiguration launchConf = GrailsLaunchConfigurationDelegate.getLaunchConfiguration(javaProject.getProject(), script, false);
monitor.worked(1);
DebugUITools.launch(launchConf, ILaunchManager.RUN_MODE);
} catch (CoreException e) {
return new Status(IStatus.ERROR, GrailsCoreActivator.PLUGIN_ID, "Problem executing: " + script, e);
}
return Status.OK_STATUS;
} finally {
monitor.done();
}
}
}.schedule();
}Example 74
| Project: gwt-eclipse-plugin-master File: BackgroundInitiatedYesNoDialog.java View source code |
/**
* Displays a yes/no dialog of a specified type with a specified title,a specified message, and a
* specified default value, then blocks until the user responds or interrupts the dialog.
*
* @param type the dialog type, specified by one of the int constants in {@link MessageDialog}
* @param title the specified title
* @param message the specified message
* @param defaultIsYes
* {@link true} if the specified default value is <i>yes</i>, false if the specified default
* value is <i>no</i>
* @return
* {@code true} if the user responded <i>yes</i>, {@code false} if the user responded
* <i>no</i>, or the value of {@code defaultValueIsYes} if the user interrupts the dialog
*/
public boolean userAnsweredYes(final int type, final String title, final String message, final boolean defaultIsYes) {
final int defaultPosition = defaultIsYes ? YesOrNo.YES.ordinal() : YesOrNo.NO.ordinal();
if (Display.getCurrent() == null) {
// This is not a UI thread. Schedule a UI job to call displayDialogAndGetAnswer, and block
// this thread until the UI job is complete.
final Semaphore barrier = new Semaphore(0);
final AtomicBoolean responseContainer = new AtomicBoolean();
UIJob dialogJob = new UIJob("background-initiated question dialog") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
boolean result = displayDialogAndGetAnswer(type, title, message, defaultPosition);
responseContainer.set(result);
barrier.release();
return Status.OK_STATUS;
}
};
dialogJob.schedule();
try {
barrier.acquire();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return defaultIsYes;
}
return responseContainer.get();
} else {
// (Scheduling a UIJob and blocking until it completes would result in deadlock.)
return displayDialogAndGetAnswer(type, title, message, defaultPosition);
}
}Example 75
| Project: jbosstools-central-master File: ShowJBossCentral.java View source code |
private void registerDropTarget(int delay) {
UIJob registerJob = new UIJob(Display.getDefault(), "Red Hat Central DND initialization") {
{
setPriority(Job.DECORATE);
}
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow window : workbenchWindows) {
Shell shell = window.getShell();
JBossCentralActivator.initDropTarget(shell);
addJBossDropListener(window);
}
return Status.OK_STATUS;
}
private void addJBossDropListener(IWorkbenchWindow window) {
if (!(window instanceof WorkbenchWindow)) {
return;
}
WorkbenchWindow workbenchWindow = (WorkbenchWindow) window;
EModelService modelService = (EModelService) window.getService(EModelService.class);
if (modelService == null) {
return;
}
List<MArea> areas = modelService.findElements(workbenchWindow.getModel(), EDITOR_AREA_ID, MArea.class, null);
if (areas == null || areas.isEmpty()) {
return;
}
for (MArea area : areas) {
Object object = area.getWidget();
if (object instanceof Composite) {
Composite composite = (Composite) object;
Object o = composite.getData(DND.DROP_TARGET_KEY);
if (o instanceof DropTarget) {
new JBossCentralDropTarget((DropTarget) o);
}
}
}
}
};
registerJob.schedule(delay);
}Example 76
| Project: mylyn-ecf-master File: Activator.java View source code |
public IStatus runInUIThread(IProgressMonitor monitor) {
final IncomingSharedTaskNotificationPopup popup = new IncomingSharedTaskNotificationPopup(shell);
popup.setTask(task);
popup.open();
new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
shell.getDisplay(), //$NON-NLS-1$
"Close Popup Job") {
public IStatus runInUIThread(IProgressMonitor monitor) {
Shell shell = popup.getShell();
if (shell != null && !shell.isDisposed()) {
popup.close();
}
monitor.done();
return Status.OK_STATUS;
}
}.schedule(5000);
return Status.OK_STATUS;
}Example 77
| Project: mylyn.context-master File: ContextPopulationStrategy.java View source code |
@Override
protected IStatus run(IProgressMonitor monitor) {
// compute data model elements
ContextComputationStrategy strategy = getContextComputationStrategy();
if (strategy == null) {
return Status.CANCEL_STATUS;
}
final List<Object> contextItems = strategy.computeContext(context, input, monitor);
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
// add elements to context through simulating selection events
if (!contextItems.isEmpty()) {
UIJob uiJob = new UIJob(Messages.ContextPopulationStrategy_Populate_Context_Job_Label) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IInteractionContext activeContext = ContextCore.getContextManager().getActiveContext();
if (activeContext != null && activeContext.getHandleIdentifier() != null && activeContext.getHandleIdentifier().equals(context.getHandleIdentifier())) {
monitor.beginTask(Messages.ContextPopulationStrategy_Populate_Context_Job_Label, contextItems.size());
try {
for (Object element : contextItems) {
monitor.worked(1);
AbstractContextStructureBridge structureBridge = ContextCore.getStructureBridge(element);
if (structureBridge != null) {
String handleIdentifier = structureBridge.getHandleIdentifier(element);
if (handleIdentifier != null) {
try {
ContextCore.getContextManager().processInteractionEvent(new InteractionEvent(InteractionEvent.Kind.SELECTION, structureBridge.getContentType(), handleIdentifier, PART_ID));
} catch (Exception e) {
IStatus status = new Status(IStatus.ERROR, ContextUiPlugin.ID_PLUGIN, "Unexpected error manipulating context", e);
ContextUiPlugin.getDefault().getLog().log(status);
}
}
}
}
} finally {
monitor.done();
}
if (!activeContext.getAllElements().isEmpty()) {
// activate structured view filters if needed
if (ContextUiPlugin.getDefault().getPreferenceStore().getBoolean(IContextUiPreferenceContstants.AUTO_FOCUS_NAVIGATORS)) {
for (IWorkbenchWindow window : Workbench.getInstance().getWorkbenchWindows()) {
for (IWorkbenchPage page : window.getPages()) {
for (IViewReference viewReference : page.getViewReferences()) {
IViewPart viewPart = (IViewPart) viewReference.getPart(false);
if (viewPart != null) {
AbstractFocusViewAction applyAction = AbstractFocusViewAction.getActionForPart(viewPart);
if (applyAction != null) {
applyAction.update(true);
}
}
}
}
}
}
}
}
return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
};
uiJob.schedule();
}
return Status.OK_STATUS;
}Example 78
| Project: org.eclipse.dltk.core-master File: ConsoleDropDownAction.java View source code |
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui.
* console.IConsole[])
*/
public void consoleAdded(IEvaluateConsole console) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"") {
public IStatus runInUIThread(IProgressMonitor monitor) {
update();
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.setPriority(Job.INTERACTIVE);
job.schedule();
}Example 79
| Project: PTP-master File: JAXBRMConfigurationImportWizard.java View source code |
/*
* Copies file to resourceManagers project and refreshes it. (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
new UIJob(JAXBUIConstants.RESOURCE_MANAGERS) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
SubMonitor subMon = SubMonitor.convert(monitor, 20);
try {
URL selection = mainPage.getSelectedConfiguration();
if (selection != null) {
try {
String name = mainPage.getSelectedName();
IProject project = checkResourceManagersProject(subMon.newChild(10));
if (project == null) {
return Status.OK_STATUS;
}
int createTry = 1;
IFile newConfig = project.getFile(name + JAXBUIConstants.SP + JAXBUIConstants.OPENP + createTry++ + JAXBUIConstants.CLOSP + JAXBUIConstants.DOT_XML);
while (newConfig.exists()) {
newConfig = project.getFile(name + JAXBUIConstants.SP + JAXBUIConstants.OPENP + createTry++ + JAXBUIConstants.CLOSP + JAXBUIConstants.DOT_XML);
}
newConfig.create(selection.openStream(), IResource.NONE, subMon.newChild(10));
} catch (CoreException io) {
JAXBUIPlugin.log(io);
} catch (IOException io) {
JAXBUIPlugin.log(io);
}
}
return Status.OK_STATUS;
} finally {
if (monitor != null) {
monitor.done();
}
}
}
}.schedule();
return true;
}Example 80
| Project: Pydev-master File: ProblemMarkerManager.java View source code |
private void postAsyncUpdate(final Display display) {
if (fNotifierJob == null) {
fNotifierJob = new UIJob(display, "Update problem marker decorations") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
//Yes, MUST be called on UI thread!
IResource[] markerResources = null;
IResource[] annotationResources = null;
synchronized (ProblemMarkerManager.this) {
if (!fResourcesWithMarkerChanges.isEmpty()) {
markerResources = fResourcesWithMarkerChanges.toArray(new IResource[fResourcesWithMarkerChanges.size()]);
fResourcesWithMarkerChanges.clear();
}
if (!fResourcesWithAnnotationChanges.isEmpty()) {
annotationResources = fResourcesWithAnnotationChanges.toArray(new IResource[fResourcesWithAnnotationChanges.size()]);
fResourcesWithAnnotationChanges.clear();
}
}
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
IProblemChangedListener curr = (IProblemChangedListener) listeners[i];
if (markerResources != null) {
curr.problemsChanged(markerResources, true);
}
if (annotationResources != null) {
curr.problemsChanged(annotationResources, false);
}
}
return Status.OK_STATUS;
}
};
fNotifierJob.setSystem(true);
fNotifierJob.setPriority(UIJob.DECORATE);
}
fNotifierJob.schedule(10);
}Example 81
| Project: rascal-eclipse-master File: RascalTerminalRegistry.java View source code |
public static void launchTerminal(String project, String module, String mode) {
Job job = new UIJob("Launching console") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(IRascalResources.LAUNCHTYPE);
ILaunchConfigurationWorkingCopy launch = type.newInstance(null, "Rascal Project Terminal Launch [" + project + "]");
DebugUITools.setLaunchPerspective(type, mode, IDebugUIConstants.PERSPECTIVE_NONE);
launch.setAttribute(IRascalResources.ATTR_RASCAL_PROJECT, project);
launch.setAttribute(IRascalResources.ATTR_RASCAL_PROGRAM, module);
getInstance().setLaunch(launch.launch(mode, monitor));
} catch (CoreException e) {
Activator.getInstance().logException("could not start a terminal for " + project, e);
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}Example 82
| Project: rt.equinox.bundles-master File: UICallbackProvider.java View source code |
public void setupPasswordRecovery(final int size, final String moduleID, final IPreferencesContainer container) {
if (!StorageUtils.showUI(container))
return;
UIJob reciverySetupJob = new UIJob(SecUIMessages.pswJobName) {
public IStatus runInUIThread(IProgressMonitor monitor) {
boolean reply = MessageDialog.openQuestion(StorageUtils.getShell(), SecUIMessages.pswdRecoveryOptionTitle, SecUIMessages.pswdRecoveryOptionMsg);
if (!reply)
return Status.OK_STATUS;
ChallengeResponseDialog dialog = new ChallengeResponseDialog(size, StorageUtils.getShell());
dialog.open();
String[][] result = dialog.getResult();
if (result != null)
InternalExchangeUtils.setupRecovery(result, moduleID, container);
return Status.OK_STATUS;
}
};
reciverySetupJob.setUser(false);
reciverySetupJob.schedule();
}Example 83
| Project: Secure-Service-Specification-and-Deployment-master File: BpmnTreeContentProvider.java View source code |
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
if (resource == null)
return false;
switch(resource.getType()) {
case IResource.ROOT:
return true;
case IResource.PROJECT:
IProject p = (IProject) resource;
try {
boolean hasNature = p.hasNature(ActivitiProjectNature.NATURE_ID);
return hasNature;
} catch (CoreException e) {
}
return false;
case IResource.FOLDER:
return true;
case IResource.FILE:
final IFile file = (IFile) resource;
if (file.getName().endsWith(ActivitiBPMNDiagramConstants.DIAGRAM_EXTENSION) || //$NON-NLS-1$
file.getName().equals(//$NON-NLS-1$
"Predefined.data")) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Update Viewer") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (viewer != null && !viewer.getControl().isDisposed()) {
BpmnElementsNode bpmnNode = projectToBpmn2ElementsNode.get(file.getProject());
if (viewer instanceof StructuredViewer && bpmnNode != null) {
((StructuredViewer) viewer).refresh(bpmnNode, true);
} else {
viewer.refresh();
}
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}
return false;
}
return false;
}Example 84
| Project: Security-Service-Validation-and-Verification-master File: BpmnTreeContentProvider.java View source code |
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
if (resource == null)
return false;
switch(resource.getType()) {
case IResource.ROOT:
return true;
case IResource.PROJECT:
IProject p = (IProject) resource;
try {
boolean hasNature = p.hasNature(ActivitiProjectNature.NATURE_ID);
return hasNature;
} catch (CoreException e) {
}
return false;
case IResource.FOLDER:
return true;
case IResource.FILE:
final IFile file = (IFile) resource;
if (file.getName().endsWith(ActivitiBPMNDiagramConstants.DIAGRAM_EXTENSION) || //$NON-NLS-1$
file.getName().equals(//$NON-NLS-1$
"Predefined.data")) {
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Update Viewer") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (viewer != null && !viewer.getControl().isDisposed()) {
BpmnElementsNode bpmnNode = projectToBpmn2ElementsNode.get(file.getProject());
if (viewer instanceof StructuredViewer && bpmnNode != null) {
((StructuredViewer) viewer).refresh(bpmnNode, true);
} else {
viewer.refresh();
}
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}
return false;
}
return false;
}Example 85
| Project: sugarj-master File: SugarJConsole.java View source code |
/**
* Activates the console for this plugin.
*
* Swallows and logs any PartInitException.
*
* @param consoleViewOnly
* Only open the console within the console view; don't activate the
* console view itself.
*
* @see Descriptor#isDynamicallyLoaded() Should typically be checked before
* opening a console.
*/
public static void activateConsole(final boolean consoleViewOnly) {
Job job = new UIJob("Open console") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
final String ID = IConsoleConstants.ID_CONSOLE_VIEW;
MessageConsole console = SugarJConsole.getConsole();
if (consoleViewOnly) {
console.activate();
return Status.OK_STATUS;
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null)
// Eclipse exiting
return Status.OK_STATUS;
IWorkbenchPage page = window.getActivePage();
try {
IConsoleView view = (IConsoleView) page.showView(ID, null, IWorkbenchPage.VIEW_VISIBLE);
view.display(console);
} catch (PartInitException e) {
Environment.logException("Could not activate the console", e);
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}Example 86
| Project: vjet.eclipse-master File: JsdocView.java View source code |
/*
* (non-Javadoc)
*
* @see org.eclipse.dltk.mod.ui.infoviews.AbstractDocumentationView#setInput(java.lang.Object)
*/
@Override
protected void setInput(final Object input) {
new UIJob(getViewSite().getShell().getDisplay(), "Jsdoc Update Job") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
VjoEditor vjoEditor = VjetUIPlugin.getVjoEditor();
if (vjoEditor == null) {
return Status.CANCEL_STATUS;
}
Object inputSrc = getInput();
if (!(inputSrc instanceof IModelElement)) {
return Status.CANCEL_STATUS;
}
IModelElement selectedElement = (IModelElement) inputSrc;
if (!(vjoEditor.getInputModelElement() instanceof IVjoSourceModule)) {
return Status.CANCEL_STATUS;
}
ISourceModule sm = (ISourceModule) vjoEditor.getInputModelElement();
int offset = getOffset(selectedElement);
if (offset == -1) {
return Status.CANCEL_STATUS;
}
VjoSelectionEngine selectionEngine = VjetUIUtils.getSelectionEngine();
IJstNode selectedJstNode = selectionEngine.convertSelection2JstNode((org.eclipse.dltk.mod.compiler.env.ISourceModule) sm, offset, offset);
String javadocHtml = VjoProposalAditionalInfoGenerator.getAdditionalPropesalInfo(selectedJstNode);
if ((javadocHtml == null) || (0 == javadocHtml.length())) {
javadocHtml = input.toString();
}
Control control = getControl();
if (control instanceof Browser) {
((Browser) control).setText(javadocHtml);
}
return Status.OK_STATUS;
}
private int getOffset(IModelElement selectedElement) {
int offset = -1;
if (selectedElement instanceof ISourceReference) {
try {
offset = ((ISourceReference) selectedElement).getSourceRange().getOffset();
} catch (ModelException e) {
VjetUIPlugin.log(e);
}
}
// handle text selection on native vjo type/property/method
if ((offset == -1) && (m_selection instanceof ITextSelection)) {
offset = ((ITextSelection) m_selection).getOffset();
}
return offset;
}
}.schedule();
}Example 87
| Project: webtools.jsdt.debug-master File: OpenSourceAction.java View source code |
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
if (script != null) {
UIJob job = new UIJob(PlatformUI.getWorkbench().getDisplay(), NLS.bind(Messages.opening_source__0, script.sourceURI())) {
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ISourceLookupResult result = DebugUITools.lookupSource(script, script.getDebugTarget().getLaunch().getSourceLocator());
DebugUITools.displaySource(result, page);
return Status.OK_STATUS;
}
};
job.setPriority(Job.INTERACTIVE);
job.setUser(true);
job.schedule();
}
}Example 88
| Project: webtools.sourceediting-master File: ShowTranslationHandler.java View source code |
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands
* .ExecutionEvent)
*/
public Object execute(final ExecutionEvent event) throws ExecutionException {
// IDE.openEditor(event.getApplicationContext(), createEditorInput(),
// JavaUI.ID_CU_EDITOR, true);
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
List list = ((IStructuredSelection) selection).toList();
if (!list.isEmpty()) {
if (list.get(0) instanceof IDOMNode) {
final IDOMModel model = ((IDOMNode) list.get(0)).getModel();
INodeAdapter adapter = model.getDocument().getAdapterFor(IJsTranslation.class);
if (adapter != null) {
Job opener = new UIJob("Opening JavaScript Translation") {
public IStatus runInUIThread(IProgressMonitor monitor) {
JsTranslationAdapter translationAdapter = (JsTranslationAdapter) model.getDocument().getAdapterFor(IJsTranslation.class);
final IJsTranslation translation = translationAdapter.getJsTranslation(false);
// create an IEditorInput for the Java editor
final IStorageEditorInput input = new JSTranslationEditorInput(translation, model.getBaseLocation());
try {
IEditorPart editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, JavaScriptUI.ID_CU_EDITOR, true);
// Now add the problems we found
if (editor instanceof ITextEditor) {
IAnnotationModel annotationModel = ((ITextEditor) editor).getDocumentProvider().getAnnotationModel(input);
translation.reconcileCompilationUnit();
List problemsList = translation.getProblems();
IProblem[] problems = (IProblem[]) problemsList.toArray(new IProblem[problemsList.size()]);
AnnotationTypeLookup lookup = new AnnotationTypeLookup();
for (int i = 0; i < problems.length; i++) {
int length = problems[i].getSourceEnd() - problems[i].getSourceStart() + 1;
Position position = new Position(problems[i].getSourceStart(), length);
Annotation annotation = null;
String type = lookup.getAnnotationType(IMarker.PROBLEM, IMarker.SEVERITY_INFO);
if (problems[i].isError()) {
type = lookup.getAnnotationType(IMarker.PROBLEM, IMarker.SEVERITY_ERROR);
} else if (problems[i].isWarning()) {
type = lookup.getAnnotationType(IMarker.PROBLEM, IMarker.SEVERITY_WARNING);
}
annotation = new Annotation(type, false, problems[i].getMessage());
if (annotation != null) {
annotationModel.addAnnotation(annotation, position);
}
}
}
} catch (PartInitException e) {
e.printStackTrace();
Display.getCurrent().beep();
}
return Status.OK_STATUS;
}
};
opener.setSystem(false);
opener.setUser(true);
opener.schedule();
}
}
}
}
return null;
}Example 89
| Project: pdt-master File: PHPDebugUIPlugin.java View source code |
public void handleDebugEvents(DebugEvent[] events) {
if (events != null) {
int size = events.length;
for (int i = 0; i < size; i++) {
DebugEvent event = events[i];
if (event.getKind() == DebugEvent.CREATE) {
Object obj = events[i].getSource();
if (!(obj instanceof IPHPDebugTarget))
continue;
if (PHPDebugPlugin.getOpenDebugViewsOption()) {
Job job = new org.eclipse.ui.progress.UIJob(PHPDebugUIMessages.PHPDebugUIPlugin_0) {
public IStatus runInUIThread(IProgressMonitor monitor) {
showView(DebugBrowserView.ID_PHPBrowserOutput);
showView(DebugOutputView.ID_PHPDebugOutput);
showView(IConsoleConstants.ID_CONSOLE_VIEW);
return Status.OK_STATUS;
}
};
job.schedule();
}
}
if (event.getKind() == DebugEvent.MODEL_SPECIFIC) {
Object obj = events[i].getSource();
if (!(obj instanceof IPHPDebugTarget))
continue;
final Object data = events[i].getData();
if (data instanceof IStatus) {
Job job = new org.eclipse.ui.progress.UIJob(PHPDebugUIMessages.PHPDebugUIPlugin_0) {
public IStatus runInUIThread(IProgressMonitor monitor) {
IStatus status = (IStatus) data;
Shell shell = getActiveWorkbenchShell();
ErrorDialog.openError(shell, null, null, status);
return Status.OK_STATUS;
}
};
job.schedule();
}
}
}
}
}Example 90
| Project: anyedittools-master File: AnyeditCompareInput.java View source code |
void reuseEditor() {
UIJob job = new UIJob("Updating differences") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (monitor.isCanceled() || left.isDisposed() || right.isDisposed()) {
return Status.CANCEL_STATUS;
}
// This causes too much flicker:
// AnyeditCompareInput input = new AnyeditCompareInput(left.recreate(), right
// .recreate());
// if(monitor.isCanceled()){
// input.internalDispose();
// return Status.CANCEL_STATUS;
// }
// CompareUI.reuseCompareEditor(input, (IReusableEditor) getWorkbenchPart());
AnyeditCompareInput input = AnyeditCompareInput.this;
// allow "no diff" result to keep the editor open
createNoDiffNode = true;
try {
StreamContent old_left = left;
left = old_left.recreate();
old_left.dispose();
StreamContent old_right = right;
right = old_right.recreate();
old_right.dispose();
// calls prepareInput(monitor);
input.run(monitor);
if (differences != null) {
CompareViewerSwitchingPane pane = getInputPane();
if (pane != null) {
Viewer viewer = pane.getViewer();
if (viewer instanceof TextMergeViewer) {
viewer.setInput(differences);
}
}
}
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
} catch (InvocationTargetException e) {
AnyEditToolsPlugin.errorDialog("Error during diff of " + getName(), e);
return Status.CANCEL_STATUS;
} finally {
createNoDiffNode = false;
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
return AnyeditCompareInput.this == family;
}
};
job.setPriority(Job.SHORT);
job.setUser(true);
job.setRule(new ExclusiveJobRule(this));
Job[] jobs = Job.getJobManager().find(this);
if (jobs.length > 0) {
for (int i = 0; i < jobs.length; i++) {
jobs[i].cancel();
}
}
jobs = Job.getJobManager().find(this);
if (jobs.length > 0) {
job.schedule(1000);
} else {
job.schedule(500);
}
}Example 91
| Project: avr-eclipse-fork-master File: MCUReadActionPart.java View source code |
@Override
protected IStatus run(IProgressMonitor monitor) {
final ScrolledForm form = getManagedForm().getForm();
try {
monitor.beginTask("Starting AVRDude", 100);
// Read the values from the attached programmer.
final ByteValues newvalues = readByteValues(progcfg, new SubProgressMonitor(monitor, 95));
// update
if (form.isDisposed()) {
return Status.CANCEL_STATUS;
}
form.getDisplay().syncExec(new Runnable() {
// Run in the UI thread in case we have to open a MCU mismatch dialog.
public void run() {
ByteValues current = getByteValues();
boolean forceMCU = false;
// Check if the mcus are compatible
String projectmcu = getByteValues().getMCUId();
String newmcu = newvalues.getMCUId();
if (current.isCompatibleWith(newmcu)) {
// Compatible MCUs
// Change the MCU type anyway to be consistent
forceMCU = true;
} else {
// No, they are not compatible. Ask the user what to do
// "Convert", "Change" or "Cancel"
Dialog dialog = new FileMCUMismatchDialog(form.getShell(), newmcu, projectmcu, current.getType());
int choice = dialog.open();
switch(choice) {
case FileMCUMismatchDialog.CANCEL:
return;
case FileMCUMismatchDialog.CHANGE:
// Change project ByteValues to the new MCU and then copy
// the values
forceMCU = true;
break;
case FileMCUMismatchDialog.CONVERT:
// Change the new ByteValues to our MCU and then copy
// the values
forceMCU = false;
break;
}
}
current.setValues(newvalues, forceMCU);
markDirty();
notifyForm();
}
});
monitor.worked(5);
} catch (AVRDudeException ade) {
if (!form.isDisposed()) {
UIJob messagejob = new AVRDudeErrorDialogJob(form.getDisplay(), ade, progcfg.getId());
messagejob.setPriority(Job.INTERACTIVE);
messagejob.schedule();
try {
messagejob.join();
} catch (InterruptedException e) {
}
}
} catch (SWTException swte) {
return Status.CANCEL_STATUS;
} finally {
monitor.done();
// remove the busy cursor
if (!form.isDisposed()) {
form.getDisplay().syncExec(new Runnable() {
public void run() {
form.setBusy(false);
}
});
}
}
return Status.OK_STATUS;
}Example 92
| Project: bioclipse.metaprint2d-master File: Activator.java View source code |
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
finderTracker = new ServiceTracker(context, IMetaPrint2DManager.class.getName(), null);
finderTracker.open();
UIJob job = new UIJob("InitCommandsWorkaround") {
public IStatus runInUIThread(IProgressMonitor monitor) {
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
Command command = commandService.getCommand("net.bioclipse.dropdown.radio");
command.isEnabled();
command = commandService.getCommand("net.bioclipse.dropdown.radio.op");
command.isEnabled();
if (PlatformUI.getWorkbench() == null)
return Status.OK_STATUS;
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() == null)
return Status.OK_STATUS;
logger.debug("Initializing M2D part and context listeners");
editorListenerMap = new HashMap<JChemPaintEditor, IPropertyChangeListener>();
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(Activator.getDefault());
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
contextService.addContextManagerListener(Activator.getDefault());
//Add perspective change listener to turn off external generators
//when switching AWAY FROM m2d-perspective
PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new IPerspectiveListener3() {
@Override
public void perspectiveChanged(IWorkbenchPage arg0, IPerspectiveDescriptor arg1, IWorkbenchPartReference arg2, String arg3) {
}
@Override
public void perspectiveActivated(IWorkbenchPage arg0, IPerspectiveDescriptor arg1) {
}
@Override
public void perspectiveChanged(IWorkbenchPage arg0, IPerspectiveDescriptor arg1, String arg2) {
}
@Override
public void perspectiveClosed(IWorkbenchPage arg0, IPerspectiveDescriptor arg1) {
}
@Override
public void perspectiveDeactivated(IWorkbenchPage arg0, IPerspectiveDescriptor arg1) {
if ("net.bioclipse.metaprint2d.ui.Metaprint2dPerspective".equals(arg1.getId())) {
JChemPaintEditor jcp = getJCPfromActiveEditor();
if (jcp == null)
return;
GeneratorHelper.turnOffAllExternalGenerators(jcp);
}
}
@Override
public void perspectiveOpened(IWorkbenchPage arg0, IPerspectiveDescriptor arg1) {
}
@Override
public void perspectiveSavedAs(IWorkbenchPage arg0, IPerspectiveDescriptor arg1, IPerspectiveDescriptor arg2) {
}
});
return new Status(IStatus.OK, PLUGIN_ID, "Init commands workaround performed succesfully");
}
};
job.schedule();
}Example 93
| Project: CertWare-master File: ContentProvider.java View source code |
/**
* Visitor for resource change deltas.
* @param delta resource change delta
* @return false for file type resource processing, true otherwise
* @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(IResourceDelta)
*/
@Override
public boolean visit(IResourceDelta delta) {
final IResource source = delta.getResource();
switch(source.getType()) {
case IResource.ROOT:
case IResource.PROJECT:
case IResource.FOLDER:
return true;
case IResource.FILE:
final IFile file = (IFile) source;
if (ICertWareConstants.SPM_EXTENSION.equals(file.getFileExtension())) {
updateModel(file);
new UIJob(Messages.Job) {
public IStatus runInUIThread(IProgressMonitor monitor) {
if (null != viewer) {
viewer.refresh(file);
}
selectedFile = file;
return Status.OK_STATUS;
}
}.schedule();
}
return false;
default:
break;
}
return false;
}Example 94
| Project: DDT-master File: ProblemMarkerManager.java View source code |
private void postAsyncUpdate(final Display display) {
if (fNotifierJob == null) {
fNotifierJob = new UIJob(display, "Sending problem marker updates...") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
runPendingUpdates();
return Status.OK_STATUS;
}
};
fNotifierJob.setSystem(true);
}
fNotifierJob.schedule();
}Example 95
| Project: Deadlock-Preventer-master File: LaunchConfigurationConfigurator.java View source code |
private void doLaunch(final ILaunchConfiguration lc) {
try {
final String attribute = lc.getAttribute(ORG_ECLIPSE_JDT_LAUNCHING_VM_ARGUMENTS, new String());
String[] attributes = attribute.split(SPACE);
StringBuffer newAttributes = new StringBuffer();
IProcess process = agent.createProcess(lc.getName());
String prefixAgent = agent.getVMArg(process, IAgent.VM_ARG_AGENT);
String prefixBootClassPath = agent.getVMArg(process, IAgent.VM_ARG_BOOT_CLASSPATH);
String prefixServerPort = agent.getVMArg(process, IAgent.VM_ARG_BOOT_SERVER_PORT);
String prefixAgentPrefix = prefixAgent.split(":")[0];
String prefixBootClassPathPrefix = prefixBootClassPath.split(":")[0];
String prefixServerPortPrefix = prefixServerPort.split("=")[0];
for (String attr : attributes) {
if (attr.startsWith(prefixAgentPrefix) || attr.startsWith(prefixBootClassPathPrefix) || attr.startsWith(prefixServerPortPrefix) || attr.contains(Settings.QUERY_SERVICE) || attr.contains(Settings.REPORT_SERVICE))
continue;
newAttributes.append(attr + SPACE);
}
final String cleanedUpAttributes = newAttributes.toString();
newAttributes.append(prefixAgent + SPACE);
newAttributes.append(prefixBootClassPath + SPACE);
newAttributes.append(prefixServerPort);
String additional = agent.getVMArg(process, IAgent.VM_ADDITIONAL_ARGUMENTS);
if (additional != null)
newAttributes.append(SPACE + additional);
newAttributes.append(SPACE + "-D" + Settings.BUNDLE_ADVISOR + "=" + WorkbenchBundleAdvisor.class.getName());
if (Platform.inDebugMode())
System.out.println("adding new vm args to launch conf: " + newAttributes.toString());
ILaunchConfigurationWorkingCopy copy = lc.getWorkingCopy();
copy.setAttribute(ORG_ECLIPSE_JDT_LAUNCHING_VM_ARGUMENTS, newAttributes.toString());
final ILaunchConfiguration newlc = copy.doSave();
oldLaunchSettings.put(newlc.getName(), cleanedUpAttributes);
UIJob job = new UIJob("Debugging: " + newlc.getName()) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
newlc.launch(ILaunchManager.DEBUG_MODE, monitor);
PlatformUI.getWorkbench().showPerspective(DEBUG_PERSPECTIVE, agent.getSite().getWorkbenchWindow());
agent.getSite().getWorkbenchWindow().getActivePage().showView(agent.getViewID());
} catch (CoreException e) {
e.printStackTrace();
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot debug launch configuration: " + newlc.getName());
}
return Status.OK_STATUS;
}
};
job.schedule();
} catch (CoreException e) {
e.printStackTrace();
}
}Example 96
| Project: DynamicSpotter-master File: NavigatorContentProvider.java View source code |
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org
* .eclipse.core.resources.IResourceChangeEvent)
*/
@Override
public void resourceChanged(IResourceChangeEvent event) {
UIJob uiJob = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"refresh Project Navigator") {
public IStatus runInUIThread(IProgressMonitor monitor) {
if (viewer != null && !viewer.getControl().isDisposed() && !viewer.isBusy()) {
TreePath[] treePaths = viewer.getExpandedTreePaths();
viewer.refresh();
viewer.setExpandedTreePaths(treePaths);
}
return Status.OK_STATUS;
}
};
uiJob.schedule();
}Example 97
| Project: eclipse-integration-tcserver-master File: JavaElementLocationHandler.java View source code |
/**
* {@inheritDoc}
*/
public void handleLocation(String serverUrl, String parameter) {
Matcher matcher = PATTERN.matcher(parameter);
if (matcher.matches()) {
final String contextRoot = serverUrl + matcher.group(1) + "/";
final String className = matcher.group(2);
// final String methodName = matcher.group(3);
final String lineNumber = matcher.group(4);
UIJob job = new //$NON-NLS-1$
UIJob(//$NON-NLS-1$
"Go to Source") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
IProject[] projects = findProjects(contextRoot);
String cleanClassName = cleanClassName(className);
IType type = null;
for (IProject project : projects) {
type = JdtUtils.getJavaType(project, cleanClassName);
if (type != null) {
break;
}
}
if (type == null) {
type = findTypeInWorkspace(cleanClassName);
}
if (type == null) {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Type not found", "Could not find type '" + className + "' in workspace");
} else {
IEditorPart editorPart = SpringUIUtils.openInEditor(type);
int ln = Integer.valueOf(lineNumber);
if (editorPart instanceof ITextEditor && ln >= 0) {
ITextEditor textEditor = (ITextEditor) editorPart;
IDocumentProvider provider = textEditor.getDocumentProvider();
provider.connect(editorPart.getEditorInput());
IDocument document = provider.getDocument(editorPart.getEditorInput());
try {
IRegion line = document.getLineInformation(ln - 1);
textEditor.selectAndReveal(line.getOffset(), line.getLength());
} catch (BadLocationException e) {
}
provider.disconnect(editorPart.getEditorInput());
}
}
} catch (CoreException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error finding class", e);
}
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
}
}Example 98
| Project: Eclipse-Postfix-Code-Completion-master File: ProblemMarkerManager.java View source code |
private void postAsyncUpdate(final Display display) {
if (fNotifierJob == null) {
fNotifierJob = new UIJob(display, JavaUIMessages.ProblemMarkerManager_problem_marker_update_job_description) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
runPendingUpdates();
return Status.OK_STATUS;
}
};
fNotifierJob.setSystem(true);
}
fNotifierJob.schedule();
}Example 99
| Project: eclipse-tools-master File: ClusterRefreshJob.java View source code |
@Override
protected IStatus run(IProgressMonitor monitor) {
String jobName = "Refreshing Aerospike cluster for " + project.getName();
monitor.beginTask(jobName, 30);
//System.out.println("****** " + jobName);
InfoPolicy infoPolicy = CoreActivator.getInfoPolicy(cluster.getProject());
try {
TimeUnit.SECONDS.sleep(1);
// refresh nodes
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
AerospikeClient client = CoreActivator.getClient(cluster.getProject());
if (client == null)
return Status.CANCEL_STATUS;
monitor.subTask("Fetching nodes");
Node[] nodes = client.getNodes();
for (Node node : nodes) {
AsNode newNode = this.cluster.addNode(node);
HashMap<String, String> info = (HashMap<String, String>) Info.request(infoPolicy, node);
newNode.setDetails(info);
String throughputInfo = Info.request(infoPolicy, node, "throughput:");
newNode.setLatency(throughputInfo);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
}
monitor.worked(10);
monitor.subTask("Fetching name spaces");
this.cluster.namespaces.clearSetData();
// refresh Namespace list for each node
for (Object kid : this.cluster.nodes.getChildren()) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
if (kid instanceof AsNode) {
AsNode node = (AsNode) kid;
String namespacesString = Info.request(infoPolicy, node.getNode(), "namespaces");
if (!namespacesString.isEmpty()) {
String[] nameSpaces = namespacesString.split(";");
for (String nameSpace : nameSpaces) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
AsNameSpace nodeNamespace = node.fetchNameSpace(nameSpace);
AsNameSpace clusterNameSpace = this.cluster.namespaces.fetchNameSpace(nameSpace);
String nameSpaceString = Info.request(infoPolicy, node.getNode(), "namespace/" + nameSpace);
nodeNamespace.setNamespaceInfo(nameSpaceString);
clusterNameSpace.mergeNamespaceInfo(nameSpaceString);
String setsString = Info.request(infoPolicy, node.getNode(), "sets/" + nameSpace);
if (!setsString.isEmpty()) {
String[] sets = setsString.split(";");
for (String setData : sets) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
nodeNamespace.addSet(setData);
clusterNameSpace.mergeSet(setData);
}
}
}
}
}
}
monitor.worked(10);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
monitor.subTask("Fetching packages");
String packagesString = Info.request(infoPolicy, nodes[0], "udf-list");
if (!packagesString.isEmpty()) {
this.cluster.packages.clear();
String[] packagesList = packagesString.split(";");
for (String pkgString : packagesList) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
Module pkg = this.cluster.packages.fetchPackage(pkgString);
String udfString = Info.request(infoPolicy, nodes[0], "udf-get:filename=" + pkg.getName());
//gen=qgmyp0d8hQNvJdnR42X3BXgUGPE=;type=LUA;recordContent=bG9jYWwgZnVuY3Rpb24gcHV0QmluKHIsbmFtZSx2YWx1ZSkKICAgIGlmIG5vdCBhZXJvc3Bpa2U6ZXhpc3RzKHIpIHRoZW4gYWVyb3NwaWtlOmNyZWF0ZShyKSBlbmQKICAgIHJbbmFtZV0gPSB2YWx1ZQogICAgYWVyb3NwaWtlOnVwZGF0ZShyKQplbmQKCi0tIFNldCBhIHBhcnRpY3VsYXIgYmluCmZ1bmN0aW9uIHdyaXRlQmluKHIsbmFtZSx2YWx1ZSkKICAgIHB1dEJpbihyLG5hbWUsdmFsdWUpCmVuZAoKLS0gR2V0IGEgcGFydGljdWxhciBiaW4KZnVuY3Rpb24gcmVhZEJpbihyLG5hbWUpCiAgICByZXR1cm4gcltuYW1lXQplbmQKCi0tIFJldHVybiBnZW5lcmF0aW9uIGNvdW50IG9mIHJlY29yZApmdW5jdGlvbiBnZXRHZW5lcmF0aW9uKHIpCiAgICByZXR1cm4gcmVjb3JkLmdlbihyKQplbmQKCi0tIFVwZGF0ZSByZWNvcmQgb25seSBpZiBnZW4gaGFzbid0IGNoYW5nZWQKZnVuY3Rpb24gd3JpdGVJZkdlbmVyYXRpb25Ob3RDaGFuZ2VkKHIsbmFtZSx2YWx1ZSxnZW4pCiAgICBpZiByZWNvcmQuZ2VuKHIpID09IGdlbiB0aGVuCiAgICAgICAgcltuYW1lXSA9IHZhbHVlCiAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQogICAgZW5kCmVuZAoKLS0gU2V0IGEgcGFydGljdWxhciBiaW4gb25seSBpZiByZWNvcmQgZG9lcyBub3QgYWxyZWFkeSBleGlzdC4KZnVuY3Rpb24gd3JpdGVVbmlxdWUocixuYW1lLHZhbHVlKQogICAgaWYgbm90IGFlcm9zcGlrZTpleGlzdHMocikgdGhlbiAKICAgICAgICBhZXJvc3Bpa2U6Y3JlYXRlKHIpIAogICAgICAgIHJbbmFtZV0gPSB2YWx1ZQogICAgICAgIGFlcm9zcGlrZTp1cGRhdGUocikKICAgIGVuZAplbmQKCi0tIFZhbGlkYXRlIHZhbHVlIGJlZm9yZSB3cml0aW5nLgpmdW5jdGlvbiB3cml0ZVdpdGhWYWxpZGF0aW9uKHIsbmFtZSx2YWx1ZSkKICAgIGlmICh2YWx1ZSA+PSAxIGFuZCB2YWx1ZSA8PSAxMCkgdGhlbgogICAgICAgIHB1dEJpbihyLG5hbWUsdmFsdWUpCiAgICBlbHNlCiAgICAgICAgZXJyb3IoIjEwMDA6SW52YWxpZCB2YWx1ZSIpIAogICAgZW5kCmVuZAoKLS0gUmVjb3JkIGNvbnRhaW5zIHR3byBpbnRlZ2VyIGJpbnMsIG5hbWUxIGFuZCBuYW1lMi4KLS0gRm9yIG5hbWUxIGV2ZW4gaW50ZWdlcnMsIGFkZCB2YWx1ZSB0byBleGlzdGluZyBuYW1lMSBiaW4uCi0tIEZvciBuYW1lMSBpbnRlZ2VycyB3aXRoIGEgbXVsdGlwbGUgb2YgNSwgZGVsZXRlIG5hbWUyIGJpbi4KLS0gRm9yIG5hbWUxIGludGVnZXJzIHdpdGggYSBtdWx0aXBsZSBvZiA5LCBkZWxldGUgcmVjb3JkLiAKZnVuY3Rpb24gcHJvY2Vzc1JlY29yZChyLG5hbWUxLG5hbWUyLGFkZFZhbHVlKQogICAgbG9jYWwgdiA9IHJbbmFtZTFdCgogICAgaWYgKHYgJSA5ID09IDApIHRoZW4KICAgICAgICBhZXJvc3Bpa2U6cmVtb3ZlKHIpCiAgICAgICAgcmV0dXJuCiAgICBlbmQKCiAgICBpZiAodiAlIDUgPT0gMCkgdGhlbgogICAgICAgIHJbbmFtZTJdID0gbmlsCiAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQogICAgICAgIHJldHVybgogICAgZW5kCgogICAgaWYgKHYgJSAyID09IDApIHRoZW4KICAgICAgICByW25hbWUxXSA9IHYgKyBhZGRWYWx1ZQogICAgICAgIGFlcm9zcGlrZTp1cGRhdGUocikKICAgIGVuZAplbmQKCi0tIFNldCBleHBpcmF0aW9uIG9mIHJlY29yZAotLSBmdW5jdGlvbiBleHBpcmUocix0dGwpCi0tICAgIGlmIHJlY29yZC50dGwocikgPT0gZ2VuIHRoZW4KLS0gICAgICAgIHJbbmFtZV0gPSB2YWx1ZQotLSAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQotLSAgICBlbmQKLS0gZW5kCg==;
pkg.setDetailInfo(udfString);
}
}
monitor.worked(10);
//refresh Indexes
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
monitor.subTask("Fetching Indexes");
String indexString = Info.request(infoPolicy, nodes[0], "sindex");
if (!indexString.isEmpty()) {
String[] indexList = indexString.split(";");
for (String index : indexList) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
this.cluster.indexes.add(index);
}
}
monitor.worked(10);
} catch (InterruptedException e) {
CoreActivator.showError(e, "Could not refresh cluster");
return Status.CANCEL_STATUS;
} catch (AerospikeException e) {
CoreActivator.log(IStatus.ERROR, "Could not refresh cluster", e);
return Status.CANCEL_STATUS;
}
// refresh the view
UIJob job = new UIJob("Refresh Aerospike nodes") {
public IStatus runInUIThread(IProgressMonitor arg0) {
if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
viewer.refresh();
}
return Status.OK_STATUS;
}
};
// ISchedulingRule rule = op.getRule();
// if (rule != null) {
// job.setRule(rule);
// }
job.setUser(true);
job.schedule();
try {
String autoRefreshString = project.getPersistentProperty(CoreActivator.AUTO_REFRESH);
boolean autoRefresh = Boolean.parseBoolean((autoRefreshString == null) ? "false" : autoRefreshString);
if (autoRefresh) {
String refreshPeriodString = project.getPersistentProperty(CoreActivator.REFRESH_PERIOD);
long period = 30000l;
if (refreshPeriodString != null)
period = 1000 * Long.parseLong(refreshPeriodString);
schedule(period);
}
} catch (CoreException e) {
CoreActivator.log(IStatus.ERROR, "Error scheduling cluster refresh", e);
}
return Status.OK_STATUS;
}Example 100
| Project: goclipse-master File: ProblemMarkerManager.java View source code |
private void postAsyncUpdate(final Display display) {
if (fNotifierJob == null) {
fNotifierJob = new UIJob(display, "Sending problem marker updates...") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
runPendingUpdates();
return Status.OK_STATUS;
}
};
fNotifierJob.setSystem(true);
}
fNotifierJob.schedule();
}Example 101
| Project: imp.runtime-master File: PreferenceInitializer.java View source code |
public void initializeDefaultPreferences() {
if (Display.getCurrent() == null) {
// This isn't the UI thread, so schedule a job to do the initialization later.
UIJob job = new UIJob("IMP Preference Initializer") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (// this should never be false, but let's be safe
Display.getCurrent() != null) {
new PreferenceInitializer().initializeDefaultPreferences();
}
return Status.OK_STATUS;
}
};
job.schedule(0);
return;
}
IPreferenceStore store = RuntimePlugin.getInstance().getPreferenceStore();
EditorsUI.useAnnotationsPreferencePage(store);
EditorsUI.useQuickDiffPreferencePage(store);
FontData fontData = findSuitableFont();
if (fontData != null) {
// System.out.println("Using font " + fontData.getName() + " at height " + fontData.getHeight());
PreferenceConverter.setDefault(store, PreferenceConstants.P_SOURCE_FONT, new FontData[] { fontData });
}
store.setDefault(PreferenceConstants.P_EMIT_MESSAGES, false);
store.setDefault(PreferenceConstants.P_EMIT_BUILDER_DIAGNOSTICS, false);
store.setDefault(PreferenceConstants.P_TAB_WIDTH, 8);
store.setDefault(PreferenceConstants.P_SPACES_FOR_TABS, false);
store.setDefault(PreferenceConstants.P_DUMP_TOKENS, false);
store.setDefault(PreferenceConstants.EDITOR_MATCHING_BRACKETS, true);
store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, true);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, false);
String colorKey = RuntimePlugin.IMP_RUNTIME + "." + PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
ColorRegistry registry = null;
if (PlatformUI.isWorkbenchRunning()) {
registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
}
PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, findRGB(registry, colorKey, new RGB(192, 192, 192)));
}