<commit_before>package de.dhbw.wi13c.jguicreator.elemente;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import de.dhbw.wi13c.jguicreator.Settings;
import de.dhbw.wi13c.jguicreator.Settings.Setting;
import de.dhbw.wi13c.jguicreator.data.util.GUIKomponente;
import de.dhbw.wi13c.jguicreator.listener.AddEditRemoveListener;

/**
 * Klasse für die GUIKomponente ComboBox zur Darstellung von Listen mit beschreibendem Label und Buttons.
 * 
 * @author <NAME>
 *
 */
@SuppressWarnings("serial")
public class ListCombo extends GUIKomponente
{
	private String labelValue;

	private JComboBox<String> comboBoxObject;

	private JLabel labelObject;

	private JButton btnEditObject;

	private JButton btnRemoveObject;

	private JButton btnAddObject;

	/**
	 * Konstruktor zur Erstellung der ListCombo-GUIKomponente. Größe wird anhand der Settings gesetzt.
	 * 
	 * @param pValueLabel
	 * @param pListKeys
	 * @param pActionListener
	 * @param pSettings
	 */
	public ListCombo(String pValueLabel, List<String> pListKeys, AddEditRemoveListener pAddEditRemoveListener, Settings pSettings)
	{
		super();
		this.labelValue = pValueLabel;

		Dimension size = new Dimension(Integer.parseInt(pSettings.getSetting(Setting.WINDOWWIDTH)), Integer.parseInt(pSettings.getSetting(Setting.WINDOWHEIGHT)));
		size.setSize((int) (size.getWidth() * 0.92), (int) (size.getHeight() * 0.1));
		setPanelSize(size);

		this.setLayout(new BorderLayout());
		checkLabelValue();
		labelObject = new JLabel(labelValue);
		labelObject.setFont(textfont);
		labelObject.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0), (int) (size.getWidth() * 0.05), (int) (size.getHeight() * 0), (int) (size.getWidth() * 0)));
		this.add(labelObject, BorderLayout.WEST);

		String[] keys = new String[pListKeys.size()];
		keys = pListKeys.toArray(keys);
		comboBoxObject = new JComboBox<>(keys);
		initFont(17);
		comboBoxObject.setFont(textfont);

//		comboBoxObject.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.05), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.05)));

		this.add(comboBoxObject, BorderLayout.CENTER);

		JPanel pnlAdd = new JPanel();
		btnAddObject = new JButton("add");
		btnAddObject.addActionListener(e -> pAddEditRemoveListener.add());
		initFont(17);
		btnAddObject.setFont(textfont);
		pnlAdd.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001)));
		pnlAdd.add(btnAddObject);
		pnlAdd.setOpaque(false);

		JPanel pnlEdit = new JPanel();
		btnEditObject = new JButton("edit");
		btnEditObject.addActionListener(e -> pAddEditRemoveListener.edit((String) comboBoxObject.getSelectedItem()));
		initFont(17);
		btnEditObject.setFont(textfont);
		pnlEdit.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001)));
		pnlEdit.add(btnEditObject);
		pnlEdit.setOpaque(false);

		JPanel pnlRemove = new JPanel();
		btnRemoveObject = new JButton("remove");
		btnRemoveObject.addActionListener(e -> pAddEditRemoveListener.remove((String) comboBoxObject.getSelectedItem()));
		initFont(17);
		btnRemoveObject.setFont(textfont);
		pnlRemove.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001)));
		pnlRemove.add(btnRemoveObject);
		pnlRemove.setOpaque(false);

		JPanel pnlBtns = new JPanel();
		pnlBtns.add(pnlAdd);
		pnlBtns.add(pnlEdit);
		pnlBtns.add(pnlRemove);
		pnlBtns.setOpaque(false);

		this.add(pnlBtns, BorderLayout.EAST);
	}

	public String getSelectedKey()
	{
		return (String) comboBoxObject.getSelectedItem();
	}

	public JButton getBtnEdit()
	{
		return btnEditObject;
	}

	public JButton getBtnRemove()
	{
		return btnRemoveObject;
	}

	public JButton getBtnAdd()
	{
		return btnAddObject;
	}

	/**
	 * Methode die den Text des Labels um ":" erweitert.
	 */
	private void checkLabelValue()
	{
		if(labelValue != null && !"".equals(labelValue))
		{
			labelValue += ": ";
		}
	}
<commit_msg>ListCombo ab jetzt On-The-Fly aenderbar wie von Lukas gewuenscht<commit_after>package de.dhbw.wi13c.jguicreator.elemente;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import de.dhbw.wi13c.jguicreator.Settings;
import de.dhbw.wi13c.jguicreator.Settings.Setting;
import de.dhbw.wi13c.jguicreator.data.util.GUIKomponente;
import de.dhbw.wi13c.jguicreator.listener.AddEditRemoveListener;

