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

Adapting plugin to assign hotkey for the "scroll from source" action in the Unity Explorer #375

Closed
SugoiDev opened this issue Feb 25, 2018 · 4 comments
Assignees

Comments

@SugoiDev
Copy link

I use this plugin to assign a keyboard hotkey to the "scroll from source" action. It works fine with the normal solution explorer, but not with the Unity Explorer.

It's a very small plugin and the relevant part of the code for the selection is this

ProjectViewImpl projectView = (ProjectViewImpl) ProjectView.getInstance(myProject);
AbstractProjectViewPane currentProjectViewPane = projectView.getCurrentProjectViewPane();
if (currentProjectViewPane != null) {
    SelectInTarget target = currentProjectViewPane.createSelectInTarget();
    if (target != null && target.canSelect(selectInContext)) {
        target.selectIn(selectInContext, false);
    }
}

I want to implement support for the Unity Explorer in this plugin.
For that, I have a few questions:

  1. How to query to determine which explorer is currently being used?
  2. How to get the AbstractProjectViewPane that represents the Unity Explorer? I thought getCurrentProjectViewPane would already work for that, but it returns the normal explorer even when the Unity Explorer is being used.

Alternatively, is there a method to get a AbstractProjectViewPane that respects the Unity Explorer and would work uniformly with both explorer views, depending on which one is visible?

Thanks for reading.

@xtmq
Copy link
Contributor

xtmq commented Mar 14, 2018

Hmm this code actually should work. At least with FileSelectInContext.
We have UnityExplorerSelectInTarget class, you can take a look.

@SugoiDev
Copy link
Author

In the latest nightly, the behavior changed: it now only works in the Unity Explorer, and will throw errors if the normal solution explorer is visible instead.

For anyone curious, below is the exception that is thrown.
I'll close this issue now, since it is working with the Unity solution explorer.

@NotNull method luonq/MySelectInContext.getFileEditorProvider must not return null
java.lang.IllegalStateException: @NotNull method luonq/MySelectInContext.getFileEditorProvider must not return null
	at luonq.MySelectInContext.getFileEditorProvider(MySelectInContext.java:45)
	at com.jetbrains.rider.projectView.solutionExplorer.SolutionExplorerSelectInTarget.selectIn(SolutionExplorerSelectInTarget.kt:46)
	at luonq.ScrollFromSource.scrollFromFile(ScrollFromSource.java:52)
	at luonq.ScrollFromSource.selectElementAtCaret(ScrollFromSource.java:41)
	at luonq.ScrollFromSource.actionPerformed(ScrollFromSource.java:33)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:220)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:237)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:618)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$processAction$2(IdeKeyEventDispatcher.java:667)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:666)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:521)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:476)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:213)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:738)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:434)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

@SugoiDev
Copy link
Author

Just removed the @NotNull attribute and it compiled and is now properly working with both solution explorer views.

If anyone is interested, I attached a working build on the original repository here: luonanqin/intellij-idea-plugins/issues/10

@xtmq
Copy link
Contributor

xtmq commented Mar 14, 2018

Ok thanks for information =)

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

No branches or pull requests

2 participants