use of com.intellij.ui.content.Content 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.Content 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());
}
use of com.intellij.ui.content.Content in project intellij-plugins by JetBrains.
the class KarmaConsoleView method registerConsoleContent.
@NotNull
private Content registerConsoleContent(@NotNull final RunnerLayoutUi ui) {
ui.getOptions().setMinimizeActionEnabled(false);
final Content consoleContent = ui.createContent(ExecutionConsole.CONSOLE_CONTENT_ID, getComponent(), "Test Run", AllIcons.Debugger.Console, getPreferredFocusableComponent());
ui.addContent(consoleContent, 1, PlaceInGrid.bottom, false);
consoleContent.setCloseable(false);
final KarmaRootTestProxyFormatter rootFormatter = new KarmaRootTestProxyFormatter(this, myServer);
if (myServer.areBrowsersReady()) {
KarmaUtil.selectAndFocusIfNotDisposed(ui, consoleContent, false, false);
} else {
myServer.onPortBound(() -> {
KarmaUtil.selectAndFocusIfNotDisposed(ui, consoleContent, false, false);
scheduleBrowserCapturingSuggestion();
});
}
final ProcessAdapter listener = new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
if (myServer.getProcessHandler().isProcessTerminated()) {
rootFormatter.onServerProcessTerminated();
printServerFinishedInfo();
}
rootFormatter.onTestRunProcessTerminated();
}
};
myExecutionSession.getProcessHandler().addProcessListener(listener);
Disposer.register(this, new Disposable() {
@Override
public void dispose() {
myExecutionSession.getProcessHandler().removeProcessListener(listener);
}
});
return consoleContent;
}
use of com.intellij.ui.content.Content in project intellij-plugins by JetBrains.
the class KarmaServerLogComponent method register.
public static void register(@NotNull Project project, @NotNull final KarmaServer server, @NotNull final RunnerLayoutUi ui, boolean requestFocus) {
final ConsoleView console = createConsole(project);
KarmaServerLogComponent component = new KarmaServerLogComponent(console, server);
final Content content = ui.createContent("KarmaServer", component, "Karma Server", null, console.getPreferredFocusableComponent());
content.setCloseable(false);
ui.addContent(content, 4, PlaceInGrid.bottom, false);
if (requestFocus && !server.isPortBound()) {
ui.selectAndFocus(content, false, false);
}
final KarmaServerTerminatedListener terminationCallback = new KarmaServerTerminatedListener() {
@Override
public void onTerminated(int exitCode) {
KarmaUtil.selectAndFocusIfNotDisposed(ui, content, false, false);
}
};
server.onTerminated(terminationCallback);
final ArchivedOutputListener outputListener = new ArchivedOutputListener() {
@Override
public void onOutputAvailable(@NotNull String text, Key outputType, boolean archived) {
ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(outputType);
console.print(text, contentType);
if (!archived && text.startsWith("ERROR ")) {
ApplicationManager.getApplication().invokeLater(() -> content.fireAlert(), ModalityState.any());
}
}
};
server.getProcessOutputManager().addOutputListener(outputListener);
Disposer.register(content, console);
Disposer.register(console, new Disposable() {
@Override
public void dispose() {
server.removeTerminatedListener(terminationCallback);
server.getProcessOutputManager().removeOutputListener(outputListener);
}
});
}
use of com.intellij.ui.content.Content in project intellij-plugins by JetBrains.
the class JstdToolWindowManager method setAvailable.
public void setAvailable(boolean available) {
if (available) {
if (myContentManager.getContentCount() == 0) {
JstdToolWindowSession session = new JstdToolWindowSession(myProject);
myCurrentSession = session;
Content content = myContentManager.getFactory().createContent(session.getComponent(), null, true);
content.setCloseable(true);
myContentManager.addContent(content);
}
} else {
myContentManager.removeAllContents(true);
myCurrentSession = null;
}
myToolWindow.setAvailable(available, null);
}
Aggregations