当前位置: 首页>>代码示例>>Java>>正文


Java ContentManager.getContents方法代码示例

本文整理汇总了Java中com.intellij.ui.content.ContentManager.getContents方法的典型用法代码示例。如果您正苦于以下问题:Java ContentManager.getContents方法的具体用法?Java ContentManager.getContents怎么用?Java ContentManager.getContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.ui.content.ContentManager的用法示例。


在下文中一共展示了ContentManager.getContents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addOrReplaceContent

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ContentsUtil.java

示例2: selectContent

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
/**
 * 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(@NotNull ContentManager manager, @NotNull 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ContentUtilEx.java

示例3: findContentComponent

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
/**
 * 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(@NotNull ContentManager manager, @NotNull 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ContentUtilEx.java

示例4: checkIfProjectLogMatches

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
private static boolean checkIfProjectLogMatches(@NotNull Project project,
                                                @NotNull GitVcs vcs,
                                                @NotNull ContentManager cm,
                                                @NotNull List<VirtualFile> requestedRoots) {
  VirtualFile[] projectRoots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs);
  if (Comparing.haveEqualElements(requestedRoots, Arrays.asList(projectRoots))) {
    Content[] contents = cm.getContents();
    for (Content content : contents) {
      if (VcsLogContentProvider.TAB_NAME.equals(content.getDisplayName())) {
        cm.setSelectedContent(content);
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitShowExternalLogAction.java

示例5: selectContent

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:ContentUtilEx.java

示例6: findContentComponent

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:ContentUtilEx.java

示例7: actionPerformed

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
@Override
protected void actionPerformed(AnActionEvent e, ViewContext context, Content[] content) {
  ContentManager manager = context.getContentManager();
  for (Content c : manager.getContents()) {
    if (c.isCloseable() && isAccepted(c, content)) {
      manager.removeContent(c, context.isToDisposeRemovedContent());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:CloseViewsActionBase.java

示例8: findContent

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
@Nullable
private static Content findContent(ContentManager manager, String name) {
  for (Content content : manager.getContents()) {
    if (content.getDisplayName().equals(name)) {
      return content;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PyEduDebugRunner.java

示例9: checkIfAlreadyOpened

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
private static boolean checkIfAlreadyOpened(@NotNull ContentManager cm, @NotNull Collection<VirtualFile> roots) {
  for (Content content : cm.getContents()) {
    final JComponent component = content.getComponent();
    if (component instanceof MyContentComponent) {
      if (Comparing.haveEqualElements(roots, ((MyContentComponent)component).myRoots)) {
        cm.setSelectedContent(content);
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GitShowExternalLogAction.java

示例10: getToolWindowElement

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Nullable
public static <T> T getToolWindowElement(@NotNull Class<T> clazz,
                                         @NotNull Project project,
                                         @NotNull DataKey<T> key,
                                         @NotNull ProjectSystemId externalSystemId)
{
  if (project.isDisposed() || !project.isOpen()) {
    return null;
  }
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
  if (toolWindowManager == null) {
    return null;
  }
  final ToolWindow toolWindow = toolWindowManager.getToolWindow(externalSystemId.getReadableName());
  if (toolWindow == null) {
    return null;
  }
  if (toolWindow instanceof ToolWindowImpl) {
    ((ToolWindowImpl)toolWindow).ensureContentInitialized();
  }

  final ContentManager contentManager = toolWindow.getContentManager();
  if (contentManager == null) {
    return null;
  }

  for (Content content : contentManager.getContents()) {
    final JComponent component = content.getComponent();
    if (component instanceof DataProvider) {
      final Object data = ((DataProvider)component).getData(key.getName());
      if (data != null && clazz.isInstance(data)) {
        return (T)data;
      }
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:ExternalSystemUtil.java

示例11: actionPerformed

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
@Override
protected void actionPerformed(final AnActionEvent e, final ViewContext context, final Content[] content) {
  final ContentManager manager = context.getContentManager();
  for (Content c : manager.getContents()) {
    if (c != content[0] && c.isCloseable()) {
      manager.removeContent(c, context.isToDisposeRemovedContent());
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:CloseOtherViewsAction.java

示例12: actionPerformed

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
@Override
protected void actionPerformed(final AnActionEvent e, final ViewContext context, final Content[] content) {
  final ContentManager manager = context.getContentManager();
  for (Content c : manager.getContents()) {
    if (c.isCloseable()) {
      manager.removeContent(c, context.isToDisposeRemovedContent());
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:CloseAllViewsAction.java

示例13: checkForProjectScope

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
private boolean checkForProjectScope(ContentManager cm, Project project, List<VirtualFile> correctRoots) {
  VirtualFile[] rootsUnderVcs = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(GitVcs.getInstance(project));
  if (Comparing.equal(correctRoots, Arrays.asList(rootsUnderVcs))) {
    Content[] contents = cm.getContents();
    for (Content content : contents) {
      if (GitProjectLogManager.CONTENT_KEY.equals(content.getDisplayName())) {
        cm.setSelectedContent(content);
        alreadyOpened(project);
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:SelectRepositoryAndShowLogAction.java

示例14: getToolWindowElement

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@javax.annotation.Nullable
public static <T> T getToolWindowElement(@Nonnull Class<T> clazz,
                                         @Nonnull Project project,
                                         @Nonnull com.intellij.openapi.util.Key<T> key,
                                         @Nonnull ProjectSystemId externalSystemId) {
  if (project.isDisposed() || !project.isOpen()) {
    return null;
  }
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
  if (toolWindowManager == null) {
    return null;
  }
  final ToolWindow toolWindow = ensureToolWindowContentInitialized(project, externalSystemId);
  if (toolWindow == null) {
    return null;
  }

  final ContentManager contentManager = toolWindow.getContentManager();
  if (contentManager == null) {
    return null;
  }

  for (Content content : contentManager.getContents()) {
    final JComponent component = content.getComponent();
    if (component instanceof DataProvider) {
      final Object data = ((DataProvider)component).getData(key);
      if (data != null && clazz.isInstance(data)) {
        return (T)data;
      }
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:35,代码来源:ExternalSystemUtil.java

示例15: findTabbedContent

import com.intellij.ui.content.ContentManager; //导入方法依赖的package包/类
@Nullable
public static TabbedContent findTabbedContent(@Nonnull ContentManager manager, @Nonnull String groupPrefix) {
  TabbedContent tabbedContent = null;
  for (Content content : manager.getContents()) {
    if (content instanceof TabbedContent && content.getTabName().startsWith(getFullPrefix(groupPrefix))) {
      tabbedContent = (TabbedContent)content;
      break;
    }
  }
  return tabbedContent;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:ContentUtilEx.java


注:本文中的com.intellij.ui.content.ContentManager.getContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。