Java 类com.intellij.util.ContentUtilEx 实例源码

项目:consulo    文件:VcsLogContentProvider.java   
public static VcsLogUiImpl openLogTab(@Nonnull VcsLogManager logManager,
                                      @Nonnull Project project,
                                      @Nonnull String shortName,
                                      @Nullable VcsLogFilter filter) {
  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);

  String name = ContentUtilEx.getFullName(TAB_NAME, shortName);

  VcsLogUiImpl logUi = logManager.createLogUi(name, name, filter);

  ContentUtilEx
          .addTabbedContent(toolWindow.getContentManager(), new VcsLogPanel(logManager, logUi), TAB_NAME, shortName, true, logUi);
  toolWindow.activate(null);

  logManager.scheduleInitialization();
  return logUi;
}
项目:consulo    文件:FileHistorySessionPartner.java   
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);
  }
}
项目:intellij-ce-playground    文件:ToolWindowContentUi.java   
private static AnAction createMergeTabsAction(final ContentManager manager, final String tabPrefix) {
  return new DumbAwareAction("Merge tabs to '" + tabPrefix + "' group") {
    @Override
    public void actionPerformed(AnActionEvent e) {
      final Content selectedContent = manager.getSelectedContent();
      final List<Pair<String, JComponent>> tabs = new ArrayList<Pair<String, JComponent>>();
      int selectedTab = -1;
      for (Content content : manager.getContents()) {
        if (tabPrefix.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY))) {
          final String label = content.getTabName().substring(tabPrefix.length() + 2);
          final JComponent component = content.getComponent();
          if (content == selectedContent) {
            selectedTab = tabs.size();
          }
          tabs.add(Pair.create(label, component));
          manager.removeContent(content, false);
          content.setComponent(null);
          Disposer.dispose(content);
        }
      }
      PropertiesComponent.getInstance().unsetValue(TabbedContent.SPLIT_PROPERTY_PREFIX + tabPrefix);
      for (int i = 0; i < tabs.size(); i++) {
        final Pair<String, JComponent> tab = tabs.get(i);
        ContentUtilEx.addTabbedContent(manager, tab.second, tabPrefix, tab.first, i == selectedTab);
      }
    }
  };
}
项目:intellij-ce-playground    文件:TabbedContentImpl.java   
@Override
public void split() {
  List<Pair<String, JComponent>> copy = new ArrayList<Pair<String, JComponent>>(myTabs);
  int selectedTab = ContentUtilEx.getSelectedTab(this);
  ContentManager manager = getManager();
  String prefix = getTitlePrefix();
  manager.removeContent(this, true);
  PropertiesComponent.getInstance().setValue(SPLIT_PROPERTY_PREFIX + prefix, Boolean.TRUE.toString());
  for (int i = 0; i < copy.size(); i++) {
    final boolean select = i == selectedTab;
    final JComponent component = copy.get(i).second;
    final String tabName = copy.get(i).first;
    ContentUtilEx.addTabbedContent(manager, component, prefix, tabName, select);
  }
}
项目:intellij-ce-playground    文件:ProjectLevelVcsManagerImpl.java   
@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()), true, updateInfoTree);
  ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS).activate(null);
  updateInfoTree.expandRootChildren();
  return updateInfoTree;
}
项目:intellij-ce-playground    文件:FileHistorySessionPartner.java   
private void createOrSelectContentIfNeeded() {
  ToolWindow toolWindow = getToolWindow(myVcs.getProject());
  if (myRefresherI.isFirstTime()) {
    ContentManager manager = toolWindow.getContentManager();
    boolean selectedExistingContent = ContentUtilEx.selectContent(manager, myFileHistoryPanel, true);
    if (!selectedExistingContent) {
      ContentUtilEx.addTabbedContent(manager, myFileHistoryPanel, "History", myPath.getName(), true);
    }
    toolWindow.activate(null);
  }
}
项目:intellij-ce-playground    文件:HgShowUnAppliedPatchesAction.java   
public static void showUnAppliedPatches(@NotNull Project project, @NotNull HgRepository selectedRepo) {
  ToolWindow toolWindow = ObjectUtils.assertNotNull(ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS));
  ContentUtilEx
    .addTabbedContent(toolWindow.getContentManager(), new HgMqUnAppliedPatchesPanel(selectedRepo), "MQ", selectedRepo.getRoot().getName(),
                      true);
  toolWindow.activate(null);
}
项目:gitextender    文件:AfterSuccessfulMergeHandler.java   
protected void showUpdateTree(final UpdateInfoTree updateInfoTree) {
    if (!mergeState.getProject().isOpen() || mergeState.getProject().isDisposed()) return;
    ContentManager contentManager = getContentManager(mergeState.getProject());
    if (contentManager == null) {
        return; // content manager is made null during dispose; flag is set later
    }
    final String tabName = mergeState.getRepoName() + " " + mergeState.getLocalBranchName() +
            "->" + mergeState.getRemoteBranchName();
    ContentUtilEx.addTabbedContent(contentManager, updateInfoTree,
            "Update Info", tabName, true, updateInfoTree);
    ToolWindowManager.getInstance(mergeState.getProject()).getToolWindow(ToolWindowId.VCS).activate(null);
    updateInfoTree.expandRootChildren();
}
项目:consulo    文件:CloseLogTabAction.java   
@Nullable
private static Content getTabbedContent(@Nonnull ContentManager contentManager) {
  Content content = contentManager.getSelectedContent();
  if (content != null) {
    if (ContentUtilEx.isContentTab(content, VcsLogContentProvider.TAB_NAME)) return content;
  }
  return null;
}
项目:consulo    文件:VcsLogContentProvider.java   
@Nonnull
private static String generateShortName(@Nonnull ToolWindow toolWindow) {
  TabbedContent tabbedContent = ContentUtilEx.findTabbedContent(toolWindow.getContentManager(), TAB_NAME);
  if (tabbedContent != null) {
    return String.valueOf(tabbedContent.getTabs().size() + 1);
  }
  else {
    List<Content> contents = ContainerUtil.filter(toolWindow.getContentManager().getContents(),
                                                  content -> TAB_NAME.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY)));
    return String.valueOf(contents.size() + 1);
  }
}
项目:consulo    文件:VcsLogContentProvider.java   
private void closeLogTabs() {
  ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS);

  if (toolWindow != null) {
    for (Content content : toolWindow.getContentManager().getContents()) {
      if (ContentUtilEx.isContentTab(content, TAB_NAME)) {
        ContentsUtil.closeContentTab(toolWindow.getContentManager(), content);
      }
    }
  }
}
项目:consulo    文件:UnifiedToolWindowContentUI.java   
private static AnAction createMergeTabsAction(final ContentManager manager, final String tabPrefix) {
  return new DumbAwareAction("Merge tabs to '" + tabPrefix + "' group") {
    @RequiredDispatchThread
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      final Content selectedContent = manager.getSelectedContent();
      final List<Pair<String, JComponent>> tabs = new ArrayList<Pair<String, JComponent>>();
      int selectedTab = -1;
      for (Content content : manager.getContents()) {
        if (tabPrefix.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY))) {
          final String label = content.getTabName().substring(tabPrefix.length() + 2);
          final JComponent component = content.getComponent();
          if (content == selectedContent) {
            selectedTab = tabs.size();
          }
          tabs.add(Pair.create(label, component));
          manager.removeContent(content, false);
          content.setComponent(null);
          Disposer.dispose(content);
        }
      }
      PropertiesComponent.getInstance().unsetValue(TabbedContent.SPLIT_PROPERTY_PREFIX + tabPrefix);
      for (int i = 0; i < tabs.size(); i++) {
        final Pair<String, JComponent> tab = tabs.get(i);
        ContentUtilEx.addTabbedContent(manager, tab.second, tabPrefix, tab.first, i == selectedTab);
      }
    }
  };
}
项目:consulo    文件:TabbedContentImpl.java   
@Override
public void split() {
  List<Pair<String, JComponent>> copy = new ArrayList<Pair<String, JComponent>>(myTabs);
  int selectedTab = ContentUtilEx.getSelectedTab(this);
  ContentManager manager = getManager();
  String prefix = getTitlePrefix();
  manager.removeContent(this, true);
  PropertiesComponent.getInstance().setValue(SPLIT_PROPERTY_PREFIX + prefix, Boolean.TRUE.toString());
  for (int i = 0; i < copy.size(); i++) {
    final boolean select = i == selectedTab;
    final JComponent component = copy.get(i).second;
    final String tabName = copy.get(i).first;
    ContentUtilEx.addTabbedContent(manager, component, prefix, tabName, select);
  }
}
项目:consulo    文件:ProjectLevelVcsManagerImpl.java   
@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;
}
项目:consulo    文件:FileHistorySessionPartner.java   
@Nullable
static FileHistoryRefresherI findExistingHistoryRefresher(@Nonnull Project project,
                                                          @Nonnull FilePath path,
                                                          @Nullable VcsRevisionNumber startingRevisionNumber) {
  JComponent component = ContentUtilEx.findContentComponent(getToolWindow(project).getContentManager(), comp ->
          comp instanceof FileHistoryPanelImpl &&
          sameHistories((FileHistoryPanelImpl)comp, path, startingRevisionNumber));
  return component == null ? null : ((FileHistoryPanelImpl)component).getRefresher();
}
项目:consulo    文件:DesktopToolWindowContentUi.java   
private static AnAction createMergeTabsAction(final ContentManager manager, final String tabPrefix) {
  return new DumbAwareAction("Merge tabs to '" + tabPrefix + "' group") {
    @RequiredDispatchThread
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      final Content selectedContent = manager.getSelectedContent();
      final List<Pair<String, JComponent>> tabs = new ArrayList<Pair<String, JComponent>>();
      int selectedTab = -1;
      for (Content content : manager.getContents()) {
        if (tabPrefix.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY))) {
          final String label = content.getTabName().substring(tabPrefix.length() + 2);
          final JComponent component = content.getComponent();
          if (content == selectedContent) {
            selectedTab = tabs.size();
          }
          tabs.add(Pair.create(label, component));
          manager.removeContent(content, false);
          content.setComponent(null);
          Disposer.dispose(content);
        }
      }
      PropertiesComponent.getInstance().unsetValue(TabbedContent.SPLIT_PROPERTY_PREFIX + tabPrefix);
      for (int i = 0; i < tabs.size(); i++) {
        final Pair<String, JComponent> tab = tabs.get(i);
        ContentUtilEx.addTabbedContent(manager, tab.second, tabPrefix, tab.first, i == selectedTab);
      }
    }
  };
}
项目:gitextender    文件:AfterSuccessfulMergeHandlerTest.java   
@SuppressWarnings("unchecked")
@Test
public void afterMerge(
        final @Mocked MergeChangeCollector collector,
        final @Mocked RefreshVFsSynchronously refreshVFsSynchronously,
        final @Mocked VcsAnnotationRefresher refresher,
        final @Mocked UpdateFilesHelper updateFilesHelper,
        final @Mocked UpdatedFilesNotifier updatedFilesNotifier,
        final @Mocked LocalHistory localHistory,
        final @Mocked ToolWindow toolWindow,
        final @Mocked ToolWindowManager toolWindowManager,
        final @Mocked RestoreUpdateTree restoreUpdateTree,
        final @Mocked UpdateInfoTree updateInfoTree,
        final @Mocked Application application,
        final @Mocked ApplicationManager applicationManager,
        final @Mocked CommittedChangesCache committedChangesCache,
        final @Mocked ContentUtilEx contentUtilEx
) throws Exception {
    final UpdatedFiles updatedFiles = UpdatedFiles.create();
    //add a file, so that it's not considered empty
    updatedFiles.getGroupById(FileGroup.UPDATED_ID).add("test", "test", null);

    new Expectations() {{
        mergeState.getUpdatedFiles(); result = updatedFiles;

        mergeState.getProject().getMessageBus().syncPublisher(VcsAnnotationRefresher.LOCAL_CHANGES_CHANGED);
        result = refresher;

        mergeState.getProject().isOpen(); result = true;
        ApplicationManager.getApplication(); result = application;
        application.isDispatchThread(); result = true;
        application.isHeadlessEnvironment(); result = true;
    }};

    handler.afterMerge();

    new Verifications() {{
        collector.collect(updatedFiles, (List<VcsException>) any);
        RefreshVFsSynchronously.updateAllChanged(updatedFiles);
        UpdateFilesHelper.iterateFileGroupFilesDeletedOnServerFirst(updatedFiles,
                (UpdateFilesHelper.Callback) any);

        mergeState.getLocalHistoryAction().finish();
        new UpdatedFilesNotifier(updatedFiles);
        updatedFilesNotifier.prepareNotificationWithUpdateInfo();

        updateInfoTree.expandRootChildren();
    }};
}
项目:consulo    文件:ViewUpdateInfoNotification.java   
public static void focusUpdateInfoTree(@Nonnull Project project, @Nonnull UpdateInfoTree updateInfoTree) {
  ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS).activate(() -> {
    ContentManager contentManager = ProjectLevelVcsManagerEx.getInstanceEx(project).getContentManager();
    if (contentManager != null) ContentUtilEx.selectContent(contentManager, updateInfoTree, true);
  }, true, true);
}