<commit_before>package org.perfcake.ide.editor.forms.impl.elements;

import org.perfcake.ide.core.command.Command;
import org.perfcake.ide.core.command.impl.DirectedSetCommand;
import org.perfcake.ide.core.model.director.ModelDirector;
import org.perfcake.ide.core.model.director.ModelField;

import javax.swing.JComboBox;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

public class ChoiceElement extends FieldElement {

	private List<String> values;

	public ChoiceElement(ModelDirector director, ModelField field, List<String> values) {
		super(director, field);
		if (values == null || values.isEmpty()){
			throw new IllegalArgumentException("values must not be neither null or empty.");
		}
		this.values = values;

		createMainComponent();
	}

	@Override
	void createMainComponent() {
		JComboBox<String> comboBox = new JComboBox<>(values.toArray(new String[values.size()]));
		this.component = comboBox;

		comboBox.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				Command command = new DirectedSetCommand(director, field, String.valueOf(comboBox.getSelectedItem()));
				command.execute();
			}
		});

	}

}
<commit_msg>Reflect current value in ChoiceElement<commit_after>package org.perfcake.ide.editor.forms.impl.elements;

import org.perfcake.ide.core.command.Command;
import org.perfcake.ide.core.command.impl.DirectedSetCommand;
import org.perfcake.ide.core.model.director.ModelDirector;
import org.perfcake.ide.core.model.director.ModelField;

import javax.swing.JComboBox;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

public class ChoiceElement extends FieldElement {

	private List<String> values;

	public ChoiceElement(ModelDirector director, ModelField field, List<String> values) {
		super(director, field);
		if (values == null || values.isEmpty()){
			throw new IllegalArgumentException("values must not be neither null or empty.");
		}
		this.values = values;

		createMainComponent();
	}

	@Override
	void createMainComponent() {
		JComboBox<String> comboBox = new JComboBox<>(values.toArray(new String[values.size()]));
		comboBox.setSelectedItem(director.getModelFieldValue(field));
		this.component = comboBox;

		comboBox.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				Command command = new DirectedSetCommand(director, field, String.valueOf(comboBox.getSelectedItem()));
				command.execute();
			}
		});

	}

}

{'fraction_non_alphanumeric': 0.11518937914877002, 'fraction_numerical': 0.0, 'mean_word_length': 5.341584158415841, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4674617', 'n_tokens_mistral': 838, 'n_tokens_neox': 758, 'n_words': 157}