Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Question about property sheet
Question about property sheet [message #193206] Wed, 18 June 2008 08:20 Go to next message
Toan is currently offline ToanFriend
Messages: 36
Registered: July 2009
Member
Hello everybody,
I have two questions about property sheet:
1. Can I use another editor (a plug-in or my own editor) instead of the
editor which is given by GMF when I set Multi-line = true? Generally, can
I customize a property field (of any type not only string type) to call to
an plug-in to set its value? If yes, how can I do that?
2. How can I filter the element list appearing in the dialog of
multi-valued attribute. For example I have 3 classes A, B, C following:
_____________ __________ _________
|Class A |attrsB |Class B | |Class C |
| |---------->| |<|---------| |
| | 0..*| | | |
|____________| |_________| |________|
Class A has a relation association with class B, and Class C inherits from
class B. How can I restrict the list in the dialog multi-valued attribute
setting the value attrsB of class A to show only instances of the class B
and not those of the class C?
Thanks in advanced!
Toan.
Re: Question about property sheet [message #193255 is a reply to message #193206] Wed, 18 June 2008 10:31 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.
--------------020105040902060506030509
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Toan,

Have a look at

3.1 Recipe: Create your own property editor in a generated
application
< http://wiki.eclipse.org/EMF/Recipes#Recipe:_Create_your_own_ property_editor_in_a_generated_application>

Here's an example from ETypedElementItemProvider where we filter the choices

protected void addETypePropertyDescriptor(Object object)
{
itemPropertyDescriptors.add
(new ItemPropertyDescriptorWithUniqueChoiceOfValueLabels

(((ComposeableAdapterFactory)adapterFactory).getRootAdapterF actory(),
getResourceLocator(),
getString("_UI_ETypedElement_eType_feature"),
getString("_UI_ETypedElement_eType_description"),
EcorePackage.Literals.ETYPED_ELEMENT__ETYPE,
true,
false,
true,
null,
null,
null)
{
@Override
public Collection<?> getChoiceOfValues(Object object)
{


Toan wrote:
> Hello everybody,
> I have two questions about property sheet:
> 1. Can I use another editor (a plug-in or my own editor) instead of
> the editor which is given by GMF when I set Multi-line = true?
> Generally, can I customize a property field (of any type not only
> string type) to call to an plug-in to set its value? If yes, how can I
> do that?
> 2. How can I filter the element list appearing in the dialog of
> multi-valued attribute. For example I have 3 classes A, B, C following:
> _____________ __________ _________
> |Class A |attrsB |Class B | |Class C |
> | |---------->| |<|---------| |
> | | 0..*| | | |
> |____________| |_________| |________|
> Class A has a relation association with class B, and Class C inherits
> from class B. How can I restrict the list in the dialog multi-valued
> attribute setting the value attrsB of class A to show only instances
> of the class B and not those of the class C?
> Thanks in advanced!
> Toan.
>

< http://wiki.eclipse.org/EMF/Recipes#Recipe:_Create_your_own_ property_editor_in_a_generated_application>


--------------020105040902060506030509
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Toan,<br>
<br>
Have a look at<br>
<blockquote><a
href=" http://wiki.eclipse.org/EMF/Recipes#Recipe:_Create_your_own_ property_editor_in_a_generated_application"><span
class="tocnumber">3.1</span> <span class="toctext">Recipe: Create
your own property editor in a generated application</span></a><br>
</blockquote>
Here's an example from ETypedElementItemProvider where we filter the
choices<br>
<blockquote><small>
Re: Question about property sheet [message #193435 is a reply to message #193255] Thu, 19 June 2008 08:04 Go to previous messageGo to next message
Toan is currently offline ToanFriend
Messages: 36
Registered: July 2009
Member
Thanks Ed Merks,
I can now filter the choices but I haven't succeeded to create my own
property editor. I follow exactly the guide in 3.1 Recipe and also in the
blog but I don't know why that doesn't work. Can you help me, please?
Thanks in advanced!
Toan.
Re: Question about property sheet [message #193475 is a reply to message #193435] Thu, 19 June 2008 08:45 Go to previous messageGo to next message
Toan is currently offline ToanFriend
Messages: 36
Registered: July 2009
Member
I test with EMF, it works! Do I have to do other configurations in order
to make it work in GMF and what are those configurations? Thanks!
Toan.
Re: Question about property sheet [message #193680 is a reply to message #193475] Thu, 19 June 2008 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Toan,

I would have thought it would work for both, but if not, I don't know
why not... Sorry...


Toan wrote:
> I test with EMF, it works! Do I have to do other configurations in
> order to make it work in GMF and what are those configurations? Thanks!
> Toan.
>
Re: Question about property sheet [message #193885 is a reply to message #193680] Fri, 20 June 2008 09:16 Go to previous messageGo to next message
Toan is currently offline ToanFriend
Messages: 36
Registered: July 2009
Member
Hi Ed Merks,
Now I know where to modify to make it work. That's in the methode
public IPropertySource getPropertySource(Object object) {}
of file xxxPropertySection.java in the package xxx.diagram.sheet in which
xxx is name of my project. The methode look like this:
public IPropertySource getPropertySource(Object object) {
if (object instanceof IPropertySource) {
return (IPropertySource) object;
}
AdapterFactory af = getAdapterFactory(object);
if (af != null) {
IItemPropertySource ips = (IItemPropertySource) af.adapt(object,
IItemPropertySource.class);
if (ips != null) {
return new PropertySource(object, ips)
{
@Override
protected IPropertyDescriptor
createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor)
{
return
new PropertyDescriptor(object, itemPropertyDescriptor)
{
@Override
public CellEditor createPropertyEditor(Composite composite)
{
// Test for your case based on the feature or the type of the
feature.
// See the super method for details.
//
Object feature = temPropertyDescriptor.getFeature(this.object);
return super.createPropertyEditor(composite);
}
};
}
};
}
}
if (object instanceof IAdaptable) {
return (IPropertySource) ((IAdaptable) object)
.getAdapter(IPropertySource.class);
}
return null;
}

I have a question: Does the plug-in must depend on the packages graphic of
eclipse or not? Can I use any existing widget in Java which is not based
on eclipse packages graphic or not? If yes, how can I call the widget from
this method? Thanks in advance!
Toan.
Re: Question about property sheet [message #193916 is a reply to message #193885] Fri, 20 June 2008 12:18 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Toan,

Comments below.

Toan wrote:
> Hi Ed Merks,
> Now I know where to modify to make it work. That's in the methode
> public IPropertySource getPropertySource(Object object) {}
> of file xxxPropertySection.java in the package xxx.diagram.sheet in
> which xxx is name of my project. The methode look like this:
> public IPropertySource getPropertySource(Object object) {
> if (object instanceof IPropertySource) {
> return (IPropertySource) object;
> }
> AdapterFactory af = getAdapterFactory(object);
> if (af != null) {
> IItemPropertySource ips = (IItemPropertySource) af.adapt(object,
> IItemPropertySource.class);
> if (ips != null) {
> return new PropertySource(object, ips)
In AdapterFactoryContent provider this call is factored into a separate
method so that it's possible to override the creation without
duplicating the rest of the logic. I think it would be reasonable to
open a bugzilla enhancement request to factor out the "new
PropertySource" into a separate method. Looking closely at the
generated code, it makes me wonder why this method is even generated.
There's nothing specific to the model here and it could just as easily
be moved up to the base class (I think).
> {
> @Override
> protected IPropertyDescriptor
> createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor)
> {
> return new
> PropertyDescriptor(object, itemPropertyDescriptor)
> {
> @Override
> public CellEditor
> createPropertyEditor(Composite composite)
> {
> // Test for your case based on the feature or
> the type of the feature.
> // See the super method for details.
> //
> Object feature =
> temPropertyDescriptor.getFeature(this.object);
> return super.createPropertyEditor(composite);
> }
> };
> }
> };
> }
> }
> if (object instanceof IAdaptable) {
> return (IPropertySource) ((IAdaptable) object)
> .getAdapter(IPropertySource.class);
> }
> return null;
> }
>
Thanks for sharing the solution. Would you consider updating the wiki
recipe with an additional "in GMF you have to do it like this" section?
> I have a question: Does the plug-in must depend on the packages
> graphic of eclipse or not?
Well, the argument is Composite so you have to create something that has
that composite as the parent.
> Can I use any existing widget in Java which is not based on eclipse
> packages graphic or not?
Not sure, but it does need to be parented by Composite since that's
where the result will be "hosted".
> If yes, how can I call the widget from this method? Thanks in advance!
> Toan.
>
Previous Topic:Re: Border Item Rectilinear router
Next Topic:UML diagram change tracking
Goto Forum:
  


Current Time: Fri Nov 08 23:55:30 GMT 2024

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

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

Back to the top