<commit_before>package app.editors;

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.openlca.ilcd.commons.IDataSet;
import org.openlca.ilcd.commons.Ref;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import app.M;
import app.editors.contact.ContactEditor;
import app.editors.epd.EpdEditor;
import app.editors.flow.FlowEditor;
import app.editors.flowproperty.FlowPropertyEditor;
import app.editors.io.UploadDialog;
import app.editors.methods.MethodEditor;
import app.editors.source.SourceEditor;
import app.editors.unitgroup.UnitGroupEditor;
import app.rcp.Icon;
import app.store.validation.ValidationDialog;
import app.util.Actions;
import app.util.MsgBox;

public class DataSetToolBar extends EditorActionBarContributor {

	private Logger log = LoggerFactory.getLogger(getClass());

	@Override
	public void contributeToToolBar(IToolBarManager manager) {
		manager.add(Actions.create(M.UploadDataSet,
				Icon.UPLOAD.des(), this::tryUpload));
		manager.add(Actions.create("#Validate data set",
				Icon.OK.des(), this::tryValidate));
	}

	private void tryUpload() {
		IEditorPart p = Editors.getActive();
		if (p.isDirty()) {
			MsgBox.error("#Unsaved changes",
					"#Please save the data set first.");
			return;<commit_msg>added a reload function to data set editors<commit_after>package app.editors;

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.openlca.ilcd.commons.IDataSet;
import org.openlca.ilcd.commons.Ref;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import app.M;
import app.editors.contact.ContactEditor;
import app.editors.epd.EpdEditor;
import app.editors.flow.FlowEditor;
import app.editors.flowproperty.FlowPropertyEditor;
import app.editors.io.UploadDialog;
import app.editors.methods.MethodEditor;
import app.editors.source.SourceEditor;
import app.editors.unitgroup.UnitGroupEditor;
import app.rcp.Icon;
import app.store.validation.ValidationDialog;
import app.util.Actions;
import app.util.MsgBox;

public class DataSetToolBar extends EditorActionBarContributor {

	private Logger log = LoggerFactory.getLogger(getClass());

	@Override
	public void contributeToToolBar(IToolBarManager manager) {
		manager.add(Actions.create("#Reload",
				Icon.RELOAD.des(), this::reload));
		manager.add(Actions.create(M.UploadDataSet,
				Icon.UPLOAD.des(), this::tryUpload));
		manager.add(Actions.create("#Validate data set",
				Icon.OK.des(), this::tryValidate));
	}

	private void reload() {
		IEditorPart p = Editors.getActive();
		IDataSet ds = getDataSet(p);
		if (ds == null)
			return;
		if (p.isDirty()) {
			boolean b = MsgBox.ask("#Unsaved changes",
					"#There are unsaved changes which "
							+ "get lost when you reload the editor. "
							+ "Reload anyway?");
			if (!b)
				return;
		}
		Ref ref = Ref.of(ds);
		Editors.close(ref);
		Editors.open(ref);
	}

	private void tryUpload() {
		IEditorPart p = Editors.getActive();
		if (p.isDirty()) {
			MsgBox.error("#Unsaved changes",
					"#Please save the data set first.");
			return;
{'fraction_non_alphanumeric': 0.12273011897307451, 'fraction_numerical': 0.0012523481527864746, 'mean_word_length': 5.062618595825427, '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': '4721326', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1045, 'n_words': 212}