1 17 package org.eclipse.emf.mapping.provider; 18 19 20 import java.util.Collection ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 24 import org.eclipse.emf.common.notify.AdapterFactory; 25 import org.eclipse.emf.common.notify.Notification; 26 import org.eclipse.emf.common.util.ResourceLocator; 27 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 28 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 29 import org.eclipse.emf.edit.provider.IItemLabelProvider; 30 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; 31 import org.eclipse.emf.edit.provider.IItemPropertySource; 32 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 33 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 34 36 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 37 import org.eclipse.emf.edit.provider.ItemPropertyDescriptorDecorator; 38 import org.eclipse.emf.mapping.Mapping; 39 import org.eclipse.emf.mapping.MappingHelper; 40 import org.eclipse.emf.mapping.MappingPackage; 41 import org.eclipse.emf.mapping.MappingPlugin; 42 43 45 46 49 public class MappingHelperItemProvider 50 extends MappingItemProviderAdapter 51 implements 52 IEditingDomainItemProvider, 53 IStructuredItemContentProvider, 54 ITreeItemContentProvider, 55 IItemLabelProvider, 56 IItemPropertySource 57 { 58 61 public MappingHelperItemProvider(AdapterFactory adapterFactory) 62 { 63 super(adapterFactory); 64 } 65 66 69 public List getPropertyDescriptors(Object object) 70 { 71 if (itemPropertyDescriptors == null) 72 { 73 super.getPropertyDescriptors(object); 74 75 MappingHelper mappingHelper = (MappingHelper)object; 76 77 Mapping mapping = mappingHelper.getMapper(); 78 79 MappingPackage ePackage = MappingPackage.eINSTANCE; 80 if (!mappingHelper.getNested().isEmpty()) 81 { 82 int count = 1; 83 for (Iterator helpers = mappingHelper.getNested().iterator(); helpers.hasNext(); ++count) 84 { 85 final MappingHelper childHelper = (MappingHelper)helpers.next(); 86 87 String additionalLabel = 88 mapping.getInputs().contains(childHelper.getHelpedObject()) ? MappingPlugin.INSTANCE.getString("_UI_Input_label") : 89 mapping.getOutputs().contains(childHelper.getHelpedObject()) ? MappingPlugin.INSTANCE.getString("_UI_Output_label") : 90 ""; 91 92 IItemPropertyDescriptor childHelperItemPropertyDescriptor = 93 (new ItemPropertyDescriptor 94 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 95 count + ". " + additionalLabel + MappingPlugin.INSTANCE.getString("_UI_Helper_label"), 96 MappingPlugin.INSTANCE.getString("_UI_Helper_description"), 97 ePackage.getMappingHelper_Nested())); 98 99 itemPropertyDescriptors.add 100 (new ItemPropertyDescriptorDecorator(childHelper, childHelperItemPropertyDescriptor) 101 { 102 protected Object createPropertyValueWrapper(Object object, Object propertyValue) 103 { 104 return 105 new ItemPropertyDescriptor.PropertyValueWrapper 106 (((ComposeableAdapterFactory)getAdapterFactory()).getRootAdapterFactory(), object, propertyValue, object); 107 } 108 public Object getPropertyValue(Object o) 109 { 110 return createPropertyValueWrapper(childHelper, childHelper.getHelpedObject()); 111 } 112 public Collection getChoiceOfValues(Object object) 113 { 114 return null; 115 } 116 }); 117 } 118 } 119 } 120 return itemPropertyDescriptors; 121 } 122 123 131 public Collection getChildrenFeatures(Object object) 132 { 133 return super.getChildrenFeatures(object); 134 } 135 136 public Collection getChildren(Object object) 137 { 138 return ((MappingHelper)object).getNested(); 139 } 140 141 public boolean hasChildren(Object object) 142 { 143 return !((MappingHelper)object).getNested().isEmpty(); 144 } 145 146 149 public Object getParent(Object object) 150 { 151 MappingHelper mappingHelper = (MappingHelper)object; 152 if (mappingHelper.getNestedIn() != null) 153 { 154 return mappingHelper.getNestedIn(); 155 } 156 else 157 { 158 return mappingHelper.getMapper(); 159 } 160 } 161 162 165 public Object getImage(Object object) 166 { 167 return MappingPlugin.getPlugin().getImage("full/obj16/MappingHelper"); 168 } 169 170 public String getText(Object object) 171 { 172 return "MappingHelper"; 173 } 174 175 178 public void notifyChanged(Notification msg) 179 { 180 if (msg.getFeature() == MappingPackage.eINSTANCE.getMappingHelper_Mapper()) 181 { 182 fireNotifyChanged(msg); 183 return; 184 } 185 super.notifyChanged(msg); 186 } 187 188 194 public ResourceLocator getResourceLocator() 195 { 196 return MappingPlugin.INSTANCE; 197 } 198 199 } 200 | Popular Tags |