blob: b7d84bfa35b860ee4cd9ed8a30c6fcb0201d8d25 [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2002-2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*
* </copyright>
*
* $Id: XSDIncludeItemProvider.java,v 1.7 2007/03/22 02:06:23 davidms Exp $
*/
package org.eclipse.xsd.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.xsd.XSDInclude;
/**
* This is the item provider adpater for a {@link org.eclipse.xsd.XSDInclude} object.
*/
public class XSDIncludeItemProvider
extends XSDSchemaCompositorItemProvider
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource
{
/**
* This constructs an instance from a factory and a notifier.
*/
public XSDIncludeItemProvider(AdapterFactory adapterFactory)
{
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object)
{
if (itemPropertyDescriptors == null)
{
super.getPropertyDescriptors(object);
// This is for the annotation feature.
//
itemPropertyDescriptors.add
(new ItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
XSDEditPlugin.INSTANCE.getString("_UI_Annotation_label"),
XSDEditPlugin.INSTANCE.getString("_UI_AnnotationOfInclude_description"),
xsdPackage.getXSDInclude_Annotation(),
false));
}
return itemPropertyDescriptors;
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object)
{
if (childrenFeatures == null)
{
super.getChildrenFeatures(object);
childrenFeatures.add(xsdPackage.getXSDInclude_Annotation());
}
return childrenFeatures;
}
/**
* This returns XSDInclude.gif.
*/
@Override
public Object getImage(Object object)
{
return XSDEditPlugin.INSTANCE.getImage("full/obj16/XSDInclude");
}
@Override
public String getText(Object object)
{
XSDInclude xsdInclude = ((XSDInclude)object);
String result = xsdInclude.getSchemaLocation();
return result == null ? "" : result;
}
/**
* This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
*/
@Override
public void notifyChanged(Notification msg)
{
if (
msg.getFeature() == xsdPackage.getXSDInclude_Annotation()
)
{
fireNotifyChanged(msg);
return;
}
super.notifyChanged(msg);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
{
super.collectNewChildDescriptors(newChildDescriptors, object);
// annotation
newChildDescriptors.add(createChildParameter(xsdPackage.getXSDInclude_Annotation(), xsdFactory.createXSDAnnotation()));
}
}