1 7 package Olj.provider; 8 9 10 import Olj.IncludeType; 11 import Olj.OljPackage; 12 13 import java.util.Collection ; 14 import java.util.List ; 15 16 import org.eclipse.emf.common.notify.AdapterFactory; 17 import org.eclipse.emf.common.notify.Notification; 18 19 import org.eclipse.emf.common.util.ResourceLocator; 20 21 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 22 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 23 import org.eclipse.emf.edit.provider.IItemLabelProvider; 24 import org.eclipse.emf.edit.provider.IItemPropertySource; 25 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 26 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 27 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 28 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 29 import org.eclipse.emf.edit.provider.ViewerNotification; 30 31 37 public class IncludeTypeItemProvider 38 extends ItemProviderAdapter 39 implements 40 IEditingDomainItemProvider, 41 IStructuredItemContentProvider, 42 ITreeItemContentProvider, 43 IItemLabelProvider, 44 IItemPropertySource { 45 51 public IncludeTypeItemProvider(AdapterFactory adapterFactory) { 52 super(adapterFactory); 53 } 54 55 61 public List getPropertyDescriptors(Object object) { 62 if (itemPropertyDescriptors == null) { 63 super.getPropertyDescriptors(object); 64 65 addHrefPropertyDescriptor(object); 66 addParsePropertyDescriptor(object); 67 } 68 return itemPropertyDescriptors; 69 } 70 71 77 protected void addHrefPropertyDescriptor(Object object) { 78 itemPropertyDescriptors.add 79 (new ItemPropertyDescriptor 80 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 81 getResourceLocator(), 82 getString("_UI_IncludeType_href_feature"), 83 getString("_UI_PropertyDescriptor_description", "_UI_IncludeType_href_feature", "_UI_IncludeType_type"), 84 OljPackage.eINSTANCE.getIncludeType_Href(), 85 true, 86 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 87 } 88 89 95 protected void addParsePropertyDescriptor(Object object) { 96 itemPropertyDescriptors.add 97 (new ItemPropertyDescriptor 98 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 99 getResourceLocator(), 100 getString("_UI_IncludeType_parse_feature"), 101 getString("_UI_PropertyDescriptor_description", "_UI_IncludeType_parse_feature", "_UI_IncludeType_type"), 102 OljPackage.eINSTANCE.getIncludeType_Parse(), 103 true, 104 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 105 } 106 107 113 public Object getImage(Object object) { 114 return getResourceLocator().getImage("full/obj16/IncludeType"); 115 } 116 117 123 public String getText(Object object) { 124 String label = ((IncludeType)object).getHref(); 125 return label == null || label.length() == 0 ? 126 getString("_UI_IncludeType_type") : 127 getString("_UI_IncludeType_type") + " " + label; 128 } 129 130 137 public void notifyChanged(Notification notification) { 138 updateChildren(notification); 139 140 switch (notification.getFeatureID(IncludeType.class)) { 141 case OljPackage.INCLUDE_TYPE__HREF: 142 case OljPackage.INCLUDE_TYPE__PARSE: 143 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 144 return; 145 } 146 super.notifyChanged(notification); 147 } 148 149 156 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { 157 super.collectNewChildDescriptors(newChildDescriptors, object); 158 } 159 160 166 public ResourceLocator getResourceLocator() { 167 return OljEditPlugin.INSTANCE; 168 } 169 170 } 171 | Popular Tags |