Search in sources :

Example 31 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project tmdm-studio-se by Talend.

the class MDMValidationRunner method validate.

public static IModelValidateResult validate(List<IRepositoryViewObject> viewObjs, IValidationPreference validationPref, boolean forbidShowResultDialog) {
    MDMValidationRunner runner = new MDMValidationRunner(viewObjs, validationPref, forbidShowResultDialog);
    IJobChangeListener listener = new JobChangeAdapter() {

        @Override
        public void aboutToRun(IJobChangeEvent event) {
            running = true;
        }

        @Override
        public void done(IJobChangeEvent event) {
            running = false;
        }
    };
    runner.addJobChangeListener(listener);
    runner.schedule();
    try {
        runner.join();
    } catch (InterruptedException e) {
        log.error(e.getMessage(), e);
    }
    return runner.validateResult;
}
Also used : IJobChangeListener(org.eclipse.core.runtime.jobs.IJobChangeListener) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Example 32 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project eclipse.jdt.ls by eclipse.

the class MavenBuildSupportTest method testIgnoreInnerPomChanges.

@Test
public void testIgnoreInnerPomChanges() throws Exception {
    IProject project = importMavenProject("archetyped");
    assertEquals("The inner pom should not have been imported", 2, WorkspaceHelper.getAllProjects().size());
    IFile innerPom = project.getFile("src/main/resources/archetype-resources/pom.xml");
    preferences.setUpdateBuildConfigurationStatus(FeatureStatus.automatic);
    boolean[] updateTriggered = new boolean[1];
    IJobChangeListener listener = new JobChangeAdapter() {

        @Override
        public void scheduled(IJobChangeEvent event) {
            if (event.getJob().getName().contains("Update project")) {
                updateTriggered[0] = true;
            }
        }
    };
    try {
        Job.getJobManager().addJobChangeListener(listener);
        projectsManager.fileChanged(innerPom.getRawLocationURI().toString(), CHANGE_TYPE.CHANGED);
        waitForBackgroundJobs();
        assertFalse("Update project should not have been triggered", updateTriggered[0]);
    } finally {
        Job.getJobManager().removeJobChangeListener(listener);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IJobChangeListener(org.eclipse.core.runtime.jobs.IJobChangeListener) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 33 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project liferay-ide by liferay.

the class MavenGoalAction method run.

public void run(IAction action) {
    if (fSelection instanceof IStructuredSelection) {
        Object[] elems = ((IStructuredSelection) fSelection).toArray();
        IFile pomXml = null;
        IProject project = null;
        Object elem = elems[0];
        if (elem instanceof IFile) {
            pomXml = (IFile) elem;
            project = pomXml.getProject();
        } else if (elem instanceof IProject) {
            project = (IProject) elem;
            pomXml = project.getFile(IMavenConstants.POM_FILE_NAME);
        }
        if (FileUtil.exists(pomXml)) {
            IProject p = project;
            IFile pomXmlFile = pomXml;
            try {
                String pluginKey = ILiferayMavenConstants.LIFERAY_MAVEN_PLUGINS_GROUP_ID + ":" + ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_ARTIFACT_ID;
                plugin = MavenUtil.getPlugin(MavenUtil.getProjectFacade(p), pluginKey, new NullProgressMonitor());
                if (plugin == null) {
                    plugin = MavenUtil.getPlugin(MavenUtil.getProjectFacade(p), getGroupId() + ":" + getPluginKey(), new NullProgressMonitor());
                }
            } catch (CoreException ce) {
            }
            Job job = new Job(p.getName() + " - " + getMavenGoals()) {

                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    try {
                        if (plugin == null) {
                            return ProjectUI.createErrorStatus("Can't find any plugins for " + getMavenGoals());
                        }
                        monitor.beginTask(getMavenGoals(), 100);
                        _runMavenGoal(pomXmlFile, getMavenGoals(), monitor);
                        monitor.worked(80);
                        p.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                        monitor.worked(10);
                        updateProject(p, monitor);
                        monitor.worked(10);
                    } catch (Exception e) {
                        return ProjectUI.createErrorStatus("Error running Maven goal " + getMavenGoals(), e);
                    }
                    return Status.OK_STATUS;
                }
            };
            job.addJobChangeListener(new JobChangeAdapter() {

                public void done(IJobChangeEvent event) {
                    afterGoal();
                }
            });
            job.schedule();
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) Job(org.eclipse.core.runtime.jobs.Job)

Example 34 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project mylyn.docs by eclipse.

the class MarkupEditor method scheduleOutlineUpdate.

private void scheduleOutlineUpdate() {
    synchronized (MarkupEditor.this) {
        if (updateJobScheduled) {
            return;
        }
    }
    updateOutlineJob = new UIJob(Messages.MarkupEditor_updateOutline) {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            synchronized (MarkupEditor.this) {
                updateJobScheduled = false;
            }
            if (!outlineDirty) {
                return Status.CANCEL_STATUS;
            }
            updateOutline();
            return Status.OK_STATUS;
        }
    };
    updateOutlineJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void scheduled(IJobChangeEvent event) {
            synchronized (MarkupEditor.this) {
                updateJobScheduled = true;
            }
        }

        @Override
        public void done(IJobChangeEvent event) {
            synchronized (MarkupEditor.this) {
                updateJobScheduled = false;
                updateOutlineJob = null;
            }
        }
    });
    updateOutlineJob.setUser(false);
    updateOutlineJob.setSystem(true);
    updateOutlineJob.setPriority(Job.INTERACTIVE);
    updateOutlineJob.schedule(600);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) UIJob(org.eclipse.ui.progress.UIJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Example 35 with IJobChangeEvent

use of org.eclipse.core.runtime.jobs.IJobChangeEvent in project egit by eclipse.

the class FindToolbar method createFinder.

private FindToolbarJob createFinder() {
    if (job != null) {
        job.cancel();
    }
    final String currentPattern = getSearchPattern();
    job = new FindToolbarJob(MessageFormat.format(UIText.HistoryPage_findbar_find, currentPattern), findResults);
    job.pattern = currentPattern;
    job.fileRevisions = fileRevisions;
    job.ignoreCase = caseItem.getSelection();
    if (allItem.getSelection()) {
        job.findInCommitId = true;
        job.findInComments = true;
        job.findInAuthor = true;
        job.findInCommitter = true;
        job.findInReference = true;
    } else {
        job.findInCommitId = commitIdItem.getSelection();
        job.findInComments = commentsItem.getSelection();
        job.findInAuthor = authorItem.getSelection();
        job.findInCommitter = committerItem.getSelection();
        job.findInReference = referenceItem.getSelection();
    }
    job.addJobChangeListener(new JobChangeAdapter() {

        private final FindToolbarJob myJob = job;

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

                    @Override
                    public void run() {
                        if (myJob != job || myJob.fileRevisions != fileRevisions) {
                            // changed
                            return;
                        }
                        if (!isDisposed()) {
                            findCompletionUpdate(currentPattern, findResults.isOverflow());
                        }
                    }
                });
            }
        }
    });
    return job;
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Aggregations

IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)166 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)157 Job (org.eclipse.core.runtime.jobs.Job)44 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)43 IStatus (org.eclipse.core.runtime.IStatus)36 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)30 ArrayList (java.util.ArrayList)13 IFile (org.eclipse.core.resources.IFile)13 CoreException (org.eclipse.core.runtime.CoreException)12 DataSourceJob (org.jkiss.dbeaver.runtime.jobs.DataSourceJob)12 Status (org.eclipse.core.runtime.Status)11 IOException (java.io.IOException)10 DBException (org.jkiss.dbeaver.DBException)10 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)10 File (java.io.File)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 IJobChangeListener (org.eclipse.core.runtime.jobs.IJobChangeListener)8 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)8 Composite (org.eclipse.swt.widgets.Composite)7 IProject (org.eclipse.core.resources.IProject)6