Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 14:41 Go to next message
Yu Sun is currently offline Yu Sun
Messages: 58
Registered: July 2009
Member
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 #529630 is a reply to message #529615] Mon, 26 April 2010 14:52 Go to previous messageGo to next message
Steffen Zschaler is currently offline Steffen Zschaler
Messages: 228
Registered: July 2009
Senior Member
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 #529666 is a reply to message #529630] Mon, 26 April 2010 16:41 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
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 #529681 is a reply to message #529666] Mon, 26 April 2010 18:10 Go to previous messageGo to next message
Yu Sun is currently offline Yu Sun
Messages: 58
Registered: July 2009
Member
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 19:04 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
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 #529698 is a reply to message #529693] Mon, 26 April 2010 19:38 Go to previous messageGo to next message
Yu Sun is currently offline Yu Sun
Messages: 58
Registered: July 2009
Member
Hi Dimitrios, that totally solved my problem. You really saved a lot of time for me. I just started looking at Eol Source and try to find anything helpful.

Thanks again!

Yu
Re: [EOL] How to call constructor when using Native [message #529700 is a reply to message #529698] Mon, 26 April 2010 19:39 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Glad this helped :)

Cheers,
Dimitris

Yu Sun wrote:
> Hi Dimitrios, that totally solved my problem. You really saved a lot of
> time for me. I just started looking at Eol Source and try to find
> anything helpful.
> Thanks again!
> Yu
Re: [EOL] How to call constructor when using Native [message #588668 is a reply to message #529630] Mon, 26 April 2010 16:41 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
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 18:10 Go to previous message
Yu Sun is currently offline Yu Sun
Messages: 58
Registered: July 2009
Member
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 19:04 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
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 #588694 is a reply to message #529693] Mon, 26 April 2010 19:38 Go to previous message
Yu Sun is currently offline Yu Sun
Messages: 58
Registered: July 2009
Member
Hi Dimitrios, that totally solved my problem. You really saved a lot of time for me. I just started looking at Eol Source and try to find anything helpful.

Thanks again!

Yu
Re: [EOL] How to call constructor when using Native [message #588705 is a reply to message #529698] Mon, 26 April 2010 19:39 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Glad this helped :)

Cheers,
Dimitris

Yu Sun wrote:
> Hi Dimitrios, that totally solved my problem. You really saved a lot of
> time for me. I just started looking at Eol Source and try to find
> anything helpful.
> Thanks again!
> Yu
Previous Topic:[EOL] How to call constructor when using Native
Next Topic:Error message from ETL following Epsilon upgrade
Goto Forum:
  


Current Time: Mon Sep 15 09:46:29 GMT 2014

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

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