<commit_before>/*******************************************************************************
 * Copyright (c) 2011 Red Hat, Inc.
 *  All rights reserved.
 * This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Red Hat, Inc. - initial API and implementation
 *
 * @author <NAME>
 ******************************************************************************/
package org.eclipse.bpmn2.modeler.ui.property;

import static org.eclipse.bpmn2.modeler.core.utils.SelectionUtil.getSelectedBusinessObject;
import static org.eclipse.bpmn2.modeler.core.utils.SelectionUtil.getSelectedModel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.bpmn2.Activity;
import org.eclipse.bpmn2.Event;
import org.eclipse.bpmn2.Gateway;
import org.eclipse.bpmn2.Participant;
import org.eclipse.bpmn2.SequenceFlow;
import org.eclipse.bpmn2.modeler.core.property.AbstractTabSection;
import org.eclipse.bpmn2.modeler.core.property.SectionDescriptor;
import org.eclipse.bpmn2.modeler.core.property.TabDescriptor;
import org.eclipse.bpmn2.modeler.ui.property.tabs.DefinitionsTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.EventTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.ListenerTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.GeneralTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.MultiInstanceTabSection;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptorProvider;

public class PropertyTabDescriptorProvider implements ITabDescriptorProvider {

	@Override
	public ITabDescriptor[] getTabDescriptors(IWorkbenchPart part, ISelection selection) {
		List<ITabDescriptor> tabs = new ArrayList<ITabDescriptor>();
		
		Object model = getSelectedModel(selection);
		EObject businessObject = getSelectedBusinessObject(model);
		
		if (businessObject != null) {
			tabs.add(createGeneralTabDescriptor());
			
			if (businessObject instanceof Event) {
				tabs.add(createEventTabDescriptor());
			}
			
			// add definitions tab for errors, messages and signals
			if (model instanceof Diagram) {
				tabs.add(createDefinitionsTabDescriptor());
			}
			
			// add multi instance tabs to activities
			if (businessObject instanceof Activity) {
				tabs.add(createMultiInstanceTabDescriptor());
			}
			
			// add execution listener tabs
			if (businessObject instanceof Activity ||
				businessObject instanceof Gateway ||
				businessObject instanceof SequenceFlow || 
				businessObject instanceof Event || 
				businessObject instanceof Process) {
				
				tabs.add(createExecutionListenerTabDescriptor());
			}
			
			// for participant, too
			if (businessObject instanceof Participant) {
				Participant participant = (Participant) businessObject;
				
				if (participant.getProcessRef() != null) {
					tabs.add(createExecutionListenerTabDescriptor());
				}
			}
		}
		
		return tabs.toArray(new ITabDescriptor[]{});
	}
	
	private ITabDescriptor createTabDescriptor(String id, String name, AbstractTabSection tabSection) {

		TabDescriptor tabDescriptor = new TabDescriptor(id, name, name);
		ISectionDescriptor sectionDescriptor = new SectionDescriptor(id + ".section", tabSection);
		tabDescriptor.setSectionDescriptors(Arrays.asList(new ISectionDescriptor[] { sectionDescriptor }));
		
		return tabDescriptor;
	}

	private ITabDescriptor createMultiInstanceTabDescriptor() {
		return createTabDescriptor("multiInstanceTab", "Multi Instance", new MultiInstanceTabSection());
	}

	private ITabDescriptor createEventTabDescriptor() {
		return createTabDescriptor("eventTab", "Event", new EventTabSection());
	}
	
	private ITabDescriptor createExecutionListenerTabDescriptor() {
		return createTabDescriptor("executionListenerTab", "Listener", new ListenerTabSection());
	}

	private ITabDescriptor createGeneralTabDescriptor() {
		return createTabDescriptor("generalTab", "General", new GeneralTabSection());
	}

	private ITabDescriptor createDefinitionsTabDescriptor() {
		return createTabDescriptor("definitionsTab", "Definitions", new DefinitionsTabSection());
	}

}<commit_msg>HEMERA-3339: Stuff<commit_after>/*******************************************************************************
 * Copyright (c) 2011 Red Hat, Inc.
 *  All rights reserved.
 * This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Red Hat, Inc. - initial API and implementation
 *
 * @author <NAME>
 ******************************************************************************/
