blob: 9dc8c97e1614586cfbae03a0d06e535d285e62b0 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011 Formal Mind GmbH and University of Dusseldorf.
* 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:
* Michael Jastram - initial API and implementation
******************************************************************************/
package org.eclipse.rmf.reqif10.pror.provider;
import java.util.ArrayList;
import java.util.Collection;
import java.util.GregorianCalendar;
import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.rmf.reqif10.AttributeValueEnumeration;
import org.eclipse.rmf.reqif10.Identifiable;
import org.eclipse.rmf.reqif10.ReqIF10Package;
import org.eclipse.rmf.reqif10.SpecElementWithAttributes;
import org.eclipse.rmf.reqif10.common.util.ReqIF10Util;
/**
* This is the item provider adapter for a {@link org.eclipse.rmf.reqif10.AttributeValueEnumeration} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class AttributeValueEnumerationItemProvider
extends AttributeValueItemProvider
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public AttributeValueEnumerationItemProvider(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);
addValuesPropertyDescriptor(object);
addDefinitionPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Values feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addValuesPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_AttributeValueEnumeration_values_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_AttributeValueEnumeration_values_feature", "_UI_AttributeValueEnumeration_type"),
ReqIF10Package.Literals.ATTRIBUTE_VALUE_ENUMERATION__VALUES,
true,
false,
true,
null,
null,
null));
}
/**
* This adds a property descriptor for the Definition feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addDefinitionPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_AttributeValueEnumeration_definition_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_AttributeValueEnumeration_definition_feature", "_UI_AttributeValueEnumeration_type"),
ReqIF10Package.Literals.ATTRIBUTE_VALUE_ENUMERATION__DEFINITION,
true,
false,
true,
null,
null,
null));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected boolean shouldComposeCreationImage() {
return true;
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getText(Object object) {
return getString("_UI_AttributeValueEnumeration_type");
}
/**
* 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);
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
protected Command createCreateChildCommand(EditingDomain domain,
EObject owner, EStructuralFeature feature, Object value, int index,
Collection<?> collection) {
System.out.println("CREATE CHILDs");
return super.createCreateChildCommand(domain, owner, feature, value, index,
collection);
}
/**
* We extended the command in order to append additional commands for
* setting the lastChanged attribute of the to be added object.
*/
@Override
protected Command createAddCommand(EditingDomain domain, EObject owner,
EStructuralFeature feature, Collection<?> collection, int index) {
List<Command> commandList = new ArrayList<Command>();
commandList.add(super.createAddCommand(domain, owner, feature,
collection, index));
GregorianCalendar lastChange = ReqIF10Util.getReqIFLastChange();
if (owner instanceof AttributeValueEnumeration) {
EObject c = owner.eContainer();
if (c != null && c instanceof SpecElementWithAttributes) {
SetCommand sc = new SetCommand(domain, (Identifiable) c,
ReqIF10Package.eINSTANCE.getIdentifiable_LastChange(),
lastChange);
commandList.add(sc);
}
}
CompoundCommand cc = new CompoundCommand(commandList);
return cc;
}
}