PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/owls.edit/src/owls/provider/OwlsAssignItemProvider.java

http://owl-composer.googlecode.com/
Java | 238 lines | 142 code | 18 blank | 78 comment | 6 complexity | c5b6ec446715f025d9ef89daadf7c875 MD5 | raw file
Possible License(s): MIT
  1. /**
  2. * <copyright>
  3. * </copyright>
  4. *
  5. * $Id$
  6. */
  7. package owls.provider;
  8. import java.util.ArrayList;
  9. import java.util.Collection;
  10. import java.util.List;
  11. import org.eclipse.emf.common.notify.AdapterFactory;
  12. import org.eclipse.emf.common.notify.Notification;
  13. import org.eclipse.emf.common.util.ResourceLocator;
  14. import org.eclipse.emf.common.util.UniqueEList;
  15. import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
  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.ItemPropertyDescriptor;
  23. import org.eclipse.emf.edit.provider.ItemProviderAdapter;
  24. import owls.OwlsAssign;
  25. import owls.OwlsPackage;
  26. import owls.impl.OwlsAssignImpl;
  27. /**
  28. * This is the item provider adapter for a {@link owls.OwlsAssign} object.
  29. * <!-- begin-user-doc -->
  30. * <!-- end-user-doc -->
  31. * @generated
  32. */
  33. public class OwlsAssignItemProvider
  34. extends ItemProviderAdapter
  35. implements
  36. IEditingDomainItemProvider,
  37. IStructuredItemContentProvider,
  38. ITreeItemContentProvider,
  39. IItemLabelProvider,
  40. IItemPropertySource {
  41. /**
  42. * This constructs an instance from a factory and a notifier.
  43. * <!-- begin-user-doc -->
  44. * <!-- end-user-doc -->
  45. * @generated
  46. */
  47. public OwlsAssignItemProvider(AdapterFactory adapterFactory) {
  48. super(adapterFactory);
  49. }
  50. /**
  51. * This returns the property descriptors for the adapted class.
  52. * <!-- begin-user-doc -->
  53. * <!-- end-user-doc -->
  54. * @generated
  55. */
  56. @Override
  57. public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
  58. if (itemPropertyDescriptors == null) {
  59. super.getPropertyDescriptors(object);
  60. addTargetPropertyDescriptor(object);
  61. addInputTargetPropertyDescriptor(object);
  62. addOutputSourcePropertyDescriptor(object);
  63. }
  64. return itemPropertyDescriptors;
  65. }
  66. /**
  67. * This adds a property descriptor for the Target feature.
  68. * <!-- begin-user-doc -->
  69. * <!-- end-user-doc -->
  70. * @generated
  71. */
  72. protected void addTargetPropertyDescriptor(Object object) {
  73. itemPropertyDescriptors.add
  74. (createItemPropertyDescriptor
  75. (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
  76. getResourceLocator(),
  77. getString("_UI_OwlsAssign_target_feature"),
  78. getString("_UI_PropertyDescriptor_description", "_UI_OwlsAssign_target_feature", "_UI_OwlsAssign_type"),
  79. OwlsPackage.Literals.OWLS_ASSIGN__TARGET,
  80. true,
  81. false,
  82. true,
  83. null,
  84. null,
  85. null));
  86. }
  87. /**
  88. * This adds a property descriptor for the Input Target feature.
  89. * <!-- begin-user-doc -->
  90. * <!-- end-user-doc -->
  91. * @generated NOT
  92. */
  93. protected void addInputTargetPropertyDescriptor(Object object) {
  94. itemPropertyDescriptors.add
  95. (new ItemPropertyDescriptor
  96. (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
  97. getResourceLocator(),
  98. getString("_UI_OwlsAssign_inputTarget_feature"),
  99. getString("_UI_PropertyDescriptor_description", "_UI_OwlsAssign_inputTarget_feature", "_UI_OwlsAssign_type"),
  100. OwlsPackage.Literals.OWLS_ASSIGN__INPUT_TARGET,
  101. true,
  102. false,
  103. true,
  104. null,
  105. null,
  106. null)
  107. {
  108. @Override
  109. public Collection<?> getChoiceOfValues(Object object)
  110. {
  111. OwlsAssign assign = (OwlsAssignImpl)object;
  112. // Filter out classes that aren't permitted.
  113. //
  114. Collection<?> inputs = super.getChoiceOfValues(assign);
  115. Collection filter = new ArrayList();
  116. Collection<?> results = new UniqueEList<Object>();
  117. for (Object input : inputs) {
  118. if((assign.getTarget().getHasInputs().contains(input))){
  119. filter.add(input);
  120. }
  121. }
  122. results.addAll(filter);
  123. return results;
  124. }
  125. });
  126. }
  127. /**
  128. * This adds a property descriptor for the Output Source feature.
  129. * <!-- begin-user-doc -->
  130. * <!-- end-user-doc -->
  131. * @generated NOT
  132. */
  133. protected void addOutputSourcePropertyDescriptor(Object object) {
  134. itemPropertyDescriptors.add
  135. (new ItemPropertyDescriptor
  136. (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
  137. getResourceLocator(),
  138. getString("_UI_OwlsAssign_outputSource_feature"),
  139. getString("_UI_PropertyDescriptor_description", "_UI_OwlsAssign_outputSource_feature", "_UI_OwlsAssign_type"),
  140. OwlsPackage.Literals.OWLS_ASSIGN__OUTPUT_SOURCE,
  141. true,
  142. false,
  143. true,
  144. null,
  145. null,
  146. null)
  147. {
  148. @Override
  149. public Collection<?> getChoiceOfValues(Object object)
  150. {
  151. OwlsAssign assign = (OwlsAssignImpl)object;
  152. // Filter out classes that aren't permitted.
  153. //
  154. Collection<?> outputs = super.getChoiceOfValues(assign);
  155. Collection filter = new ArrayList();
  156. Collection<?> results = new UniqueEList<Object>();
  157. for (Object output : outputs) {
  158. if(assign.getSource().getHasOutputs().contains(output)){
  159. filter.add(output);
  160. }
  161. }
  162. results.addAll(filter);
  163. return results;
  164. }
  165. });
  166. }
  167. /**
  168. * This returns OwlsAssign.gif.
  169. * <!-- begin-user-doc -->
  170. * <!-- end-user-doc -->
  171. * @generated
  172. */
  173. @Override
  174. public Object getImage(Object object) {
  175. return overlayImage(object, getResourceLocator().getImage("full/obj16/OwlsAssign"));
  176. }
  177. /**
  178. * This returns the label text for the adapted class.
  179. * <!-- begin-user-doc -->
  180. * <!-- end-user-doc -->
  181. * @generated
  182. */
  183. @Override
  184. public String getText(Object object) {
  185. return getString("_UI_OwlsAssign_type");
  186. }
  187. /**
  188. * This handles model notifications by calling {@link #updateChildren} to update any cached
  189. * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
  190. * <!-- begin-user-doc -->
  191. * <!-- end-user-doc -->
  192. * @generated
  193. */
  194. @Override
  195. public void notifyChanged(Notification notification) {
  196. updateChildren(notification);
  197. super.notifyChanged(notification);
  198. }
  199. /**
  200. * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
  201. * that can be created under this object.
  202. * <!-- begin-user-doc -->
  203. * <!-- end-user-doc -->
  204. * @generated
  205. */
  206. @Override
  207. protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
  208. super.collectNewChildDescriptors(newChildDescriptors, object);
  209. }
  210. /**
  211. * Return the resource locator for this item provider's resources.
  212. * <!-- begin-user-doc -->
  213. * <!-- end-user-doc -->
  214. * @generated
  215. */
  216. @Override
  217. public ResourceLocator getResourceLocator() {
  218. return OwlsEditPlugin.INSTANCE;
  219. }
  220. }