Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF Forms] Different labels for nodes of the same type(Nodes A and B have the same child node C. Node C has a node Value. How to add different labels for Value node depending on the parent? (A or B))
[EMF Forms] Different labels for nodes of the same type [message #1711352] Thu, 15 October 2015 09:08 Go to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hello guys,

I succeeded in making a functional ecore model from my XSD file, but now I have a problem related to control labels.

I have the following situation:

XSD:
<xs:complexType name="bool_string_valueType">
<xs:attribute name="type" type="xs:string" fixed="EUTILstringValue"/>
<xs:attribute name="value" type="boolStringEnum" default="FALSE"/>
</xs:complexType>

<xs:complexType name="auto_commitType">
<xs:sequence>
<xs:element type="bool_string_valueType" name="bool_string_value"/>
</xs:sequence>
<xs:attribute type="xs:string" name="type" fixed="EUTILparameter"/>
<xs:attribute type="xs:string" name="name" fixed="auto_commit"/>
<xs:attribute type="xs:string" name="valueType" fixed="str"/>
</xs:complexType>

<xs:complexType name="use_degradedType">
<xs:sequence>
<xs:element type="bool_string_valueType" name="bool_string_value"/>
</xs:sequence>
<xs:attribute type="xs:string" name="type" fixed="EUTILparameter"/>
<xs:attribute type="xs:string" name="name" fixed="use_degraded_mode"/>
<xs:attribute type="xs:string" name="valueType" fixed="str"/>
</xs:complexType>

XMI:
<autoCommit
name="auto_commit"
type="EUTILparameter"
valueType="str">
<boolStringValue
value="TRUE"
type="EUTILstringValue"/>
</autoCommit>

<useDegraded
name="use_degraded_mode"
type="EUTILparameter"
valueType="str">
<boolStringValue
value="TRUE"
type="EUTILstringValue"/>
</useDegraded>

In a new view model I want to add both values of the boolStringValue (the auto_commit and use_degraded ones), but then it will display two drop-downs having the same label called "Value". How can I change this depending on the parent somehow, without making another bool string value type?

Thank you very much,
Simona T.

[Updated on: Thu, 15 October 2015 12:54]

Report message to a moderator

Re: Different labels for nodes of the same type [message #1711364 is a reply to message #1711352] Thu, 15 October 2015 11:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
What do you mean by "the view model"? Is this a question about EMF Forms?


On 15/10/2015 11:08 AM, Teohari Simona wrote:
> Hello guys,
>
> I succeeded in making a functional ecore model from my XSD file, but
> now I have a problem related to control labels.
>
> I have the following situation:
>
> XSD:
> <xs:complexType name="bool_string_valueType">
> <xs:attribute name="type" type="xs:string"
> fixed="EUTILstringValue"/>
> <xs:attribute name="value" type="boolStringEnum" default="FALSE"/>
> </xs:complexType>
>
> <xs:complexType name="auto_commitType">
> <xs:sequence>
> <xs:element type="bool_string_valueType" name="bool_string_value"/>
> </xs:sequence>
> <xs:attribute type="xs:string" name="type" fixed="EUTILparameter"/>
> <xs:attribute type="xs:string" name="name" fixed="auto_commit"/>
> <xs:attribute type="xs:string" name="valueType" fixed="str"/>
> </xs:complexType>
>
> <xs:complexType name="use_degradedType">
> <xs:sequence>
> <xs:element type="bool_string_valueType" name="bool_string_value"/>
> </xs:sequence>
> <xs:attribute type="xs:string" name="type" fixed="EUTILparameter"/>
> <xs:attribute type="xs:string" name="name" fixed="use_degraded_mode"/>
> <xs:attribute type="xs:string" name="valueType" fixed="str"/>
> </xs:complexType>
>
> XMI:
> <autoCommit
> name="auto_commit"
> type="EUTILparameter"
> valueType="str">
> <boolStringValue
> value="TRUE"
> type="EUTILstringValue"/>
> </autoCommit>
>
> <useDegraded
> name="use_degraded_mode"
> type="EUTILparameter"
> valueType="str">
> <boolStringValue
> value="TRUE"
> type="EUTILstringValue"/>
> </useDegraded>
>
> In a new view model I want to add both values of the boolStringValue
> (the auto_commit and use_degraded ones), but then it will display two
> drop-downs having the same label called "Value". How can I change this
> depending on the parent somehow, without making another bool string
> value type?
>
> Thank you very much,
> Simona T.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Different labels for nodes of the same type [message #1711373 is a reply to message #1711364] Thu, 15 October 2015 11:57 Go to previous messageGo to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Sorry, I meant to say view, not view model. The view model is the project created in IDE.
Re: Different labels for nodes of the same type [message #1711376 is a reply to message #1711373] Thu, 15 October 2015 12:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
I'm trying to figure out what you mean by "view model". Is this an EMF
Forms question?

On 15/10/2015 1:57 PM, Teohari Simona wrote:
> Sorry, I meant to say view, not view model. The view model is the
> project created in IDE.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Different labels for nodes of the same type [message #1711379 is a reply to message #1711376] Thu, 15 October 2015 12:26 Go to previous messageGo to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Yes it is.
Re: Different labels for nodes of the same type [message #1711383 is a reply to message #1711379] Thu, 15 October 2015 12:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
The EMF Forms developers monitor the eclipse.technology.emft forum and
generally expect the subject line to be prefixed with [EMF Forms]. They
might not notice your post here or without that prefix.

On 15/10/2015 2:26 PM, Teohari Simona wrote:
> Yes it is.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Different labels for nodes of the same type [message #1711447 is a reply to message #1711352] Fri, 16 October 2015 08:08 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Simona,

I am not sure, if I understand your requirement. Could you add a
screenshot or a drawing?

Best regards

Jonas



Am 15.10.2015 um 11:08 schrieb Teohari Simona:
> Hello guys,
>
> I succeeded in making a functional ecore model from my XSD file, but now
> I have a problem related to control labels.
>
> I have the following situation:
>
> XSD:
> <xs:complexType name="bool_string_valueType">
> <xs:attribute name="type" type="xs:string" fixed="EUTILstringValue"/>
> <xs:attribute name="value" type="boolStringEnum" default="FALSE"/>
> </xs:complexType>
>
> <xs:complexType name="auto_commitType">
> <xs:sequence>
> <xs:element type="bool_string_valueType" name="bool_string_value"/>
> </xs:sequence>
> <xs:attribute type="xs:string" name="type" fixed="EUTILparameter"/>
> <xs:attribute type="xs:string" name="name" fixed="auto_commit"/>
> <xs:attribute type="xs:string" name="valueType" fixed="str"/>
> </xs:complexType>
>
> <xs:complexType name="use_degradedType">
> <xs:sequence>
> <xs:element type="bool_string_valueType" name="bool_string_value"/>
> </xs:sequence>
> <xs:attribute type="xs:string" name="type" fixed="EUTILparameter"/>
> <xs:attribute type="xs:string" name="name" fixed="use_degraded_mode"/>
> <xs:attribute type="xs:string" name="valueType" fixed="str"/>
> </xs:complexType>
>
> XMI:
> <autoCommit
> name="auto_commit"
> type="EUTILparameter"
> valueType="str">
> <boolStringValue
> value="TRUE"
> type="EUTILstringValue"/>
> </autoCommit>
>
> <useDegraded
> name="use_degraded_mode"
> type="EUTILparameter"
> valueType="str">
> <boolStringValue
> value="TRUE"
> type="EUTILstringValue"/>
> </useDegraded>
>
> In a new view model I want to add both values of the boolStringValue
> (the auto_commit and use_degraded ones), but then it will display two
> drop-downs having the same label called "Value". How can I change this
> depending on the parent somehow, without making another bool string
> value type?
>
> Thank you very much,
> Simona T.
>


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: Different labels for nodes of the same type [message #1711470 is a reply to message #1711447] Fri, 16 October 2015 10:45 Go to previous messageGo to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hello Jonas,

Sorry for not being able to explain (I am an EMF beginner), it is more simpler than it looks maybe.

The first photo attached (Part_of_ecore.png) shows how the three complex types from the XSD (autoCommit, useDegraded, boolStringValue) + 1 enum (BoolStringEnum) are generated in the ecore. The AutoCommitType and UseDegradedType both have the same EAttribute boolStringValue of type BoolStringValueType. The BoolStringValueType has also an EAttribute called "Value".

Now, I want to be able to create a view with both boolean values (that means both the AutoCommit->boolStringValue->value and the UseDegraded->boolStringValue->value), but not with the default label "Value".
I attached a second photo in which you can see how the controls are generated in the view and how I want them to be.

Please tell me if it is clear now, if not, I will try to explain better. Any help is appreciated.

Thank you very much for your time!
Simona
Re: Different labels for nodes of the same type [message #1711725 is a reply to message #1711470] Mon, 19 October 2015 12:52 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

have you tried to set the Label Alihment to "none" in the view model for
these controls?

Best regards

Jonas

Am 16.10.2015 um 12:45 schrieb Teohari Simona:
> Hello Jonas,
>
> Sorry for not being able to explain (I am an EMF beginner), it is more simpler than it looks maybe.
>
> The first photo attached (Part_of_ecore.png) shows how the three complex types from the XSD (autoCommit, useDegraded, boolStringValue) + 1 enum (BoolStringEnum) are generated in the ecore. The AutoCommitType and UseDegradedType both have the same EAttribute boolStringValue of type BoolStringValueType. The BoolStringValueType has also an EAttribute called "Value".
>
> Now, I want to be able to create a view with both boolean values (that means both the AutoCommit->boolStringValue->value and the UseDegraded->boolStringValue->value), but not with the default label "Value".
> I attached a second photo in which you can see how the controls are generated in the view and how I want them to be.
>
> Please tell me if it is clear now, if not, I will try to explain better. Any help is appreciated.
>
> Thank you very much for your time!
> Simona
>


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: Different labels for nodes of the same type [message #1711867 is a reply to message #1711725] Tue, 20 October 2015 08:10 Go to previous messageGo to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
If I do that, then the label "Value" disappears. Then, I can manually create in the view an Horizontal Layout and a label component with name "Auto commit" indeed. But this is the only way?

There isn't any other programmatic way in which I can obtain this? To have access to the source code and modify the implementation of this label to take into account the parent in which BoolStringType is in? Usually I saw that this labels are changed through plugin.properties file from the edit plugin. I also saw that you can modify the label in the model explorer by changing the implementation in getText(Object object) method from the ItemProvider.

Anyway, thank you very much for the solution!
Re: Different labels for nodes of the same type [message #1712018 is a reply to message #1711867] Tue, 20 October 2015 18:25 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

the problem with the two approaches you describe is that the label
depends on the type of the parent, which is a very special case. That is
why plugin.properties will not work. Labels are provided by a service in
EMF Forms, which needs to be registered as an OSGi service. The default
is this:
org.eclipse.emfforms.internal.core.services.label.EMFFormsLabelProviderImpl

You can register a custom implementation with a higher service rank to
replace the default behavior.

Best regards

Jonas


Am 20.10.2015 um 10:10 schrieb Teohari Simona:
> If I do that, then the label "Value" disappears. Then, I can manually
> create in the view an Horizontal Layout and a label component with name
> "Auto commit" indeed. But this is the only way?
>
> There isn't any other programmatic way in which I can obtain this? To
> have access to the source code and modify the implementation of this
> label to take into account the parent in which BoolStringType is in?
> Usually I saw that this labels are changed through plugin.properties
> file from the edit plugin. I also saw that you can modify the label in
> the model explorer by changing the implementation in getText(Object
> object) method from the ItemProvider.
> Anyway, thank you very much for the solution!


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: Different labels for nodes of the same type [message #1722513 is a reply to message #1712018] Fri, 05 February 2016 11:25 Go to previous message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hi again Jonas,

I came back to this topic recently. Now, I want to create a custom control with a configurable label instead of creating an OSGI service. Custom controls will help me more in the future.
I have some questions:

1) How can I take the parent of the parent of the parent in isApplicable method?
if (eStructuralFeature.getName().equals("value") && eStructuralFeature.getEContainingClass() == (EEnum) pack.getEClassifier("BoolStringEnum")) && parentofBoolStringEnum is BoolStringValueType && parentofBoolStringValueType is AutoCommitType)
{
return 10;
}
2) think I should use a combobox swt control renderer to create the control? Which one should apply in this case?
3) Is it ok if I add new annotations in Ecore model to mark the objects where this custom control should apply? But then when a user clicks to see a view, the custom control would look in all models to read the elements with a certain annotation? I believe it puts an overload on the application, right?


Thank you very much,
S.
Previous Topic:Formatter
Next Topic:XSD to Ecore
Goto Forum:
  


Current Time: Thu Apr 25 08:23:08 GMT 2024

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

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

Back to the top