<commit_before>package org.openlca.app.devtools;

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.openlca.app.M;
import org.openlca.app.db.Database;
import org.openlca.app.rcp.images.Icon;
import org.openlca.app.util.Actions;
import org.openlca.app.util.Editors;
import org.openlca.app.util.Info;

public class Toolbar extends EditorActionBarContributor {

	@Override
	public void contributeToToolBar(IToolBarManager manager) {
		manager.add(Actions.create("Run", Icon.RUN.descriptor(),
				() -> {
					if (Database.get() == null) {
						Info.showBox(M.NoDatabaseOpened, M.NeedOpenDatabase);
						return;
					}
					FormEditor editor = Editors.getActive();
					if (!(editor instanceof IScriptEditor))
						return;
					IScriptEditor scriptEditor = (IScriptEditor) editor;
					scriptEditor.evalContent();
				}));
	}
}<commit_msg>fix issue #23: Allow to execute Python scripts without an open database<commit_after>package org.openlca.app.devtools;

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.openlca.app.rcp.images.Icon;
import org.openlca.app.util.Actions;
import org.openlca.app.util.Editors;

public class Toolbar extends EditorActionBarContributor {

	@Override
	public void contributeToToolBar(IToolBarManager manager) {
		manager.add(Actions.create("Run", Icon.RUN.descriptor(), () -> {
			FormEditor editor = Editors.getActive();
			if (!(editor instanceof IScriptEditor))
				return;
			IScriptEditor scriptEditor = (IScriptEditor) editor;
			scriptEditor.evalContent();
		}));
	}
}
{'fraction_non_alphanumeric': 0.11849710982658959, 'fraction_numerical': 0.0011560693641618498, 'mean_word_length': 4.77, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6607890', 'n_tokens_mistral': 613, 'n_tokens_neox': 545, 'n_words': 101}