|
Re: [Xcore] Extending property view with custom property [message #1734721 is a reply to message #1734697] |
Fri, 10 June 2016 16:14 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
If you want it to be serializeable, you'd need a convert method as well,
and that needs to produce a string representation that can be passed to
the create method; in both cases, the value is referenced by "it" and
your create method should us it. Then, given there is a string
representation, the text cell editor will be sufficient.
If you want a specialized cell editor you can use this approach:
https://wiki.eclipse.org/EMF/Recipes#Recipe:_Create_your_own_property_editor_in_a_generated_application
On 10.06.2016 13:56, Phil Hei wrote:
> Hi,
>
> I want to enrich my model with a custom property which represents the
> data size. A data size is a tuple of a value and a certain unit type.
> I've seen the Data type example in the xcore help
> (https://wiki.eclipse.org/Xcore#Specifying_a_Data_Type) so I tried to
> achieve the same. In the following there is an minialistic example in
> xcore:
>
> hw.xcore:
>
>
> import unit.DataSize
>
> class Memory extends HardwareElement{
> DataSize memorySize
> }
>
> type DataSize wraps DataSize
> create{
> new DataSize();
> }
>
>
> DataSize.java:
>
>
> package org.eclipse.app4mc.amalthea.variability.hvm.unit;
>
> public class DataSize {
> long value;
> DataSizeUnit dataSizeUnit;
>
> public DataSize() {
> super();
> }
>
> public DataSize(long value, DataSizeUnit dataSizeUnit) {
> super();
> this.value = value;
> this.dataSizeUnit = dataSizeUnit;
> }
>
> public long getValue() {
> return value;
> }
>
> public void setValue(long value) {
> this.value = value;
> }
>
> public DataSizeUnit getDataSizeUnit() {
> return dataSizeUnit;
> }
>
> public void setDataSizeUnit(DataSizeUnit dataSizeUnit) {
> this.dataSizeUnit = dataSizeUnit;
> }
> }
>
>
> Doing so it's possbile to generate the EMF editor, but within the
> properties view I'm not able to set the attributes for the DataSize as
> there are two values to set, but the property view only offers one
> input field.
> First Question: Is this approach in generally possible? I assume that
> the "create" command and therefore the constructor call is probably a
> problem.
> In case it's possible in this way: What would be the best way to edit
> the property view?
>
> Cheers,
> Phil
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: [Xcore] Extending property view with custom property [message #1734881 is a reply to message #1734834] |
Mon, 13 June 2016 12:06 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Phil,
No, those two methods (convert/create ) must implement the
serialization/deserialization logic. Your data values won't be
serializeable without implementing that logic. So you must write logic
to convert the data value to a single string representation that can be
parsed and used to recreate to your data value. That is the purpose of
these two methods. There's no avoiding it.
On 13.06.2016 13:54, Phil Hei wrote:
> Hi Ed,
>
> thx for the explanation.
> So let's assume I create a specialized cell editor with two fields,
> whereby one field represent s a long value (for data size) and the
> other one represents an enum (data unit). Is there any chance to read
> in both attributes value within the create method in my xcore file in
> order to call the constructor of my class DataSize and create an
> appropriate instance?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04008 seconds