Java Code Examples for com.intellij.ui.content.ContentManager

The following examples show how to use com.intellij.ui.content.ContentManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: consulo   Source File: PredefinedSearchScopeProviderImpl.java    License: Apache License 2.0 6 votes vote down vote up
private static void addHierarchyScope(@Nonnull 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)"));
  }
}
 
Example 2
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
  ContentManager contentManager = toolWindow.getContentManager();
  AnalyzeSizeToolWindow analyzeSizeToolWindow =
      new AnalyzeSizeToolWindow(
          toolWindow,
          project,
          categorizedSuggestions,
          categoryDisplayOrder
          );
  Content content =
      ContentFactory.SERVICE
          .getInstance()
          .createContent(analyzeSizeToolWindow.getContent(), CONTENT_TITLE, false);
  // We want only one content tab to exist at a time, but clearing all of them will cause the
  // tool window to disappear, so we add the new tab and remove the others after.
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);
  for (Content otherContent : contentManager.getContents()) {
    if (otherContent != content) {
      contentManager.removeContent(otherContent, true);
    }
  }
  toolWindow.show(null);
}
 
Example 3
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example 4
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example 5
private static void listenForRenderTreeActivations(@NotNull ToolWindow toolWindow) {
  final ContentManager contentManager = toolWindow.getContentManager();
  contentManager.addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(@NotNull ContentManagerEvent event) {
      final ContentManagerEvent.ContentOperation operation = event.getOperation();
      if (operation == ContentManagerEvent.ContentOperation.add) {
        final String name = event.getContent().getTabName();
        if (Objects.equals(name, RENDER_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "renderTreeSelected");
        }
        else if (Objects.equals(name, WIDGET_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "widgetTreeSelected");
        }
      }
    }
  });
}
 
Example 6
Source Project: consulo   Source File: FileHistorySessionPartner.java    License: Apache License 2.0 6 votes vote down vote up
private void createOrSelectContentIfNeeded() {
  ToolWindow toolWindow = getToolWindow(myVcs.getProject());
  if (myRefresherI.isFirstTime()) {
    ContentManager manager = toolWindow.getContentManager();
    boolean selectedExistingContent = ContentUtilEx.selectContent(manager, myFileHistoryPanel, true);
    if (!selectedExistingContent) {
      String tabName = myPath.getName();
      if (myStartingRevisionNumber != null) {
        tabName += " (";
        if (myStartingRevisionNumber instanceof ShortVcsRevisionNumber) {
          tabName += ((ShortVcsRevisionNumber)myStartingRevisionNumber).toShortString();
        }
        else {
          tabName += myStartingRevisionNumber.asString();
        }
        tabName += ")";
      }
      ContentUtilEx.addTabbedContent(manager, myFileHistoryPanel, "History", tabName, true);
    }
    toolWindow.activate(null);
  }
}
 
Example 7
@Override
public void createToolWindowContent(
    @NotNull final Project project, @NotNull ToolWindow toolWindow) {
  toolWindow.setAvailable(true, null);
  toolWindow.setToHideOnEmptyContent(true);

  RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project);
  Content consoleContent = createConsoleContent(runnerLayoutUi, project);

  runnerLayoutUi.addContent(consoleContent, 0, PlaceInGrid.center, false);
  runnerLayoutUi.getOptions().setLeftToolbar(
      getLeftToolbarActions(project), ActionPlaces.UNKNOWN);

  runnerLayoutUi.updateActionsNow();

  final ContentManager contentManager = toolWindow.getContentManager();
  Content content = contentManager.getFactory().createContent(
      runnerLayoutUi.getComponent(), "", true);
  contentManager.addContent(content);

  updateBuckToolWindowTitle(project);
}
 
