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 #1690001] Fri, 31 October 2014 14:49 Go to next message
Chris Gage is currently offline Chris GageFriend
Messages: 27
Registered: July 2009
Junior 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. 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.

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
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1690004 is a reply to message #1690001] Mon, 03 November 2014 19:44 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 250
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 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
Re: Can I create scripts that I can run inside the Eclipse Editor? [message #1690028 is a reply to message #1690004] Tue, 24 February 2015 14:19 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 #1690029 is a reply to message #1690028] Tue, 24 February 2015 17:18 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 250
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 #1690031 is a reply to message #1690029] Tue, 24 February 2015 21:38 Go to previous 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 :)

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 ?
Previous Topic:Scripting mode with EASE and Luna
Next Topic:EASE and Application e4
Goto Forum:
  


Current Time: Tue Oct 08 18:44:40 GMT 2024

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

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

Back to the top