Debian Codegraph @

plugins/org.eclipse.xsd.edit/src/org/eclipse/xsd/provider/XSDRedefineItemProvider.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.IEditingDomainItemProvider;
21 import org.eclipse.emf.edit.provider.IItemLabelProvider;
22 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
23 import org.eclipse.emf.edit.provider.IItemPropertySource;
24 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
25 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
26
27 import org.eclipse.xsd.XSDRedefine;
28
29
30 /**
31 * This is the item provider adpater for a {@link org.eclipse.xsd.XSDRedefine} object.
32 */
33 public class XSDRedefineItemProvider
34 extends XSDSchemaCompositorItemProvider
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 XSDRedefineItemProvider(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 return itemPropertyDescriptors;
61 }
62
63 /**
64 * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
65 * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
66 * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
67 */
68 @Override
69 public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object)
70 {
71 if (childrenFeatures == null)
72 {
73 super.getChildrenFeatures(object);
74 childrenFeatures.add(xsdPackage.getXSDRedefine_Contents());
75 }
76 return childrenFeatures;
77 }
78
79 /**
80 * This returns XSDRedefine.gif.
81 */
82 @Override
83 public Object getImage(Object object)
84 {
85 return XSDEditPlugin.INSTANCE.getImage("full/obj16/XSDRedefine");
86 }
87
88 @Override
89 public String getText(Object object)
90 {
91 XSDRedefine xsdRedefine = ((XSDRedefine)object);
92 String result = xsdRedefine.getSchemaLocation();
93 return result == null ? "" : result;
94 }
95
96 /**
97 * This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
98 */
99 @Override
100 public void notifyChanged(Notification msg)
101 {
102 if (
103 msg.getFeature() == xsdPackage.getXSDRedefine_Annotations() ||
104 msg.getFeature() == xsdPackage.getXSDRedefine_Contents()
105 )
106 {
107 fireNotifyChanged(msg);
108 return;
109 }
110 super.notifyChanged(msg);
111 }
112
113 /**
114 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
115 * that can be created under this object.
116 */
117 @Override
118 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
119 {
120 super.collectNewChildDescriptors(newChildDescriptors, object);
121 XSDRedefine r = (XSDRedefine) object;
122
123 // annotation
124 newChildDescriptors.add(createChildParameter(xsdPackage.getXSDRedefine_Contents(), xsdFactory.createXSDAnnotation()));
125
126 // model group definition
127 newChildDescriptors.add(createChildParameter(xsdPackage.getXSDRedefine_Contents(), createModelGroupDefinition(r)));
128
129 // attribute group definition
130 newChildDescriptors.add(createChildParameter(xsdPackage.getXSDRedefine_Contents(), createAttributeGroupDefinition(r)));
131
132 // atomic, list, and union simple type definitions
133 addSimpleTypeDefinitionChildParameters(newChildDescriptors, r, xsdPackage.getXSDRedefine_Contents(), true, true, true);
134
135 // complex type definition
136 newChildDescriptors.add(createChildParameter(xsdPackage.getXSDRedefine_Contents(), createComplexTypeDefinition(r)));
137 }
138 }