use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class OccurenceNavigatorActionBase method getNavigator.
@Nullable
protected OccurenceNavigator getNavigator(DataContext dataContext) {
ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(dataContext, false);
if (contentManager != null) {
Content content = contentManager.getSelectedContent();
if (content == null)
return null;
JComponent component = content.getComponent();
return findNavigator(component);
}
return (OccurenceNavigator) getOccurenceNavigatorFromContext(dataContext);
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class CloseActiveTabAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true);
boolean processed = false;
if (contentManager != null && contentManager.canCloseContents()) {
final Content selectedContent = contentManager.getSelectedContent();
if (selectedContent != null && selectedContent.isCloseable()) {
contentManager.removeContent(selectedContent, true);
processed = true;
}
}
if (!processed && contentManager != null) {
final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent());
final ToolWindow tw = PlatformDataKeys.TOOL_WINDOW.getData(context);
if (tw != null) {
tw.hide(null);
}
}
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class TodoCheckinHandler method showTodo.
private void showTodo(TodoCheckinHandlerWorker worker) {
String title = "For commit (" + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ")";
ServiceManager.getService(myProject, TodoView.class).addCustomTodoView(new TodoTreeBuilderFactory() {
@Override
public TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
return new CustomChangelistTodosTreeBuilder(tree, treeModel, myProject, title, worker.inOneList());
}
}, title, new TodoPanelSettings(myConfiguration.myTodoPanelSettings));
ApplicationManager.getApplication().invokeLater(() -> {
ToolWindowManager manager = ToolWindowManager.getInstance(myProject);
if (manager != null) {
ToolWindow window = manager.getToolWindow("TODO");
if (window != null) {
window.show(() -> {
ContentManager cm = window.getContentManager();
Content[] contents = cm.getContents();
if (contents.length > 0) {
cm.setSelectedContent(contents[contents.length - 1], true);
}
});
}
}
}, ModalityState.NON_MODAL, myProject.getDisposed());
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class VcsLogContentProvider method findAndSelectContent.
public static <U extends AbstractVcsLogUi> boolean findAndSelectContent(@NotNull Project project, @NotNull Class<U> clazz, @NotNull Condition<U> condition) {
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
ContentManager manager = toolWindow.getContentManager();
JComponent component = ContentUtilEx.findContentComponent(manager, c -> {
if (c instanceof VcsLogPanel) {
AbstractVcsLogUi ui = ((VcsLogPanel) c).getUi();
return clazz.isInstance(ui) && condition.value((U) ui);
}
return false;
});
if (component == null)
return false;
if (!toolWindow.isVisible())
toolWindow.activate(null);
return ContentUtilEx.selectContent(manager, component, true);
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class CloseLogTabAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
if (e.getProject() == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
ContentManager contentManager = getContentManager(e.getProject());
if (contentManager == null || getTabbedContent(contentManager) == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
e.getPresentation().setEnabledAndVisible(true);
}
Aggregations