Ant-Grand / GrandUI

Graphical Representation of ANt Dependencies (GUI version)
https://ant-grand.github.io/Grand/grand.html
Other
28 stars 8 forks source link

Cannot export image, exception java.lang.StringIndexOutOfBoundsException: String index out of range: -1 #18

Closed nghinv closed 4 years ago

nghinv commented 4 years ago

Hello, I am using grand-ui v.0.8.6 in ubuntu. The grand started by command line: ./grand-ui-0.8.6/grand-ui

The ant script visualization works well, but while I cannot export image using "Export Graph as an image". Exception in the console: {code} Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in doPackageAddonsWarFile Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in doEbxAddonsPackageUpdate Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in doEbxAddonsPackageUpdate Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in doEbxAddonsPackageUpdate Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in doEbxAddonsPackageUpdate Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in confirmDownloadLGPLFromTibco Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in confirmDownloadLGPLFromTibco Dec 05, 2019 4:05:20 PM net.ggtools.grand.ant.LinkFinderVisitor info INFO: Processing antcall target in doRepackageTestsWAR Dec 05, 2019 4:05:21 PM net.ggtools.grand.ui.graph.GraphController info INFO: Opening graph displayer Dec 05, 2019 4:05:21 PM net.ggtools.grand.ui.graph.GraphController info INFO: Graph loaded & rendered java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1927) at org.eclipse.swt.widgets.FileDialog.presetChooserDialog(FileDialog.java:437) at org.eclipse.swt.widgets.FileDialog.openChooserDialog(FileDialog.java:339) at org.eclipse.swt.widgets.FileDialog.open(FileDialog.java:305) at net.ggtools.grand.ui.actions.ExportGraphAction.run(ExportGraphAction.java:92) at org.eclipse.jface.action.Action.runWithEvent(Action.java:476) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:568) at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:400) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5797) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1374) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5051) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4583) at org.eclipse.jface.window.Window.runEventLoop(Window.java:821) at org.eclipse.jface.window.Window.open(Window.java:797) at net.ggtools.grand.ui.Application.run(Application.java:364) at net.ggtools.grand.ui.Application.main(Application.java:162) {code}

Could you please give me some advice?

thanks, Nghi

nghinv commented 4 years ago

Java version: java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

twogee commented 4 years ago

Hello Nghi,

by the looks of it, there is a problem with interaction between SWT and GTK.

In the history of FileDialog I see recent changes related to switch from GTK 2 to 3 (which add about 50 lines of code, so the exception happens in a different place in presetChooserDialog(), if you try to compare with the latest version of code) just after the Eclipse 4.9 release which is used by GrandUI. The problematic code is

                int separatorIndex = extFilter.lastIndexOf (FILE_EXTENSION_SEPARATOR);
                String extension = extFilter.substring (separatorIndex);

where extFilter is extracted from a string returned by a call to GTK.

A corresponding change of GTK in JDK is JEP 283, backported to Java 8 and released by Oracle as u231. I am not sure if OpenJDK follows Oracle feature by feature. Could you please check which versions of GTK are available in your Ubuntu setup? I will investigate the issue more throughly during the weekend and having that bit of knowledge available would surely help.

nghinv commented 4 years ago

Hi, The problem still persists on java 1.8.0_231-b11

java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1927) at org.eclipse.swt.widgets.FileDialog.presetChooserDialog(FileDialog.java:437) at org.eclipse.swt.widgets.FileDialog.openChooserDialog(FileDialog.java:339) at org.eclipse.swt.widgets.FileDialog.open(FileDialog.java:305) at net.ggtools.grand.ui.actions.ExportGraphAction.run(ExportGraphAction.java:92) at org.eclipse.jface.action.Action.runWithEvent(Action.java:476) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:568) at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:400) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5797) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1374) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5051) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4583) at org.eclipse.jface.window.Window.runEventLoop(Window.java:821) at org.eclipse.jface.window.Window.open(Window.java:797) at net.ggtools.grand.ui.Application.run(Application.java:364) at net.ggtools.grand.ui.Application.main(Application.java:162) ^C /tmp$ java -version java version "1.8.0_231" Java(TM) SE Runtime Environment (build 1.8.0_231-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode) Please check! thanks, Nghi

twogee commented 4 years ago

It is an interplay between SWT and GTK installed in Ubuntu, really; something goes wrong with filename filter selection. Since similar bug reports are scarce, and Ubuntu seems to be using GTK LTS 3.22 for a few years, I will try to open an issue with SWT developers and see what is the best solution here.

twogee commented 4 years ago

It turns out that ImageSaver was not following the SWT specs 😊 I'll try to release a 0.9 before Christmas.

nghinv commented 4 years ago

thanks for your effort!

twogee commented 4 years ago

The release is done (#20)

nghinv commented 4 years ago

It works for me now. thanks a lot!