/**
 * Klasse für die GUIKomponente ComboBox zur Darstellung von Listen mit beschreibendem Label und Buttons.
 * 
 * @author <NAME>
 *
 */
@SuppressWarnings("serial")
public class ListCombo extends GUIKomponente
{
	private String labelValue;

	private JComboBox<String> comboBoxObject;

	private JLabel labelObject;

	private JButton btnEditObject;

	private JButton btnRemoveObject;

	private JButton btnAddObject;

	/**
	 * Konstruktor zur Erstellung der ListCombo-GUIKomponente. Größe wird anhand der Settings gesetzt.
	 * 
	 * @param pValueLabel
	 * @param pListKeys
	 * @param pActionListener
	 * @param pSettings
	 */
	public ListCombo(String pValueLabel, List<String> pListKeys, AddEditRemoveListener pAddEditRemoveListener, Settings pSettings)
	{
		super();
		this.labelValue = pValueLabel;

		Dimension size = new Dimension(Integer.parseInt(pSettings.getSetting(Setting.WINDOWWIDTH)), Integer.parseInt(pSettings.getSetting(Setting.WINDOWHEIGHT)));
		size.setSize((int) (size.getWidth() * 0.92), (int) (size.getHeight() * 0.1));
		setPanelSize(size);

		this.setLayout(new BorderLayout());
		checkLabelValue();
		labelObject = new JLabel(labelValue);
		labelObject.setFont(textfont);
		labelObject.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0), (int) (size.getWidth() * 0.05), (int) (size.getHeight() * 0), (int) (size.getWidth() * 0)));
		this.add(labelObject, BorderLayout.WEST);
		
		String[] keys = new String[pListKeys.size()];
		keys = pListKeys.toArray(keys);
		comboBoxObject = new JComboBox<>(keys);
		
		initFont(17);
		comboBoxObject.setFont(textfont);

//		comboBoxObject.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.05), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.05)));

		this.add(comboBoxObject, BorderLayout.CENTER);

		JPanel pnlAdd = new JPanel();
		btnAddObject = new JButton("add");
		btnAddObject.addActionListener(e -> pAddEditRemoveListener.add());
		initFont(17);
		btnAddObject.setFont(textfont);
		pnlAdd.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001)));
		pnlAdd.add(btnAddObject);
		pnlAdd.setOpaque(false);

		JPanel pnlEdit = new JPanel();
		btnEditObject = new JButton("edit");
		btnEditObject.addActionListener(e -> pAddEditRemoveListener.edit((String) comboBoxObject.getSelectedItem()));
		initFont(17);
		btnEditObject.setFont(textfont);
		pnlEdit.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001)));
		pnlEdit.add(btnEditObject);
		pnlEdit.setOpaque(false);

		JPanel pnlRemove = new JPanel();
		btnRemoveObject = new JButton("remove");
		btnRemoveObject.addActionListener(e -> pAddEditRemoveListener.remove((String) comboBoxObject.getSelectedItem()));
		initFont(17);
		btnRemoveObject.setFont(textfont);
		pnlRemove.setBorder(BorderFactory.createEmptyBorder((int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001), (int) (size.getHeight() * 0.01), (int) (size.getWidth() * 0.0001)));
		pnlRemove.add(btnRemoveObject);
		pnlRemove.setOpaque(false);

		JPanel pnlBtns = new JPanel();
		pnlBtns.add(pnlAdd);
		pnlBtns.add(pnlEdit);
		pnlBtns.add(pnlRemove);
		pnlBtns.setOpaque(false);

		this.add(pnlBtns, BorderLayout.EAST);
	}

	public String getSelectedKey()
	{
		return (String) comboBoxObject.getSelectedItem();
	}

	public JButton getBtnEdit()
	{
		return btnEditObject;
	}

	public JButton getBtnRemove()
	{
		return btnRemoveObject;
	}

	public JButton getBtnAdd()
	{
		return btnAddObject;
	}

	public void updateListValue(List<String> pListKeys){
		comboBoxObject.removeAllItems();
		for(String item : pListKeys)
		{
			comboBoxObject.addItem(item);
		}
	}
	
	/**
	 * Methode die den Text des Labels um ":" erweitert.
	 */
	private void checkLabelValue()
	{
		if(labelValue != null && !"".equals(labelValue))
		{
			labelValue += ": ";
		}
	}

{'fraction_non_alphanumeric': 0.14467566969227363, 'fraction_numerical': 0.019703342926721275, 'mean_word_length': 5.318181818181818, 'pattern_counts': {'":': 4, '<': 12, '<?xml version=': 0, '>': 18, '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': '1220693', 'n_tokens_mistral': 3483, 'n_tokens_neox': 3174, 'n_words': 573}