Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1: add support of default attribute values #13

Closed
wants to merge 1 commit into from

Conversation

anb0s
Copy link
Owner

@anb0s anb0s commented Mar 18, 2017

WIP: added Value to Attribute and regenerated code
So in Model Editor (FM) the value can be defined and used in own code
generator as fallback if not AttributeValue was defined by user in
Feature Configuration (FC).

TODO:

  • show the default value in FC
  • add something like "use default value" checkbox in FC, if checked copy
    the value from FM to FC and store that is was copied not entered. If not
    checked then delete AttributeValue if was copied from FM before or just
    empty the value inside AttributeValue... just thinking...

https://bitbucket.org/jpikl/yafmt/issues/1/add-support-of-default-attribute-values

WIP: added Value to Attribute and regenerated code
So in Model Editor (FM) the value can be defined and used in own code
generator as fallback if not AttributeValue was defined by user in
Feature Configuration (FC).

TODO:
- show the default value in FC
- add something like "use default value" checkbox in FC, if checked copy
the value from FM to FC and store that is was copied not entered. If not
checked then delete AttributeValue if was copied from FM before or just
empty the value inside AttributeValue... just thinking...

https://bitbucket.org/jpikl/yafmt/issues/1/add-support-of-default-attribute-values
@anb0s
Copy link
Owner Author

anb0s commented Mar 18, 2017

Andre Bossert AUTHOR
Hello,
FYI: i've already created / maintained some small Eclipse plugins (EasyShell, LogViewer etc.) and I'm working with IBM Rhapsody (C, C++) at work, so some OOP and MDD skills are there ;) But i'm new to Eclipse Modeling, so just started learn this stuff with some tutorials: http://www.vogella.com/tutorials/EclipseEMF/article.html http://www.theserverside.com/news/1365073/The-Pragmatic-Code-Generator-Programmerhttp://www.peterfriese.de/getting-started-with-xtext-part-2/
May be you have some other sources to learn from...
So may be there are some unexpected changes for you, that i'm contributing. Please correct and inform me, i will do my best to fix them.
I've changed the model files and regenerated the sources from genmodel. Added just "Value" to "Attribute" to have default value in FM,
See my desctription above and TODOs that i've now indicated
I'm wondering about "line ending" (CR / LF) changes in generated source files. No idea now if it comes from Xtext etc. and how to fix it.
Thanks for your support! Andre
Reply Edit Delete 2015-09-04

@anb0s
Copy link
Owner Author

anb0s commented Mar 18, 2017

Jan Pikl REPO OWNER
I think it would be better to call it "defaultValue" instead of just "value" to make clear what it does. Also, it should be optional (Lower Bound = 0 in model).
For FC editor, I can think of much simpler approach:
When users select new feature (or when they delete attribute value) and that attribute has a default value the value is automatically set to default value. In other words, I wouldn't distinguish wheter the value was set manually by user or automatically copied from FM. Or is there a good reason for making the distinction?
The situation when "value == defaultValue" should be visible in FC editor. E.g. the value can have gray color.
I suspect that the code generator is using line ending configured in Preferences > Workspace (which is CR/LF on Windows by default). You can configure git to automatically convert newline endings when commiting changes https://help.github.com/articles/dealing-with-line-endings/. Also, I noticed that the generated code contains tabs for indentation instead of 4 spaces (Preferences > Java > Code Style > Formatter).
You should also update FM validation (cz.zcu.yafmt.model.validation.fm.FeatureModelValidator), so it checks wheter the default value is appropriate for the given attribute type.
As a best source to learn about EMF I'd recommend http://www.amazon.com/EMF-Eclipse-Modeling-Framework-Edition/dp/0321331885
Reply Like 2015-09-06

@anb0s
Copy link
Owner Author

anb0s commented Mar 18, 2017

Andre Bossert AUTHOR
Thanks! I've now some time to try adapt Yafmt for my needs. More patches to make it installable and buildable again with newer Eclipse versions will be done first...

@anb0s
Copy link
Owner Author

anb0s commented May 30, 2017

This will be not merged, because the issues are addressed for YAFMT 0.4.x only and via multiple commits, see issue #1

@anb0s anb0s closed this May 30, 2017
@anb0s anb0s deleted the issue1_default_value branch May 30, 2017 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant