<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 org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateConnectionFeature;
import org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateFeature;
import org.eclipse.bpmn2.modeler.ui.diagram.BPMNFeatureProvider;
import org.eclipse.bpmn2.modeler.ui.editor.BPMN2Editor;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.graphiti.features.IFeature;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;

/**
 * @author <NAME>
 * 
 */
public class DescriptionPropertySection extends AbstractBpmn2PropertySection implements ITabbedPropertyConstants {

	/* (non-Javadoc)
	 * @see org.eclipse.bpmn2.modeler.ui.property.AbstractBpmn2PropertySection#createSectionRoot()
	 */
	@Override
	protected AbstractBpmn2PropertiesComposite createSectionRoot() {
		return new DescriptionPropertyComposite(this);		
	}

	public class DescriptionPropertyComposite extends AbstractBpmn2PropertiesComposite {

		/**
		 * @param section
		 */
		public DescriptionPropertyComposite(AbstractBpmn2PropertySection section) {
			super(section);
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * org.eclipse.bpmn2.modeler.ui.property.AbstractBpmn2PropertiesComposite
		 * #createBindings(org.eclipse.emf.ecore.EObject)
		 */
		@Override
		public void createBindings(EObject be) {
			String description = null;

			BPMN2Editor editor = (BPMN2Editor)getDiagramEditor();

			BPMNFeatureProvider fp = (BPMNFeatureProvider) editor.getDiagramTypeProvider().getFeatureProvider();
			PictogramElement pe = propertySection.getSelectedPictogramElement();
			IFeature cf = fp.getCreateFeatureForPictogramElement(pe);
			if (cf instanceof AbstractBpmn2CreateConnectionFeature) {
				AbstractBpmn2CreateConnectionFeature acf = (AbstractBpmn2CreateConnectionFeature) cf;
				description = acf.getCreateDescription();
			} else if (cf instanceof AbstractBpmn2CreateFeature) {
				AbstractBpmn2CreateFeature acf = (AbstractBpmn2CreateFeature) cf;
				description = acf.getDescription();
			}
			if (description == null) {
				description = "No description";
			}
			if (description != null) {
				createDescription(this, description);
			}
			
			bindAttribute(be,"id");
			bindAttribute(be,"name");
			bindList(be, "documentation");
		}
	}
}<commit_msg>Always show Description tab<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 org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateConnectionFeature;
import org.eclipse.bpmn2.modeler.core.features.AbstractBpmn2CreateFeature;
import org.eclipse.bpmn2.modeler.ui.diagram.BPMNFeatureProvider;
import org.eclipse.bpmn2.modeler.ui.editor.BPMN2Editor;
import org.eclipse.bpmn2.modeler.ui.property.editors.ObjectEditor;
import org.eclipse.bpmn2.modeler.ui.property.editors.TextObjectEditor;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.graphiti.features.IFeature;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;

/**
 * @author <NAME>
 * 
 */
public class DescriptionPropertySection extends AbstractBpmn2PropertySection implements ITabbedPropertyConstants {

	/* (non-Javadoc)
	 * @see org.eclipse.bpmn2.modeler.ui.property.AbstractBpmn2PropertySection#createSectionRoot()
	 */
	@Override
	protected AbstractBpmn2PropertiesComposite createSectionRoot() {
		return new DescriptionPropertyComposite(this);		
	}
	
	@Override
	public boolean appliesTo(IWorkbenchPart part, ISelection selection) {
		// always show this tab
		return true;
	}

	public class DescriptionPropertyComposite extends AbstractBpmn2PropertiesComposite {

		/**
		 * @param section
		 */
		public DescriptionPropertyComposite(AbstractBpmn2PropertySection section) {
			super(section);
		}
		
		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * org.eclipse.bpmn2.modeler.ui.property.AbstractBpmn2PropertiesComposite
		 * #createBindings(org.eclipse.emf.ecore.EObject)
		 */
		@Override
		public void createBindings(EObject be) {
			String description = null;

			BPMN2Editor editor = (BPMN2Editor)getDiagramEditor();

			BPMNFeatureProvider fp = (BPMNFeatureProvider) editor.getDiagramTypeProvider().getFeatureProvider();
			PictogramElement pe = propertySection.getSelectedPictogramElement();
			IFeature cf = fp.getCreateFeatureForPictogramElement(pe);
			if (cf instanceof AbstractBpmn2CreateConnectionFeature) {
				AbstractBpmn2CreateConnectionFeature acf = (AbstractBpmn2CreateConnectionFeature) cf;
				description = acf.getCreateDescription();
			} else if (cf instanceof AbstractBpmn2CreateFeature) {
				AbstractBpmn2CreateFeature acf = (AbstractBpmn2CreateFeature) cf;
				description = acf.getDescription();
			}
			if (description == null) {
				description = "No description";
			}
			if (description != null) {
				createDescription(this, description);
			}
			
			// temporarily enable these for this tab only!
			boolean idEnabled = modelEnablement.isEnabled(be.eClass().getName(), "id");
			boolean nameEnabled = modelEnablement.isEnabled(be.eClass().getName(), "name");
			boolean documentationEnabled = modelEnablement.isEnabled(be.eClass().getName(), "documentation");
			
			modelEnablement.setEnabled(be.eClass().getName(), "id", true);
			modelEnablement.setEnabled(be.eClass().getName(), "name", true);
			modelEnablement.setEnabled(be.eClass().getName(), "documentation", true);

			bindAttribute(be,"id");
			bindAttribute(be,"name");
			bindList(be, "documentation");

			if (!idEnabled)
				modelEnablement.setEnabled(be.eClass().getName(), "id", false);
			if (!nameEnabled)
				modelEnablement.setEnabled(be.eClass().getName(), "name", false);
			if (!documentationEnabled)
				modelEnablement.setEnabled(be.eClass().getName(), "documentation", false);
		}
	}
}
{'fraction_non_alphanumeric': 0.14543253060675368, 'fraction_numerical': 0.008879321942688014, 'mean_word_length': 5.381115879828326, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1379395', 'n_tokens_mistral': 2419, 'n_tokens_neox': 2149, 'n_words': 391}