Decorate EMF editor icons [message #411802] |
Mon, 06 August 2007 10:10  |
Eclipse User |
|
|
|
Hello !
I wish to decorate elements in all kind of EMF editors. Is it possible ?
I have found org.eclipse.ui.decorators extension point to decorate
IResource in the package explorer (but it works only on package explorer ?).
I have alse found org.eclipse.ui.startup extension point but I have to
list the editors packages in the "earlyStartup" method and I can't list
all the editors I want.
public class Startup implements IStartup {
/**
* Initializes me.
*/
public Startup() {
super();
}
/**
* Install the validator.
*/
public void earlyStartup() {
EValidator.Registry.INSTANCE.put(FooPackage.eINSTANCE,
new EValidatorAdapter());
EValidator.Registry.INSTANCE.put(Foo2Package.eINSTANCE,
new EValidatorAdapter());
...
}
}
Thanks.
Nathalie Lépine, Obeo.
|
|
|
|
|
Re: Decorate EMF editor icons [message #411807 is a reply to message #411805] |
Mon, 06 August 2007 11:37  |
Eclipse User |
|
|
|
Nathalie,
I'm not sure what that means exactly, but note that decoration could
happen directly via a specialized AdapterFactoryLabelProvider that
decorates the normal results you'd get from the item provider. I.e.,
it's not necessary to modify the item providers themselves to use this
technique. And of course the AdapterFactoryLabelProvider constructed
using a ComposedAdapterFactory that in turn is constructed with
ComposedAdapterFactory.Registry.INSTANCE could be used to produce labels
for any model that has registered its item providers...
Nathalie Lépine wrote:
> Thanks, but I need a generic decoration.
>
> Ed Merks a écrit :
>> Nathalie,
>>
>> We've not provided integration with Eclipse's decorator APIs. You
>> can accomplish decoration quite easily by augmenting the icons
>> returned by a standard item provider using
>> org.eclipse.emf.edit.provider.ComposedImage. Here's an example from
>> EStructuralFeatureItemProvider which is called for the images of an
>> EReference and an EAttribute:
>>
>> public Object getComposedImage(Object object, Object
>> imageToCompose)
>> {
>> EStructuralFeature eStructuralFeature =
>> (EStructuralFeature)object;
>> Collection<Object> images = new ArrayList<Object>();
>> images.add(imageToCompose);
>> String imageName = "full/obj16/EOccurrence";
>> int minOccurs = eStructuralFeature.getLowerBound();
>> int maxOccurs = eStructuralFeature.getUpperBound();
>> if (minOccurs >= 0 && (minOccurs <= maxOccurs || maxOccurs ==
>> -1))
>> {
>> switch (minOccurs)
>> {
>> case 0:
>> {
>> imageName += "Zero";
>> break;
>> }
>> case 1:
>> {
>> imageName += "One";
>> break;
>> }
>> default:
>> {
>> imageName += "N";
>> break;
>> }
>> }
>>
>> if (minOccurs != maxOccurs)
>> {
>> switch (maxOccurs)
>> {
>> case -1:
>> {
>> imageName += "ToUnbounded";
>> break;
>> }
>> case 0:
>> {
>> break;
>> }
>> case 1:
>> {
>> imageName += "ToOne";
>> break;
>> }
>> default:
>> {
>> imageName += minOccurs <= 1 ? "ToN" : "ToM";
>> break;
>> }
>> }
>> }
>> }
>> else
>> {
>> imageName += "NToM";
>> }
>>
>> if (!imageName.equals("full/obj16/EOccurrenceZeroToOne"))
>> {
>> images.add(EcoreEditPlugin.INSTANCE.getImage(imageName));
>> }
>>
>> return
>> new ComposedImage(images)
>> {
>> @Override
>> public List<ComposedImage.Point> getDrawPoints(Size size)
>> {
>> List<ComposedImage.Point> result =
>> super.getDrawPoints(size);
>> if (result.size() > 1)
>> {
>> result.get(0).y = -2;
>> }
>> return result;
>> }
>> };
>> }
>>
>>
>> Nathalie Lépine wrote:
>>> Hello !
>>>
>>> I wish to decorate elements in all kind of EMF editors. Is it
>>> possible ?
>>>
>>> I have found org.eclipse.ui.decorators extension point to decorate
>>> IResource in the package explorer (but it works only on package
>>> explorer ?).
>>> I have alse found org.eclipse.ui.startup extension point but I have
>>> to list the editors packages in the "earlyStartup" method and I
>>> can't list all the editors I want.
>>>
>>> public class Startup implements IStartup {
>>>
>>> /**
>>> * Initializes me.
>>> */
>>> public Startup() {
>>> super();
>>> }
>>>
>>> /**
>>> * Install the validator.
>>> */
>>> public void earlyStartup() {
>>> EValidator.Registry.INSTANCE.put(FooPackage.eINSTANCE,
>>> new EValidatorAdapter());
>>> EValidator.Registry.INSTANCE.put(Foo2Package.eINSTANCE,
>>> new EValidatorAdapter());
>>> ...
>>> }
>>> }
>>>
>>> Thanks.
>>>
>>> Nathalie Lépine, Obeo.
>>
|
|
|
Powered by
FUDForum. Page generated in 0.04232 seconds