Search in sources :

Example 56 with IJobChangeEvent

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

the class DockerContainersView method changeEvent.

@Override
public void changeEvent(final IDockerConnection connection, final int type) {
    if (type == IDockerConnectionManagerListener.UPDATE_SETTINGS_EVENT) {
        final Job refreshJob = new Job(DVMessages.getString("ContainersRefresh.msg")) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                connection.getContainers(true);
                return Status.OK_STATUS;
            }
        };
        refreshJob.addJobChangeListener(new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                Display.getDefault().asyncExec(() -> refreshViewTitle());
            }
        });
        refreshJob.schedule();
    } else if (type == IDockerConnectionManagerListener.RENAME_EVENT) {
        Display.getDefault().asyncExec(() -> refreshViewTitle());
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job)

Example 57 with IJobChangeEvent

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

the class LibHoverPreferencePage method regenerate.

private synchronized void regenerate() {
    generateButton.setEnabled(false);
    Job k = new Job(LibHoverMessages.getString(REGENERATE_MSG)) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            IPreferenceStore ps = DevHelpPlugin.getDefault().getPreferenceStore();
            ParseDevHelp.DevHelpParser p = new ParseDevHelp.DevHelpParser(ps.getString(PreferenceConstants.DEVHELP_DIRECTORY));
            LibHoverInfo hover = p.parse(monitor);
            // Update the devhelp library info if it is on library list
            Collection<LibHoverLibrary> libs = LibHover.getLibraries();
            for (LibHoverLibrary l : libs) {
                if (l.getName().equals("devhelp")) {
                    // $NON-NLS-1$
                    l.setHoverinfo(hover);
                    break;
                }
            }
            try {
                // Now, output the LibHoverInfo for caching later
                // $NON-NLS-1$
                IPath location = LibhoverPlugin.getDefault().getStateLocation().append("C");
                File ldir = new File(location.toOSString());
                ldir.mkdir();
                // $NON-NLS-1$
                location = location.append("devhelp.libhover");
                try (FileOutputStream f = new FileOutputStream(location.toOSString());
                    ObjectOutputStream out = new ObjectOutputStream(f)) {
                    out.writeObject(hover);
                }
                monitor.done();
            } catch (IOException e) {
                monitor.done();
                return new Status(IStatus.ERROR, DevHelpPlugin.PLUGIN_ID, e.getLocalizedMessage(), e);
            }
            return Status.OK_STATUS;
        }
    };
    k.setUser(true);
    k.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            Display.getDefault().syncExec(() -> {
                if (generateButton != null)
                    generateButton.setEnabled(true);
            });
        }
    });
    k.schedule();
}
Also used : LibHoverLibrary(org.eclipse.linuxtools.internal.cdt.libhover.LibHoverLibrary) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IPath(org.eclipse.core.runtime.IPath) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IOException(java.io.IOException) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) ObjectOutputStream(java.io.ObjectOutputStream) LibHoverInfo(org.eclipse.linuxtools.cdt.libhover.LibHoverInfo) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ParseDevHelp(org.eclipse.linuxtools.internal.cdt.libhover.devhelp.ParseDevHelp) FileOutputStream(java.io.FileOutputStream) Job(org.eclipse.core.runtime.jobs.Job) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) File(java.io.File)

Example 58 with IJobChangeEvent

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

the class AbstractP2Action method startLoadJob.

/**
 * Starts the repository load job. After the repositories have been loaded,
 * {@link #openWizard(LoadMetadataRepositoryJob, ProvisioningUI)} is called.
 */
protected final void startLoadJob() {
    final ProvisioningUI provUI = ProvisioningUI.getDefaultUI();
    Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
    final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(provUI);
    loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
    loadJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(final IJobChangeEvent event) {
            if (PlatformUI.isWorkbenchRunning() && event.getResult().isOK()) {
                openWizard(loadJob, provUI);
            }
        }
    });
    loadJob.setUser(true);
    loadJob.schedule();
}
Also used : ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) LoadMetadataRepositoryJob(org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob)

Aggregations

IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)58 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)52 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)26 Job (org.eclipse.core.runtime.jobs.Job)20 IStatus (org.eclipse.core.runtime.IStatus)17 ArrayList (java.util.ArrayList)7 Status (org.eclipse.core.runtime.Status)7 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)6 IFile (org.eclipse.core.resources.IFile)6 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)6 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)5 File (java.io.File)5 LoadMetadataRepositoryJob (org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob)5 ITask (com.cubrid.common.core.task.ITask)4 CheckDirTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)4 IOException (java.io.IOException)4 QAXmlHandler (net.heartsome.cat.ts.core.qa.QAXmlHandler)4 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 CheckFileTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask)3