Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Filter out properties from EMF section
Filter out properties from EMF section [message #59908] Fri, 06 October 2006 05:14 Go to next message
Eclipse UserFriend
In many editors, all relevant EReferences may be edited in the diagram
and there is no need for supporting them in the property sheet. The
following code may be inserted in the generated XXXPropertyProvider
and filters out the EReference properties from the EMF section of the
Advanced tab. The shouldRemove method may be changed to change the
filtering strategy. Hope it's useful for others.

Hallvard

protected ICompositePropertySource createPropertySource(Object
object, IItemPropertySource itemPropertySource) {
return new FilteringCompositePropertySource(object,
itemPropertySource, "EMF");
}

private class FilteringCompositePropertySource extends
EMFCompositePropertySource {

public FilteringCompositePropertySource(Object object,
IItemPropertySource itemPropertySource, String string) {
super(object, itemPropertySource, string);
}

protected boolean shouldRemove(IPropertyDescriptor
descriptor) {
if (! (descriptor instanceof
EMFCompositeSourcePropertyDescriptor)) {
return false;
}
EMFCompositeSourcePropertyDescriptor
emfDescriptor = (EMFCompositeSourcePropertyDescriptor)descriptor;
if (emfDescriptor.getFeature() instanceof
EReference) {
return true;
}
return false;
}

public IPropertyDescriptor[] getPropertyDescriptors()
{
IPropertyDescriptor[] descriptors =
super.getPropertyDescriptors();
int count = 0;
for (int i = 0; i < descriptors.length; i++) {
if (! shouldRemove(descriptors[i])) {
count++;
}
}
if (count < descriptors.length) {
IPropertyDescriptor[] descriptors2 =
new IPropertyDescriptor[count];
for (int i = descriptors.length - 1; i
>= 0; i--) {
if (!
shouldRemove(descriptors[i])) {
descriptors2[--count]
= descriptors[i];
}
}
descriptors = descriptors2;
}
return descriptors;
}
}
Re: Filter out properties from EMF section [message #60197 is a reply to message #59908] Fri, 06 October 2006 09:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------050103020801020409070204
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hallvard,

You can also not generate them at all by changing the GenFeature's
"Property Type" property to be None.


Hallvard Tr
Re: Filter out properties from EMF section [message #60498 is a reply to message #60197] Sat, 07 October 2006 05:46 Go to previous messageGo to next message
Eclipse UserFriend
Ed,

Yes, I'm aware of that, but they are needed in the generated
tree-based editor, which I sometimes have to use, to bootstrap the
models. So, I want them generated, but filter them out, when they're
not needed anymore in (in addition to cluttering the property sheet).

Hallvard

On Fri, 06 Oct 2006 09:25:57 -0400, Ed Merks <merks@ca.ibm.com> wrote:

>Hallvard,
>
>You can also not generate them at all by changing the GenFeature's
>"Property Type" property to be None.
>
>
>Hallvard Trætteberg wrote:
>> In many editors, all relevant EReferences may be edited in the diagram
>> and there is no need for supporting them in the property sheet. The
>> following code may be inserted in the generated XXXPropertyProvider
>> and filters out the EReference properties from the EMF section of the
>> Advanced tab. The shouldRemove method may be changed to change the
>> filtering strategy. Hope it's useful for others.
>>
>> Hallvard
>>
>> protected ICompositePropertySource createPropertySource(Object
>> object, IItemPropertySource itemPropertySource) {
>> return new FilteringCompositePropertySource(object,
>> itemPropertySource, "EMF");
>> }
>>
>> private class FilteringCompositePropertySource extends
>> EMFCompositePropertySource {
>>
>> public FilteringCompositePropertySource(Object object,
>> IItemPropertySource itemPropertySource, String string) {
>> super(object, itemPropertySource, string);
>> }
>>
>> protected boolean shouldRemove(IPropertyDescriptor
>> descriptor) {
>> if (! (descriptor instanceof
>> EMFCompositeSourcePropertyDescriptor)) {
>> return false;
>> }
>> EMFCompositeSourcePropertyDescriptor
>> emfDescriptor = (EMFCompositeSourcePropertyDescriptor)descriptor;
>> if (emfDescriptor.getFeature() instanceof
>> EReference) {
>> return true;
>> }
>> return false;
>> }
>>
>> public IPropertyDescriptor[] getPropertyDescriptors()
>> {
>> IPropertyDescriptor[] descriptors =
>> super.getPropertyDescriptors();
>> int count = 0;
>> for (int i = 0; i < descriptors.length; i++) {
>> if (! shouldRemove(descriptors[i])) {
>> count++;
>> }
>> }
>> if (count < descriptors.length) {
>> IPropertyDescriptor[] descriptors2 =
>> new IPropertyDescriptor[count];
>> for (int i = descriptors.length - 1; i
>>
>>> = 0; i--) {
>>>
>> if (!
>> shouldRemove(descriptors[i])) {
>> descriptors2[--count]
>> = descriptors[i];
>> }
>> }
>> descriptors = descriptors2;
>> }
>> return descriptors;
>> }
>> }
>>
>>
Re: Filter out properties from EMF section [message #63861 is a reply to message #60498] Tue, 17 October 2006 07:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi Hallvard,

Instead of removing some properties from the EMF-section I'd rather like
to remove those properties generated in View-section. I know that these
properties are derived from the Node that is displayed, but I don't know
how to prevent my PropertiesView from displaying them.

Could you provide any help in this direction?
I want to remove the view-Properties because I'd like to prevent the
user from editing them. Them user should only be able to change the
layout of the nodes in the graphical diagram-editor with its given
actions (move, resize, etc.).

Thanks for any advice
Alex Haag


Hallvard Trætteberg wrote:
> Ed,
>
> Yes, I'm aware of that, but they are needed in the generated
> tree-based editor, which I sometimes have to use, to bootstrap the
> models. So, I want them generated, but filter them out, when they're
> not needed anymore in (in addition to cluttering the property sheet).
>
> Hallvard
>
> On Fri, 06 Oct 2006 09:25:57 -0400, Ed Merks <merks@ca.ibm.com> wrote:
>
>> Hallvard,
>>
>> You can also not generate them at all by changing the GenFeature's
>> "Property Type" property to be None.
>>
>>
>> Hallvard Trætteberg wrote:
>>> In many editors, all relevant EReferences may be edited in the diagram
>>> and there is no need for supporting them in the property sheet. The
>>> following code may be inserted in the generated XXXPropertyProvider
>>> and filters out the EReference properties from the EMF section of the
>>> Advanced tab. The shouldRemove method may be changed to change the
>>> filtering strategy. Hope it's useful for others.
>>>
>>> Hallvard
>>>
>>> protected ICompositePropertySource createPropertySource(Object
>>> object, IItemPropertySource itemPropertySource) {
>>> return new FilteringCompositePropertySource(object,
>>> itemPropertySource, "EMF");
>>> }
>>>
>>> private class FilteringCompositePropertySource extends
>>> EMFCompositePropertySource {
>>>
>>> public FilteringCompositePropertySource(Object object,
>>> IItemPropertySource itemPropertySource, String string) {
>>> super(object, itemPropertySource, string);
>>> }
>>>
>>> protected boolean shouldRemove(IPropertyDescriptor
>>> descriptor) {
>>> if (! (descriptor instanceof
>>> EMFCompositeSourcePropertyDescriptor)) {
>>> return false;
>>> }
>>> EMFCompositeSourcePropertyDescriptor
>>> emfDescriptor = (EMFCompositeSourcePropertyDescriptor)descriptor;
>>> if (emfDescriptor.getFeature() instanceof
>>> EReference) {
>>> return true;
>>> }
>>> return false;
>>> }
>>>
>>> public IPropertyDescriptor[] getPropertyDescriptors()
>>> {
>>> IPropertyDescriptor[] descriptors =
>>> super.getPropertyDescriptors();
>>> int count = 0;
>>> for (int i = 0; i < descriptors.length; i++) {
>>> if (! shouldRemove(descriptors[i])) {
>>> count++;
>>> }
>>> }
>>> if (count < descriptors.length) {
>>> IPropertyDescriptor[] descriptors2 =
>>> new IPropertyDescriptor[count];
>>> for (int i = descriptors.length - 1; i
>>>
>>>> = 0; i--) {
>>>>
>>> if (!
>>> shouldRemove(descriptors[i])) {
>>> descriptors2[--count]
>>> = descriptors[i];
>>> }
>>> }
>>> descriptors = descriptors2;
>>> }
>>> return descriptors;
>>> }
>>> }
>>>
>>>
>
Re: Filter out properties from EMF section [message #64089 is a reply to message #63861] Tue, 17 October 2006 08:06 Go to previous message
Eclipse UserFriend
It's easy with M2, check our project wiki for details.

Artem

"Alex Haag" <Alexander.Haag@esg.de> wrote in message
news:eh2dov$s52$1@utils.eclipse.org...
> Hi Hallvard,
>
> Instead of removing some properties from the EMF-section I'd rather like
> to remove those properties generated in View-section. I know that these
> properties are derived from the Node that is displayed, but I don't know
> how to prevent my PropertiesView from displaying them.
>
> Could you provide any help in this direction?
> I want to remove the view-Properties because I'd like to prevent the user
> from editing them. Them user should only be able to change the layout of
> the nodes in the graphical diagram-editor with its given actions (move,
> resize, etc.).
>
> Thanks for any advice
> Alex Haag
>
>
> Hallvard Tr
Previous Topic:SWT property editor
Next Topic:Some explanation/guidance/help for the GMF graph editor?
Goto Forum:
  


Current Time: Mon Jun 09 06:37:12 EDT 2025

Powered by FUDForum. Page generated in 0.07020 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top