Debian Codegraph @

plugins/org.eclipse.xsd.edit/src/org/eclipse/xsd/provider/XSDFacetItemProvider.java

raw
1 /**
2 * Copyright (c) 2002-2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v2.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v20.html
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 */
11 package org.eclipse.xsd.provider;
12
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 import org.eclipse.emf.ecore.EStructuralFeature;
20 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
21 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
22 import org.eclipse.emf.edit.provider.IItemLabelProvider;
23 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
24 import org.eclipse.emf.edit.provider.IItemPropertySource;
25 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
26 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
27 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
28
29
30 /**
31 * This is the item provider adpater for a {@link org.eclipse.xsd.XSDFacet} object.
32 */
33 public class XSDFacetItemProvider
34 extends XSDComponentItemProvider
35 implements
36 IEditingDomainItemProvider,
37 IStructuredItemContentProvider,
38 ITreeItemContentProvider,
39 IItemLabelProvider,
40 IItemPropertySource
41 {
42 /**
43 * This constructs an instance from a factory and a notifier.
44 */
45 public XSDFacetItemProvider(AdapterFactory adapterFactory)
46 {
47 super(adapterFactory);
48 }
49
50 /**
51 * This returns the property descriptors for the adapted class.
52 */
53 @Override
54 public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object)
55 {
56 if (itemPropertyDescriptors == null)
57 {
58 super.getPropertyDescriptors(object);
59
60 // This is for the lexicalValue feature.
61 //
62 itemPropertyDescriptors.add
63 (new ItemPropertyDescriptor
64 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
65 XSDEditPlugin.INSTANCE.getString("_UI_LexicalValue_label"),
66 XSDEditPlugin.INSTANCE.getString("_UI_LexicalValueOfFacet_description"),
67 xsdPackage.getXSDFacet_LexicalValue(),
68 true,
69 ItemPropertyDescriptor.TEXT_VALUE_IMAGE));
70
71 // This is for the annotation feature.
72 //
73 itemPropertyDescriptors.add
74 (new ItemPropertyDescriptor
75 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
76 XSDEditPlugin.INSTANCE.getString("_UI_Annotation_label"),
77 XSDEditPlugin.INSTANCE.getString("_UI_AnnotationOfFacet_description"),
78 xsdPackage.getXSDFacet_Annotation(),
79 false));
80
81 // This is for the simpleTypeDefinition feature.
82 //
83 itemPropertyDescriptors.add
84 (new ItemPropertyDescriptor
85 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
86 XSDEditPlugin.INSTANCE.getString("_UI_SimpleTypeDefinition_label"),
87 XSDEditPlugin.INSTANCE.getString("_UI_SimpleTypeDefinition_description"),
88 xsdPackage.getXSDFacet_SimpleTypeDefinition(),
89 false));
90 }
91 return itemPropertyDescriptors;
92 }
93
94 /**
95 * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
96 * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
97 * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
98 */
99 @Override
100 public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object)
101 {
102 if (childrenFeatures == null)
103 {
104 super.getChildrenFeatures(object);
105 childrenFeatures.add(xsdPackage.getXSDFacet_Annotation());
106 }
107 return childrenFeatures;
108 }
109
110 /**
111 * This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
112 */
113 @Override
114 public void notifyChanged(Notification msg)
115 {
116 if (
117 msg.getFeature() == xsdPackage.getXSDFacet_LexicalValue() ||
118 msg.getFeature() == xsdPackage.getXSDFacet_Annotation()
119 )
120 {
121 fireNotifyChanged(msg);
122 return;
123 }
124 super.notifyChanged(msg);
125 }
126
127 /**
128 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
129 * that can be created under this object.
130 */
131 @Override
132 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
133 {
134 super.collectNewChildDescriptors(newChildDescriptors, object);
135
136 // annotation
137 newChildDescriptors.add(createChildParameter(xsdPackage.getXSDFacet_Annotation(), xsdFactory.createXSDAnnotation()));
138 }
139 }