package org.eclipse.bpmn2.modeler.ui.property;

import static org.eclipse.bpmn2.modeler.core.utils.SelectionUtil.getSelectedBusinessObject;
import static org.eclipse.bpmn2.modeler.core.utils.SelectionUtil.getSelectedModel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.bpmn2.Activity;
import org.eclipse.bpmn2.Event;
import org.eclipse.bpmn2.Gateway;
import org.eclipse.bpmn2.Participant;
import org.eclipse.bpmn2.SequenceFlow;
import org.eclipse.bpmn2.Process;
import org.eclipse.bpmn2.modeler.core.property.AbstractTabSection;
import org.eclipse.bpmn2.modeler.core.property.SectionDescriptor;
import org.eclipse.bpmn2.modeler.core.property.TabDescriptor;
import org.eclipse.bpmn2.modeler.ui.property.tabs.DefinitionsTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.EventTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.ListenerTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.GeneralTabSection;
import org.eclipse.bpmn2.modeler.ui.property.tabs.MultiInstanceTabSection;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptorProvider;

public class PropertyTabDescriptorProvider implements ITabDescriptorProvider {

	@Override
	public ITabDescriptor[] getTabDescriptors(IWorkbenchPart part, ISelection selection) {
		List<ITabDescriptor> tabs = new ArrayList<ITabDescriptor>();
		
		Object model = getSelectedModel(selection);
		EObject businessObject = getSelectedBusinessObject(model);
		
		if (businessObject != null) {
			tabs.add(createGeneralTabDescriptor());
			
			if (businessObject instanceof Event) {
				tabs.add(createEventTabDescriptor());
			}
			
			// add definitions tab for errors, messages and signals
			if (model instanceof Diagram) {
				tabs.add(createDefinitionsTabDescriptor());
			}
			
			// add multi instance tabs to activities
			if (businessObject instanceof Activity) {
				tabs.add(createMultiInstanceTabDescriptor());
			}
			
			// add execution listener tabs
			if (businessObject instanceof Activity ||
				businessObject instanceof Gateway ||
				businessObject instanceof SequenceFlow || 
				businessObject instanceof Event || 
				businessObject instanceof Process) {
				
				tabs.add(createListenerTabDescriptor());
			}
			
			// for participant, too
			if (businessObject instanceof Participant) {
				Participant participant = (Participant) businessObject;
				
				if (participant.getProcessRef() != null) {
					tabs.add(createListenerTabDescriptor());
				}
			}
		}
		
		return tabs.toArray(new ITabDescriptor[]{});
	}
	
	private ITabDescriptor createTabDescriptor(String id, String name, AbstractTabSection tabSection) {

		TabDescriptor tabDescriptor = new TabDescriptor(id, name, name);
		ISectionDescriptor sectionDescriptor = new SectionDescriptor(id + ".section", tabSection);
		tabDescriptor.setSectionDescriptors(Arrays.asList(new ISectionDescriptor[] { sectionDescriptor }));
		
		return tabDescriptor;
	}

	private ITabDescriptor createMultiInstanceTabDescriptor() {
		return createTabDescriptor("multiInstanceTab", "Multi Instance", new MultiInstanceTabSection());
	}

	private ITabDescriptor createEventTabDescriptor() {
		return createTabDescriptor("eventTab", "Event", new EventTabSection());
	}
	
	private ITabDescriptor createListenerTabDescriptor() {
		return createTabDescriptor("listenerTab", "Listener", new ListenerTabSection());
	}

	private ITabDescriptor createGeneralTabDescriptor() {
		return createTabDescriptor("generalTab", "General", new GeneralTabSection());
	}

	private ITabDescriptor createDefinitionsTabDescriptor() {
		return createTabDescriptor("definitionsTab", "Definitions", new DefinitionsTabSection());
	}

}
{'fraction_non_alphanumeric': 0.129288472145615, 'fraction_numerical': 0.005846662989520132, 'mean_word_length': 5.550578034682081, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3442570', 'n_tokens_mistral': 2742, 'n_tokens_neox': 2436, 'n_words': 517}