<commit_before>package edu.uci.lighthouse.core.dbactions;

import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

import edu.uci.lighthouse.core.util.UserDialog;
import edu.uci.lighthouse.model.jpa.JPAException;

public class JobDecoratorAction implements IDatabaseAction{

	private IDatabaseAction action;
	
	private String titleLabel;
	
	private String taskLabel;
	
	private static Logger logger = Logger.getLogger(JobDecoratorAction.class);
	
	public JobDecoratorAction(IDatabaseAction action) {
		this(action, "Lighthouse Database Actions", "Executing "+action.getClass().getName()+" ...");
	}
	
	public JobDecoratorAction(IDatabaseAction action, String titleLabel, String taskLabel) {
		this.action = action;
		this.titleLabel = titleLabel;
		this.taskLabel = taskLabel;
	}
	
	@Override
	public void run() {
		final Job job = new Job(titleLabel) {
			@Override
			protected IStatus run(IProgressMonitor monitor) {
				try {
					monitor.beginTask(taskLabel,
							IProgressMonitor.UNKNOWN);
					action.run();
				} catch (JPAException e) {
					logger.error(e, e);
					UserDialog.openError("JPAException: " + e.getMessage());
				} finally {
					monitor.done();
				}
				return Status.OK_STATUS;
			}
		};
		job.setUser(true);
		job.schedule();
	}
}<commit_msg>Added job listener method<commit_after>package edu.uci.lighthouse.core.dbactions;

import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;

import edu.uci.lighthouse.core.Activator;
import edu.uci.lighthouse.core.util.UserDialog;
import edu.uci.lighthouse.model.jpa.JPAException;

public class JobDecoratorAction implements IDatabaseAction{

	private IDatabaseAction action;
	
	private String titleLabel;
	
	private String taskLabel;
	
	private static Logger logger = Logger.getLogger(JobDecoratorAction.class);
	
	private Job job;
	
	public JobDecoratorAction(IDatabaseAction action) {
		this(action, "Lighthouse Database Actions", "Executing "+action.getClass().getSimpleName()+" ...");
	}
	
	public JobDecoratorAction(IDatabaseAction action, String titleLabel, String taskLabel) {
		this.action = action;
		this.titleLabel = titleLabel;
		this.taskLabel = taskLabel;
		attachJob();
	}
	
	@Override
	public void run() {
		job.setUser(true);
		job.schedule();
	}
	
	private void attachJob() {
		job = new Job(titleLabel) {
			@Override
			protected IStatus run(IProgressMonitor monitor) {
				try {
					monitor.beginTask(taskLabel,
							IProgressMonitor.UNKNOWN);
					action.run();
				} catch (JPAException e) {
					logger.error(e, e);
					return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage());
				} finally {
					monitor.done();
				}
				return Status.OK_STATUS;
			}
		};
//		job.addJobChangeListener(new JobChangeAdapter() {
//			@Override
//			public void done(final IJobChangeEvent event) {
//				if (event.getResult() != Status.CANCEL_STATUS && !event.getResult().isOK()) {
//					UserDialog.openError(event.getResult().getMessage());
//				}
//			}
//		});
	}
	
	public void addJobChangeListener(IJobChangeListener listener) {
		job.addJobChangeListener(listener);
	}
}
{'fraction_non_alphanumeric': 0.11807909604519774, 'fraction_numerical': 0.0005649717514124294, 'mean_word_length': 4.253709198813056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6649943', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1118, 'n_words': 213}