Created
July 6, 2009 05:25
-
-
Save masanobuimai/141273 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.googlecode.intellimars.quicklook; | |
import com.intellij.codeInsight.hint.ImplementationViewComponent; | |
import com.intellij.openapi.actionSystem.AnAction; | |
import com.intellij.openapi.actionSystem.AnActionEvent; | |
import com.intellij.openapi.actionSystem.LangDataKeys; | |
import com.intellij.openapi.actionSystem.PlatformDataKeys; | |
import com.intellij.openapi.actionSystem.impl.ActionMenuItem; | |
import com.intellij.openapi.diagnostic.Logger; | |
import com.intellij.openapi.project.Project; | |
import com.intellij.openapi.ui.popup.ComponentPopupBuilder; | |
import com.intellij.openapi.ui.popup.JBPopup; | |
import com.intellij.openapi.ui.popup.JBPopupFactory; | |
import com.intellij.openapi.vfs.VirtualFile; | |
import com.intellij.psi.PsiElement; | |
import com.intellij.ui.awt.RelativePoint; | |
public class QuickLookAction extends AnAction { | |
Logger logger = Logger.getInstance(QuickLookAction.class.getSimpleName()); | |
public void actionPerformed(AnActionEvent e) { | |
VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); | |
if (file == null || file.isDirectory()) return; | |
Project project = e.getData(PlatformDataKeys.PROJECT); | |
PsiElement psiElement = e.getData(LangDataKeys.PSI_ELEMENT); | |
logger.debug("psiElement = " + psiElement); | |
if (psiElement == null) return; | |
ImplementationViewComponent viewComponent = new ImplementationViewComponent(new PsiElement[] { psiElement }, 0); | |
JBPopupFactory factory = JBPopupFactory.getInstance(); | |
ComponentPopupBuilder popupBuilder = factory.createComponentPopupBuilder(viewComponent, viewComponent.getPrefferedFocusableComponent()); | |
popupBuilder.setProject(project); | |
popupBuilder.setResizable(true); | |
popupBuilder.setMovable(true); | |
popupBuilder.setTitle("HINT"); | |
JBPopup popup = popupBuilder.createPopup(); | |
popup.showInBestPositionFor(e.getDataContext()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<idea-plugin version="2"> | |
<name>Plugin name here</name> | |
<description>short description of the plugin</description> | |
<version>1.0</version> | |
<vendor>YourCompany</vendor> | |
<idea-version since-build="8000"/> | |
<application-components> | |
<!-- Add your application components here --> | |
</application-components> | |
<project-components> | |
<!-- Add your project components here --> | |
</project-components> | |
<actions> | |
<!-- Add your actions here --> | |
<action id="intellimars.QuickLookAction" class="com.googlecode.intellimars.quicklook.QuickLookAction" text="quick look"> | |
<add-to-group group-id="ProjectViewPopupMenu" anchor="after" relative-to-action="OpenInBrowser"/> | |
<keyboard-shortcut keymap="$default" first-keystroke="ctrl 1" /> | |
</action> | |
</actions> | |
<extensions defaultExtensionNs="com.intellij"> | |
<!-- Add your extensions here --> | |
</extensions> | |
</idea-plugin> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment