1 17 package org.eclipse.emf.edit.provider.resource; 18 19 20 import java.util.Collection ; 21 import java.util.Collections ; 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.common.util.URI; 28 import org.eclipse.emf.ecore.resource.Resource; 29 import org.eclipse.emf.edit.EMFEditPlugin; 30 import org.eclipse.emf.edit.domain.EditingDomain; 31 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 32 import org.eclipse.emf.edit.provider.IItemLabelProvider; 33 import org.eclipse.emf.edit.provider.IItemPropertySource; 34 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 35 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 36 import org.eclipse.emf.edit.provider.ItemProviderAdapter; 37 38 39 43 public class ResourceItemProvider 44 extends ItemProviderAdapter 45 implements 46 IEditingDomainItemProvider, 47 IStructuredItemContentProvider, 48 ITreeItemContentProvider, 49 IItemLabelProvider, 50 IItemPropertySource 51 { 52 56 public ResourceItemProvider(AdapterFactory adapterFactory) 57 { 58 super(adapterFactory); 59 } 60 61 65 public List getPropertyDescriptors(Object object) 66 { 67 return super.getPropertyDescriptors(object); 68 } 69 70 public Collection getChildren(Object object) 71 { 72 Resource resource= (Resource)object; 73 return resource.getContents(); 74 } 75 76 84 public Collection getChildrenFeatures(Object object) 85 { 86 if (childrenFeatures == null) 87 { 88 super.getChildrenFeatures(object); 89 } 92 return childrenFeatures; 93 } 94 95 99 public Object getParent(Object object) 100 { 101 return ((Resource)object).getResourceSet(); 102 } 103 104 108 public Object getImage(Object object) 109 { 110 Resource resource = (Resource)object; 111 return URI.createURI(getResourceLocator().getImage("full/obj16/Resource").toString() + "#" + resource.getURI().fileExtension()); 112 } 113 114 118 public String getText(Object object) 119 { 120 Resource resource = (Resource)object; 121 return resource.getURI() == null ? "" : resource.getURI().toString(); 122 } 123 124 128 public void notifyChanged(Notification notification) 129 { 130 switch (notification.getFeatureID(Resource.class)) 131 { 132 case Resource.RESOURCE__URI: 133 case Resource.RESOURCE__CONTENTS: 137 { 139 fireNotifyChanged(notification); 140 return; 141 } 142 } 143 super.notifyChanged(notification); 144 } 145 146 public Collection getNewChildDescriptors(Object object, EditingDomain editingDomain, Object sibling) 147 { 148 return Collections.EMPTY_LIST; 149 } 150 151 156 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 157 { 158 super.collectNewChildDescriptors(newChildDescriptors, object); 159 167 } 168 169 173 public ResourceLocator getResourceLocator() 174 { 175 return EMFEditPlugin.INSTANCE; 176 } 177 } 178 | Popular Tags |