Search in sources :

Example 26 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class RunDashboardManagerImpl method getRunConfigurations.

@Override
public List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> getRunConfigurations() {
    List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> result = new ArrayList<>();
    List<RunnerAndConfigurationSettings> configurations = RunManager.getInstance(myProject).getAllSettings().stream().filter(runConfiguration -> RunDashboardContributor.isShowInDashboard(runConfiguration.getType())).collect(Collectors.toList());
    //noinspection ConstantConditions ???
    ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(myProject);
    configurations.forEach(configurationSettings -> {
        List<RunContentDescriptor> descriptors = executionManager.getDescriptors(settings -> Comparing.equal(settings.getConfiguration(), configurationSettings.getConfiguration()));
        if (descriptors.isEmpty()) {
            result.add(Pair.create(configurationSettings, null));
        } else {
            descriptors.forEach(descriptor -> result.add(Pair.create(configurationSettings, descriptor)));
        }
    });
    // It is possible that run configuration was deleted, but there is running content descriptor for such run configuration.
    // It should be shown in he dashboard tree.
    List<RunConfiguration> storedConfigurations = configurations.stream().map(RunnerAndConfigurationSettings::getConfiguration).collect(Collectors.toList());
    List<RunContentDescriptor> notStoredDescriptors = executionManager.getRunningDescriptors(settings -> {
        RunConfiguration configuration = settings.getConfiguration();
        return RunDashboardContributor.isShowInDashboard(settings.getType()) && !storedConfigurations.contains(configuration);
    });
    notStoredDescriptors.forEach(descriptor -> {
        Set<RunnerAndConfigurationSettings> settings = executionManager.getConfigurations(descriptor);
        settings.forEach(setting -> result.add(Pair.create(setting, descriptor)));
    });
    return result;
}
Also used : Storage(com.intellij.openapi.components.Storage) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Arrays(java.util.Arrays) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AllIcons(com.intellij.icons.AllIcons) PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent) ArrayList(java.util.ArrayList) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Comparing(com.intellij.openapi.util.Comparing) DashboardGrouper(com.intellij.execution.dashboard.tree.DashboardGrouper) ToolWindowId(com.intellij.openapi.wm.ToolWindowId) State(com.intellij.openapi.components.State) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) ContentUI(com.intellij.ui.content.ContentUI) ToolWindowAnchor(com.intellij.openapi.wm.ToolWindowAnchor) DumbService(com.intellij.openapi.project.DumbService) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) Set(java.util.Set) Collectors(java.util.stream.Collectors) ProcessHandler(com.intellij.execution.process.ProcessHandler) com.intellij.execution(com.intellij.execution) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ContentFactory(com.intellij.ui.content.ContentFactory) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) StoragePathMacros(com.intellij.openapi.components.StoragePathMacros) Pair(com.intellij.openapi.util.Pair) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl) ContentManager(com.intellij.ui.content.ContentManager) Registry(com.intellij.openapi.util.registry.Registry) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ArrayList(java.util.ArrayList) Pair(com.intellij.openapi.util.Pair) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl)

Example 27 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class RunDashboardManagerImpl method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
    myDashboardContent = new RunDashboardContent(myProject, myContentManager, myGroupers);
    ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(myDashboardContent, null, false);
    Disposer.register(content, myDashboardContent);
    Disposer.register(content, () -> myDashboardContent = null);
    toolWindow.getContentManager().addContent(content);
}
Also used : Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager)

Example 28 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class ReplaceInProjectManager method replaceInProject.

public void replaceInProject(@NotNull DataContext dataContext) {
    final boolean isOpenInNewTabEnabled;
    final boolean toOpenInNewTab;
    final Content selectedContent = com.intellij.usageView.UsageViewManager.getInstance(myProject).getSelectedContent(true);
    if (selectedContent != null && selectedContent.isPinned()) {
        toOpenInNewTab = true;
        isOpenInNewTabEnabled = false;
    } else {
        toOpenInNewTab = FindSettings.getInstance().isShowResultsInSeparateView();
        isOpenInNewTabEnabled = com.intellij.usageView.UsageViewManager.getInstance(myProject).getReusableContentsCount() > 0;
    }
    final FindManager findManager = FindManager.getInstance(myProject);
    final FindModel findModel = findManager.getFindInProjectModel().clone();
    findModel.setReplaceState(true);
    findModel.setOpenInNewTabVisible(true);
    findModel.setOpenInNewTabEnabled(isOpenInNewTabEnabled);
    findModel.setOpenInNewTab(toOpenInNewTab);
    FindInProjectUtil.setDirectoryName(findModel, dataContext);
    FindInProjectUtil.initStringToFindFromDataContext(findModel, dataContext);
    findManager.showFindDialog(findModel, () -> {
        if (!findModel.isProjectScope() && FindInProjectUtil.getDirectory(findModel) == null && findModel.getModuleName() == null && findModel.getCustomScope() == null) {
            return;
        }
        UsageViewManager manager = UsageViewManager.getInstance(myProject);
        if (manager == null)
            return;
        findManager.getFindInProjectModel().copyFrom(findModel);
        final FindModel findModelCopy = findModel.clone();
        final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(findModel.isOpenInNewTab(), findModelCopy);
        final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, true, presentation);
        UsageSearcherFactory factory = new UsageSearcherFactory(findModelCopy, processPresentation);
        searchAndShowUsages(manager, factory, findModelCopy, presentation, processPresentation, findManager);
    });
}
Also used : Content(com.intellij.ui.content.Content)

Example 29 with Content

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;
}
Also used : Disposable(com.intellij.openapi.Disposable) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) HierarchyBrowser(com.intellij.ide.hierarchy.HierarchyBrowser) HierarchyBrowserManager(com.intellij.ide.hierarchy.HierarchyBrowserManager) HierarchyBrowserBase(com.intellij.ide.hierarchy.HierarchyBrowserBase) NotNull(org.jetbrains.annotations.NotNull)

Example 30 with Content

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);
        }
    });
}
Also used : DependenciesPanel(com.intellij.packageDependencies.ui.DependenciesPanel) Content(com.intellij.ui.content.Content)

Aggregations

Content (com.intellij.ui.content.Content)157 ContentManager (com.intellij.ui.content.ContentManager)42 ToolWindow (com.intellij.openapi.wm.ToolWindow)37 NotNull (org.jetbrains.annotations.NotNull)19 ContentFactory (com.intellij.ui.content.ContentFactory)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)13 MessageView (com.intellij.ui.content.MessageView)10 Disposable (com.intellij.openapi.Disposable)8 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)7 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)7 ConsoleView (com.intellij.execution.ui.ConsoleView)6 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)6 TabbedContent (com.intellij.ui.content.TabbedContent)6 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)5 Ref (com.intellij.openapi.util.Ref)5 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)4 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)4 Assert.assertNotNull (junit.framework.Assert.assertNotNull)4