Search in sources :

Example 1 with AnalyseBundleResolutionJob

use of bndtools.tasks.AnalyseBundleResolutionJob in project bndtools by bndtools.

the class ResolutionView method executeAnalysis.

void executeAnalysis() {
    if (inputLocked)
        return;
    outOfDate = false;
    synchronized (this) {
        Job oldJob = analysisJob;
        if (oldJob != null && oldJob.getState() != Job.NONE)
            oldJob.cancel();
        if (!loaders.isEmpty()) {
            final AnalyseBundleResolutionJob job = new AnalyseBundleResolutionJob("importExportAnalysis", loaders);
            job.setSystem(true);
            job.addJobChangeListener(new JobChangeAdapter() {

                @Override
                public void aboutToRun(IJobChangeEvent event) {
                    if (display != null && !display.isDisposed()) {
                        Runnable update = new Runnable() {

                            @Override
                            public void run() {
                                setContentDescription("Working...");
                            }
                        };
                        if (display.getThread() == Thread.currentThread())
                            update.run();
                        else
                            display.asyncExec(update);
                    }
                }

                @Override
                public void done(IJobChangeEvent event) {
                    IStatus result = job.getResult();
                    if (result != null && result.isOK()) {
                        if (display != null && !display.isDisposed())
                            display.asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    setInput(loaders, job.getCapabilities(), job.getRequirements());
                                }
                            });
                    }
                }
            });
            analysisJob = job;
            analysisJob.schedule(500);
        } else {
            analysisJob = null;
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) AnalyseBundleResolutionJob(bndtools.tasks.AnalyseBundleResolutionJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) AnalyseBundleResolutionJob(bndtools.tasks.AnalyseBundleResolutionJob) Job(org.eclipse.core.runtime.jobs.Job)

Example 2 with AnalyseBundleResolutionJob

use of bndtools.tasks.AnalyseBundleResolutionJob in project bndtools by bndtools.

the class BundleCalculatedImportsPart method refresh.

@Override
public void refresh() {
    super.refresh();
    IFile file = getEditorFile();
    if (file == null)
        return;
    IPath location = file.getLocation();
    if (location == null)
        return;
    Set<BndFileCapReqLoader> loaders = Collections.singleton(new BndFileCapReqLoader(location.toFile()));
    final AnalyseBundleResolutionJob job = new AnalyseBundleResolutionJob(Messages.BundleCalculatedImportsPart_jobAnalyse, loaders);
    final Display display = tree.getDisplay();
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            if (job.getResult().isOK()) {
                display.asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (tree != null && !tree.isDisposed())
                            viewer.setInput(job.getRequirements());
                    }
                });
            }
        }
    });
    job.schedule();
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) AnalyseBundleResolutionJob(bndtools.tasks.AnalyseBundleResolutionJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) BndFileCapReqLoader(bndtools.tasks.BndFileCapReqLoader) Display(org.eclipse.swt.widgets.Display)

Aggregations

AnalyseBundleResolutionJob (bndtools.tasks.AnalyseBundleResolutionJob)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)2 BndFileCapReqLoader (bndtools.tasks.BndFileCapReqLoader)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Job (org.eclipse.core.runtime.jobs.Job)1 Display (org.eclipse.swt.widgets.Display)1