Example 8
Source Project: p4ic4idea   Source File: VcsDockedComponent.java    License: Apache License 2.0 6 votes vote down vote up
private VcsDockedComponent(final Project project) {
    this.project = project;
    ApplicationManager.getApplication().invokeLater(() -> {
        if (project.isDisposed()) {
            return;
        }
        final ToolWindow toolWindow = getToolWindow();
        if (toolWindow == null) {
            // can happen if the project isn't fully initialized yet
            return;
        }
        final ContentManager contentManager = toolWindow.getContentManager();
        contentManager.addContentManagerListener(new ContentManagerAdapter() {
            @Override
            public void contentRemoved(ContentManagerEvent event) {
                final JComponent component = event.getContent().getComponent();
                if (component instanceof Disposable) {
                    Disposer.dispose((Disposable) component);
                }
            }
        });
        toolWindow.installWatcher(contentManager);
    });
}
 
Example 9
Source Project: consulo   Source File: TodoCheckinHandler.java    License: Apache License 2.0 6 votes vote down vote up
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, Project project) {
      return new CustomChangelistTodosTreeBuilder(tree, 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());
}
 
Example 10
Source Project: consulo   Source File: ContentsUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void addOrReplaceContent(ContentManager manager, Content content, boolean select) {
  final String contentName = content.getDisplayName();

  Content[] contents = manager.getContents();
  Content oldContentFound = null;
  for(Content oldContent: contents) {
    if (!oldContent.isPinned() && oldContent.getDisplayName().equals(contentName)) {
      oldContentFound = oldContent;
      break;
    }
  }

  manager.addContent(content);
  if (oldContentFound != null) {
    manager.removeContent(oldContentFound, true);
  }
  if (select) {
    manager.setSelectedContent(content);
  }
}
 
Example 11
Source Project: consulo   Source File: ProjectLevelVcsManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
private Content getOrCreateConsoleContent(final ContentManager contentManager) {
  final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name");
  Content content = contentManager.findContent(displayName);
  if (content == null) {
    releaseConsole();

    myConsole = TextConsoleBuilderFactory.getInstance().createBuilder(myProject).getConsole();

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(myConsole.getComponent(), BorderLayout.CENTER);

    ActionToolbar toolbar = ActionManager.getInstance()
            .createActionToolbar("VcsManager", new DefaultActionGroup(myConsole.createConsoleActions()), false);
    panel.add(toolbar.getComponent(), BorderLayout.WEST);

    content = ContentFactory.getInstance().createContent(panel, displayName, true);
    content.setDisposer(myConsoleDisposer);
    contentManager.addContent(content);

    for (Pair<String, ConsoleViewContentType> pair : myPendingOutput) {
      printToConsole(pair.first, pair.second);
    }
    myPendingOutput.clear();
  }
  return content;
}
 
Example 12
Source Project: consulo   Source File: ContentUtilEx.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Searches through all {@link Content simple} and {@link TabbedContent tabbed} contents of the given ContentManager,
 * and selects the one which holds the specified {@code contentComponent}.
 *
 * @return true if the necessary content was found (and thus selected) among content components of the given ContentManager.
 */
public static boolean selectContent(@Nonnull ContentManager manager, @Nonnull final JComponent contentComponent, boolean requestFocus) {
  for (Content content : manager.getContents()) {
    if (content instanceof TabbedContentImpl) {
      boolean found = ((TabbedContentImpl)content).findAndSelectContent(contentComponent);
      if (found) {
        manager.setSelectedContent(content, requestFocus);
        return true;
      }
    }
    else if (Comparing.equal(content.getComponent(), contentComponent)) {
      manager.setSelectedContent(content, requestFocus);
      return true;
    }
  }
  return false;
}
 
Example 13
Source Project: consulo   Source File: ContentUtilEx.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Searches through all {@link Content simple} and {@link TabbedContent tabbed} contents of the given ContentManager,
 * trying to find the first one which matches the given condition.
 */
