Skip to main content



      Home
Home » Eclipse Projects » e(fx)clipse » Create JavaFX getter/setter/property(javafx code generation)
Create JavaFX getter/setter/property [message #1386178] Sat, 14 June 2014 02:31 Go to next message
Eclipse UserFriend
From what I've read, there's already a standard for JavaFX getters and setters, e. g.:

public class Person {

	private StringProperty name;

	public Person() {
		name = new SimpleStringProperty("Unnamed");
	}

	public String getName() {
		return name.get();
	}

	public void setName(String value) {
		name.set(value);
	}

	public StringProperty nameProperty() {
		return name;
	}
}


Obviously the existing "Generate Getters and Setters" eclipse menu doesn't work anymore with this. Is there an automatic way to create JavaFX methods (getter / setter / property)?

Thank you very much Smile
Re: Create JavaFX getter/setter/property [message #1386203 is a reply to message #1386178] Sat, 14 June 2014 16:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Unfortunately we don't yet had time to implement this feature. There was
a question a few days back on this forum see "Tooling to create JavaFX
Beans?" where I gave some pointers on code we started but not yet finished.

Tom

On 14.06.14 20:42, Lofi Mayer wrote:
> From what I've read, there's already a standard for JavaFX getters and
> setters, e. g.:
>
> public class Person {
>
> private StringProperty name;
>
> public Person() {
> name = new SimpleStringProperty("Unnamed");
> }
>
> public String getName() {
> return name.get();
> }
>
> public void setName(String value) {
> name.set(value);
> }
>
> public StringProperty nameProperty() {
> return name;
> }
> }
>
> Obviously the existing "Generate Getters and Setters" eclipse menu
> doesn't work anymore with this. Is there an automatic way to create
> JavaFX methods (getter / setter / property)?
>
> Thank you very much :)
Re: Create JavaFX getter/setter/property [message #1386249 is a reply to message #1386203] Mon, 16 June 2014 02:45 Go to previous messageGo to next message
Eclipse UserFriend
This is the post Tom is referring to:
https://www.eclipse.org/forums/index.php/m/1385955/
Re: Create JavaFX getter/setter/property [message #1386363 is a reply to message #1386249] Tue, 17 June 2014 02:07 Go to previous messageGo to next message
Eclipse UserFriend
Thank you very much. It looks rather complicated with all the parsing. I just checked what Netbeans has to offer, seems to be the only tool that provides such a feature currently. But it doesn't seem to have more than a simple "Add Property" (source -> insert code -> Add Java FX Property) dialog. No analyzation of the existing code. But it does create the methods out of the specified property name and type, which saves time & code typing. I guess that could suffice for a start as well.
Re: Create JavaFX getter/setter/property [message #1386367 is a reply to message #1386363] Tue, 17 June 2014 03:26 Go to previous messageGo to next message
Eclipse UserFriend
File a bug and if possible provide a simple implementation, i guess
that's better than nothing and we can improve it step by step.

Tom

On 17.06.14 08:07, Lofi Mayer wrote:
> Thank you very much. It looks rather complicated with all the parsing. I
> just checked what Netbeans has to offer, seems to be the only tool that
> provides such a feature currently. But it doesn't seem to have more than
> a simple "Add Property" (source -> insert code -> Add Java FX Property)
> dialog. No analyzation of the existing code. But it does create the
> methods out of the specified property name and type, which saves time &
> code typing. I guess that could suffice for a start as well.
Re: Create JavaFX getter/setter/property [message #1386472 is a reply to message #1386367] Tue, 17 June 2014 14:17 Go to previous messageGo to next message
Eclipse UserFriend
Ok, will do. First I'll try to create a plugin, haven't done this before. I guess all it'll have to do is add a menu to eclipse, open a dialog and write some code.

By the way, THANK YOU VERY MUCH for e(fx)clipse. Saved me a lot of time to get into Java F Smile
Re: Create JavaFX getter/setter/property [message #1386481 is a reply to message #1386472] Tue, 17 June 2014 14:43 Go to previous messageGo to next message
Eclipse UserFriend
Better you add the stuff to the "org.eclipse.fx.ide.jdt.ui" plugin. Let
me see if I can help you bootstrapping it ;-)

Tom

On 17.06.14 20:17, Lofi Mayer wrote:
> Ok, will do. First I'll try to create a plugin, haven't done this
> before. I guess all it'll have to do is add a menu to eclipse, open a
> dialog and write some code.
>
> By the way, THANK YOU VERY MUCH for e(fx)clipse. Saved me a lot of time
> to get into Java F :)
Re: Create JavaFX getter/setter/property [message #1386503 is a reply to message #1386481] Tue, 17 June 2014 19:47 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I had some time while watching soccer and implemented a start of a
dialog which has the main feature set allowing you to select fields and
generates get*/set*/*Property for you.

It needs some love e.g. to add whitespace between methods, detect lazy
init, ... but it is a good start for you to polish and add new features.

The push to git I made is
http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/commit/?id=177dc8334c65a76539045bc8826950dd9a47a5d3
where the code you need to pick up and enhance is
AddFXBeanGetterSetterHandler!

Tom

On 17.06.14 20:43, Tom Schindl wrote:
> Better you add the stuff to the "org.eclipse.fx.ide.jdt.ui" plugin. Let
> me see if I can help you bootstrapping it ;-)
>
> Tom
>
> On 17.06.14 20:17, Lofi Mayer wrote:
>> Ok, will do. First I'll try to create a plugin, haven't done this
>> before. I guess all it'll have to do is add a menu to eclipse, open a
>> dialog and write some code.
>>
>> By the way, THANK YOU VERY MUCH for e(fx)clipse. Saved me a lot of time
>> to get into Java F :)
>
Re: Create JavaFX getter/setter/property [message #1386626 is a reply to message #1386503] Wed, 18 June 2014 16:11 Go to previous messageGo to next message
Eclipse UserFriend
Thank you very much. Huge respect for your work, it's very impressive. I haven't done anything like this so far. It's impressive how quickly it was possible to install the plugin and debug it. However, I'm totally not into this kind of stuff and am already stuck when I tried to fix this bug: Creating a getter/setter for ListProperty<Integer> returns an error. Problem is that instead of List<Integer> only Integer is generated as return parameter in the getter, which results in a compile error of the generated code.

In more detail: The method f.getTypeSignature() returns QListProperty<QInteger;>; which would look good, but Signature.toString(typeArgs[0]) returns only an Integer as return value instead of List<Integer>. How do you get the typed list instead of the type of the list?
Re: Create JavaFX getter/setter/property [message #1386646 is a reply to message #1386626] Thu, 19 June 2014 01:44 Go to previous messageGo to next message
Eclipse UserFriend
On 18.06.14 22:11, Lofi Mayer wrote:
> Thank you very much. Huge respect for your work, it's very impressive. I
> haven't done anything like this so far. It's impressive how quickly it
> was possible to install the plugin and debug it. However, I'm totally
> not into this kind of stuff and am already stuck when I tried to fix
> this bug: Creating a getter/setter for ListProperty<Integer> returns an
> error. Problem is that instead of List<Integer> only Integer is
> generated as return parameter in the getter, which results in a compile
> error of the generated code.
>
> In more detail: The method f.getTypeSignature() returns
> QListProperty<QInteger;>; which would look good, but

no this is not enough - my detection of the type is not smart enough
here because in reality it is

ObservableList<Integer>

I think the solution to this problem is not really simple - I need to
test this myself but I think I need to get to the real AST so that I get
all informations the compiler has so that I can find the real return
type with all informations the compiler inferred. Currently I went the
simple way and used the IType-API which is similar to the
Java-Reflection API.

Tom
Re: Create JavaFX getter/setter/property [message #1386650 is a reply to message #1386646] Thu, 19 June 2014 02:41 Go to previous message
Eclipse UserFriend
No, it's not simple, I tried for hours now Smile The closest I came up with was to use the parameter of setValue as type, which would be ObservableList<E>. But that's most probably not the proper solution.
Previous Topic:java.lang.ClassNotFoundException
Next Topic:Status of tooltip support
Goto Forum:
  


Current Time: Wed Apr 30 04:30:16 EDT 2025

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

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

Back to the top