scijava / script-editor

Script Editor and Interpreter for SciJava script languages
http://imagej.net/Script_Editor
BSD 2-Clause "Simplified" License
12 stars 11 forks source link

Fix source code and javadoc lookup functions #44

Closed ctrueden closed 4 years ago

ctrueden commented 4 years ago

This fixes the following commands:

imagesc-bot commented 4 years ago

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/help-with-mvn-in-fiji/40834/24

acardona commented 4 years ago

Sorry, merged too early: can't get it to work. This is related to selecting a chunk of text containing the simple name of a class, and then running "Tools / Open help for class..." and having a web browser open and showing the class, right? I've compiled locally and I may have messed up mvn again, because I can't get this functionality to work.

Got error, when running for UnsignedByteType

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Cannot load class: UnsignedByteType
    at org.scijava.util.Types.iae(Types.java:975)
    at org.scijava.util.Types.load(Types.java:234)
    at org.scijava.util.Types.load(Types.java:155)
    at org.scijava.ui.swing.script.TextEditor.openHelp(TextEditor.java:2606)
    at org.scijava.ui.swing.script.TextEditor.actionPerformed(TextEditor.java:1397)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:842)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:886)
ctrueden commented 4 years ago

@acardona Does it work if you select the fully qualified name of the class?

Did it used to work from only the simple name of the class? If so, I can try to figure out how to restore that behavior...

acardona commented 4 years ago

When running for net.imglib2.type.numeric.integer.UnsignedByteType I get:

Opens: https://javadoc.io/static/net.imglib2/imglib2/5.10.1-SNAPSHOT/net/imglib2/type/numeric/integer/UnsignedByteType.html

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>F60EE453DDB991C0</RequestId>
<HostId>
AQMCPs8KmDJKf+E73zwIAR0ZKKxEHlhbzK/tiVJIkQ47sCidrX33XiQ6tMQL3YjXzzIZzUG1Zo8=
</HostId>
</Error>

And yes: this functionality only ever worked for simple class names. Used to open a choose dialog, IIRC, when there were multiple possible class names.

Perhaps a temp replacement would be to open a browser that googles for the class name?

Although what I think could work is to get the root class loader and to systematically search for the class name, so as to get the fully qualified class name, and from there search in scijava javadoc. If not present there, then open a google search for it.

imagejan commented 4 years ago

@acardona wrote:

And yes: this functionality only ever worked for simple class names. Used to open a choose dialog, IIRC, when there were multiple possible class names.

This reminds me of the open issue to restore the Add import functionality:

https://github.com/imagej/imagej-ui-swing/pull/67

In both cases, we need to detect the correct package given just the bare class name.

ctrueden commented 4 years ago

Opens: https://javadoc.io/static/net.imglib2/imglib2/5.10.1-SNAPSHOT/net/imglib2/type/numeric/integer/UnsignedByteType.html

We don't publish SNAPSHOT versions to Maven Central, so javadoc.io cannot serve them. It should work if you use a release version of imglib2.