use of org.eclipse.core.runtime.jobs.JobChangeAdapter 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();
}
use of org.eclipse.core.runtime.jobs.JobChangeAdapter 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();
}
Aggregations