@Nullable
public static JComponent findContentComponent(@Nonnull ContentManager manager, @Nonnull Condition<JComponent> condition) {
  for (Content content : manager.getContents()) {
    if (content instanceof TabbedContentImpl) {
      List<Pair<String, JComponent>> tabs = ((TabbedContentImpl)content).getTabs();
      for (Pair<String, JComponent> tab : tabs) {
        if (condition.value(tab.second)) {
          return tab.second;
        }
      }
    }
    else if (condition.value(content.getComponent())) {
      return content.getComponent();
    }
  }
  return null;
}
 
Example 14
Source Project: consulo   Source File: TabNavigationActionBase.java    License: Apache License 2.0 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }

  ToolWindowManager windowManager = ToolWindowManager.getInstance(project);

  if (windowManager.isEditorComponentActive()) {
    doNavigate(dataContext, project);
    return;
  }

  ContentManager contentManager = e.getData(PlatformDataKeys.NONEMPTY_CONTENT_MANAGER);
  if (contentManager == null) return;
  doNavigate(contentManager);
}
 
Example 15
Source Project: consulo   Source File: TabNavigationActionBase.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  presentation.setEnabled(false);
  if (project == null) {
    return;
  }
  final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  if (windowManager.isEditorComponentActive()) {
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    EditorWindow currentWindow = event.getData(EditorWindow.DATA_KEY);
    if (currentWindow == null) {
      editorManager.getCurrentWindow();
    }
    if (currentWindow != null) {
      final VirtualFile[] files = currentWindow.getFiles();
      presentation.setEnabled(files.length > 1);
    }
    return;
  }

  ContentManager contentManager = event.getData(PlatformDataKeys.NONEMPTY_CONTENT_MANAGER);
  presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
 
Example 16
Source Project: consulo   Source File: CloseActiveTabAction.java    License: Apache License 2.0 6 votes vote down vote up
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 = context.getData(PlatformDataKeys.TOOL_WINDOW);
    if (tw != null) {
      tw.hide(null);
    }
  }
}
 
Example 17
Source Project: consulo   Source File: ToggleToolbarAction.java    License: Apache License 2.0 6 votes vote down vote up
private ToggleToolbarAction(@Nonnull ToolWindow toolWindow, @Nonnull PropertiesComponent propertiesComponent) {
  super("Show Toolbar");
  myPropertiesComponent = propertiesComponent;
  myToolWindow = toolWindow;
  myToolWindow.getContentManager().addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void contentAdded(ContentManagerEvent event) {
      JComponent component = event.getContent().getComponent();
      setContentToolbarVisible(component, getVisibilityValue());

      // support nested content managers, e.g. RunnerLayoutUi as content component
      ContentManager contentManager =
              component instanceof DataProvider ? ((DataProvider)component).getDataUnchecked(PlatformDataKeys.CONTENT_MANAGER) : null;
      if (contentManager != null) contentManager.addContentManagerListener(this);
    }
  });
}
 
