/*******************************************************************************
* This file is protected by Copyright.
* Please refer to the COPYRIGHT file distributed with this source distribution.
*
* This file is part of REDHAWK IDE.
*
* 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
*******************************************************************************/
// BEGIN GENERATED CODE
package gov.redhawk.model.sca.provider;
import gov.redhawk.model.sca.ScaPackage;
import gov.redhawk.model.sca.ScaStructProperty;
import gov.redhawk.model.sca.ScaStructSequenceProperty;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ViewerNotification;
/**
* This is the item provider adapter for a {@link gov.redhawk.model.sca.ScaStructProperty} object.
* <!-- begin-user-doc -->
* @since 7.0
* <!-- end-user-doc -->
* @generated
*/
public class ScaStructPropertyItemProvider extends ScaAbstractPropertyItemProvider {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ScaStructPropertyItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addFieldsPropertyDescriptor(object);
addSimplesPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Fields feature.
* <!-- begin-user-doc -->
* @since 12.3
* <!-- end-user-doc -->
* @generated
*/
protected void addFieldsPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), getResourceLocator(),
getString("_UI_ScaStructProperty_fields_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ScaStructProperty_fields_feature", "_UI_ScaStructProperty_type"),
ScaPackage.Literals.SCA_STRUCT_PROPERTY__FIELDS, false, false, false, null, null, null));
}
/**
* This adds a property descriptor for the Simples feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSimplesPropertyDescriptorGen(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), getResourceLocator(),
getString("_UI_ScaStructProperty_simples_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ScaStructProperty_simples_feature", "_UI_ScaStructProperty_type"),
ScaPackage.Literals.SCA_STRUCT_PROPERTY__SIMPLES, false, false, false, null, null, null));
}
/**
* This adds a property descriptor for the Simples feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected void addSimplesPropertyDescriptor(Object object) {
ItemPropertyDescriptor propertyDescriptor = createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
getResourceLocator(), getString("_UI_ScaStructProperty_simples_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ScaStructProperty_simples_feature", "_UI_ScaStructProperty_type"),
ScaPackage.Literals.SCA_STRUCT_PROPERTY__SIMPLES, false, false, false, null, null, null);
itemPropertyDescriptors.add(new ScaStructValuePropertyDescriptor(object, propertyDescriptor, getRootAdapterFactory()));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection< ? extends EStructuralFeature> getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(ScaPackage.Literals.SCA_STRUCT_PROPERTY__FIELDS);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String getText(Object object) {
// END GENERATED CODE
ScaStructProperty prop = (ScaStructProperty) object;
String label = ((ScaStructProperty) object).getName();
if (label == null) {
label = ((ScaStructProperty) object).getId();
}
if (prop.eContainer() instanceof ScaStructSequenceProperty) {
ScaStructSequenceProperty parent = (ScaStructSequenceProperty) prop.eContainer();
int max = parent.getStructs().size();
int index = parent.getStructs().indexOf(prop);
final String fmt = (max < 10) ? "%s [%d]" : "%s [%0" + (int) Math.ceil(Math.log10(max)) + "d]"; // SUPPRESS
// CHECKSTYLE
// AvoidInline
label = String.format(fmt, label, index);
}
return label;
// BEGIN GENERATED CODE
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(ScaStructProperty.class)) {
case ScaPackage.SCA_STRUCT_PROPERTY__SIMPLES:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case ScaPackage.SCA_STRUCT_PROPERTY__FIELDS:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
@Override
public Object getImage(Object object) {
return overlayImage(object, getPrfResourceLocator().getImage("full/obj16/Struct"));
}
}