<commit_before>package de.uni.freiburg.iig.telematik.swat.bernhard;

import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JPanel;

import de.uni.freiburg.iig.telematik.swat.lukas.OperandType;
import de.uni.freiburg.iig.telematik.swat.lukas.ParamValue;

public class ActivityOrStatePredicateParameter extends
		ParameterPanel {

	private PetriNetInformationReader informationReader;
	private TransitionParameter activityPanel;
	private StatePredicateParameter statePredicatePanel;
	boolean activityActive;
	private JComboBox chooseTypeBox;
	public ActivityOrStatePredicateParameter(String name, PetriNetInformationReader pr) {
		super(name);
		informationReader=pr;
		activityPanel=new TransitionParameter(name,pr);
		statePredicatePanel=new StatePredicateParameter(name, informationReader);
		activityActive=true;
		String arr[]={"Activity","State Predicate"};
		chooseTypeBox=new JComboBox(arr);
		chooseTypeBox.addItemListener(new ItemListener() {

			@Override
			public void itemStateChanged(ItemEvent arg0) {
				// TODO Auto-generated method stub
				if(arg0.getItem().equals("Activity")) {
					setTypeActivity();
				} else {
					setTypeStatePredicate();
				}
				
			}
			
		});
		content=new JPanel(new FlowLayout(FlowLayout.LEFT));
		content.add(chooseTypeBox);
		content.add(activityPanel.getContent());
		// TODO Auto-generated constructor stub
	}

	protected void setTypeStatePredicate() {
		// TODO Auto-generated method stub
		content.remove(activityPanel.getContent());
		content.add(statePredicatePanel.getContent());
		
		activityActive=false;
		content.repaint();
		content.updateUI();
	}

	protected void setTypeActivity() {
		// TODO Auto-generated method stub
		content.remove(statePredicatePanel.getContent());
		content.add(activityPanel.getContent());
		activityActive=true;
		content.repaint();
		content.updateUI();
	}

	@Override
	public List<ParamValue> getValue() {
		// TODO Auto-generated method stub
		if(activityActive) {
			return activityPanel.getValue();
		} else {
			return statePredicatePanel.getValue();
		}
	}

	@Override
	public void setValue(List<ParamValue> value) {
		// TODO Auto-generated method stub
		ParamValue val=value.get(0);
		if(val.getOperandType() == OperandType.TRANSITION) {
			chooseTypeBox.setSelectedItem("Activity");
			System.out.println("hallo");
			setTypeActivity();
			System.out.println(value.get(0).getOperandName());
			activityPanel.setValue(value);
		} else if (val.getOperandType() == OperandType.STATEPREDICATE) {
			chooseTypeBox.setSelectedItem("State Predicate");
			setTypeStatePredicate();
			statePredicatePanel.setValue(value);
		}
	}<commit_msg>forgot to remove debug information<commit_after>package de.uni.freiburg.iig.telematik.swat.bernhard;

import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JPanel;

import de.uni.freiburg.iig.telematik.swat.lukas.OperandType;
import de.uni.freiburg.iig.telematik.swat.lukas.ParamValue;

public class ActivityOrStatePredicateParameter extends
		ParameterPanel {

	private PetriNetInformationReader informationReader;
	private TransitionParameter activityPanel;
	private StatePredicateParameter statePredicatePanel;
	boolean activityActive;
	private JComboBox chooseTypeBox;
	public ActivityOrStatePredicateParameter(String name, PetriNetInformationReader pr) {
		super(name);
		informationReader=pr;
		activityPanel=new TransitionParameter(name,pr);
		statePredicatePanel=new StatePredicateParameter(name, informationReader);
		activityActive=true;
		String arr[]={"Activity","State Predicate"};
		chooseTypeBox=new JComboBox(arr);
		chooseTypeBox.addItemListener(new ItemListener() {

			@Override
			public void itemStateChanged(ItemEvent arg0) {
				// TODO Auto-generated method stub
				if(arg0.getItem().equals("Activity")) {
					setTypeActivity();
				} else {
					setTypeStatePredicate();
				}
				
			}
			
		});
		content=new JPanel(new FlowLayout(FlowLayout.LEFT));
		content.add(chooseTypeBox);
		content.add(activityPanel.getContent());
		// TODO Auto-generated constructor stub
	}

	protected void setTypeStatePredicate() {
		// TODO Auto-generated method stub
		content.remove(activityPanel.getContent());
		content.add(statePredicatePanel.getContent());
		
		activityActive=false;
		content.repaint();
		content.updateUI();
	}

	protected void setTypeActivity() {
		// TODO Auto-generated method stub
		content.remove(statePredicatePanel.getContent());
		content.add(activityPanel.getContent());
		activityActive=true;
		content.repaint();
		content.updateUI();
	}

	@Override
	public List<ParamValue> getValue() {
		// TODO Auto-generated method stub
		if(activityActive) {
			return activityPanel.getValue();
		} else {
			return statePredicatePanel.getValue();
		}
	}

	@Override
	public void setValue(List<ParamValue> value) {
		// TODO Auto-generated method stub
		ParamValue val=value.get(0);
		if(val.getOperandType() == OperandType.TRANSITION) {
			chooseTypeBox.setSelectedItem("Activity");
			setTypeActivity();
			activityPanel.setValue(value);
		} else if (val.getOperandType() == OperandType.STATEPREDICATE) {
			chooseTypeBox.setSelectedItem("State Predicate");
			setTypeStatePredicate();
			statePredicatePanel.setValue(value);
		}
	}
{'fraction_non_alphanumeric': 0.11117246456837843, 'fraction_numerical': 0.0012884226026136573, 'mean_word_length': 5.253164556962025, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5016366', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1634, 'n_words': 288}