本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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;
}