Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Advanced Scripting Environment (EASE) » Can I create scripts that I can run inside the Eclipse Editor?
Can I create scripts that I can run inside the Eclipse Editor? [message #1457640] Fri, 31 October 2014 14:49 Go to next message
Chris Gage is currently offline Chris GageFriend
Messages: 74
Registered: July 2009
Member
I have been waiting and hoping for a Scripting capability in Eclipse since I first started using it in 2001 (IBM WSAD4). I am now retired (from IBM WebSphere development) and my chosen retirement activity is working on many files which are raw OCR text from a bookscanner. These files usually have many errors in them. I use the eclipse Editor to remove as many of these errors as possible before I move the files to MS Word. I do this because I can use real regular expressions to make complex edits -- MS Word's wildcard syntax is a weak subset of regex.

Each of these regex edits has to be typed in again for every file.

I have EASE installed on Luna from the lastest nightly build, and I can create an empty script and run it.
So:

    Does EASE have the ability to let me store these regex edits as scripts and run them inside the editor as if they were part of it?
    Can I interact with, for example, the find/replace dialog from a script?
    Can I capture them from keystrokes, as in MS Word's record macro function?
    Any plans to allow scripts to be written in java? Personally I'd prefer it.
    Help me get started and I'll gladly contribute examples.

Chris Gage
www.ibiblio.org/britishRaj

[Updated on: Fri, 31 October 2014 20:35]

Report message to a moderator

Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1460638 is a reply to message #1457640] Mon, 03 November 2014 19:44 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
Hi Chris,

always glad to see people using the project. Lets see about your questions:
Quote:
Any plans to allow scripts to be written in java? Personally I'd prefer it.

I'll take this one first as it helps answering some of the other questions.
You may already mix Java code with JS. Only drawback: you have to provide FQN eg:

var file = new java.io.File("C:\\")
if (file.exists())
   print("found...")


As JS runs on the JRE currently executing eclipse you may interact with the whole java class library along with any public eclipse API.

Quote:
Does EASE have the ability to let me store these regex edits as scripts and run them inside the editor as if they were part of it?

You may create a script in your workspace (or anywhere on your file system) that contains your regEx, which processes a certain file containing your text data. So you cannot mix script code and your sample data in the same file very well. (In fact you could by quoting your whole data content as a string literal resulting in a huge script file modifying itself, but that's not a real world use case I think.)

Look at the Resources module which allows to read/write files. Mix it with an open dialog (also from the resources module) and add some java code for your regexp parsing.

Quote:
Can I interact with, for example, the find/replace dialog from a script?

Yes, definitely. But you need to look at the find/replace API from eclipse for that. Currently EASE has no convenience methods for that.

Quote:
Can I capture them from keystrokes, as in MS Word's record macro function?


No, not to my knowledge. The script shell view allows to record commands you type into it (use rightmost toolbar button), but this will not capture any keyboard shortcuts or whatever data you provide in dialogs or other views.

Quote:
Help me get started and I'll gladly contribute examples.

There exists an (currently empty) git repository for examples. Feel free to push example scripts there!

come back if you have further questions
Christian

[Updated on: Mon, 03 November 2014 19:45]

Report message to a moderator

Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1632737 is a reply to message #1460638] Tue, 24 February 2015 12:56 Go to previous messageGo to next message
Prabhat Kosuru is currently offline Prabhat KosuruFriend
Messages: 10
Registered: February 2015
Junior Member

var file = new java.io.File("C:\\")
if (file.exists())
print("found...")


This works most of the time and is very nice. The problem arises when sometimes, the Rhino Engine throws up an error when i try to call a method in a class.. an error like -

org.mozilla.javascript.EcmaError: TypeError: Cannot call property getString in object [******]. It is not a function, it is "object".

Am i doing something wrong here ?
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1633087 is a reply to message #1632737] Tue, 24 February 2015 17:18 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
Hi,

could you be a bit more specific on this error?
Are you running exactly the referred script in a loop until it fails?
Are you executing it from a file and the EASE launch target? In the shell?

Generally we do execute tons of scripts each day and I am not aware of the error case you described.
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1633433 is a reply to message #1633087] Tue, 24 February 2015 21:38 Go to previous messageGo to next message
Prabhat Kosuru is currently offline Prabhat KosuruFriend
Messages: 10
Registered: February 2015
Junior Member
Hi Christian,

Sorry for not giving much background. Wildly hoped that it was a famous error Smile

Anyway, i created a plugin project (X) in my workspace and i run the plugin along with the rest of the plugins in my target. In the launched eclipse instance, i can access all the public APIs that are in my target using the FQN as mentioned in my/your previous comment in JS.

But when trying to access the APIs (using FQN) of the plugin project (X) that i created, throws up this Ecma error.

Is it because, of the state of the plugin that it might not be active ? How is this project different from the others in target .. all are run in the launched eclipse instance..

or in a larger context, is it necessary that i expose java only via "modules" of EASE ?
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1635252 is a reply to message #1633433] Wed, 25 February 2015 17:58 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
Prabhat Kosuru wrote on Tue, 24 February 2015 21:38
... or in a larger context, is it necessary that i expose java only via "modules" of EASE ?


No definitely not. You may access all public API in your RCP application. And that might be your problem. Are you exporting the package that hosts your class in your manifest.mf file? If not, that package (and all its classes) are not visible to other eclipse plugins.
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1638720 is a reply to message #1635252] Fri, 27 February 2015 09:05 Go to previous messageGo to next message
Prabhat Kosuru is currently offline Prabhat KosuruFriend
Messages: 10
Registered: February 2015
Junior Member
Ah, That works now... i was trying to call an API whose package was not exported. Thanks !

is there also a way in which i can call java which is in a project in the same workspace and not deployed into the running eclipse ? would this be possible ... the java file and package are exposed in the plugin...
i am asking this question solely because of developing in js would be tedious if we have a very complex model and no content assist. Jdt provides a better environment to develop in such a situation.. and then maybe one can hook it up with JS and EASE.
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1639408 is a reply to message #1638720] Fri, 27 February 2015 16:22 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
Interestingly we have such a contribution pending in gerrit.
https://git.eclipse.org/r/#/c/38696/

The contribution is about a 'Java Engine', allowing to write 'scripts' in pure java. I played a little with it and could easily come up with a module for JS, that allowed me to dynamically load classes from your current workspace.

The contribution is currently on hold as we are waiting for the contributor to work on this. Eventually I will drive this further if it stays idle for some more weeks.
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1647567 is a reply to message #1639408] Tue, 03 March 2015 13:53 Go to previous messageGo to next message
Prabhat Kosuru is currently offline Prabhat KosuruFriend
Messages: 10
Registered: February 2015
Junior Member
that would be really cool .. thanks ..
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1690032 is a reply to message #1633433] Wed, 25 February 2015 17:58 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
Prabhat Kosuru wrote on Tue, 24 February 2015 21:38
> ... or in a larger context, is it necessary that i expose java only via "modules" of EASE ?


No definitely not. You may access all public API in your RCP application. And that might be your problem. Are you exporting the package that hosts your class in your manifest.mf file? If not, that package (and all its classes) are not visible to other eclipse plugins.
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1690033 is a reply to message #1635252] Fri, 27 February 2015 09:05 Go to previous messageGo to next message
Prabhat Kosuru is currently offline Prabhat KosuruFriend
Messages: 10
Registered: February 2015
Junior Member
Ah, That works now... i was trying to call an API whose package was not exported. Thanks !

is there also a way in which i can call java which is in a project in the same workspace and not deployed into the running eclipse ? would this be possible ... the java file and package are exposed in the plugin...
i am asking this question solely because of developing in js would be tedious if we have a very complex model and no content assist. Jdt provides a better environment to develop in such a situation.. and then maybe one can hook it up with JS and EASE.
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1690035 is a reply to message #1690033] Fri, 27 February 2015 16:22 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
Interestingly we have such a contribution pending in gerrit.
https://git.eclipse.org/r/#/c/38696/

The contribution is about a 'Java Engine', allowing to write 'scripts' in pure java. I played a little with it and could easily come up with a module for JS, that allowed me to dynamically load classes from your current workspace.

The contribution is currently on hold as we are waiting for the contributor to work on this. Eventually I will drive this further if it stays idle for some more weeks.
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1690039 is a reply to message #1690035] Tue, 03 March 2015 13:53 Go to previous message
Prabhat Kosuru is currently offline Prabhat KosuruFriend
Messages: 10
Registered: February 2015
Junior Member
that would be really cool .. thanks ..
Previous Topic:EASE and Application e4
Next Topic:Rhino resets the class path
Goto Forum:
  


Current Time: Wed Oct 17 16:47:58 GMT 2018

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

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

Back to the top