Example 18
@Override
public void focusGained(FocusEvent e) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
    if (toolWindow != null) {
        try {
            ContentManager contentManager = toolWindow.getContentManager();
            JComponent component = contentManager.getSelectedContent().getComponent();
            if (component != null) {
                component.requestFocusInWindow();
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
}
 
Example 19
Source Project: consulo   Source File: UpdateInfoTree.java    License: Apache License 2.0 5 votes vote down vote up
public UpdateInfoTree(@Nonnull ContentManager contentManager, @Nonnull Project project, UpdatedFiles updatedFiles, String rootName, ActionInfo actionInfo) {
  super(contentManager, "reference.versionControl.toolwindow.update");
  myActionInfo = actionInfo;

  myFileStatusListener = new FileStatusListener() {
    public void fileStatusesChanged() {
      myTree.repaint();
    }

    public void fileStatusChanged(@Nonnull VirtualFile virtualFile) {
      myTree.repaint();
    }
  };

  myProject = project;
  myUpdatedFiles = updatedFiles;
  myRootName = rootName;

  myShowOnlyFilteredItems = VcsConfiguration.getInstance(myProject).UPDATE_FILTER_BY_SCOPE;

  myFileStatusManager = FileStatusManager.getInstance(myProject);
  myFileStatusManager.addFileStatusListener(myFileStatusListener);
  createTree();
  init();
  myTreeExpander = new DefaultTreeExpander(myTree);
  myTreeIterable = new MyTreeIterable();
}
 
Example 20
@Nullable
private static Pair<Content, Process> getSuitableProcess(@NotNull ContentManager contentManager, @NotNull String workingDirectory) {
  Content selectedContent = contentManager.getSelectedContent();
  if (selectedContent != null) {
    Pair<Content, Process> pair = getSuitableProcess(selectedContent, workingDirectory);
    if (pair != null) return pair;
  }

  return Arrays.stream(contentManager.getContents())
    .map(content -> getSuitableProcess(content, workingDirectory))
    .filter(Objects::nonNull)
    .findFirst()
    .orElse(null);
}
 
Example 21
Source Project: consulo   Source File: ProjectLevelVcsManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@CalledInAwt
@Nullable
@Override
public UpdateInfoTree showUpdateProjectInfo(UpdatedFiles updatedFiles, String displayActionName, ActionInfo actionInfo, boolean canceled) {
  if (!myProject.isOpen() || myProject.isDisposed()) return null;
  ContentManager contentManager = getContentManager();
  if (contentManager == null) {
    return null;  // content manager is made null during dispose; flag is set later
  }
  final UpdateInfoTree updateInfoTree = new UpdateInfoTree(contentManager, myProject, updatedFiles, displayActionName, actionInfo);
  ContentUtilEx.addTabbedContent(contentManager, updateInfoTree, "Update Info", DateFormatUtil.formatDateTime(System.currentTimeMillis()), false, updateInfoTree);
  updateInfoTree.expandRootChildren();
  return updateInfoTree;
}
 
Example 22
Source Project: consulo   Source File: RunnerLayoutUiImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public RunnerLayoutUi addListener(@Nonnull final ContentManagerListener listener, @Nonnull final Disposable parent) {
  final ContentManager mgr = getContentManager();
  mgr.addContentManagerListener(listener);
  Disposer.register(parent, new Disposable() {
    @Override
    public void dispose() {
      mgr.removeContentManagerListener(listener);
    }
  });
  return this;
}
 
Example 23
Source Project: consulo   Source File: RunDashboardManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@Nonnull 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);
}
 
Example 24
/**
 * Moves this console to the end of the tool window's tab list, selects it, and shows the tool window.
 */
void bringToFront() {
  // Move the tab to be last and select it.
  final MessageView messageView = MessageView.SERVICE.getInstance(project);
  final ContentManager contentManager = messageView.getContentManager();
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  // Show the panel.
  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
  if (toolWindow != null) {
    toolWindow.activate(null, true);
  }
}
 
Example 25
/**
 * Moves this console to the end of the tool window's tab list, selects it, and shows the tool window.
 */
void bringToFront() {
  // Move the tab to be last and select it.
  final MessageView messageView = MessageView.SERVICE.getInstance(project);
  final ContentManager contentManager = messageView.getContentManager();
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  // Show the panel.
  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
  if (toolWindow != null) {
    toolWindow.activate(null, true);
  }
}
 
