Edit - @ Uri has correctly indicated that this was misuse of annotation; Actually trying to create menu data manually in annotations is just silly.
But it's good for the binding, I think I'll use text data to link to links (link to "menu" ("file")) because it reflects a method name To be more clear and flexible than Apart from this, I learned a lot in mess with it. I will post the code as a reply in a few days.
- Original post -
I have not used these new fashioned annotations, but they look surprisingly interesting. Although I'm having trouble finding syntax (or better, this is the best way to use it).
In writing this, it has happened to me in writing some code that my methods are quite old I
I used to parse the string to define my method structure, then I use reflection to pass sections, but I think annotations can create a better menu structure.
Want to change my test class in the file like this:
@TemMenu ("file, edit") @ menu (name = "file", "save" Public Menu (name = "print", "preview, print") @ menu (name = "edit", "copy, paste") public class test menu {@MenuItem ("save") public zeros save ( } {System.out.println ("saved");} @manuitem ("load") public zero load () {System.out.println ("load");} ...
and completely with any input Closes to any method that forces a JNU borr to class installation.
The first problem is that I did not know how to pass the "default" of the string Want (attribute = "value") instead of all ("value"), can it be done? I can live without it, but this is a little literal, if I can get rid of legs and / or quotes , Then better than that Neither do I have my breath (I think I have to define a different interface for each menu item, which is not acceptable).
Second, it does not like multiple @ menu tags on a single class. I can parse a string about this, but I was wondering if there is any other way.
Most importantly, is there a library that already does? (If no one has come along with it, then I will publish the code to this thread when I will work on someone else's interest.)
The way I have attached multiple annotations, it is to use a container annotation, and then specify the item as an array.
@Retention (RetentionPolicy.RUNTIME) public @ interface menu {string name (); String [] child (); } @ Retention (Retention Policy. RUNTEm) Public @ Interface Menubar {Menu [] Value (); } @tittens (retention policy. RUNTEm) public @ interface menu {string value (); } @MenuBar (@Menu (name = "file", children = {"save", "load", "print", "preview", "leave"}), @ manu (name = "print", children = public Word Test Menu {@MenuItem ("Save") Public Zero Save () "@" ("Preview", "Print"}), @ Menu (name = "edit", children = {"copy", "paste"} }} {System.out.println ("saved");} @manuitem ("load") public zero load () {System.out.println ("load");}}
Comments
Post a Comment