|
Re: Hide unnecessary attributes in Property view [message #206799 is a reply to message #206791] |
Wed, 24 September 2008 12:57 |
Eclipse User |
|
|
|
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 |
yeliu 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 |
Kristian O'Connor 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
>>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02934 seconds