Example 26
public void createToolWindowContent(final Project project, final ToolWindow toolWindow) {
    // Plugin is now placed into a Tabbed Pane to add additional views to it
    JBTabbedPane master = new JBTabbedPane(SwingConstants.BOTTOM);
    SlingPluginExplorer explorer = new SlingPluginExplorer(project);
    LOGGER.debug("CTWC: Explorer: '" + explorer + "'");
    master.insertTab("Plugin", null, explorer, "Plugin Windows", 0);

    WebContentFXPanel info = new WebContentFXPanel();
    master.insertTab("Info", null, info, "Plugin Info", 1);

    final AemdcPanel aemdcPanel = ComponentProvider.getComponent(project, AemdcPanel.class);
    LOGGER.debug("AEMDC Panel found: '{}'", aemdcPanel);
    aemdcPanel.setContainer(master);

    final ContentManager contentManager = toolWindow.getContentManager();
    final Content content = contentManager.getFactory().createContent(master, null, false);
    contentManager.addContent(content);
    Disposer.register(project, explorer);

    final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {
        boolean wasVisible = false;

        @Override
        public void stateChanged() {
            if (toolWindow.isDisposed()) {
                return;
            }
            boolean visible = toolWindow.isVisible();
            // If the Plugin became visible then we let the AEMDC Panel know to recrate the JFX Panel
            // to avoid the double buffering
            if(!wasVisible && visible) {
                aemdcPanel.reset();
            }
            wasVisible = visible;
        }
    };
    final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
    manager.addToolWindowManagerListener(listener, project);
}
 
Example 27
static void createContent(Project project, ToolWindow toolWindow, ConsoleLogConsole console, String title) {
    // update default Event Log tab title
    ContentManager contentManager = toolWindow.getContentManager();
    Content generalContent = contentManager.getContent(0);
    if (generalContent != null && contentManager.getContentCount() == 1) {
        generalContent.setDisplayName("General");
    }

    final Editor editor = console.getConsoleEditor();

    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
        @Override
        public Object getData(@NonNls String dataId) {
            return PlatformDataKeys.HELP_ID.is(dataId) ? ConsoleLog.HELP_ID : super.getData(dataId);
        }
    };
    panel.setContent(editor.getComponent());
    panel.addAncestorListener(new LogShownTracker(project));

    ActionToolbar toolbar = createToolbar(project, editor, console);
    toolbar.setTargetComponent(editor.getContentComponent());
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
}
 
Example 28
Source Project: p4ic4idea   Source File: VcsDockedComponent.java    License: Apache License 2.0 5 votes vote down vote up
public void removeFromVcsTab(@NotNull @NonNls String title) {
    final ToolWindow toolW = getToolWindow();
    if (toolW == null) {
        // cannot do anything
        return;
    }
    final ContentManager contentManager = getToolWindow().getContentManager();
    final Content existingContent = contentManager.findContent(title);
    if (existingContent != null) {
        if (!existingContent.isPinned()) {
            contentManager.removeContent(existingContent, true);
            existingContent.release();
        }
    }
}
 
Example 29
Source Project: consulo   Source File: FavoritesViewToolWindowFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
  if (toolWindow != null) {
    final ContentManager contentManager = toolWindow.getContentManager();
    final FavoritesTreeViewPanel panel = new FavoritesPanel(project).getPanel();
    panel.setupToolWindow((ToolWindowEx)toolWindow);
    final Content content = contentManager.getFactory().createContent(panel, null, false);
    contentManager.addContent(content);
  }
}
 
Example 30
Source Project: buck   Source File: BuckToolWindowImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initBuckToolWindow() {
  mainToolWindow = ToolWindowManager.getInstance(project).getToolWindow(MAIN_TOOL_WINDOW_ID);
  runToolWindow = ToolWindowManager.getInstance(project).getToolWindow(RUN_TOOL_WINDOW_ID);
  runnerLayoutUi.getOptions().setLeftToolbar(getLeftToolbarActions(), ActionPlaces.UNKNOWN);

  runnerLayoutUi.updateActionsNow();

  final ContentManager contentManager = mainToolWindow.getContentManager();
  Content content =
      contentManager.getFactory().createContent(runnerLayoutUi.getComponent(), "", true);
  contentManager.addContent(content);

  updateMainToolWindowTitleByTarget();
}