1 7 package Olj.provider; 8 9 10 import Olj.CounterColumnsType; 11 import Olj.OljFactory; 12 import Olj.OljPackage; 13 14 import java.util.Collection ; 15 import java.util.List ; 16 17 import org.eclipse.emf.common.notify.AdapterFactory; 18 import org.eclipse.emf.common.notify.Notification; 19 20 import org.eclipse.emf.common.util.ResourceLocator; 21 22 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 23 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 24 import org.eclipse.emf.edit.provider.IItemLabelProvider; 25 import org.eclipse.emf.edit.provider.IItemPropertySource; 26 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 27 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 28 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 29 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 30 import org.eclipse.emf.edit.provider.ViewerNotification; 31 32 38 public class CounterColumnsTypeItemProvider 39 extends ItemProviderAdapter 40 implements 41 IEditingDomainItemProvider, 42 IStructuredItemContentProvider, 43 ITreeItemContentProvider, 44 IItemLabelProvider, 45 IItemPropertySource { 46 52 public CounterColumnsTypeItemProvider(AdapterFactory adapterFactory) { 53 super(adapterFactory); 54 } 55 56 62 public List getPropertyDescriptors(Object object) { 63 if (itemPropertyDescriptors == null) { 64 super.getPropertyDescriptors(object); 65 66 addCounterNameColumnPropertyDescriptor(object); 67 addCounterTableNamePropertyDescriptor(object); 68 addCounterValueColumnPropertyDescriptor(object); 69 } 70 return itemPropertyDescriptors; 71 } 72 73 79 protected void addCounterNameColumnPropertyDescriptor(Object object) { 80 itemPropertyDescriptors.add 81 (new ItemPropertyDescriptor 82 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 83 getResourceLocator(), 84 getString("_UI_CounterColumnsType_counterNameColumn_feature"), 85 getString("_UI_PropertyDescriptor_description", "_UI_CounterColumnsType_counterNameColumn_feature", "_UI_CounterColumnsType_type"), 86 OljPackage.eINSTANCE.getCounterColumnsType_CounterNameColumn(), 87 true, 88 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 89 } 90 91 97 protected void addCounterTableNamePropertyDescriptor(Object object) { 98 itemPropertyDescriptors.add 99 (new ItemPropertyDescriptor 100 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 101 getResourceLocator(), 102 getString("_UI_CounterColumnsType_counterTableName_feature"), 103 getString("_UI_PropertyDescriptor_description", "_UI_CounterColumnsType_counterTableName_feature", "_UI_CounterColumnsType_type"), 104 OljPackage.eINSTANCE.getCounterColumnsType_CounterTableName(), 105 true, 106 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 107 } 108 109 115 protected void addCounterValueColumnPropertyDescriptor(Object object) { 116 itemPropertyDescriptors.add 117 (new ItemPropertyDescriptor 118 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 119 getResourceLocator(), 120 getString("_UI_CounterColumnsType_counterValueColumn_feature"), 121 getString("_UI_PropertyDescriptor_description", "_UI_CounterColumnsType_counterValueColumn_feature", "_UI_CounterColumnsType_type"), 122 OljPackage.eINSTANCE.getCounterColumnsType_CounterValueColumn(), 123 true, 124 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); 125 } 126 127 135 public Collection getChildrenFeatures(Object object) { 136 if (childrenFeatures == null) { 137 super.getChildrenFeatures(object); 138 childrenFeatures.add(OljPackage.eINSTANCE.getCounterColumnsType_Group()); 139 } 140 return childrenFeatures; 141 } 142 143 149 public Object getImage(Object object) { 150 return getResourceLocator().getImage("full/obj16/CounterColumnsType"); 151 } 152 153 159 public String getText(Object object) { 160 String label = ((CounterColumnsType)object).getCounterTableName(); 161 return label == null || label.length() == 0 ? 162 getString("_UI_CounterColumnsType_type") : 163 getString("_UI_CounterColumnsType_type") + " " + label; 164 } 165 166 173 public void notifyChanged(Notification notification) { 174 updateChildren(notification); 175 176 switch (notification.getFeatureID(CounterColumnsType.class)) { 177 case OljPackage.COUNTER_COLUMNS_TYPE__COUNTER_NAME_COLUMN: 178 case OljPackage.COUNTER_COLUMNS_TYPE__COUNTER_TABLE_NAME: 179 case OljPackage.COUNTER_COLUMNS_TYPE__COUNTER_VALUE_COLUMN: 180 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 181 return; 182 case OljPackage.COUNTER_COLUMNS_TYPE__GROUP: 183 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 184 return; 185 } 186 super.notifyChanged(notification); 187 } 188 189 196 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { 197 super.collectNewChildDescriptors(newChildDescriptors, object); 198 199 newChildDescriptors.add 200 (createChildParameter 201 (OljPackage.eINSTANCE.getCounterColumnsType_CounterColumn(), 202 OljFactory.eINSTANCE.createCounterColumnType())); 203 204 newChildDescriptors.add 205 (createChildParameter 206 (OljPackage.eINSTANCE.getCounterColumnsType_SubCounterColumn(), 207 OljFactory.eINSTANCE.createSubCounterColumnType())); 208 } 209 210 216 public ResourceLocator getResourceLocator() { 217 return OljEditPlugin.INSTANCE; 218 } 219 220 } 221 | Popular Tags |