<commit_before>package org.eclipse.bpmn2.modeler.ui.property.tabs.builder;

import java.util.List;

import org.eclipse.bpmn2.Bpmn2Package;
import org.eclipse.bpmn2.Definitions;
import org.eclipse.bpmn2.EventDefinition;
import org.eclipse.bpmn2.RootElement;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.bpmn2.modeler.ui.property.tabs.binding.BaseElementIdComboBinding;
import org.eclipse.bpmn2.modeler.ui.property.tabs.binding.change.EAttributeChangeSupport;
import org.eclipse.bpmn2.modeler.ui.property.tabs.binding.change.EObjectChangeSupport.ModelChangedEvent;
import org.eclipse.bpmn2.modeler.ui.property.tabs.util.Events;
import org.eclipse.bpmn2.modeler.ui.property.tabs.util.PropertyUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.graphiti.ui.platform.GFPropertySection;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

/**
 * Builder for the error code / name property.
 * 
 * @author nico.rehwaldt
 */
public class DefinitionReferencePropertyBuilder<T extends RootElement> extends AbstractPropertiesBuilder<EventDefinition> {

	private final EStructuralFeature ROOT_ELEMENTS_FEATURE = Bpmn2Package.eINSTANCE.getDefinitions_RootElements();
	
	private final EStructuralFeature refFeature;
	
	private final String label;

	private final Class<T> definitionCls;

	public DefinitionReferencePropertyBuilder(
			Composite parent, GFPropertySection section, EventDefinition bo, 
			String label, EStructuralFeature refFeature, Class<T> definitionCls) {
		
		super(parent, section, bo);
		
		this.refFeature = refFeature;
		this.definitionCls = definitionCls;
		
		this.label = label;
	}
	
	@Override
	public void create() {

		final CCombo dropDown = PropertyUtil.createDropDown(section, parent, label);
		
		Definitions definitions = ModelUtil.getDefinitions(bo);
		
		// register change support<commit_msg>Add note to error/message/signal ref<commit_after>package org.eclipse.bpmn2.modeler.ui.property.tabs.builder;

import java.util.List;

import org.eclipse.bpmn2.Bpmn2Package;
import org.eclipse.bpmn2.Definitions;
import org.eclipse.bpmn2.EventDefinition;
import org.eclipse.bpmn2.RootElement;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.bpmn2.modeler.ui.property.tabs.binding.BaseElementIdComboBinding;
import org.eclipse.bpmn2.modeler.ui.property.tabs.binding.change.EAttributeChangeSupport;
import org.eclipse.bpmn2.modeler.ui.property.tabs.binding.change.EObjectChangeSupport.ModelChangedEvent;
import org.eclipse.bpmn2.modeler.ui.property.tabs.util.Events;
import org.eclipse.bpmn2.modeler.ui.property.tabs.util.PropertyUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.graphiti.ui.platform.GFPropertySection;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

/**
 * Builder for the error code / name property.
 * 
 * @author nico.rehwaldt
 */
public class DefinitionReferencePropertyBuilder<T extends RootElement> extends AbstractPropertiesBuilder<EventDefinition> {

	private final EStructuralFeature ROOT_ELEMENTS_FEATURE = Bpmn2Package.eINSTANCE.getDefinitions_RootElements();
	
	private final EStructuralFeature refFeature;
	
	private final String label;

	private final Class<T> definitionCls;

	private String note;

	public DefinitionReferencePropertyBuilder(
			Composite parent, GFPropertySection section, EventDefinition bo, 
			String label, EStructuralFeature refFeature, Class<T> definitionCls) {
		
		super(parent, section, bo);
		
		this.refFeature = refFeature;
		this.definitionCls = definitionCls;
		
		this.label = label;
		this.note = String.format("%ss can be defined on the Definitions tab", new Object[] { definitionCls.getSimpleName() });
	}
	
	@Override
	public void create() {

		final CCombo dropDown = PropertyUtil.createDropDown(section, parent, label);
		
		if (note != null) {
			PropertyUtil.attachNote(dropDown, note);
		}
		
		Definitions definitions = ModelUtil.getDefinitions(bo);
		
		// register change support
{'fraction_non_alphanumeric': 0.09725802671666275, 'fraction_numerical': 0.006093273962971643, 'mean_word_length': 5.535987748851455, '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': '7256123', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1304, 'n_words': 243}