Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Property ComboBox for References to objects
icon9.gif  Property ComboBox for References to objects [message #496558] Tue, 10 November 2009 14:25 Go to next message
Eduardo Cirilo is currently offline Eduardo CiriloFriend
Messages: 5
Registered: November 2009
Junior Member
Hello!
I am also having a similar problem discussed in the topic "Property ComboBox for String". In my EMF model I have an attribute which is a reference to an object "Operation". I have the following code:


protected void addNovoTestePropertyDescriptor(Object object) {
		itemPropertyDescriptors
				.add(new ItemPropertyDescriptor(
						((ComposeableAdapterFactory) adapterFactory)
								.getRootAdapterFactory(),
						getResourceLocator(),
						getString("_UI_Message_novoTeste_feature"), //$NON-NLS-1$
						getString(
								"_UI_PropertyDescriptor_description", "_UI_Message_novoTeste_feature", "_UI_Message_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
						UMLPackage.Literals.MESSAGE__NOVO_TESTE, true, true,
						true, null, null, null){
					@Override
					public Collection<?> getChoiceOfValues(Object object) {
						final MessageImpl ClassObj = (MessageImpl) object;
						Collection<Operation> result = new ArrayList<Operation>();
						if (ClassObj != null
								&& ((MessageOccurrenceSpecification) ClassObj
										.getReceiveEvent()).getCovereds()
										.get(0) != null) {
							ClassImpl targetClass = (ClassImpl) ((MessageOccurrenceSpecification) ClassObj
									.getReceiveEvent()).getCovereds().get(0)
									.getType();
							for (Operation op : targetClass.getOperations())
								result.add(op);
						}
						return result;
					}
				});
	}


I want the objects of type "Operation" to appear in a combobox so that I can select. However, in the property view appears a button [...] that opens a popup for me to look for the object in a diagram file. But this way I can select any object "Operation", which is not desirable. Actually I just want to select a subset of these objects, which are the ones I'm trying to come in combobox.
If I change the type of the attribute in the EMF model to Estring and get only the object name "Operation", the combobox appears correctly. But this way I lose the reference to the object.
Could anyone help me please?
Re: Property ComboBox for References to objects [message #496561 is a reply to message #496558] Tue, 10 November 2009 14:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Eduardo,

Try to post questions just once. Basic question: is your override
method being called?


Eduardo Cirilo wrote:
> Hello! I am also having a similar problem discussed in the topic
> "Property ComboBox for String". In my EMF model I have an attribute
> which is a reference to an object "Operation". I have the following code:
>
> protected void addNovoTestePropertyDescriptor(Object object) {
> itemPropertyDescriptors
> .add(new ItemPropertyDescriptor(
> ((ComposeableAdapterFactory) adapterFactory)
> .getRootAdapterFactory(),
> getResourceLocator(),
> getString("_UI_Message_novoTeste_feature"),
> //$NON-NLS-1$
> getString(
> "_UI_PropertyDescriptor_description",
> "_UI_Message_novoTeste_feature", "_UI_Message_type"), //$NON-NLS-1$
> //$NON-NLS-2$ //$NON-NLS-3$
> UMLPackage.Literals.MESSAGE__NOVO_TESTE, true,
> true,
> true, null, null, null){
> @Override
> public Collection<?> getChoiceOfValues(Object
> object) {
> final MessageImpl ClassObj = (MessageImpl)
> object;
> Collection<Operation> result = new
> ArrayList<Operation>();
> if (ClassObj != null
> && ((MessageOccurrenceSpecification)
> ClassObj
> .getReceiveEvent()).getCovereds()
> .get(0) != null) {
> ClassImpl targetClass = (ClassImpl)
> ((MessageOccurrenceSpecification) ClassObj
>
> .getReceiveEvent()).getCovereds().get(0)
> .getType();
> for (Operation op :
> targetClass.getOperations())
> result.add(op);
> }
> return result;
> }
> });
> }
>
> I want the objects of type "Operation" to appear in a combobox so that
> I can select. However, in the property view appears a button [...]
> that opens a popup for me to look for the object in a diagram file.
> But this way I can select any object "Operation", which is not
> desirable. Actually I just want to select a subset of these objects,
> which are the ones I'm trying to come in combobox. If I change the
> type of the attribute in the EMF model to Estring and get only the
> object name "Operation", the combobox appears correctly. But this way
> I lose the reference to the object. Could anyone help me please?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Property ComboBox for References to objects [message #496621 is a reply to message #496561] Tue, 10 November 2009 17:10 Go to previous messageGo to next message
Eduardo Cirilo is currently offline Eduardo CiriloFriend
Messages: 5
Registered: November 2009
Junior Member
Hello, Ed!

Thanks for answering.

Oh, sorry. It's my fault. I thought I should create a new topic for my question was answered. Thanks for the tip.

Regarding the method call, it is being called. I gave a System.out.println() in the variable result and it is properly collecting operations.

However, when the variable result is a collection of strings with the names of objects, the combobox is created correctly in the property view. But when the variable result is a collection of objects "Operation",only appears the button [...] in the property view.

Is there any way in the ItemPropertyDescriptor to indicate that I want is to create a combobox to select the objects rather than pushing a button [...] to browse the operation in any diagram?

In the model, my attribute is a reference to an object "Operation". Both its lower and upper bounds are set at 1...
Re: Property ComboBox for References to objects [message #496658 is a reply to message #496621] Tue, 10 November 2009 19:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Eduardo,

Comments below.

Eduardo Cirilo wrote:
> Hello, Ed!
>
> Thanks for answering.
>
> Oh, sorry. It's my fault. I thought I should create a new topic for my
> question was answered. Thanks for the tip.
>
> Regarding the method call, it is being called. I gave a
> System.out.println() in the variable result and it is properly
> collecting operations.
>
> However, when the variable result is a collection of strings with the
> names of objects, the combobox is created correctly in the property
> view. But when the variable result is a collection of objects
> "Operation",only appears the button [...] in the property view.
Is the feature you're populating a multi-valued feature?
>
> Is there any way in the ItemPropertyDescriptor to indicate that I want
> is to create a combobox to select the objects rather than pushing a
> button [...] to browse the operation in any diagram?
If it's a single valued feature a combo box will be used to make the one
and only choice, but if it's a multi-valued feature, then you need to be
able to select one or more of the possible choices and therefore a
dialog is used to doing that.
>
> In the model, my attribute is a reference to an object "Operation".
> Both its lower and upper bounds are set at 1...
You're sure? What does the "..." bring up then. What happens when you
choose multiple things?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Property ComboBox for References to objects [message #496675 is a reply to message #496658] Tue, 10 November 2009 21:41 Go to previous messageGo to next message
Eduardo Cirilo is currently offline Eduardo CiriloFriend
Messages: 5
Registered: November 2009
Junior Member
Hi, Ed.

Thanks for answering again.

The feature I'm populating is a single-valued feature.

Here is the declaration of the feature in the class MessageImpl:

/**
	 * The cached value of the '{@link #getNovoTeste() <em>Operation</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNovoTeste()
	 * @generated
	 * @ordered
	 */
	protected Operation novoTeste;


As I said earlier, this is a reference to objects of type (EType) Operation. In fact, it has lower and upper bounds set at 1. The dialog that opens (attached image) only allows to select an operation in any diagram. It is not possible to select more than one operation ...

I forgot to say that I am creating a UML sequence diagram using the GMF framework. The GMF may be influencing the creation of the widget in this case?
Re: Property ComboBox for References to objects [message #496829 is a reply to message #496675] Wed, 11 November 2009 14:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Eduardo,

Comments below.

Eduardo Cirilo wrote:
> Hi, Ed.
>
> Thanks for answering again.
>
> The feature I'm populating is a single-valued feature.
>
> Here is the declaration of the feature in the class MessageImpl:
>
> /**
> * The cached value of the '{@link #getNovoTeste()
> <em>Operation</em>}' reference.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @see #getNovoTeste()
> * @generated
> * @ordered
> */
> protected Operation novoTeste;
>
> As I said earlier, this is a reference to objects of type (EType)
> Operation. In fact, it has lower and upper bounds set at 1. The dialog
> that opens (attached image) only allows to select an operation in any
> diagram. It is not possible to select more than one operation ...
I'm not seeing an attachment. I don't recognize the description of the
dialog as an EMF one.
>
> I forgot to say that I am creating a UML sequence diagram using the
> GMF framework. The GMF may be influencing the creation of the widget
> in this case?
It sounds like that's the case, yes. Set a breakpoint in your method
and see who's calling it and what they're doing with the result. Perhaps
try the generated EMF editor to see how it behaves in this case.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Property ComboBox for References to objects [message #496948 is a reply to message #496829] Wed, 11 November 2009 20:10 Go to previous message
Eduardo Cirilo is currently offline Eduardo CiriloFriend
Messages: 5
Registered: November 2009
Junior Member
Hello, Ed.

I did upload the image, but it seems not working.

I'll try to include the breakpoints to see the behavior.

Thanks.
Previous Topic:Error trying to partially p2.mirror EMF 2.5.0 update site
Next Topic:Resolving references during model creation
Goto Forum:
  


Current Time: Tue Apr 23 15:21:32 GMT 2024

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

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

Back to the top