001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id: ProjectItemProvider.java 24145 2007-02-01 18:03:34Z jeichar $
006: */package net.refractions.udig.project.internal.provider;
007:
008: import java.util.Collection;
009: import java.util.List;
010:
011: import net.refractions.udig.project.IProject;
012: import net.refractions.udig.project.internal.Project;
013: import net.refractions.udig.project.internal.ProjectPackage;
014:
015: import org.eclipse.emf.common.notify.AdapterFactory;
016: import org.eclipse.emf.common.notify.Notification;
017: import org.eclipse.emf.common.util.ResourceLocator;
018: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
019: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
020: import org.eclipse.emf.edit.provider.IItemLabelProvider;
021: import org.eclipse.emf.edit.provider.IItemPropertySource;
022: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
023: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
024: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
025: import org.eclipse.emf.edit.provider.ViewerNotification;
026:
027: /**
028: * This is the item provider adapter for a {@link net.refractions.udig.project.internal.Project}
029: * object. <!-- begin-user-doc --> <!-- end-user-doc -->
030: *
031: * @generated NOT
032: */
033: public class ProjectItemProvider extends
034: AbstractLazyLoadingItemProvider implements
035: IEditingDomainItemProvider, IStructuredItemContentProvider,
036: ITreeItemContentProvider, IItemLabelProvider,
037: IItemPropertySource {
038: /**
039: * <!-- begin-user-doc --> <!-- end-user-doc -->
040: *
041: * @generated
042: */
043: public static final String copyright = "uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004, Refractions Research Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; //$NON-NLS-1$
044:
045: /**
046: * This constructs an instance from a factory and a notifier. <!-- begin-user-doc --> <!--
047: * end-user-doc -->
048: *
049: * @generated
050: */
051: public ProjectItemProvider(AdapterFactory adapterFactory) {
052: super (adapterFactory);
053: }
054:
055: /**
056: * This returns the property descriptors for the adapted class. <!-- begin-user-doc --> <!--
057: * end-user-doc -->
058: *
059: * @generated
060: */
061: public List getPropertyDescriptors(Object object) {
062: if (itemPropertyDescriptors == null) {
063: super .getPropertyDescriptors(object);
064:
065: addNamePropertyDescriptor(object);
066: }
067: return itemPropertyDescriptors;
068: }
069:
070: /**
071: * This adds a property descriptor for the Name feature. <!-- begin-user-doc --> <!--
072: * end-user-doc -->
073: *
074: * @generated
075: */
076: protected void addNamePropertyDescriptor(Object object) {
077: itemPropertyDescriptors
078: .add(createItemPropertyDescriptor(
079: ((ComposeableAdapterFactory) adapterFactory)
080: .getRootAdapterFactory(),
081: getResourceLocator(),
082: getString("_UI_Project_name_feature"), //$NON-NLS-1$
083: getString(
084: "_UI_PropertyDescriptor_description", "_UI_Project_name_feature", "_UI_Project_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
085: ProjectPackage.eINSTANCE.getProject_Name(),
086: true,
087: ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
088: null, null));
089: }
090:
091: /**
092: * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate
093: * feature for an {@link org.eclipse.emf.edit.command.AddCommand},
094: * {@link org.eclipse.emf.edit.command.RemoveCommand} or
095: * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. <!--
096: * begin-user-doc --> <!-- end-user-doc -->
097: *
098: * @generated
099: */
100: public Collection getChildrenFeatures(Object object) {
101: if (childrenFeatures == null) {
102: super .getChildrenFeatures(object);
103: childrenFeatures.add(ProjectPackage.eINSTANCE
104: .getProject_ElementsInternal());
105: }
106: return childrenFeatures;
107: }
108:
109: // @Override
110: // protected Collection< ? extends Object> getConcreteChildren( Object object ) {
111: // if( object instanceof IProject )
112: // return ((IProject)object).getElements();
113: // return super.getConcreteChildren(object);
114: // }
115: /**
116: * This returns Project.gif. <!-- begin-user-doc --> <!-- end-user-doc -->
117: *
118: * @generated
119: */
120: public Object getImage(Object object) {
121: return getResourceLocator().getImage("full/obj16/Project"); //$NON-NLS-1$
122: }
123:
124: /**
125: * This returns the label text for the adapted class. <!-- begin-user-doc --> <!-- end-user-doc
126: * -->
127: *
128: * @generated NOT
129: */
130: public String getText(Object object) {
131: String label = ((Project) object).getName();
132: return label == null || label.length() == 0 ? "Project" : //$NON-NLS-1$
133: label;
134: }
135:
136: /**
137: * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object)
138: */
139: public boolean hasChildren(Object object) {
140: return true;
141: }
142:
143: /**
144: * This handles model notifications by calling {@link #updateChildren} to update any cached
145: * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
146: * <!-- begin-user-doc --> <!-- end-user-doc -->
147: *
148: * @generated
149: */
150: public void notifyChanged(Notification notification) {
151: updateChildren(notification);
152:
153: switch (notification.getFeatureID(Project.class)) {
154: case ProjectPackage.PROJECT__NAME:
155: fireNotifyChanged(new ViewerNotification(notification,
156: notification.getNotifier(), false, true));
157: return;
158: case ProjectPackage.PROJECT__ELEMENTS_INTERNAL:
159: fireNotifyChanged(new ViewerNotification(notification,
160: notification.getNotifier(), true, false));
161: return;
162: }
163: super .notifyChanged(notification);
164: }
165:
166: /**
167: * Return the resource locator for this item provider's resources. <!-- begin-user-doc --> <!--
168: * end-user-doc -->
169: *
170: * @generated
171: */
172: public ResourceLocator getResourceLocator() {
173: return ProjectEditPlugin.INSTANCE;
174: }
175:
176: @Override
177: protected Collection<? extends Object> getConcreteChildren(
178: Object object) {
179: if (object instanceof IProject) {
180: return ((IProject) object).getElements();
181: }
182:
183: return super.getConcreteChildren(object);
184: }
185:
186: }
|