Java Code Examples for com.intellij.ui.content.Content#getDisplayName()

The following examples show how to use com.intellij.ui.content.Content#getDisplayName() . 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 File: ContentsUtil.java    From consulo with 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 2
Source File: PredefinedSearchScopeProviderImpl.java    From consulo with 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 3
Source File: ContentLayout.java    From consulo with Apache License 2.0 6 votes vote down vote up
private String getTitleSuffix() {
  switch (myUi.myManager.getContentCount()) {
    case 0:
      return null;
    case 1:
      Content content = myUi.myManager.getContent(0);
      if (content == null) return null;

      final String text = content.getDisplayName();
      if (text != null && text.trim().length() > 0 && myUi.myManager.canCloseContents()) {
        return ":";
      }
      return null;
    default:
      return ":";
  }
}
 
Example 4
Source File: SelectContentStep.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public String getTextFor(Content value) {
  TabbedContent tabbedContent = asMultiTabbed(value);
  if(tabbedContent != null) {
    String titlePrefix = tabbedContent.getTitlePrefix();
    if(titlePrefix != null) {
      return titlePrefix;
    }
  }

  String displayName = value.getDisplayName();
  if(displayName != null) {
    return displayName;
  }
  return super.getTextFor(value);
}
 
Example 5
Source File: RunnerLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static String getOrCreateContentId(@Nonnull Content content) {
  @NonNls String id = content.getUserData(ViewImpl.ID);
  if (id == null) {
    id = "UnknownView-" + content.getDisplayName();
    content.putUserData(ViewImpl.ID, id);
  }
  return id;
}