use of org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor in project eclipse.platform.text by eclipse.
the class LockJob method setUp.
@Before
public void setUp() throws Exception {
IFolder folder = ResourceHelper.createFolder("FileDocumentProviderTestProject/test");
file = (File) ResourceHelper.createFile(folder, "file.txt", "");
assertTrue(file.exists());
fsManager = file.getLocalManager();
assertTrue(fsManager.fastIsSynchronized(file));
stopLockingFlag = new AtomicBoolean(false);
stoppedByTest = new AtomicBoolean(false);
fileProvider = new FileDocumentProviderMock();
lockJob = new LockJob("Locking workspace", file, stopLockingFlag, stoppedByTest);
// We need the editor only to get the default editor status line manager
IWorkbench workbench = PlatformUI.getWorkbench();
page = workbench.getActiveWorkbenchWindow().getActivePage();
editor = IDE.openEditor(page, file);
TestUtil.runEventLoop();
IStatusLineManager statusLineManager = editor.getEditorSite().getActionBars().getStatusLineManager();
// This is default monitor which almost all editors are using
IProgressMonitor progressMonitor = statusLineManager.getProgressMonitor();
assertNotNull(progressMonitor);
assertFalse(progressMonitor instanceof NullProgressMonitor);
assertFalse(progressMonitor instanceof EventLoopProgressMonitor);
assertTrue(progressMonitor instanceof IProgressMonitorWithBlocking);
// Because this monitor is not EventLoopProgressMonitor, it will not
// process UI events while waiting on workspace lock
fileProvider.setProgressMonitor(progressMonitor);
TestUtil.waitForJobs(500, 5000);
Job[] jobs = Job.getJobManager().find(null);
String jobsList = Arrays.toString(jobs);
System.out.println("Still running jobs: " + jobsList);
if (!Job.getJobManager().isIdle()) {
jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
System.out.println("Going to cancel: " + job.getName() + " / " + job);
job.cancel();
}
}
}
Aggregations