Home » Modeling » Epsilon » [EOL] How to call constructor when using Native
[EOL] How to call constructor when using Native [message #529615] |
Mon, 26 April 2010 10:41  |
Eclipse User |
|
|
|
Hi everyone,
Is it possible to call java classes with constructor in Native?
For example, java.lang.Short can only be instantiated with a parameter like Short(1), Short("1"), but how to realize this in EOL Native?
Thanks a lot.
Yu
|
|
| | |
Re: [EOL] How to call constructor when using Native [message #529681 is a reply to message #529666] |
Mon, 26 April 2010 14:10   |
Eclipse User |
|
|
|
Thanks Dimitrios and Steffen. The problem has been solved. I used the new syntax and it works perfect!
However, I do still have one problem regarding Native remaining:
In the initial Eclipse WS, I have a Plugin Project A, which contains a EOL program, and a popup menu event handler to run EOL by Java (I used the EolStandaloneExample).
Then, in the runtime Eclipse WS, I can right-click on the model and run the EOL on the selected model. It works well.
The problem comes when I use Native to call my own classes.
I put my class (e.g., testnative.MyUtility.java) into a plug-in project in the initial Eclipse WS (I refered to http:// www.eclipse.org/gmt/epsilon/doc/articles/call-java-from-epsi lon/), and setup the Tool Extension Point.
Then, in the runtime Eclipse WS, if I create a new EOL in the runtime WS, and use Native('testnative.MyUtility.java'), it works perfect! which means that I setup the extension point correctly.
But, if I run the right-click popup menu option, it will say that "Type MyUtility not found...."
Later, I checked the article again(http:// www.eclipse.org/gmt/epsilon/doc/articles/call-java-from-epsi lon/), and it says "To invoke the tool you have two options: You can either run a new Eclipse instance, or export the plugin and place it in the dropins folder of your installation. Then you can invoke the tool using the following EOL program. "
I thought that since the EOL is in the initial Eclipse WS, maybe I should export the plugin. So I just exported the plugin contain MyUtility.java and put it in the plugin folder of the initial Eclipse. But the right-click running in the runtime Eclipse still cannot find the type. In stead, if you create an EOL in the initial Eclipse WS, it works well, which means that the exported plugin is also setup correctly.
To sum up, I have a plugin containing a java class that I want to use as Nativa in EOL. It has been setup, so that we can use Native to call it either by running a EOL file created in runtime Eclipse, or running a EOL file in initial Eclipse. However, it cannot be found if we trigger the popup menu option in runtime Eclipse (EOL is in the initial Eclipse WS and being called by the event handler).
Sorry for the wordy description. I really appreciate if you can give me some advice.
Thanks a lot.
Yu
|
|
|
Re: [EOL] How to call constructor when using Native [message #529693 is a reply to message #529681] |
Mon, 26 April 2010 15:04   |
Eclipse User |
|
|
|
Hi Yu,
When preparing the context you should also add this line:
context.getNativeTypeDelegates().add(new
ExtensionPointToolNativeTypeDelegate());
(The reason why EolStandaloneExample doesn't contain this line is that
it is meant to be executable outside Eclipse too)
Cheers,
Dimitris
Yu Sun wrote:
> Thanks Dimitrios and Steffen. The problem has been solved. I used the
> new syntax and it works perfect!
>
> However, I do still have one problem regarding Native remaining:
>
> In the initial Eclipse WS, I have a Plugin Project A, which contains a
> EOL program, and a popup menu event handler to run EOL by Java (I used
> the EolStandaloneExample).
>
> Then, in the runtime Eclipse WS, I can right-click on the model and run
> the EOL on the selected model. It works well.
>
> The problem comes when I use Native to call my own classes.
>
> I put my class (e.g., testnative.MyUtility.java) into a plug-in project
> in the initial Eclipse WS (I refered to
> http://www.eclipse.org/gmt/epsilon/doc/articles/call-java-fr om-epsilon/),
> and setup the Tool Extension Point.
> Then, in the runtime Eclipse WS, if I create a new EOL in the runtime
> WS, and use Native('testnative.MyUtility.java'), it works perfect! which
> means that I setup the extension point correctly.
>
> But, if I run the right-click popup menu option, it will say that "Type
> MyUtility not found...."
>
> Later, I checked the article
> again( http://www.eclipse.org/gmt/epsilon/doc/articles/call-java-fr om-epsilon/),
> and it says "To invoke the tool you have two options: You can either run
> a new Eclipse instance, or export the plugin and place it in the
> dropins folder of your installation. Then you can invoke the tool using
> the following EOL program. "
>
> I thought that since the EOL is in the initial Eclipse WS, maybe I
> should export the plugin. So I just exported the plugin contain
> MyUtility.java and put it in the plugin folder of the initial Eclipse.
> But the right-click running in the runtime Eclipse still cannot find the
> type. In stead, if you create an EOL in the initial Eclipse WS, it works
> well, which means that the exported plugin is also setup correctly.
>
> To sum up, I have a plugin containing a java class that I want to use as
> Nativa in EOL. It has been setup, so that we can use Native to call it
> either by running a EOL file created in runtime Eclipse, or running a
> EOL file in initial Eclipse. However, it cannot be found if we trigger
> the popup menu option in runtime Eclipse (EOL is in the initial Eclipse
> WS and being called by the event handler).
>
> Sorry for the wordy description. I really appreciate if you can give me
> some advice.
>
> Thanks a lot.
>
> Yu
>
|
|
| | |
Re: [EOL] How to call constructor when using Native [message #588668 is a reply to message #529630] |
Mon, 26 April 2010 12:41  |
Eclipse User |
|
|
|
This is actually supported natively since 0.8.5. The syntax is:
var x = new Native("java.lang.Short")("1");
I don't think this is mentioned anywhere else beyond
https://bugs.eclipse.org/bugs/show_bug.cgi?id=266331 though :) I'll
update the book shortly.
Cheers,
Dimitris
Steffen Zschaler wrote:
> I guess you may need to use a factory.
>
> Steffen
>
> On 26/04/2010 15:41, Yu Sun wrote:
>> Hi everyone,
>>
>> Is it possible to call java classes with constructor in Native?
>>
>> For example, java.lang.Short can only be instantiated with a parameter
>> like Short(1), Short("1"), but how to realize this in EOL Native?
>>
>> Thanks a lot.
>>
>> Yu
|
|
|
Re: [EOL] How to call constructor when using Native [message #588675 is a reply to message #529666] |
Mon, 26 April 2010 14:10  |
Eclipse User |
|
|
|
Thanks Dimitrios and Steffen. The problem has been solved. I used the new syntax and it works perfect!
However, I do still have one problem regarding Native remaining:
In the initial Eclipse WS, I have a Plugin Project A, which contains a EOL program, and a popup menu event handler to run EOL by Java (I used the EolStandaloneExample).
Then, in the runtime Eclipse WS, I can right-click on the model and run the EOL on the selected model. It works well.
The problem comes when I use Native to call my own classes.
I put my class (e.g., testnative.MyUtility.java) into a plug-in project in the initial Eclipse WS (I refered to http://www.eclipse.org/gmt/epsilon/doc/articles/call-java-fr om-epsilon/), and setup the Tool Extension Point.
Then, in the runtime Eclipse WS, if I create a new EOL in the runtime WS, and use Native('testnative.MyUtility.java'), it works perfect! which means that I setup the extension point correctly.
But, if I run the right-click popup menu option, it will say that "Type MyUtility not found...."
Later, I checked the article again( http://www.eclipse.org/gmt/epsilon/doc/articles/call-java-fr om-epsilon/), and it says "To invoke the tool you have two options: You can either run a new Eclipse instance, or export the plugin and place it in the dropins folder of your installation. Then you can invoke the tool using the following EOL program. "
I thought that since the EOL is in the initial Eclipse WS, maybe I should export the plugin. So I just exported the plugin contain MyUtility.java and put it in the plugin folder of the initial Eclipse. But the right-click running in the runtime Eclipse still cannot find the type. In stead, if you create an EOL in the initial Eclipse WS, it works well, which means that the exported plugin is also setup correctly.
To sum up, I have a plugin containing a java class that I want to use as Nativa in EOL. It has been setup, so that we can use Native to call it either by running a EOL file created in runtime Eclipse, or running a EOL file in initial Eclipse. However, it cannot be found if we trigger the popup menu option in runtime Eclipse (EOL is in the initial Eclipse WS and being called by the event handler).
Sorry for the wordy description. I really appreciate if you can give me some advice.
Thanks a lot.
Yu
|
|
|
Re: [EOL] How to call constructor when using Native [message #588682 is a reply to message #588675] |
Mon, 26 April 2010 15:04  |
Eclipse User |
|
|
|
Hi Yu,
When preparing the context you should also add this line:
context.getNativeTypeDelegates().add(new
ExtensionPointToolNativeTypeDelegate());
(The reason why EolStandaloneExample doesn't contain this line is that
it is meant to be executable outside Eclipse too)
Cheers,
Dimitris
Yu Sun wrote:
> Thanks Dimitrios and Steffen. The problem has been solved. I used the
> new syntax and it works perfect!
>
> However, I do still have one problem regarding Native remaining:
>
> In the initial Eclipse WS, I have a Plugin Project A, which contains a
> EOL program, and a popup menu event handler to run EOL by Java (I used
> the EolStandaloneExample).
>
> Then, in the runtime Eclipse WS, I can right-click on the model and run
> the EOL on the selected model. It works well.
>
> The problem comes when I use Native to call my own classes.
>
> I put my class (e.g., testnative.MyUtility.java) into a plug-in project
> in the initial Eclipse WS (I refered to
> http://www.eclipse.org/gmt/epsilon/doc/articles/call-java-fr om-epsilon/),
> and setup the Tool Extension Point.
> Then, in the runtime Eclipse WS, if I create a new EOL in the runtime
> WS, and use Native('testnative.MyUtility.java'), it works perfect! which
> means that I setup the extension point correctly.
>
> But, if I run the right-click popup menu option, it will say that "Type
> MyUtility not found...."
>
> Later, I checked the article
> again( http://www.eclipse.org/gmt/epsilon/doc/articles/call-java-fr om-epsilon/),
> and it says "To invoke the tool you have two options: You can either run
> a new Eclipse instance, or export the plugin and place it in the
> dropins folder of your installation. Then you can invoke the tool using
> the following EOL program. "
>
> I thought that since the EOL is in the initial Eclipse WS, maybe I
> should export the plugin. So I just exported the plugin contain
> MyUtility.java and put it in the plugin folder of the initial Eclipse.
> But the right-click running in the runtime Eclipse still cannot find the
> type. In stead, if you create an EOL in the initial Eclipse WS, it works
> well, which means that the exported plugin is also setup correctly.
>
> To sum up, I have a plugin containing a java class that I want to use as
> Nativa in EOL. It has been setup, so that we can use Native to call it
> either by running a EOL file created in runtime Eclipse, or running a
> EOL file in initial Eclipse. However, it cannot be found if we trigger
> the popup menu option in runtime Eclipse (EOL is in the initial Eclipse
> WS and being called by the event handler).
>
> Sorry for the wordy description. I really appreciate if you can give me
> some advice.
>
> Thanks a lot.
>
> Yu
>
|
|
| | |
Goto Forum:
Current Time: Wed Jul 23 14:37:15 EDT 2025
Powered by FUDForum. Page generated in 0.23073 seconds
|