| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.core.composition.provider; |
| 7 | |
| 8 | |
| 9 | import java.util.Collection; |
| 10 | import java.util.List; |
| 11 | |
| 12 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 13 | import org.eclipse.emf.common.notify.Notification; |
| 14 | import org.eclipse.emf.common.util.ResourceLocator; |
| 15 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 16 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 17 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 18 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 19 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 20 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 21 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 22 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 23 | |
| 24 | import de.uka.ipd.sdq.pcm.core.composition.ComposedStructure; |
| 25 | import de.uka.ipd.sdq.pcm.core.composition.CompositionFactory; |
| 26 | import de.uka.ipd.sdq.pcm.core.composition.CompositionPackage; |
| 27 | import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProvider; |
| 28 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
| 29 | |
| 30 | /** |
| 31 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.core.composition.ComposedStructure} object. |
| 32 | * <!-- begin-user-doc --> |
| 33 | * <!-- end-user-doc --> |
| 34 | * @generated |
| 35 | */ |
| 36 | public class ComposedStructureItemProvider |
| 37 | extends EntityItemProvider |
| 38 | implements |
| 39 | IEditingDomainItemProvider, |
| 40 | IStructuredItemContentProvider, |
| 41 | ITreeItemContentProvider, |
| 42 | IItemLabelProvider, |
| 43 | IItemPropertySource { |
| 44 | /** |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @generated |
| 48 | */ |
| 49 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 50 | |
| 51 | /** |
| 52 | * This constructs an instance from a factory and a notifier. |
| 53 | * <!-- begin-user-doc --> |
| 54 | * <!-- end-user-doc --> |
| 55 | * @generated |
| 56 | */ |
| 57 | public ComposedStructureItemProvider(AdapterFactory adapterFactory) { |
| 58 | super(adapterFactory); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * This returns the property descriptors for the adapted class. |
| 63 | * <!-- begin-user-doc --> |
| 64 | * <!-- end-user-doc --> |
| 65 | * @generated |
| 66 | */ |
| 67 | @Override |
| 68 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 69 | if (itemPropertyDescriptors == null) { |
| 70 | super.getPropertyDescriptors(object); |
| 71 | |
| 72 | } |
| 73 | return itemPropertyDescriptors; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 78 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 79 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 80 | * <!-- begin-user-doc --> |
| 81 | * <!-- end-user-doc --> |
| 82 | * @generated |
| 83 | */ |
| 84 | @Override |
| 85 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 86 | if (childrenFeatures == null) { |
| 87 | super.getChildrenFeatures(object); |
| 88 | childrenFeatures.add(CompositionPackage.Literals.COMPOSED_STRUCTURE__ASSEMBLY_CONTEXTS_COMPOSED_STRUCTURE); |
| 89 | childrenFeatures.add(CompositionPackage.Literals.COMPOSED_STRUCTURE__RESOURCE_REQUIRED_DELEGATION_CONNECTORS_COMPOSED_STRUCTURE); |
| 90 | childrenFeatures.add(CompositionPackage.Literals.COMPOSED_STRUCTURE__EVENT_CHANNEL_COMPOSED_STRUCTURE); |
| 91 | childrenFeatures.add(CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE); |
| 92 | } |
| 93 | return childrenFeatures; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * <!-- begin-user-doc --> |
| 98 | * <!-- end-user-doc --> |
| 99 | * @generated |
| 100 | */ |
| 101 | @Override |
| 102 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 103 | // Check the type of the specified child object and return the proper feature to use for |
| 104 | // adding (see {@link AddCommand}) it as a child. |
| 105 | |
| 106 | return super.getChildFeature(object, child); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * This returns the label text for the adapted class. |
| 111 | * <!-- begin-user-doc --> |
| 112 | * <!-- end-user-doc --> |
| 113 | * @generated |
| 114 | */ |
| 115 | @Override |
| 116 | public String getText(Object object) { |
| 117 | String label = ((ComposedStructure)object).getId(); |
| 118 | return label == null || label.length() == 0 ? |
| 119 | getString("_UI_ComposedStructure_type") : |
| 120 | getString("_UI_ComposedStructure_type") + " " + label; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 125 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 126 | * <!-- begin-user-doc --> |
| 127 | * <!-- end-user-doc --> |
| 128 | * @generated |
| 129 | */ |
| 130 | @Override |
| 131 | public void notifyChanged(Notification notification) { |
| 132 | updateChildren(notification); |
| 133 | |
| 134 | switch (notification.getFeatureID(ComposedStructure.class)) { |
| 135 | case CompositionPackage.COMPOSED_STRUCTURE__ASSEMBLY_CONTEXTS_COMPOSED_STRUCTURE: |
| 136 | case CompositionPackage.COMPOSED_STRUCTURE__RESOURCE_REQUIRED_DELEGATION_CONNECTORS_COMPOSED_STRUCTURE: |
| 137 | case CompositionPackage.COMPOSED_STRUCTURE__EVENT_CHANNEL_COMPOSED_STRUCTURE: |
| 138 | case CompositionPackage.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE: |
| 139 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 140 | return; |
| 141 | } |
| 142 | super.notifyChanged(notification); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 147 | * that can be created under this object. |
| 148 | * <!-- begin-user-doc --> |
| 149 | * <!-- end-user-doc --> |
| 150 | * @generated |
| 151 | */ |
| 152 | @Override |
| 153 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 154 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 155 | |
| 156 | newChildDescriptors.add |
| 157 | (createChildParameter |
| 158 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__ASSEMBLY_CONTEXTS_COMPOSED_STRUCTURE, |
| 159 | CompositionFactory.eINSTANCE.createAssemblyContext())); |
| 160 | |
| 161 | newChildDescriptors.add |
| 162 | (createChildParameter |
| 163 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__RESOURCE_REQUIRED_DELEGATION_CONNECTORS_COMPOSED_STRUCTURE, |
| 164 | CompositionFactory.eINSTANCE.createResourceRequiredDelegationConnector())); |
| 165 | |
| 166 | newChildDescriptors.add |
| 167 | (createChildParameter |
| 168 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__EVENT_CHANNEL_COMPOSED_STRUCTURE, |
| 169 | CompositionFactory.eINSTANCE.createEventChannel())); |
| 170 | |
| 171 | newChildDescriptors.add |
| 172 | (createChildParameter |
| 173 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 174 | CompositionFactory.eINSTANCE.createEventChannelSourceConnector())); |
| 175 | |
| 176 | newChildDescriptors.add |
| 177 | (createChildParameter |
| 178 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 179 | CompositionFactory.eINSTANCE.createEventChannelSinkConnector())); |
| 180 | |
| 181 | newChildDescriptors.add |
| 182 | (createChildParameter |
| 183 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 184 | CompositionFactory.eINSTANCE.createProvidedDelegationConnector())); |
| 185 | |
| 186 | newChildDescriptors.add |
| 187 | (createChildParameter |
| 188 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 189 | CompositionFactory.eINSTANCE.createRequiredDelegationConnector())); |
| 190 | |
| 191 | newChildDescriptors.add |
| 192 | (createChildParameter |
| 193 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 194 | CompositionFactory.eINSTANCE.createAssemblyConnector())); |
| 195 | |
| 196 | newChildDescriptors.add |
| 197 | (createChildParameter |
| 198 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 199 | CompositionFactory.eINSTANCE.createAssemblyEventConnector())); |
| 200 | |
| 201 | newChildDescriptors.add |
| 202 | (createChildParameter |
| 203 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 204 | CompositionFactory.eINSTANCE.createSourceDelegationConnector())); |
| 205 | |
| 206 | newChildDescriptors.add |
| 207 | (createChildParameter |
| 208 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 209 | CompositionFactory.eINSTANCE.createSinkDelegationConnector())); |
| 210 | |
| 211 | newChildDescriptors.add |
| 212 | (createChildParameter |
| 213 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 214 | CompositionFactory.eINSTANCE.createAssemblyInfrastructureConnector())); |
| 215 | |
| 216 | newChildDescriptors.add |
| 217 | (createChildParameter |
| 218 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 219 | CompositionFactory.eINSTANCE.createProvidedInfrastructureDelegationConnector())); |
| 220 | |
| 221 | newChildDescriptors.add |
| 222 | (createChildParameter |
| 223 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 224 | CompositionFactory.eINSTANCE.createRequiredInfrastructureDelegationConnector())); |
| 225 | |
| 226 | newChildDescriptors.add |
| 227 | (createChildParameter |
| 228 | (CompositionPackage.Literals.COMPOSED_STRUCTURE__CONNECTORS_COMPOSED_STRUCTURE, |
| 229 | CompositionFactory.eINSTANCE.createRequiredResourceDelegationConnector())); |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Return the resource locator for this item provider's resources. |
| 234 | * <!-- begin-user-doc --> |
| 235 | * <!-- end-user-doc --> |
| 236 | * @generated |
| 237 | */ |
| 238 | @Override |
| 239 | public ResourceLocator getResourceLocator() { |
| 240 | return PalladioComponentModelEditPlugin.INSTANCE; |
| 241 | } |
| 242 | |
| 243 | } |