use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.
the class ChooseByNameBase method isDescendingFromTemporarilyFocusableToolWindow.
private boolean isDescendingFromTemporarilyFocusableToolWindow(@Nullable Component component) {
if (component == null || myProject == null || myProject.isDisposed())
return false;
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
ToolWindow toolWindow = toolWindowManager.getToolWindow(toolWindowManager.getActiveToolWindowId());
JComponent toolWindowComponent = toolWindow != null ? toolWindow.getComponent() : null;
return toolWindowComponent != null && toolWindowComponent.getClientProperty(TEMPORARILY_FOCUSABLE_COMPONENT_KEY) != null && SwingUtilities.isDescendingFrom(component, toolWindowComponent);
}
use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.
the class CopyHandler method updateSelectionInActiveProjectView.
static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) {
String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
if (id != null) {
ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id);
Content selectedContent = window.getContentManager().getSelectedContent();
if (selectedContent != null) {
JComponent component = selectedContent.getComponent();
if (component instanceof TwoPaneIdeView) {
((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel);
return;
}
}
}
if (ToolWindowId.PROJECT_VIEW.equals(id)) {
ProjectView.getInstance(project).selectPsiElement(newElement, true);
} else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) {
VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile();
FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile);
StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true);
}
}
use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.
the class PsiPackageImplementationHelperImpl method navigate.
@Override
public void navigate(@NotNull final PsiPackage psiPackage, final boolean requestFocus) {
final Project project = psiPackage.getProject();
ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW);
window.activate(null);
window.getActivation().doWhenDone(() -> {
final ProjectView projectView = ProjectView.getInstance(project);
PsiDirectory[] directories = suggestMostAppropriateDirectories(psiPackage);
if (directories.length == 0)
return;
projectView.select(directories[0], directories[0].getVirtualFile(), requestFocus);
});
}
use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.
the class PredefinedSearchScopeProviderImpl method addHierarchyScope.
private static void addHierarchyScope(@NotNull Project project, Collection<SearchScope> result) {
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY);
if (toolWindow == null) {
return;
}
final ContentManager contentManager = toolWindow.getContentManager();
final Content content = contentManager.getSelectedContent();
if (content == null) {
return;
}
final String name = content.getDisplayName();
final JComponent component = content.getComponent();
if (!(component instanceof HierarchyBrowserBase)) {
return;
}
final HierarchyBrowserBase hierarchyBrowserBase = (HierarchyBrowserBase) component;
final PsiElement[] elements = hierarchyBrowserBase.getAvailableElements();
if (elements.length > 0) {
result.add(new LocalSearchScope(elements, "Hierarchy '" + name + "' (visible nodes only)"));
}
}
use of com.intellij.openapi.wm.ToolWindow in project intellij-code-outline by sitano.
the class CodeOutlinePlugin method regForProject.
/**
* Creates a code outline tool window for the given project.
*
* @param project the project to register
*/
private synchronized void regForProject(final Project project) {
final CodeOutlineToolWindow window = new CodeOutlineToolWindow(this, project);
ToolWindowManager twm = ToolWindowManager.getInstance(project);
ToolWindowManagerEx twmEx = (ToolWindowManagerEx) twm;
ToolWindow tw = twm.registerToolWindow(TOOLWINDOW_ID, false, ToolWindowAnchor.RIGHT);
ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
Content content = contentFactory.createContent(window, "", false);
tw.getContentManager().addContent(content);
tw.getContentManager().setSelectedContent(content, false);
twmEx.addToolWindowManagerListener(window.getToolWindowManagerListener());
}
Aggregations