Debian Codegraph @

plugins/org.eclipse.xsd.edit/src/org/eclipse/xsd/provider/XSDLengthFacetItemProvider.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 import org.eclipse.xsd.XSDLengthFacet;
28
29
30 /**
31 * This is the item provider adpater for a {@link org.eclipse.xsd.XSDLengthFacet} object.
32 */
33 public class XSDLengthFacetItemProvider
34 extends XSDFixedFacetItemProvider
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 XSDLengthFacetItemProvider(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 value feature.
61 //
62 itemPropertyDescriptors.add
63 (new ItemPropertyDescriptor
64 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
65 XSDEditPlugin.INSTANCE.getString("_UI_Value_label"),
66 XSDEditPlugin.INSTANCE.getString("_UI_ValueLengthFacet_description"),
67 xsdPackage.getXSDLengthFacet_Value(),
68 true,
69 ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE));
70
71 }
72 return itemPropertyDescriptors;
73 }
74
75 /**
76 * This returns XSDLengthFacet.gif.
77 */
78 @Override
79 public Object getImage(Object object)
80 {
81 return XSDEditPlugin.INSTANCE.getImage("full/obj16/XSDLengthFacet");
82 }
83
84 @Override
85 public String getText(Object object)
86 {
87 XSDLengthFacet xsdLengthFacet = ((XSDLengthFacet)object);
88 String result = xsdLengthFacet.getLexicalValue();
89 return result == null ? "" : result;
90 }
91
92 /**
93 * This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}.
94 */
95 @Override
96 public void notifyChanged(Notification msg)
97 {
98 if (
99 msg.getFeature() == xsdPackage.getXSDLengthFacet_Value()
100 )
101 {
102 fireNotifyChanged(msg);
103 return;
104 }
105 super.notifyChanged(msg);
106 }
107
108 }