use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class AbstractExternalSystemToolWindowFactory method createToolWindowContent.
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
toolWindow.setTitle(myExternalSystemId.getReadableName());
ContentManager contentManager = toolWindow.getContentManager();
final ExternalProjectsViewImpl projectsView = new ExternalProjectsViewImpl(project, (ToolWindowEx) toolWindow, myExternalSystemId);
ExternalProjectsManager.getInstance(project).registerView(projectsView);
ContentImpl tasksContent = new ContentImpl(projectsView, ExternalSystemBundle.message("tool.window.title.projects"), true);
contentManager.addContent(tasksContent);
}
use of com.intellij.ui.content.ContentManager 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.ui.content.ContentManager in project intellij-community by JetBrains.
the class TabNavigationActionBase method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
DataContext dataContext = event.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
presentation.setEnabled(false);
if (project == null || project.isDisposed()) {
return;
}
final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
if (windowManager.isEditorComponentActive()) {
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
if (currentWindow == null) {
editorManager.getCurrentWindow();
}
if (currentWindow != null) {
final VirtualFile[] files = currentWindow.getFiles();
presentation.setEnabled(files.length > 1);
}
return;
}
ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class EventLogToolWindowFactory method createContent.
static void createContent(Project project, ToolWindow toolWindow, EventLogConsole console, String title) {
// update default Event Log tab title
ContentManager contentManager = toolWindow.getContentManager();
Content generalContent = contentManager.getContent(0);
if (generalContent != null && contentManager.getContentCount() == 1) {
generalContent.setDisplayName("General");
}
final Editor editor = console.getConsoleEditor();
JPanel editorPanel = new JPanel(new AbstractLayoutManager() {
private int getOffset() {
return JBUI.scale(4);
}
@Override
public Dimension preferredLayoutSize(Container parent) {
Dimension size = parent.getComponent(0).getPreferredSize();
return new Dimension(size.width + getOffset(), size.height);
}
@Override
public void layoutContainer(Container parent) {
int offset = getOffset();
parent.getComponent(0).setBounds(offset, 0, parent.getWidth() - offset, parent.getHeight());
}
}) {
@Override
public Color getBackground() {
return ((EditorEx) editor).getBackgroundColor();
}
};
editorPanel.add(editor.getComponent());
SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
@Override
public Object getData(@NonNls String dataId) {
return PlatformDataKeys.HELP_ID.is(dataId) ? EventLog.HELP_ID : super.getData(dataId);
}
};
panel.setContent(editorPanel);
panel.addAncestorListener(new LogShownTracker(project));
ActionToolbar toolbar = createToolbar(project, editor, console);
toolbar.setTargetComponent(editor.getContentComponent());
panel.setToolbar(toolbar.getComponent());
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
contentManager.addContent(content);
contentManager.setSelectedContent(content);
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class TabbedContentImpl method split.
@Override
public void split() {
List<Pair<String, JComponent>> copy = new ArrayList<Pair<String, JComponent>>(myTabs);
int selectedTab = ContentUtilEx.getSelectedTab(this);
ContentManager manager = getManager();
String prefix = getTitlePrefix();
manager.removeContent(this, false);
PropertiesComponent.getInstance().setValue(SPLIT_PROPERTY_PREFIX + prefix, Boolean.TRUE.toString());
for (int i = 0; i < copy.size(); i++) {
final boolean select = i == selectedTab;
final JComponent component = copy.get(i).second;
final String tabName = copy.get(i).first;
ContentUtilEx.addTabbedContent(manager, component, prefix, tabName, select);
}
Disposer.dispose(this);
}
Aggregations