本文整理汇总了Java中com.intellij.ide.SelectInContext类的典型用法代码示例。如果您正苦于以下问题:Java SelectInContext类的具体用法?Java SelectInContext怎么用?Java SelectInContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectInContext类属于com.intellij.ide包,在下文中一共展示了SelectInContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCreateEditorContext
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
private static SelectInContext doCreateEditorContext(Project project, FileEditor editor, @Nullable DataContext dataContext) {
if (project == null || editor == null) {
return null;
}
VirtualFile file = FileEditorManagerEx.getInstanceEx(project).getFile(editor);
if (file == null) {
file = dataContext == null ? null : CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file == null) {
return null;
}
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile == null) {
return null;
}
if (editor instanceof TextEditor) {
return new TextEditorContext((TextEditor)editor, psiFile);
}
else {
StructureViewBuilder builder = editor.getStructureViewBuilder();
StructureView structureView = builder != null ? builder.createStructureView(editor, project) : null;
Object selectorInFile = structureView != null ? structureView.getTreeModel().getCurrentEditorElement() : null;
if (structureView != null) Disposer.dispose(structureView);
return new SimpleSelectInContext(psiFile, ObjectUtils.chooseNotNull(selectorInFile, psiFile));
}
}
示例2: getContextPsiFile
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Nullable
protected PsiFileSystemItem getContextPsiFile(@NotNull SelectInContext context) {
VirtualFile virtualFile = context.getVirtualFile();
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
final PsiFileSystemItem psiFile;
if (document != null) {
psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
}
else if (context.getSelectorInFile() instanceof PsiFile) {
psiFile = (PsiFile)context.getSelectorInFile();
}
else if (virtualFile.isDirectory()) {
psiFile = PsiManager.getInstance(myProject).findDirectory(virtualFile);
}
else {
psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
}
return psiFile;
}
示例3: selectIn
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
public final void selectIn(@NotNull SelectInContext context, boolean requestFocus) {
VirtualFile file = context.getVirtualFile();
Object selector = context.getSelectorInFile();
if (selector == null) {
PsiManager psiManager = PsiManager.getInstance(myProject);
selector = file.isDirectory() ? psiManager.findDirectory(file) : psiManager.findFile(file);
}
if (selector instanceof PsiElement) {
select(((PsiElement)selector).getOriginalElement(), requestFocus);
}
else {
select(selector, file, requestFocus);
}
}
示例4: selectIn
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
public void selectIn(SelectInContext context, final boolean requestFocus) {
final Project project = context.getProject();
final VirtualFile file = context.getVirtualFile();
final MvcFramework framework = MvcFramework.getInstance(ModuleUtilCore.findModuleForFile(file, project));
if (framework == null) {
return;
}
final Runnable select = new Runnable() {
@Override
public void run() {
final MvcProjectViewPane view = MvcProjectViewPane.getView(project, framework);
if (view != null) {
view.selectFile(file, requestFocus);
}
}
};
if (requestFocus) {
ToolWindowManager.getInstance(project).getToolWindow(MvcToolWindowDescriptor.getToolWindowId(framework)).activate(select, false);
} else {
select.run();
}
}
示例5: doCreateEditorContext
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
private static SelectInContext doCreateEditorContext(Project project, FileEditor editor, @Nullable DataContext dataContext) {
if (project == null || editor == null) {
return null;
}
VirtualFile file = FileEditorManagerEx.getInstanceEx(project).getFile(editor);
if (file == null) {
file = dataContext == null ? null : PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file == null) {
return null;
}
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile == null) {
return null;
}
if (editor instanceof TextEditor) {
return new TextEditorContext((TextEditor)editor, psiFile);
}
else {
return new SimpleSelectInContext(psiFile);
}
}
示例6: canSelect
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
public final boolean canSelect(SelectInContext context) {
if (myProject.isDisposed()) return false;
VirtualFile virtualFile = context.getVirtualFile();
if (!virtualFile.isValid()) return false;
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
final PsiFileSystemItem psiFile;
if (document != null) {
psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
}
else if (context.getSelectorInFile() instanceof PsiFile) {
psiFile = (PsiFile)context.getSelectorInFile();
}
else if (virtualFile.isDirectory()) {
psiFile = PsiManager.getInstance(myProject).findDirectory(virtualFile);
}
else {
psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
}
return psiFile != null && canSelect(psiFile) || canWorkWithCustomObjects();
}
示例7: canSelect
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
public boolean canSelect(SelectInContext context) {
Object selectorInFile = context.getSelectorInFile();
if (!(selectorInFile instanceof PsiElement)) {
return false;
}
PsiFile file = ((PsiElement)selectorInFile).getContainingFile();
if (file == null || file.getVirtualFile() == null) {
return false;
}
Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
currentName = XmlBundle.message("browser.select.in.default.name");
if (browserUrlProvider == null) {
return HtmlUtil.isHtmlFile(file) && !(file.getVirtualFile() instanceof LightVirtualFile);
}
else {
String customText = browserUrlProvider.first.getOpenInBrowserActionText(file);
if (customText != null) {
currentName = customText;
}
}
return true;
}
示例8: selectElementFromEditor
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
protected void selectElementFromEditor(@Nonnull FileEditor editor) {
final VirtualFile file = FileEditorManagerEx.getInstanceEx(myProject).getFile(editor);
if (file != null) {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile != null) {
final SelectInTarget target = mySelectInTarget;
if (target != null) {
final SelectInContext selectInContext = SelectInContextImpl.createEditorContext(myProject, editor);
if (target.canSelect(selectInContext)) {
target.selectIn(selectInContext, false);
}
}
}
}
}
示例9: createEditorContext
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
public static SelectInContext createEditorContext(Project project, FileEditor editor) {
if (project == null || editor == null) {
return null;
}
VirtualFile file = FileEditorManagerEx.getInstanceEx(project).getFile(editor);
if (file == null) {
return null;
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile == null) {
return null;
}
if (editor instanceof TextEditor) {
return new TextEditorContext((TextEditor)editor, psiFile);
}
else {
return new SimpleSelectInContext(psiFile);
}
}
示例10: selectIn
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
final FileEditor fileEditor = context.getFileEditorProvider().get();
ToolWindowManager windowManager=ToolWindowManager.getInstance(context.getProject());
final Runnable runnable = new Runnable() {
@Override
public void run() {
StructureViewFactoryEx.getInstanceEx(myProject).runWhenInitialized(new Runnable() {
@Override
public void run() {
final StructureViewWrapper structureView = getStructureViewWrapper();
structureView.selectCurrentElement(fileEditor, context.getVirtualFile(), requestFocus);
}
});
}
};
if (requestFocus) {
windowManager.getToolWindow(ToolWindowId.STRUCTURE_VIEW).activate(runnable);
}
else {
runnable.run();
}
}
示例11: getContextPsiFile
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Nullable
protected PsiFileSystemItem getContextPsiFile(@Nonnull SelectInContext context) {
VirtualFile virtualFile = context.getVirtualFile();
PsiFileSystemItem psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
if (psiFile != null) {
return psiFile;
}
if (context.getSelectorInFile() instanceof PsiFile) {
return (PsiFile)context.getSelectorInFile();
}
if (virtualFile.isDirectory()) {
return PsiManager.getInstance(myProject).findDirectory(virtualFile);
}
return null;
}
示例12: selectIn
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
public final void selectIn(@Nonnull SelectInContext context, boolean requestFocus) {
VirtualFile file = context.getVirtualFile();
Object selector = context.getSelectorInFile();
if (selector == null) {
PsiManager psiManager = PsiManager.getInstance(myProject);
selector = file.isDirectory() ? psiManager.findDirectory(file) : psiManager.findFile(file);
}
if (selector instanceof PsiElement) {
select(((PsiElement)selector).getOriginalElement(), requestFocus);
}
else {
select(selector, file, requestFocus);
}
}
示例13: canSelect
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
@Override
public boolean canSelect(SelectInContext context)
{
Object selectorInFile = context.getSelectorInFile();
OpenInBrowserRequest request = selectorInFile instanceof PsiElement ? OpenInBrowserRequest.create((PsiElement) selectorInFile) : null;
if(request == null)
{
return false;
}
WebBrowserUrlProvider urlProvider = WebBrowserServiceImpl.getProvider(request);
if(urlProvider == null)
{
VirtualFile virtualFile = request.getVirtualFile();
return virtualFile instanceof HttpVirtualFile || (HtmlUtil.isHtmlFile(request.getFile()) && !(virtualFile instanceof LightVirtualFile));
}
return true;
}
示例14: selectIn
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
public void selectIn(SelectInContext context, boolean requestFocus)
{
Container container = this.container();
Project project = context.getProject();
VirtualFile file = context.getVirtualFile();
container.runner().runForFile(project, file, this.container().openInBrowserHandler());
}
示例15: selectIn
import com.intellij.ide.SelectInContext; //导入依赖的package包/类
public void selectIn(final SelectInContext context, final boolean requestFocus) {
final VirtualFile file = context.getVirtualFile();
Runnable runnable = new Runnable() {
public void run() {
ChangesViewContentManager.getInstance(myProject).selectContent(ChangesViewContentManager.LOCAL_CHANGES);
ChangesViewManager.getInstance(myProject).selectFile(file);
}
};
if (requestFocus) {
ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID).activate(runnable);
}
else {
runnable.run();
}
}