Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix source code and javadoc lookup functions #44

Merged
merged 5 commits into from
Aug 5, 2020
Merged

Conversation

ctrueden
Copy link
Member

@ctrueden ctrueden commented Aug 2, 2020

This fixes the following commands:

  • Tools > Open Help for Class...
  • Tools > Open Help for Class (with frames)...
  • Tools > Open .java file for class...

The common case these days is to open the source code in the browser --
typically on GitHub, but whatever SCM URL the POM lists.
The "http://fiji.sc/Foo.java" shortcut has not worked for many years.
And will not be made to work again, due to security considerations.
Instead, we look in the POM and/or JAR manifest for the given class.
@ctrueden ctrueden requested a review from acardona August 2, 2020 22:09
@imagesc-bot
Copy link

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

Copy link
Collaborator

@acardona acardona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will test right away.

@acardona acardona merged commit 91fadb6 into master Aug 5, 2020
@acardona
Copy link
Collaborator

acardona commented Aug 5, 2020

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
Copy link
Member Author

ctrueden commented Aug 5, 2020

@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...

@ctrueden ctrueden deleted the fix-tools-commands branch August 5, 2020 23:48
@acardona
Copy link
Collaborator

acardona commented Aug 6, 2020

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
Copy link
Member

imagejan commented Aug 6, 2020

@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:

imagej/imagej-ui-swing#67

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

@ctrueden
Copy link
Member Author

ctrueden commented Sep 5, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants