if(window.editorRules.getEnclosingRuleAtPosition(window.getCaretPosition()) == null) {
XJAlert.display(window.getJavaContainer(), "Export Rule to EPS", "There is no rule at cursor position.");
return;
}
GGraphAbstract graph = window.syntaxDiagramTab.getCurrentGraph();
if(graph == null) {
XJAlert.display(window.getJavaContainer(), "Export Rule to EPS", "There is no graphical visualization.");
return;
}
if(!XJFileChooser.shared().displaySaveDialog(window.getJavaContainer(), "eps", "EPS file", false))
return;
String file = XJFileChooser.shared().getSelectedFilePath();
if(file == null)
return;
try {
GEnginePS engine = new GEnginePS();
GContext context = graph.getContext();
GEngine oldEngine = context.engine;
context.setEngine(engine);
graph.draw();
context.setEngine(oldEngine);
XJUtils.writeStringToFile(engine.getPSText(), file);
} catch (Exception e) {
window.consoleTab.println(e);