Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Hide unnecessary attributes in Property view
Hide unnecessary attributes in Property view [message #206791] Wed, 24 September 2008 12:03 Go to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello,
There is a class Data inherit from an abstract class CObject which has
more attributes than is needed in Data,and after generating code from
Ecore model,I try to delete some of the unnecessary properties by
overriding getPropertyDescriptors() in the DataProvider.
I add a number of removeXXXPropertyDescriptor(object);
and corresponding methods like:
private void removeTypePropertyDescriptor(Object object) {
itemPropertyDescriptors.remove(6);

}
the number which is removed should refer to specific attributes in the
super class.but how to know which number match which attributes?


Thanks a lot!

Ye
Re: Hide unnecessary attributes in Property view [message #206799 is a reply to message #206791] Wed, 24 September 2008 12:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tobk42.gmx.de

There is an easier way for hiding properties: Just open the genmodel
(the EMF generation file), navigate to the property in question, expand
the 'Edit' group and set 'Property Type' to 'none'.

Tobias



ye schrieb:
> Hello,
> There is a class Data inherit from an abstract class CObject which has
> more attributes than is needed in Data,and after generating code from
> Ecore model,I try to delete some of the unnecessary properties by
> overriding getPropertyDescriptors() in the DataProvider.
> I add a number of removeXXXPropertyDescriptor(object);
> and corresponding methods like:
> private void removeTypePropertyDescriptor(Object object) {
> itemPropertyDescriptors.remove(6);
>
> }
> the number which is removed should refer to specific attributes in the
> super class.but how to know which number match which attributes?
>
>
> Thanks a lot!
>
> Ye
>
Re: Hide unnecessary attributes in Property view [message #206963 is a reply to message #206799] Thu, 25 September 2008 07:56 Go to previous messageGo to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hello Tobias,
Yes ,this is a easy way.but these common attributes are only shown under
the super class Object and are not shown under sub classes .how to set
'Property type ' to specific attributes under certain sub class?
e.g.super class has attribute Type,but in sub class Data,I don't want Type
be shown.But in the .genmodel,Type is not shown under Data,how can I set
'Property type' to Data?


Regards


ye












Tobias wrote:

> There is an easier way for hiding properties: Just open the genmodel
> (the EMF generation file), navigate to the property in question, expand
> the 'Edit' group and set 'Property Type' to 'none'.

> Tobias



> ye schrieb:
>> Hello,
>> There is a class Data inherit from an abstract class CObject which has
>> more attributes than is needed in Data,and after generating code from
>> Ecore model,I try to delete some of the unnecessary properties by
>> overriding getPropertyDescriptors() in the DataProvider.
>> I add a number of removeXXXPropertyDescriptor(object);
>> and corresponding methods like:
>> private void removeTypePropertyDescriptor(Object object) {
>> itemPropertyDescriptors.remove(6);
>>
>> }
>> the number which is removed should refer to specific attributes in the
>> super class.but how to know which number match which attributes?
>>
>>
>> Thanks a lot!
>>
>> Ye
>>
Re: Hide unnecessary attributes in Property view [message #210126 is a reply to message #206963] Fri, 31 October 2008 11:09 Go to previous message
Kristian O'Connor is currently offline Kristian O'ConnorFriend
Messages: 29
Registered: July 2009
Junior Member
Hello all -

I think that you nearly solved this yourself in the initial message... but
try this solution, I hope it works for you...

1.Create a utility method somewhere like this -

public boolean removeDescriptor(Object object, List descriptors,
EAttribute attribute)
{
Assert.isNotNull(object);
Assert.isNotNull(descriptors);
Assert.isNotNull(attribute);

ItemPropertyDescriptor descriptor = null;
for (Iterator iterator = descriptors.iterator(); iterator.hasNext();)
{
ItemPropertyDescriptor tempDescriptor = (ItemPropertyDescriptor)
iterator
.next();
if (tempDescriptor.getFeature(object) == attribute)
{
descriptor = tempDescriptor;
break;
}
}
if (descriptor != null)
{
descriptors.remove(descriptor);
return true;
}
return false;
}

2. Use the utilty method - passing in the object, the current list of
descriptors and the EAttribute you want to remove...

eg.
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public List getPropertyDescriptors(Object object)
{
if (itemPropertyDescriptors == null)
{
List descriptors = super.getPropertyDescriptors(object);
// Remove the type property -
MyItemProviderUtils
.getInstance()
.removeDescriptor(
object,
descriptors,
ModelPackage.Literals.COBJECT_TYPE);
MyItemProviderUtils
.getInstance()
.removeDescriptor(
object,
descriptors,
ModelPackage.Literals.COBJECT_SOMEOTHERTYPE);

addBlahBlahBlahPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}

That should allow you to selectively remove properties from the property
sheet based upon there EAttribute...

Hope that helps
Kristian.



"ye" <yeliu@abo.fi> wrote in message
news:8396536d722a87a4207d6ffa4d37119d$1@www.eclipse.org...
> Hello Tobias,
> Yes ,this is a easy way.but these common attributes are only shown under
> the super class Object and are not shown under sub classes .how to set
> 'Property type ' to specific attributes under certain sub class?
> e.g.super class has attribute Type,but in sub class Data,I don't want Type
> be shown.But in the .genmodel,Type is not shown under Data,how can I set
> 'Property type' to Data?
>
>
> Regards
>
>
> ye
>
>
>
>
>
>
>
>
>
>
>
>
> Tobias wrote:
>
>> There is an easier way for hiding properties: Just open the genmodel (the
>> EMF generation file), navigate to the property in question, expand the
>> 'Edit' group and set 'Property Type' to 'none'.
>
>> Tobias
>
>
>
>> ye schrieb:
>>> Hello,
>>> There is a class Data inherit from an abstract class CObject which has
>>> more attributes than is needed in Data,and after generating code from
>>> Ecore model,I try to delete some of the unnecessary properties by
>>> overriding getPropertyDescriptors() in the DataProvider.
>>> I add a number of removeXXXPropertyDescriptor(object);
>>> and corresponding methods like:
>>> private void removeTypePropertyDescriptor(Object object) {
>>> itemPropertyDescriptors.remove(6);
>>> }
>>> the number which is removed should refer to specific attributes in the
>>> super class.but how to know which number match which attributes?
>>>
>>>
>>> Thanks a lot!
>>>
>>> Ye
>>>
>
Previous Topic:Why a popmenu appear?
Next Topic:DiagramLabel draw too far of the connection line
Goto Forum:
  


Current Time: Mon Jan 25 02:32:36 GMT 2021

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

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

Back to the top