use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class SpecfileEditorPrepareSourcesActionDelegate method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Shell shell = HandlerUtil.getActiveShellChecked(event);
final SpecfileParser specparser = new SpecfileParser();
final IResource resource = RPMHandlerUtils.getResource(event);
final RPMProject rpj = RPMHandlerUtils.getRPMProject(resource);
final IFile workFile = (IFile) rpj.getSpecFile();
final Specfile specfile = specparser.parse(workFile);
if (!downloadFile(shell, rpj, specfile)) {
return null;
}
Job job = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"Preparing sources") {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(NLS.bind(Messages.PrepareSources_prepareSources, rpj.getSpecFile().getName()), IProgressMonitor.UNKNOWN);
// $NON-NLS-1$
int offset = rpj.getSpecFile().getName().lastIndexOf(".");
MessageConsoleStream out = getConsole(rpj.getSpecFile().getName().substring(0, offset)).newMessageStream();
IStatus is = null;
try {
is = rpj.buildPrep(out);
} catch (CoreException e) {
SpecfileLog.logError(Messages.PrepareSources_coreException, e);
RPMUtils.showErrorDialog(shell, Messages.PrepareSources_error, Messages.PrepareSources_coreException);
return is;
} finally {
monitor.done();
}
return is;
}
};
// suppress UI. That's done in encapsulated
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class GcovTest method testGcovSummaryByLaunch.
@Test
public void testGcovSummaryByLaunch() {
display.syncExec(() -> {
try {
CommonNavigator vc = (CommonNavigator) window.getActivePage().showView(ProjectExplorer.VIEW_ID);
vc.selectReveal(new StructuredSelection(project.getFile(getBinName())));
Menu menu = new MenuManager().createContextMenu(vc.getCommonViewer().getControl());
new ProfileContextualLaunchAction(menu);
for (MenuItem item : menu.getItems()) {
if (item.getText().endsWith("Profile Code Coverage")) {
((ActionContributionItem) item.getData()).getAction().run();
break;
}
}
} catch (PartInitException e1) {
Assert.fail("Cannot show Project Explorer.");
}
try {
window.getActivePage().showView("org.eclipse.linuxtools.gcov.view");
} catch (PartInitException e2) {
Assert.fail("Cannot show GCov View.");
}
});
// Wait for the build job to finish (note: DebugUIPlugin doesn't put launch jobs in a family)
Job[] jobs = Job.getJobManager().find(null);
for (Job job : jobs) {
if (job.getName().contains("Gcov")) {
try {
job.join();
} catch (InterruptedException e) {
}
break;
}
}
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class DownloadPrepareSourcesTest method downloadFile.
/**
* Download and also test if the file was downloaded correctly
*
* @param project The RPM project
* @throws IOException
* @throws InterruptedException
*/
public void downloadFile(RPMProject project) throws IOException, InterruptedException {
// connect to the URL
URL url = new URL("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_OK);
// download the file
String filename = "hello-2.8.tar.gz";
IFile file = project.getConfiguration().getSourcesFolder().getFile(new Path(filename));
Job downloadJob = new DownloadJob(file, connection);
downloadJob.setUser(true);
downloadJob.schedule();
downloadJob.join();
assertEquals(downloadJob.getResult(), Status.OK_STATUS);
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class SpecfileEditorRPMBuildHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
final IResource resource = getResource(event);
rpj = getRPMProject(resource);
if (rpj != null) {
Job job = new RPMExportOperation(rpj, event.getParameter(BUILD_TYPE));
job.setUser(true);
job.schedule();
}
return null;
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class CreaterepoCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// $NON-NLS-1$
final String executionType = event.getParameter("executionType");
try {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchPage wbPage = wb.getActiveWorkbenchWindow().getActivePage();
IEditorInput editorInput = wbPage.getActiveEditor().getEditorInput();
IResource resource = ResourceUtil.getResource(editorInput);
final CreaterepoProject project = new CreaterepoProject(resource.getProject());
Job executeCreaterepo = new Job(Messages.Createrepo_jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(Messages.CreaterepoProject_executeCreaterepo, IProgressMonitor.UNKNOWN);
MessageConsoleStream os = CreaterepoUtils.findConsole(Messages.CreaterepoProject_consoleName).newMessageStream();
if (executionType.equals("refresh")) {
// $NON-NLS-1$
return project.update(os);
} else {
return project.createrepo(os);
}
} catch (CoreException e) {
Activator.logError(Messages.Createrepo_errorExecuting, e);
} finally {
monitor.done();
}
return null;
}
};
executeCreaterepo.setUser(true);
executeCreaterepo.schedule();
} catch (CoreException e) {
Activator.logError(Messages.CreaterepoProject_executeCreaterepo, e);
}
return null;
}
Aggregations