KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > edit > provider > resource > ResourceItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: ResourceItemProvider.java,v 1.5 2005/06/12 13:32:37 emerks Exp $
16  */

17 package org.eclipse.emf.edit.provider.resource;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.Collections JavaDoc;
22 import java.util.List JavaDoc;
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 /**
40  * This is the item provider adpater for a {@link org.eclipse.emf.ecore.resource.Resource} object.
41  * @generated
42  */

43 public class ResourceItemProvider
44   extends ItemProviderAdapter
45   implements
46     IEditingDomainItemProvider,
47     IStructuredItemContentProvider,
48     ITreeItemContentProvider,
49     IItemLabelProvider,
50     IItemPropertySource
51 {
52   /**
53    * This constructs an instance from a factory and a notifier.
54    * @generated
55    */

56   public ResourceItemProvider(AdapterFactory adapterFactory)
57   {
58     super(adapterFactory);
59   }
60
61   /**
62    * This returns the property descriptors for the adapted class.
63    * @generated
64    */

65   public List JavaDoc getPropertyDescriptors(Object JavaDoc object)
66   {
67     return super.getPropertyDescriptors(object);
68   }
69
70   public Collection JavaDoc getChildren(Object JavaDoc object)
71   {
72     Resource resource= (Resource)object;
73     return resource.getContents();
74   }
75
76   /**
77    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
78    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
79    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
80    * <!-- begin-user-doc -->
81    * <!-- end-user-doc -->
82    * @generated
83    */

84   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
85   {
86     if (childrenFeatures == null)
87     {
88       super.getChildrenFeatures(object);
89       // Resource resource = (Resource)object;
90
// childrenFeatures.add(ResourcePackage.eINSTANCE.getResource_Contents());
91
}
92     return childrenFeatures;
93   }
94
95   /**
96    * This returns the parent of the Resource.
97    * @generated
98    */

99   public Object JavaDoc getParent(Object JavaDoc object)
100   {
101     return ((Resource)object).getResourceSet();
102   }
103
104   /**
105    * This returns Resource.gif.
106    * @generated
107    */

108   public Object JavaDoc getImage(Object JavaDoc object)
109   {
110     Resource resource = (Resource)object;
111     return URI.createURI(getResourceLocator().getImage("full/obj16/Resource").toString() + "#" + resource.getURI().fileExtension());
112   }
113
114   /**
115    * This returns the label text for the adapted class.
116    * @generated
117    */

118   public String JavaDoc getText(Object JavaDoc object)
119   {
120     Resource resource = (Resource)object;
121     return resource.getURI() == null ? "" : resource.getURI().toString();
122   }
123
124   /**
125    * This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
126    * @generated
127    */

128   public void notifyChanged(Notification notification)
129   {
130     switch (notification.getFeatureID(Resource.class))
131     {
132       case Resource.RESOURCE__URI:
133       // case Resource.RESOURCE__IS_MODIFIED:
134
// case Resource.RESOURCE__IS_LOADED:
135
// case Resource.RESOURCE__IS_TRACKING_MODIFICATION:
136
case Resource.RESOURCE__CONTENTS:
137       // case Resource.RESOURCE__RESOURCE_SET:
138
{
139         fireNotifyChanged(notification);
140         return;
141       }
142     }
143     super.notifyChanged(notification);
144   }
145
146   public Collection JavaDoc getNewChildDescriptors(Object JavaDoc object, EditingDomain editingDomain, Object JavaDoc sibling)
147   {
148     return Collections.EMPTY_LIST;
149   }
150
151   /**
152    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
153    * describing all of the children that can be created under this object.
154    * @generated
155    */

156   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
157   {
158     super.collectNewChildDescriptors(newChildDescriptors, object);
159 /*
160     Resource resource = (Resource)object;
161
162     newChildDescriptors.add
163       (createChildParameter
164         (ResourcePackage.eINSTANCE.getResource_Contents(),
165          ResourcePackage.eINSTANCE.getResourceFactory().createEObject()));
166 */

167   }
168
169   /**
170    * Return the resource locator for this item provider's resources.
171    * @generated
172    */

173   public ResourceLocator getResourceLocator()
174   {
175     return EMFEditPlugin.INSTANCE;
176   }
177 }
178
Popular Tags