KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > provider > FunctionNamePairItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: FunctionNamePairItemProvider.java,v 1.4 2005/06/08 06:21:43 nickb Exp $
16  */

17 package org.eclipse.emf.mapping.provider;
18
19
20 import java.util.List JavaDoc;
21
22 import org.eclipse.emf.common.notify.AdapterFactory;
23 import org.eclipse.emf.common.notify.Notification;
24 import org.eclipse.emf.common.util.ResourceLocator;
25 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
26 import org.eclipse.emf.edit.provider.IItemLabelProvider;
27 import org.eclipse.emf.edit.provider.IItemPropertySource;
28 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
29 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
30 //import org.eclipse.emf.edit.provider.ViewerNotification;
31

32 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
33 import org.eclipse.emf.mapping.FunctionNamePair;
34 import org.eclipse.emf.mapping.MappingPackage;
35 import org.eclipse.emf.mapping.MappingPlugin;
36
37
38 /**
39  * This is the item provider adpater for a {@link org.eclipse.emf.mapping.FunctionNamePair} object.
40  */

41 public class FunctionNamePairItemProvider
42   extends TypeConverterItemProvider
43   implements
44     IEditingDomainItemProvider,
45     IStructuredItemContentProvider,
46     ITreeItemContentProvider,
47     IItemLabelProvider,
48     IItemPropertySource
49 {
50   /**
51    * This constructs an instance from a factory and a notifier.
52    */

53   public FunctionNamePairItemProvider(AdapterFactory adapterFactory)
54   {
55     super(adapterFactory);
56   }
57
58   /**
59    * This returns the property descriptors for the adapted class.
60    */

61   public List JavaDoc getPropertyDescriptors(Object JavaDoc object)
62   {
63     if (itemPropertyDescriptors == null)
64     {
65       super.getPropertyDescriptors(object);
66
67       //MappingPackage ePackage = ((FunctionNamePair)object).ePackageMapping();
68
MappingPackage ePackage = MappingPackage.eINSTANCE;
69
70       // This is for the in2out feature.
71
//
72
itemPropertyDescriptors.add
73         (new ItemPropertyDescriptor
74           (adapterFactory,
75            MappingPlugin.getPlugin().getString("_UI_In2out_property_label"),
76            MappingPlugin.getPlugin().getString("_UI_In2out_property_description"),
77            ePackage.getFunctionNamePair_In2out()));
78
79       // This is for the out2in feature.
80
//
81
itemPropertyDescriptors.add
82         (new ItemPropertyDescriptor
83           (adapterFactory,
84            MappingPlugin.getPlugin().getString("_UI_Out2in_property_label"),
85            MappingPlugin.getPlugin().getString("_UI_Out2in_property_description"),
86            ePackage.getFunctionNamePair_Out2in()));
87
88     }
89     return itemPropertyDescriptors;
90   }
91
92   protected static final String JavaDoc DIVIDER = " " + MappingPlugin.getPlugin().getString("_UI_Mapping_label_divider") + " ";
93
94   public String JavaDoc getText(Object JavaDoc object)
95   {
96     String JavaDoc out2in = ((FunctionNamePair)object).getOut2in();
97     String JavaDoc in2out = ((FunctionNamePair)object).getIn2out();
98     return (out2in == null ? "" : out2in) + DIVIDER + in2out;
99   }
100
101   /**
102    * This handles notification by delegating to {@link #fireNotifyChanged fireNotifyChanged}.
103    */

104   public void notifyChanged(Notification msg)
105   {
106     //MappingPackage ePackage = ((FunctionNamePair)msg.getNotifier()).ePackageMapping();
107
MappingPackage ePackage = MappingPackage.eINSTANCE;
108     if (msg.getFeature() == ePackage.getFunctionNamePair_In2out() || msg.getFeature() == ePackage.getFunctionNamePair_Out2in())
109     {
110       fireNotifyChanged(msg);
111       // HGD::fireNotifyChanged(msg.getNotifier(), msg.getEventType(), msg.getStructuralFeature(), msg.getOldValue(), msg.getNewValue(), msg.getPosition());
112
return;
113     }
114     super.notifyChanged(msg);
115   }
116   
117   /**
118    * Return the resource locator for this item provider's resources.
119    * <!-- begin-user-doc -->
120    * <!-- end-user-doc -->
121    * @generated
122    */

123   public ResourceLocator getResourceLocator()
124   {
125     return MappingPlugin.INSTANCE;
126   }
127
128 }
129
Popular Tags