diff options
Diffstat (limited to 'plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/style/ellipsenodedescription/EllipseNodeDescriptionColorPropertySection.java')
-rw-r--r-- | plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/style/ellipsenodedescription/EllipseNodeDescriptionColorPropertySection.java | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/style/ellipsenodedescription/EllipseNodeDescriptionColorPropertySection.java b/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/style/ellipsenodedescription/EllipseNodeDescriptionColorPropertySection.java new file mode 100644 index 0000000000..ae70a5e9fd --- /dev/null +++ b/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/style/ellipsenodedescription/EllipseNodeDescriptionColorPropertySection.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2007-2013 THALES GLOBAL SERVICES. + * All rights reserved. This program and the accompanying materials + * are 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.editor.properties.sections.style.ellipsenodedescription; + +// Start of user code imports + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; + +import org.eclipse.sirius.description.style.StylePackage; +import org.eclipse.sirius.editor.editorPlugin.SiriusEditor; +import org.eclipse.sirius.editor.properties.sections.common.AbstractComboPropertySection; + +// End of user code imports + +/** + * A section for the color property of a EllipseNodeDescription object. + */ +public class EllipseNodeDescriptionColorPropertySection extends AbstractComboPropertySection { + /** + * @see org.eclipse.sirius.editor.properties.sections.AbstractComboPropertySection#getDefaultLabelText() + */ + protected String getDefaultLabelText() { + return "Color"; //$NON-NLS-1$ + } + + /** + * @see org.eclipse.sirius.editor.properties.sections.AbstractComboPropertySection#getLabelText() + */ + protected String getLabelText() { + String labelText; + labelText = super.getLabelText() + "*:"; //$NON-NLS-1$ + // Start of user code get label text + + // End of user code get label text + return labelText; + } + + /** + * @see org.eclipse.sirius.editor.properties.sections.AbstractComboPropertySection#getFeature() + */ + protected EReference getFeature() { + return StylePackage.eINSTANCE.getEllipseNodeDescription_Color(); + } + + /** + * @see org.eclipse.sirius.editor.properties.sections.AbstractComboPropertySection#getFeatureValue(int) + */ + protected Object getFeatureValue(int index) { + return getFeatureValueAt(index); + } + + /** + * @see org.eclipse.sirius.editor.properties.sections.AbstractComboPropertySection#isEqual(int) + */ + protected boolean isEqual(int index) { + boolean isEqual = false; + if (getFeatureValueAt(index) == null) + isEqual = eObject.eGet(getFeature()) == null; + else + isEqual = getFeatureValueAt(index).equals(eObject.eGet(getFeature())); + return isEqual; + } + + /** + * Returns the value at the specified index in the choice of values for the + * feature. + * + * @param index + * Index of the value. + * @return the value at the specified index in the choice of values. + */ + protected Object getFeatureValueAt(int index) { + List<?> values = getChoiceOfValues(); + if (values.size() < index || values.size() == 0 || index == -1) { + return null; + } + return values.get(index); + } + + /** + * Fetches the list of available values for the feature. + * + * @return The list of available values for the feature. + */ + protected List<?> getChoiceOfValues() { + List<?> values = Collections.emptyList(); + List<IItemPropertyDescriptor> propertyDescriptors = getDescriptors(); + for (Iterator<IItemPropertyDescriptor> iterator = propertyDescriptors.iterator(); iterator.hasNext();) { + IItemPropertyDescriptor propertyDescriptor = (IItemPropertyDescriptor) iterator.next(); + if (((EStructuralFeature) propertyDescriptor.getFeature(eObject)) == getFeature()) + values = new ArrayList<Object>(propertyDescriptor.getChoiceOfValues(eObject)); + } + + // Required singleValued color reference : do not propose null. + values.remove(null); + + // Start of user code choice of values + // End of user code choice of values + return values; + } + + /** + * {@inheritDoc} + */ + public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { + super.createControls(parent, tabbedPropertySheetPage); + nameLabel.setFont(SiriusEditor.getFontRegistry().get("required")); + // Start of user code create controls + + // End of user code create controls + } + // Start of user code user operations + + // End of user code user operations +} |