Search in sources :

Example 61 with Content

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

Example 62 with Content

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);
}
Also used : MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Example 63 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 64 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 65 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)

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