Debian Codegraph @

plugins/org.eclipse.xsd.edit/src/org/eclipse/xsd/provider/XSDNotationDeclarationItemProvider.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.IItemPropertyDescriptor;
22 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
23
24 import org.eclipse.xsd.XSDNotationDeclaration;
25
26
27 /**
28 * This is the item provider adpater for a {@link org.eclipse.xsd.XSDNotationDeclaration} object.
29 */
30 public class XSDNotationDeclarationItemProvider
31 extends XSDNamedComponentItemProvider
32 {
33 /**
34 * This constructs an instance from a factory and a notifier.
35 */
36 public XSDNotationDeclarationItemProvider(AdapterFactory adapterFactory)
37 {
38 super(adapterFactory);
39 }
40
41 /**
42 * This returns the property descriptors for the adapted class.
43 */
44 @Override
45 public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object)
46 {
47 if (itemPropertyDescriptors == null)
48 {
49 super.getPropertyDescriptors(object);
50
51 // This is for the systemIdentifier feature.
52 //
53 itemPropertyDescriptors.add
54 (new ItemPropertyDescriptor
55 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
56 XSDEditPlugin.INSTANCE.getString("_UI_SystemIdentifier_label"),
57 XSDEditPlugin.INSTANCE.getString("_UI_SystemIdentifier_description"),
58 xsdPackage.getXSDNotationDeclaration_SystemIdentifier(),
59 true,
60 ItemPropertyDescriptor.TEXT_VALUE_IMAGE));
61
62 // This is for the publicIdentifier feature.
63 //
64 itemPropertyDescriptors.add
65 (new ItemPropertyDescriptor
66 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
67 XSDEditPlugin.INSTANCE.getString("_UI_PublicIdentifier_label"),
68 XSDEditPlugin.INSTANCE.getString("_UI_PublicIdentifier_description"),
69 xsdPackage.getXSDNotationDeclaration_PublicIdentifier(),
70 true,
71 ItemPropertyDescriptor.TEXT_VALUE_IMAGE));
72
73 // This is for the annotation feature.
74 //
75 itemPropertyDescriptors.add
76 (new ItemPropertyDescriptor
77 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
78 XSDEditPlugin.INSTANCE.getString("_UI_Annotation_label"),
79 XSDEditPlugin.INSTANCE.getString("_UI_AnnotationOfNotation_description"),
80 xsdPackage.getXSDNotationDeclaration_Annotation(),
81 false));
82
83 }
84 return itemPropertyDescriptors;
85 }
86
87 /**
88 * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
89 * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
90 * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
91 */
92 @Override
93 public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object)
94 {
95 if (childrenFeatures == null)
96 {
97 super.getChildrenFeatures(object);
98 childrenFeatures.add(xsdPackage.getXSDNotationDeclaration_Annotation());
99 }
100 return childrenFeatures;
101 }
102
103 /**
104 * This returns XSDNotationDeclaration.gif.
105 */
106 @Override
107 public Object getImage(Object object)
108 {
109 return XSDEditPlugin.INSTANCE.getImage("full/obj16/XSDNotationDeclaration");
110 }
111
112 @Override
113 public String getText(Object object)
114 {
115 XSDNotationDeclaration xsdNotationDeclaration = ((XSDNotationDeclaration)object);
116 String result = xsdNotationDeclaration.getName();
117 return result == null ? "" : result;
118 }
119
120 /**
121 * This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
122 */
123 @Override
124 public void notifyChanged(Notification msg)
125 {
126 if (msg.getFeature() == xsdPackage.getXSDNotationDeclaration_SystemIdentifier() ||
127 msg.getFeature() == xsdPackage.getXSDNotationDeclaration_PublicIdentifier() ||
128 msg.getFeature() == xsdPackage.getXSDNotationDeclaration_Annotation())
129 {
130 fireNotifyChanged(msg);
131 return;
132 }
133 super.notifyChanged(msg);
134 }
135
136 /**
137 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
138 * that can be created under this object.
139 */
140 @Override
141 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
142 {
143 super.collectNewChildDescriptors(newChildDescriptors, object);
144
145 // annotation
146 newChildDescriptors.add(createChildParameter(xsdPackage.getXSDNotationDeclaration_Annotation(), xsdFactory.createXSDAnnotation()));
147 }
148 }