use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class BrowseHierarchyActionBase method createAndAddToPanel.
@NotNull
public static HierarchyBrowser createAndAddToPanel(@NotNull Project project, @NotNull final HierarchyProvider provider, @NotNull PsiElement target) {
HierarchyBrowser hierarchyBrowser = provider.createHierarchyBrowser(target);
final Content content;
HierarchyBrowserManager hierarchyBrowserManager = HierarchyBrowserManager.getInstance(project);
final ContentManager contentManager = hierarchyBrowserManager.getContentManager();
final Content selectedContent = contentManager.getSelectedContent();
if (selectedContent != null && !selectedContent.isPinned()) {
content = selectedContent;
final Component component = content.getComponent();
if (component instanceof Disposable) {
Disposer.dispose((Disposable) component);
}
content.setComponent(hierarchyBrowser.getComponent());
} else {
content = ContentFactory.SERVICE.getInstance().createContent(hierarchyBrowser.getComponent(), null, true);
contentManager.addContent(content);
}
contentManager.setSelectedContent(content);
hierarchyBrowser.setContent(content);
final Runnable runnable = () -> {
if (hierarchyBrowser instanceof HierarchyBrowserBase && ((HierarchyBrowserBase) hierarchyBrowser).isDisposed()) {
return;
}
provider.browserActivated(hierarchyBrowser);
};
ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY).activate(runnable);
return hierarchyBrowser;
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class DependenciesHandlerBase method onSuccess.
private void onSuccess(final List<DependenciesBuilder> builders) {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> {
if (shouldShowDependenciesPanel(builders)) {
final String displayName = getPanelDisplayName(builders);
DependenciesPanel panel = new DependenciesPanel(myProject, builders, myExcluded);
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, false);
content.setDisposer(panel);
panel.setContent(content);
DependenciesToolWindow.getInstance(myProject).addContent(content);
}
});
}
use of com.intellij.ui.content.Content 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.ui.content.Content in project intellij-community by JetBrains.
the class DocumentationManager method showJavaDocInfoAtToolWindow.
public void showJavaDocInfoAtToolWindow(@NotNull PsiElement element, @NotNull PsiElement original) {
final Content content = recreateToolWindow(element, original);
if (content == null)
return;
fetchDocInfo(getDefaultCollector(element, original), (DocumentationComponent) content.getComponent(), true);
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class DocumentationManager method doShowJavaDocInfo.
private void doShowJavaDocInfo(@NotNull final PsiElement element, boolean requestFocus, PopupUpdateProcessor updateProcessor, final PsiElement originalElement, @Nullable final Runnable closeCallback) {
Project project = getProject(element);
if (!project.isOpen())
return;
storeOriginalElement(project, originalElement, element);
myPreviouslyFocused = WindowManagerEx.getInstanceEx().getFocusedComponent(project);
JBPopup _oldHint = getDocInfoHint();
if (PreviewManager.SERVICE.preview(myProject, DocumentationPreviewPanelProvider.ID, Couple.of(element, originalElement), requestFocus) != null) {
return;
}
if (myToolWindow == null && PropertiesComponent.getInstance().isTrueValue(SHOW_DOCUMENTATION_IN_TOOL_WINDOW)) {
createToolWindow(element, originalElement);
} else if (myToolWindow != null) {
Content content = myToolWindow.getContentManager().getSelectedContent();
if (content != null) {
DocumentationComponent component = (DocumentationComponent) content.getComponent();
boolean sameElement = element.getManager().areElementsEquivalent(component.getElement(), element);
if (sameElement) {
JComponent preferredFocusableComponent = content.getPreferredFocusableComponent();
// focus toolwindow on the second actionPerformed
boolean focus = requestFocus || CommandProcessor.getInstance().getCurrentCommand() != null;
if (preferredFocusableComponent != null && focus) {
IdeFocusManager.getInstance(myProject).requestFocus(preferredFocusableComponent, true);
}
}
if (!sameElement || !component.isUpToDate()) {
content.setDisplayName(getTitle(element, true));
fetchDocInfo(getDefaultCollector(element, originalElement), component, true);
}
}
if (!myToolWindow.isVisible()) {
myToolWindow.show(null);
}
} else if (_oldHint != null && _oldHint.isVisible() && _oldHint instanceof AbstractPopup) {
DocumentationComponent oldComponent = (DocumentationComponent) ((AbstractPopup) _oldHint).getComponent();
fetchDocInfo(getDefaultCollector(element, originalElement), oldComponent);
} else {
showInPopup(element, requestFocus, updateProcessor, originalElement, closeCallback);
}
}
Aggregations