Home » Modeling » EMF » Property ComboBox for References to objects
Property ComboBox for References to objects [message #496558] |
Tue, 10 November 2009 14:25 |
Eduardo Cirilo 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 |
Ed Merks 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 #496658 is a reply to message #496621] |
Tue, 10 November 2009 19:44 |
Ed Merks 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/
|
|
| | | |
Goto Forum:
Current Time: Tue Apr 23 15:21:32 GMT 2024
Powered by FUDForum. Page generated in 0.03751 seconds
|