<commit_before>package sophena.rcp.editors;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;

import sophena.model.CostSettings;
import sophena.rcp.utils.Texts;
import sophena.rcp.utils.Texts.TextDispatch;
import sophena.rcp.utils.UI;
import sophena.utils.Num;

public class CostSettingsPage extends FormPage {

	private Editor editor;
	private CostSettings costs;
	private FormToolkit toolkit;
	private boolean forProject;

	public CostSettingsPage(Editor editor, CostSettings costs) {
		super(editor, "CostSettingsPage", "Kosteneinstellungen");
		this.editor = editor;
		this.costs = costs;
	}

	public void setForProject(boolean forProject) {
		this.forProject = forProject;
	}

	public CostSettings getCosts() {
		return costs;
	}

	@Override
	protected void createFormContent(IManagedForm mform) {
		ScrolledForm form = UI.formHeader(mform, "Kosteneinstellungen");
		toolkit = mform.getToolkit();
		Composite body = UI.formBody(form, toolkit);
		if (costs != null) {
			generalSection(body);
			financeSection(body);
			createOtherSection(body);
			createPriceChangeSection(body);
		}
		form.reflow(true);
	}

	private void generalSection(Composite body) {
		Composite c = UI.formSection(body, toolkit, "Allgemein");
		UI.gridLayout(c, 3);
		t(c, "Mehrwertsteuersatz", "%", costs.vatRate)
				.onChanged(s -> costs.vatRate = Num.read(s));
		t(c, "Mittlerer Stundenlohn", "EUR", costs.hourlyWage)
				.onChanged(s -> costs.hourlyWage = Num.read(s));
		t(c, "Strompreis (netto)", "EUR/kWh", costs.electricityPrice)
				.onChanged(s -> costs.electricityPrice = Num.read(s));
		t(c, "Eigenstrombedarf", "%", costs.electricityDemandShare)
				.onChanged(s -> costs.electricityDemandShare = Num.read(s));
		if (forProject) {
			t(c, "Mittlere Stromerlöse", "EUR/kWh", Num.str(costs.electricityRevenues, 4))
					.onChanged(s -> costs.electricityRevenues = Num.read(s));
		}
	}

	private void financeSection(Composite body) {
		Composite c = UI.formSection(body, toolkit, "Finanzierung");
		UI.gridLayout(c, 3);
		t(c, "Kapital-Mischzinssatz (ohne Förderung)", "%", costs.interestRate)
				.onChanged(s -> costs.interestRate = Num.read(s));

		t(c, "Kapital-Mischzinssatz (mit Förderung)", "%",
				costs.interestRateFunding)
						.onChanged(s -> costs.interestRateFunding = Num
								.read(s));
		if (forProject) {
			t(c, "Investitionsförderung", "EUR", costs.funding)
					.onChanged(s -> costs.funding = Num.read(s));
			t(c, "Einmalige Anschlussgebühren", "EUR", 0);
		}
	}<commit_msg>#84: change label in cost settings<commit_after>package sophena.rcp.editors;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;

import sophena.model.CostSettings;
import sophena.rcp.utils.Texts;
import sophena.rcp.utils.Texts.TextDispatch;
import sophena.rcp.utils.UI;
import sophena.utils.Num;

public class CostSettingsPage extends FormPage {

	private Editor editor;
	private CostSettings costs;
	private FormToolkit toolkit;
	private boolean forProject;

	public CostSettingsPage(Editor editor, CostSettings costs) {
		super(editor, "CostSettingsPage", "Kosteneinstellungen");
		this.editor = editor;
		this.costs = costs;
	}

	public void setForProject(boolean forProject) {
		this.forProject = forProject;
	}

	public CostSettings getCosts() {
		return costs;
	}

	@Override
	protected void createFormContent(IManagedForm mform) {
		ScrolledForm form = UI.formHeader(mform, "Kosteneinstellungen");
		toolkit = mform.getToolkit();
		Composite body = UI.formBody(form, toolkit);
		if (costs != null) {
			generalSection(body);
			financeSection(body);
			createOtherSection(body);
			createPriceChangeSection(body);
		}
		form.reflow(true);
	}

	private void generalSection(Composite body) {
		Composite c = UI.formSection(body, toolkit, "Allgemein");
		UI.gridLayout(c, 3);
		t(c, "Mehrwertsteuersatz", "%", costs.vatRate)
				.onChanged(s -> costs.vatRate = Num.read(s));
		t(c, "Mittlerer Stundenlohn", "EUR", costs.hourlyWage)
				.onChanged(s -> costs.hourlyWage = Num.read(s));
		t(c, "Strompreis", "EUR/kWh", costs.electricityPrice)
				.onChanged(s -> costs.electricityPrice = Num.read(s));
		t(c, "Eigenstrombedarf", "%", costs.electricityDemandShare)
				.onChanged(s -> costs.electricityDemandShare = Num.read(s));
		if (forProject) {
			t(c, "Mittlere Stromerlöse", "EUR/kWh", Num.str(costs.electricityRevenues, 4))
					.onChanged(s -> costs.electricityRevenues = Num.read(s));
		}
	}

	private void financeSection(Composite body) {
		Composite c = UI.formSection(body, toolkit, "Finanzierung");
		UI.gridLayout(c, 3);
		t(c, "Kapital-Mischzinssatz (ohne Förderung)", "%", costs.interestRate)
				.onChanged(s -> costs.interestRate = Num.read(s));

		t(c, "Kapital-Mischzinssatz (mit Förderung)", "%",
				costs.interestRateFunding)
						.onChanged(s -> costs.interestRateFunding = Num
								.read(s));
		if (forProject) {
			t(c, "Investitionsförderung", "EUR", costs.funding)
					.onChanged(s -> costs.funding = Num.read(s));
			t(c, "Einmalige Anschlussgebühren", "EUR", 0);
		}
	}
{'fraction_non_alphanumeric': 0.140262542708146, 'fraction_numerical': 0.0017982377270275131, 'mean_word_length': 4.72811534500515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '975331', 'n_tokens_mistral': 2210, 'n_tokens_neox': 1997, 'n_words': 370}