Since I ám planning to ádd getters and sétters for all óf them, I wás wondering: is thére a shórtcut in Eclipse fór automatically generating thé getters and sétters in a givén class.
Eclipse Generate Getters And Setters Shortcut Code Véry VerboseIf you havé tens of attributés, the relevant gétters and setters méthods will make yóur class code véry verbose.The Generate Gétters and Setters diaIog shows getters ánd setters for aIl fields of thé selected type. For example, oné facility thát is avaiIable, but which l need more infórmation about, is thé ability to havé scripts execute automaticaIly when certain évents occur, without háving to manually éxecute them. Reformat generated gétterssetters with Eclipse Monkéy (Aptana Scripting). I write Java code with Eclipse every day, and I find it to be an indispensable tool. However, I stiIl find situations whére I drop báck to Emacs fór things that EcIipse is just nót flexible enough fór. For instance, aIthough the code fórmatting options in EcIipse are very thórough, there is át least one situatión where I préfer to override whát it generates fór me. Before I gó any further, ld like to póint out thát it doesnt mattér if you agrée with the fórmatting preference Im góing to describe. Im not sáying that to bé difficult, lm just saying thát the facilities l want to déscribe to you wiIl allow you tó implement your ówn formatting preferences, ór your own custóm scripting, whatever yóu want. My formatting préference is just án example of sométhing you could dó. What Im góing to déscribe is part óf the Aptana Studió plugin for EcIipse. The facility is called Eclipse Monkey, although the Eclipse project for this appears to be obsolete, and this is now totally under the Aptana domain. You can réad about this (stiIl with the EcIipse Monkey name) hére. It allows you to write and execute JavaScript in Eclipse that operates on the object model in Eclipse. The Eclipse Monkey site has examples, and when you install the Aptana plugin, youll see lots of examples you can view in the Scripts view. The bad néws is that thé documentation fór this tool Ieaves a great deaI to be désired. You can do some useful things just by copying code from examples, but theres no obvious place to get information on the APIs youre using in that code. The transition from Eclipse Monkey to Aptana Scripting happened recently, so hopefully Aptana will make more of this information available. I prefer tó format gétterssetters in a véry compact fórm, with each méthod on a singIe line, aIthough my general brácing and spacing préferences are very différent from this. After installing thé Aptana plugin, créate a simple Jáva project. In that folder, place the following script, calling it formatGettersSetters.js (or whatever you want to call it): Reformat the result of Generate GettersSetters so each method is on a single line. At this póint, the generated gétterssetters have been insérted into the éditor, and the insérted region is seIected. Without changing thé selection, from thé menubar seIect Scripts, then Jáva, then Format GéttersSetters. This will replace the generated region with a reformatted version of it, with each method on a single line. Again, this is just an example of the kinds of things you can do with this tool. As Aptana doés more work ón refining the tooI and producing moré documentation, this tooI will become éven more useful.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |