use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class TodoView method initToolWindow.
public void initToolWindow(@NotNull ToolWindow toolWindow) {
// Create panels
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
Content allTodosContent = contentFactory.createContent(null, IdeBundle.message("title.project"), false);
myAllTodos = new TodoPanel(myProject, state.all, false, allTodosContent) {
@Override
protected TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
AllTodosTreeBuilder builder = createAllTodoBuilder(tree, treeModel, project);
builder.init();
return builder;
}
};
allTodosContent.setComponent(myAllTodos);
Disposer.register(this, myAllTodos);
Content currentFileTodosContent = contentFactory.createContent(null, IdeBundle.message("title.todo.current.file"), false);
CurrentFileTodosPanel currentFileTodos = new CurrentFileTodosPanel(myProject, state.current, currentFileTodosContent) {
@Override
protected TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
CurrentFileTodosTreeBuilder builder = new CurrentFileTodosTreeBuilder(tree, treeModel, project);
builder.init();
return builder;
}
};
Disposer.register(this, currentFileTodos);
currentFileTodosContent.setComponent(currentFileTodos);
myChangeListTodosContent = contentFactory.createContent(null, IdeBundle.message("changelist.todo.title", ChangeListManager.getInstance(myProject).getDefaultChangeList().getName()), false);
ChangeListTodosPanel changeListTodos = new ChangeListTodosPanel(myProject, state.current, myChangeListTodosContent) {
@Override
protected TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
ChangeListTodosTreeBuilder builder = new ChangeListTodosTreeBuilder(tree, treeModel, project);
builder.init();
return builder;
}
};
Disposer.register(this, changeListTodos);
myChangeListTodosContent.setComponent(changeListTodos);
Content scopeBasedTodoContent = contentFactory.createContent(null, "Scope Based", false);
ScopeBasedTodosPanel scopeBasedTodos = new ScopeBasedTodosPanel(myProject, state.current, scopeBasedTodoContent);
Disposer.register(this, scopeBasedTodos);
scopeBasedTodoContent.setComponent(scopeBasedTodos);
myContentManager = toolWindow.getContentManager();
myContentManager.addContent(allTodosContent);
myContentManager.addContent(currentFileTodosContent);
myContentManager.addContent(scopeBasedTodoContent);
if (ProjectLevelVcsManager.getInstance(myProject).hasActiveVcss()) {
myVcsListener.myIsVisible = true;
myContentManager.addContent(myChangeListTodosContent);
}
for (Content content : myNotAddedContent) {
myContentManager.addContent(content);
}
myChangeListTodosContent.setCloseable(false);
allTodosContent.setCloseable(false);
currentFileTodosContent.setCloseable(false);
scopeBasedTodoContent.setCloseable(false);
Content content = myContentManager.getContent(state.selectedIndex);
myContentManager.setSelectedContent(content == null ? allTodosContent : content);
myPanels.add(myAllTodos);
myPanels.add(changeListTodos);
myPanels.add(currentFileTodos);
myPanels.add(scopeBasedTodos);
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class TodoView method addCustomTodoView.
public void addCustomTodoView(final TodoTreeBuilderFactory factory, final String title, final TodoPanelSettings settings) {
Content content = ContentFactory.SERVICE.getInstance().createContent(null, title, true);
final ChangeListTodosPanel panel = new ChangeListTodosPanel(myProject, settings, content) {
@Override
protected TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
TodoTreeBuilder todoTreeBuilder = factory.createTreeBuilder(tree, treeModel, project);
todoTreeBuilder.init();
return todoTreeBuilder;
}
};
content.setComponent(panel);
Disposer.register(this, panel);
if (myContentManager == null) {
myNotAddedContent.add(content);
} else {
myContentManager.addContent(content);
}
myPanels.add(panel);
content.setCloseable(true);
content.setDisposer(new Disposable() {
@Override
public void dispose() {
myPanels.remove(panel);
}
});
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class SliceManager method createToolWindow.
public void createToolWindow(boolean dataFlowToThis, @NotNull SliceRootNode rootNode, boolean splitByLeafExpressions, @NotNull String displayName) {
final SliceToolwindowSettings sliceToolwindowSettings = SliceToolwindowSettings.getInstance(myProject);
final ContentManager contentManager = getContentManager(dataFlowToThis);
final Content[] myContent = new Content[1];
ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(dataFlowToThis ? BACK_TOOLWINDOW_ID : FORTH_TOOLWINDOW_ID);
final SlicePanel slicePanel = new SlicePanel(myProject, dataFlowToThis, rootNode, splitByLeafExpressions, toolWindow) {
@Override
protected void close() {
super.close();
contentManager.removeContent(myContent[0], true);
}
@Override
public boolean isAutoScroll() {
return sliceToolwindowSettings.isAutoScroll();
}
@Override
public void setAutoScroll(boolean autoScroll) {
sliceToolwindowSettings.setAutoScroll(autoScroll);
}
@Override
public boolean isPreview() {
return sliceToolwindowSettings.isPreview();
}
@Override
public void setPreview(boolean preview) {
sliceToolwindowSettings.setPreview(preview);
}
};
myContent[0] = contentManager.getFactory().createContent(slicePanel, displayName, true);
contentManager.addContent(myContent[0]);
contentManager.setSelectedContent(myContent[0]);
toolWindow.activate(null);
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class ExecutionHelper method removeContents.
private static void removeContents(@Nullable final Content notToRemove, @NotNull final Project myProject, @NotNull final String tabDisplayName) {
MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
Content[] contents = messageView.getContentManager().getContents();
for (Content content : contents) {
LOG.assertTrue(content != null);
if (content.isPinned())
continue;
if (tabDisplayName.equals(content.getDisplayName()) && content != notToRemove) {
ErrorTreeView listErrorView = (ErrorTreeView) content.getComponent();
if (listErrorView != null) {
if (messageView.getContentManager().removeContent(content, true)) {
content.release();
}
}
}
}
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class ExecutionHelper method openMessagesView.
private static void openMessagesView(@NotNull final ErrorViewPanel errorTreeView, @NotNull final Project myProject, @NotNull final String tabDisplayName) {
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(myProject, () -> {
final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
final Content content = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true);
messageView.getContentManager().addContent(content);
Disposer.register(content, errorTreeView);
messageView.getContentManager().setSelectedContent(content);
removeContents(content, myProject, tabDisplayName);
}, "Open message view", null);
}
Aggregations