| 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.XSDDiagnostic; |
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* This is the item provider adpater for a {@link org.eclipse.xsd.XSDDiagnostic} object. |
| 32 |
*/ |
| 33 |
public class XSDDiagnosticItemProvider |
| 34 |
extends XSDItemProviderAdapter |
| 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 XSDDiagnosticItemProvider(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 severity feature. |
| 61 |
// |
| 62 |
itemPropertyDescriptors.add |
| 63 |
(new ItemPropertyDescriptor |
| 64 |
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 65 |
XSDEditPlugin.INSTANCE.getString("_UI_Severity_label"), |
| 66 |
XSDEditPlugin.INSTANCE.getString("_UI_Severity_description"), |
| 67 |
xsdPackage.getXSDDiagnostic_Severity(), |
| 68 |
true, |
| 69 |
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); |
| 70 |
|
| 71 |
// This is for the message feature. |
| 72 |
// |
| 73 |
itemPropertyDescriptors.add |
| 74 |
(new ItemPropertyDescriptor |
| 75 |
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 76 |
XSDEditPlugin.INSTANCE.getString("_UI_Message_label"), |
| 77 |
XSDEditPlugin.INSTANCE.getString("_UI_Message_description"), |
| 78 |
xsdPackage.getXSDDiagnostic_Message(), |
| 79 |
true, |
| 80 |
ItemPropertyDescriptor.TEXT_VALUE_IMAGE)); |
| 81 |
|
| 82 |
// This is for the locationURI feature. |
| 83 |
// |
| 84 |
itemPropertyDescriptors.add |
| 85 |
(new ItemPropertyDescriptor |
| 86 |
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 87 |
XSDEditPlugin.INSTANCE.getString("_UI_LocationURI_label"), |
| 88 |
XSDEditPlugin.INSTANCE.getString("_UI_LocationURI_description"), |
| 89 |
xsdPackage.getXSDDiagnostic_LocationURI(), |
| 90 |
true, |
| 91 |
ItemPropertyDescriptor.TEXT_VALUE_IMAGE)); |
| 92 |
|
| 93 |
// This is for the line feature. |
| 94 |
// |
| 95 |
itemPropertyDescriptors.add |
| 96 |
(new ItemPropertyDescriptor |
| 97 |
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 98 |
XSDEditPlugin.INSTANCE.getString("_UI_Line_label"), |
| 99 |
XSDEditPlugin.INSTANCE.getString("_UI_Line_description"), |
| 100 |
xsdPackage.getXSDDiagnostic_Line(), |
| 101 |
true, |
| 102 |
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE)); |
| 103 |
|
| 104 |
// This is for the column feature. |
| 105 |
// |
| 106 |
itemPropertyDescriptors.add |
| 107 |
(new ItemPropertyDescriptor |
| 108 |
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 109 |
XSDEditPlugin.INSTANCE.getString("_UI_Column_label"), |
| 110 |
XSDEditPlugin.INSTANCE.getString("_UI_Column_description"), |
| 111 |
xsdPackage.getXSDDiagnostic_Column(), |
| 112 |
true, |
| 113 |
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE)); |
| 114 |
|
| 115 |
// This is for the node feature. |
| 116 |
// |
| 117 |
itemPropertyDescriptors.add |
| 118 |
(new ItemPropertyDescriptor |
| 119 |
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 120 |
XSDEditPlugin.INSTANCE.getString("_UI_Node_label"), |
| 121 |
XSDEditPlugin.INSTANCE.getString("_UI_Node_description"), |
| 122 |
xsdPackage.getXSDDiagnostic_Node(), |
| 123 |
true, |
| 124 |
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE)); |
| 125 |
|
| 126 |
// This is for the annotationURI feature. |
| 127 |
// |
| 128 |
itemPropertyDescriptors.add |
| 129 |
(new ItemPropertyDescriptor |
| 130 |
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 131 |
XSDEditPlugin.INSTANCE.getString("_UI_AnnotationURI_label"), |
| 132 |
XSDEditPlugin.INSTANCE.getString("_UI_AnnotationURI_description"), |
| 133 |
xsdPackage.getXSDDiagnostic_AnnotationURI(), |
| 134 |
true, |
| 135 |
ItemPropertyDescriptor.TEXT_VALUE_IMAGE)); |
| 136 |
|
| 137 |
} |
| 138 |
return itemPropertyDescriptors; |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* This returns XSDDiagnostic.gif. |
| 143 |
*/ |
| 144 |
@Override |
| 145 |
public Object getImage(Object object) |
| 146 |
{ |
| 147 |
return XSDEditPlugin.INSTANCE.getImage("full/obj16/XSDDiagnostic"); |
| 148 |
} |
| 149 |
|
| 150 |
@Override |
| 151 |
public String getText(Object object) |
| 152 |
{ |
| 153 |
XSDDiagnostic xsdDiagnostic = ((XSDDiagnostic)object); |
| 154 |
return xsdDiagnostic.getMessage(); |
| 155 |
} |
| 156 |
|
| 157 |
/** |
| 158 |
* This handles notification by calling {@link #fireNotifyChanged fireNotifyChanged}. |
| 159 |
*/ |
| 160 |
@Override |
| 161 |
public void notifyChanged(Notification msg) |
| 162 |
{ |
| 163 |
if (msg.getFeature() == xsdPackage.getXSDDiagnostic_Severity() || |
| 164 |
msg.getFeature() == xsdPackage.getXSDDiagnostic_Message() || |
| 165 |
msg.getFeature() == xsdPackage.getXSDDiagnostic_LocationURI() || |
| 166 |
msg.getFeature() == xsdPackage.getXSDDiagnostic_Line() || |
| 167 |
msg.getFeature() == xsdPackage.getXSDDiagnostic_Column() || |
| 168 |
msg.getFeature() == xsdPackage.getXSDDiagnostic_Node() || |
| 169 |
msg.getFeature() == xsdPackage.getXSDDiagnostic_AnnotationURI() || |
| 170 |
msg.getFeature() == xsdPackage.getXSDDiagnostic_Components()) |
| 171 |
{ |
| 172 |
fireNotifyChanged(msg); |
| 173 |
} |
| 174 |
else |
| 175 |
{ |
| 176 |
super.notifyChanged(msg); |
| 177 |
} |
| 178 |
} |
| 179 |
} |