How to run your script on Astah version – on Java 8

Astah

The Script Plug-in is the easiest way to add customized features to Astah for your specific needs using API.
Astah moved its Java Runtime from Java7 to Java8 since version 7.0 and due to its update, the script you were using in Astah 6.9 or earlier will no longer function in version 7.0 or later. You need a small tweak to make it run.

How to update your existing Script

1. importPackage

Use one of the following notations ;

Before

importPackage(com.change_vision.jude.api.inf.editor);
//use the classes in the package

(A) Use JavaImporter

with(new JavaImporter(com.change_vision.jude.api.inf.editor)) {
    //use the classes in the package
}

(B) Load “nashorn:mozilla_compat.js”

load("nashorn:mozilla_compat.js");
importPackage(com.change_vision.jude.api.inf.editor);
//use the classes in the package

(C) Use Java.type

var TransactionManager = Java.type("com.change_vision.jude.api.inf.editor.TransactionManager");
//use the class

2. println

Before

println("Astah"); 

(A) Use print instead of println

print("Astah");

(B) Add println=print;

println=print;
println("Astah");

3. .class

Before

var classes = astah.findElements(IClass);

Add .class


var classes = astah.findElements(IClass.class);

Reference

Please refer to the following website for more details.
https://wiki.openjdk.java.net/display/Nashorn/Rhino+Migration+Guide

Cheers,
SJ

Advertisements

One thought on “How to run your script on Astah version – on Java 8

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s