Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Change ComboBox entries in the properties view
Change ComboBox entries in the properties view [message #517890] Tue, 02 March 2010 13:15 Go to next message
Ines  is currently offline Ines
Messages: 4
Registered: March 2010
Junior Member
Hi all,

in my GMF based editor I have various elements which may be linked by a connection. The connection has a string property. I want to have a combobox in the properties view to select the value of this property. I found an example in the GMF tutorial with fixed (static) values in the combobox. Now, I have two problems to solve:

1. The values in the combobox should be dependend of the element type of the source and target element of the connection.
2. There should be the possibilty to edit the combobox value. I want to type in a new value for the property beside the fixed values of the combobox.

I'm new to GMF and all advices are welcome!

Regards
Ines
Re: Change ComboBox entries in the properties view [message #517917 is a reply to message #517890] Tue, 02 March 2010 14:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26089
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050606040803030509050502
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Ines,

If you specify a set of choices, you won't get an entry field you can
modify. I think you'd need a custom editor if you want a dropdown and
the ability to type in an arbitrary value:

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>


Ines wrote:
> Hi all,
>
> in my GMF based editor I have various elements which may be linked by
> a connection. The connection has a string property. I want to have a
> combobox in the properties view to select the value of this property.
> I found an example in the GMF tutorial with fixed (static) values in
> the combobox. Now, I have two problems to solve:
>
> 1. The values in the combobox should be dependend of the element type
> of the source and target element of the connection. 2. There should be
> the possibilty to edit the combobox value. I want to type in a new
> value for the property beside the fixed values of the combobox.
>
> I'm new to GMF and all advices are welcome!
>
> Regards
> Ines

--------------050606040803030509050502
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ines,<br>
<br>
If you specify a set of choices, you won't get an entry field you can
modify.  I think you'd need a custom editor if you want a dropdown and
the ability to type in an arbitrary value:<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>
<br>
Ines wrote:
<blockquote cite="mid:hmj310$n5i$1@build.eclipse.org" type="cite">Hi
all,
<br>
<br>
in my GMF based editor I have various elements which may be linked by a
connection. The connection has a string property. I want to have a
combobox in the properties view to select the value of this property. I
found an example in the GMF tutorial with fixed (static) values in the
combobox. Now, I have two problems to solve:
<br>
<br>
1. The values in the combobox should be dependend of the element type
of the source and target element of the connection. 2. There should be
the possibilty to edit the combobox value. I want to type in a new
value for the property beside the fixed values of the combobox.
<br>
<br>
I'm new to GMF and all advices are welcome!
<br>
<br>
Regards
<br>
Ines
<br>
</blockquote>
</body>
</html>

--------------050606040803030509050502--
Re: Change ComboBox entries in the properties view [message #518169 is a reply to message #517917] Wed, 03 March 2010 11:00 Go to previous messageGo to next message
Ines  is currently offline Ines
Messages: 4
Registered: March 2010
Junior Member
Hi Ed,

thank you for your help. I followed the steps in the link but when I open my application in debug mode the XyzEditor from the EMF code is never reached. There is also no reference to the XyzEditor's constructor in the generated code.
I can't find the code where the editor for the used PropertySheetPage is set.

Any idea?

Ines
Re: Change ComboBox entries in the properties view [message #518176 is a reply to message #518169] Wed, 03 March 2010 06:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26089
Registered: July 2009
Senior Member
Ines,

You're opening GMF's generated editor, right? You need to apply these
changes there. GMF is using a tabbed properties view, so you'll likely
need to adjust the editor portion of the code to that API.


Ines wrote:
> Hi Ed,
> thank you for your help. I followed the steps in the link but when I
> open my application in debug mode the XyzEditor from the EMF code is
> never reached. There is also no reference to the XyzEditor's
> constructor in the generated code. I can't find the code where the
> editor for the used PropertySheetPage is set.
>
> Any idea?
>
> Ines
Re: Change ComboBox entries in the properties view [message #518558 is a reply to message #518176] Thu, 04 March 2010 13:32 Go to previous messageGo to next message
Ines  is currently offline Ines
Messages: 4
Registered: March 2010
Junior Member
Hi Ed,

thank you very much for your advise! It works.

I found a class XyzPropertySection where I modified the following method:

/**
* @generated NOT
*/
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 XyzPropertySource(object, ips);
}
}
if (object instanceof IAdaptable)
{
return (IPropertySource) ((IAdaptable) object).getAdapter(IPropertySource.class);
}
return null;
}


The class XyzPropertySource creates my own XyzPropertyDescriptor which creates my own XyzCellEditor.

Kind regards!
Ines
Re: Change ComboBox entries in the properties view [message #669901 is a reply to message #518558] Thu, 12 May 2011 01:48 Go to previous message
Cindy  is currently offline Cindy
Messages: 59
Registered: May 2011
Member
Hey,i am interested in what you have done here as i have come up with the same question~ i am quite new to GMF and would be grateful if you could give me a copy of your solution in detail ~ thanks a lot:-)
Previous Topic:data type conversion in OCL
Next Topic:joining class and attribute which are in different packages
Goto Forum:
  


Current Time: Thu Oct 02 16:49:33 GMT 2014

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

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