Debian Codegraph @

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

raw
1 /**
2 * Copyright (c) 2002-2006 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.List;
15
16 import org.eclipse.emf.common.notify.AdapterFactory;
17 import org.eclipse.emf.common.notify.Notification;
18 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
19 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
20 import org.eclipse.emf.edit.provider.IItemLabelProvider;
21 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
22 import org.eclipse.emf.edit.provider.IItemPropertySource;
23 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
24 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
25 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
26
27
28 /**
29 * This is the item provider adpater for a {@link org.eclipse.xsd.XSDFeature} object.
30 */
31 public class XSDFeatureItemProvider
32 extends XSDNamedComponentItemProvider
33 implements
34 IEditingDomainItemProvider,
35 IStructuredItemContentProvider,
36 ITreeItemContentProvider,
37 IItemLabelProvider,
38 IItemPropertySource
39 {
40 /**
41 * This constructs an instance from a factory and a notifier.
42 */
43 public XSDFeatureItemProvider(AdapterFactory adapterFactory)
44 {
45 super(adapterFactory);
46 }
47
48 /**
49 * This returns the property descriptors for the adapted class.
50 */
51 @Override
52 public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object)
53 {
54 if (itemPropertyDescriptors == null)
55 {
56 super.getPropertyDescriptors(object);
57 createLexicalValuePropertyDescriptor(object);
58 createConstraintPropertyDescriptor(object);
59 createScopePropertyDescriptor(object);
60
61 }
62 return itemPropertyDescriptors;
63 }
64
65 protected void createLexicalValuePropertyDescriptor(Object object)
66 {
67 // This is for the value feature.
68 //
69 itemPropertyDescriptors.add
70 (new ItemPropertyDescriptor
71 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
72 XSDEditPlugin.INSTANCE.getString("_UI_LexicalValue_label"),
73 XSDEditPlugin.INSTANCE.getString("_UI_LexicalValueOfFeature_description"),
74 xsdPackage.getXSDFeature_LexicalValue(),
75 true,
76 ItemPropertyDescriptor.TEXT_VALUE_IMAGE));
77 }
78
79 protected void createConstraintPropertyDescriptor(Object object)
80 {
81 // This is for the constraint feature.
82 //
83 itemPropertyDescriptors.add
84 (new ItemPropertyDescriptor
85 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
86 XSDEditPlugin.INSTANCE.getString("_UI_Constraint_label"),
87 XSDEditPlugin.INSTANCE.getString("_UI_ConstraintOfFeature_description"),
88 xsdPackage.getXSDFeature_Constraint(),
89 true,
90 ItemPropertyDescriptor.TEXT_VALUE_IMAGE));
91 }
92
93 protected void createScopePropertyDescriptor(Object object)
94 {
95 // This is for the scope feature.
96 //
97 itemPropertyDescriptors.add
98 (new ItemPropertyDescriptor
99 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
100 XSDEditPlugin.INSTANCE.getString("_UI_Scope_label"),
101 XSDEditPlugin.INSTANCE.getString("_UI_ScopeOfFeature_description"),
102 xsdPackage.getXSDFeature_Scope(),
103 false));
104 }
105
106
107 /**
108 * This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
109 */
110 @Override
111 public void notifyChanged(Notification msg)
112 {
113 if (
114 msg.getFeature() == xsdPackage.getXSDFeature_LexicalValue() ||
115 msg.getFeature() == xsdPackage.getXSDFeature_Constraint() ||
116 msg.getFeature() == xsdPackage.getXSDFeature_Scope()
117 )
118 {
119 fireNotifyChanged(msg);
120 return;
121 }
122 super.notifyChanged(msg);
123 }
124 }