Debian Codegraph @

plugins/org.eclipse.xsd.edit/src/org/eclipse/xsd/provider/XSDXPathDefinitionItemProvider.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.edit.provider.ComposeableAdapterFactory;
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 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
27
28 import org.eclipse.xsd.XSDXPathDefinition;
29 import org.eclipse.xsd.XSDXPathVariety;
30
31
32 /**
33 * This is the item provider adpater for a {@link org.eclipse.xsd.XSDXPathDefinition} object.
34 */
35 public class XSDXPathDefinitionItemProvider
36 extends XSDComponentItemProvider
37 implements
38 IEditingDomainItemProvider,
39 IStructuredItemContentProvider,
40 ITreeItemContentProvider,
41 IItemLabelProvider,
42 IItemPropertySource
43 {
44 /**
45 * This constructs an instance from a factory and a notifier.
46 */
47 public XSDXPathDefinitionItemProvider(AdapterFactory adapterFactory)
48 {
49 super(adapterFactory);
50 }
51
52 /**
53 * This returns the property descriptors for the adapted class.
54 */
55 @Override
56 public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object)
57 {
58 if (itemPropertyDescriptors == null)
59 {
60 super.getPropertyDescriptors(object);
61
62 // This is for the variety feature.
63 //
64 itemPropertyDescriptors.add
65 (new ItemPropertyDescriptor
66 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
67 XSDEditPlugin.INSTANCE.getString("_UI_Variety_label"),
68 XSDEditPlugin.INSTANCE.getString("_UI_VarietyOfXPath_description"),
69 xsdPackage.getXSDXPathDefinition_Variety(),
70 true,
71 ItemPropertyDescriptor.TEXT_VALUE_IMAGE));
72
73 }
74 return itemPropertyDescriptors;
75 }
76
77 /**
78 * This returns XSDXPathDefinition.gif.
79 */
80 @Override
81 public Object getImage(Object object)
82 {
83 XSDXPathDefinition xsdXPathDefinition = ((XSDXPathDefinition)object);
84 return
85 XSDEditPlugin.INSTANCE.getImage
86 (XSDXPathVariety.SELECTOR_LITERAL == xsdXPathDefinition.getVariety() ?
87 "full/obj16/XSDXPathDefinitionSelector" :
88 "full/obj16/XSDXPathDefinitionField");
89 }
90
91 @Override
92 public String getText(Object object)
93 {
94 XSDXPathDefinition xsdXPathDefinition = ((XSDXPathDefinition)object);
95 String result = xsdXPathDefinition.getValue();
96 return result == null ? XSDEditPlugin.INSTANCE.getString("_UI_Absent_label") : result;
97 }
98
99 /**
100 * This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
101 */
102 @Override
103 public void notifyChanged(Notification msg)
104 {
105 if (
106 msg.getFeature() == xsdPackage.getXSDXPathDefinition_Variety()
107 )
108 {
109 fireNotifyChanged(msg);
110 return;
111 }
112 super.notifyChanged(msg);
113 }
114
115 /**
116 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
117 * that can be created under this object.
118 */
119 @Override
120 protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
121 {
122 super.collectNewChildDescriptors(newChildDescriptors, object);
123
124 // annotation
125 newChildDescriptors.add(createChildParameter(xsdPackage.getXSDXPathDefinition_Annotation(), xsdFactory.createXSDAnnotation()));
126 }
127 }