Java 类com.intellij.ui.content.Content 实例源码

项目:IdeaCurrency    文件:IdeaCurrencyToolWindow.java   
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Set<SelectedExchangeCurrencyPair> selectedExchangeCurrencyPairs = IdeaCurrencyConfig.getInstance().getSelectedExchangeCurrencyPairs();
    if (IdeaCurrencyConfig.getInstance().getActive()) {
        List<TickerDto> data = IdeaCurrencyApp.getInstance().getTickers(selectedExchangeCurrencyPairs);
        fillData(data);
    }
    Content content = contentFactory.createContent(contentPane, "", false);
    toolWindow.getContentManager().addContent(content);

    MessageBus messageBus = project.getMessageBus();
    messageBusConnection = messageBus.connect();
    messageBusConnection.subscribe(ConfigChangeNotifier.CONFIG_TOPIC, active -> {
        if (active) {
            scheduleNextTask();
        }
    });
}
项目:react-native-console    文件:ReactNativeConsole.java   
/**
 * 获取 RN Console实例.
 *
 * @param displayName - the tab's display name must be unique.
 * @param icon        - used to set a tab icon, not used for search
 * @return
 */
public RNConsoleImpl getRNConsole(String displayName, Icon icon) {
    ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
    if (window != null) {
        Content existingContent = createConsoleTabContent(window, false, displayName, icon);
        if (existingContent != null) {
            final JComponent existingComponent = existingContent.getComponent();

            if (existingComponent instanceof SimpleToolWindowPanel) {
                JComponent component = ((SimpleToolWindowPanel) existingComponent).getContent();
                if (component instanceof RNConsoleImpl) {
                    RNConsoleImpl rnConsole = (RNConsoleImpl) component;
                    return rnConsole;
                }
            }
        }
    }

    return null;
}
项目:react-native-console    文件:ReactNativeTerminal.java   
/**
 * Create a terminal panel
 *
 * @param terminalRunner
 * @param toolWindow
 * @return
 */
private Content createTerminalInContentPanel(@NotNull AbstractTerminalRunner terminalRunner, @NotNull final ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(true);
    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);
    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(this);

    createToolbar(terminalRunner, myTerminalWidget, toolWindow, panel);// west toolbar

    ActionToolbar toolbar = createTopToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent(), false);

    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());
    return content;
}
项目:reasonml-idea-plugin    文件:BsToolWindowFactory.java   
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    BsConsole console = new BsConsole(project);
    panel.setContent(console.getComponent());

    ActionToolbar toolbar = console.createToolbar();
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);
    toolWindow.getContentManager().addContent(content);

    // Start compiler
    BsCompiler bsc = BucklescriptProjectComponent.getInstance(project).getCompiler();
    if (bsc != null) {
        bsc.addListener(new BsOutputListener(project));
        ProcessHandler handler = bsc.getHandler();
        if (handler == null) {
            console.print("Bsb not found, check the event logs.", ERROR_OUTPUT);
        } else {
            console.attachToProcess(handler);
        }
        bsc.startNotify();
    }
}
项目:SmartQQ4IntelliJ    文件:ReviewDialog.java   
private void updateTarget() {
    targetPanel.setLayout(new GridLayout(0, 1, 0, 0));
    if (IMWindowFactory.getDefault() == null || IMWindowFactory.getDefault().getProject() == null) {
        return;
    }
    ToolWindow window = ToolWindowManager.getInstance(IMWindowFactory.getDefault().getProject()).getToolWindow(IMWindowFactory.TOOL_WINDOW_ID);
    if (window != null) {
        Content[] contents = window.getContentManager().getContents();
        if (contents != null) {
            for (Content content : contents) {
                if (content.getComponent() != null && content.getComponent() instanceof IMPanel) {
                    IMPanel panel = (IMPanel) content.getComponent();
                    List<IMChatConsole> chats = panel.getConsoleList();
                    if (!chats.isEmpty()) {
                        consoles.addAll(chats);
                        targetPanel.add(new GroupPanel(content.getDisplayName(), chats));
                    }
                }
            }
        }
    }
}
项目:educational-plugin    文件:StudyUtils.java   
@Nullable
public static StudyToolWindow getStudyToolWindow(@NotNull final Project project) {
  if (project.isDisposed()) return null;

  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
  if (toolWindow != null) {
    Content[] contents = toolWindow.getContentManager().getContents();
    for (Content content: contents) {
      JComponent component = content.getComponent();
      if (component != null && component instanceof StudyToolWindow) {
        return (StudyToolWindow)component;
      }
    }
  }
  return null;
}
项目:educational-plugin    文件:StudyToolWindowFactory.java   
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
  toolWindow.setIcon(EducationalCoreIcons.TaskDescription);
  final Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course != null) {
    final StudyToolWindow studyToolWindow;
    if (StudyUtils.hasJavaFx() && StudySettings.getInstance().shouldUseJavaFx()) {
      studyToolWindow = new StudyJavaFxToolWindow();
    }
    else {
      studyToolWindow = new StudySwingToolWindow();
    }
    studyToolWindow.init(project, true);
    final ContentManager contentManager = toolWindow.getContentManager();
    final Content content = contentManager.getFactory().createContent(studyToolWindow, null, false);
    contentManager.addContent(content);
    Disposer.register(project, studyToolWindow);
  }
}
项目:educational-plugin    文件:StudyCheckUtils.java   
public static void showTestResultsToolWindow(@NotNull final Project project, @NotNull final String message) {
  ApplicationManager.getApplication().invokeLater(() -> {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
    if (window == null) {
      toolWindowManager.registerToolWindow(StudyTestResultsToolWindowFactoryKt.ID, true, ToolWindowAnchor.BOTTOM);
      window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
      new StudyTestResultsToolWindowFactory().createToolWindowContent(project, window);
    }

    final Content[] contents = window.getContentManager().getContents();
    for (Content content : contents) {
      final JComponent component = content.getComponent();
      if (component instanceof ConsoleViewImpl) {
        ((ConsoleViewImpl)component).clear();
        ((ConsoleViewImpl)component).print(message, ConsoleViewContentType.ERROR_OUTPUT);
        window.setAvailable(true,null);
        window.show(null);
      }
    }
  });
}
项目:intellij-mattermost-plugin    文件:MattermostClientWindow.java   
private void createChat(MMUserStatus user) throws IOException, URISyntaxException {
    Channel.ChannelData channel = client.createChat(user.userId());
    if (channel == null) {
        Notifications.Bus.notify(new Notification("mattermost", "channel error", "no channel found for " + user.username(), NotificationType.ERROR));
        return;
    }
    SwingUtilities.invokeLater(() -> {
        String name = user.username();
        Chat chat = this.channelIdChatMap.computeIfAbsent(channel.getId(), k -> new Chat());
        chat.channelId = channel.getId();
        if (this.toolWindow.getContentManager().getContent(chat) == null) {
            Content messages = ContentFactory.SERVICE.getInstance().createContent(chat, name, false);
            messages.setIcon(TEAM);
            this.toolWindow.getContentManager().addContent(messages);
            this.toolWindow.getContentManager().setSelectedContent(messages);
        } else {
            Content c = this.toolWindow.getContentManager().getContent(chat);
            this.toolWindow.getContentManager().setSelectedContent(c);
        }
        SwingUtilities.invokeLater(chat.inputArea::grabFocus);
    });
}
项目:intellij-basisjs-plugin    文件:InspectorWindow.java   
public void createWindow(Project project) {
    jFXPanel = new JFXPanel();
    ToolWindow toolWindow = ToolWindowManager.getInstance(project).registerToolWindow("Basis.js", false, ToolWindowAnchor.BOTTOM, false);
    toolWindow.setIcon(IconLoader.getIcon("/icons/basisjs.png"));
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(jFXPanel, "inspector", false);
    toolWindow.getContentManager().addContent(content);

    InspectorController sceneInspectorController = new InspectorController();
    FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(getClass().getResource("/com/basisjs/ui/windows/tools/inspector/InspectorScene.fxml"));
    fxmlLoader.setController(sceneInspectorController);

    Platform.setImplicitExit(false);
    PlatformImpl.runLater(() -> {
        try {
            Scene scene = new Scene(fxmlLoader.load());
            jFXPanel.setScene(scene);
            webView = sceneInspectorController.webView;
            webView.setContextMenuEnabled(false);
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
}
项目:intellij-ce-playground    文件:BrowseRepositoryAction.java   
public void actionPerformed(AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    RepositoryBrowserDialog dialog = new RepositoryBrowserDialog(ProjectManager.getInstance().getDefaultProject());
    dialog.show();
  }
  else {
    ToolWindowManager manager = ToolWindowManager.getInstance(project);
    ToolWindow w = manager.getToolWindow(REPOSITORY_BROWSER_TOOLWINDOW);
    if (w == null) {
      RepositoryToolWindowPanel component = new RepositoryToolWindowPanel(project);
      w = manager.registerToolWindow(REPOSITORY_BROWSER_TOOLWINDOW, true, ToolWindowAnchor.BOTTOM, project, true);
      final Content content = ContentFactory.SERVICE.getInstance().createContent(component, "", false);
      Disposer.register(content, component);
      w.getContentManager().addContent(content);
    }
    w.show(null);
    w.activate(null);
  }
}
项目:intellij-ce-playground    文件:LogcatExecutionConsole.java   
LogcatExecutionConsole(Project project,
                       IDevice device,
                       @NotNull ConsoleView consoleView,
                       String configurationId) {
  myProject = project;
  myConsoleView = consoleView;
  myConfigurationId = configurationId;
  myToolWindowView = new AndroidLogcatView(project, device) {
    @Override
    protected boolean isActive() {
      final XDebugSession session = XDebuggerManager.getInstance(myProject).getDebugSession(LogcatExecutionConsole.this);
      if (session == null) {
        return false;
      }
      final Content content = session.getUI().findContent(AndroidDebugRunner.ANDROID_LOGCAT_CONTENT_ID);
      return content != null && content.isSelected();
    }
  };
  Disposer.register(this, myToolWindowView);
}
项目:intellij-ce-playground    文件:ProjectViewImpl.java   
@Override
public synchronized void removeProjectPane(@NotNull AbstractProjectViewPane pane) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  myUninitializedPanes.remove(pane);
  //assume we are completely initialized here
  String idToRemove = pane.getId();

  if (!myId2Pane.containsKey(idToRemove)) return;
  pane.removeTreeChangeListener();
  for (int i = myContentManager.getContentCount() - 1; i >= 0; i--) {
    Content content = myContentManager.getContent(i);
    String id = content != null ? content.getUserData(ID_KEY) : null;
    if (id != null && id.equals(idToRemove)) {
      myContentManager.removeContent(content, true);
    }
  }
  myId2Pane.remove(idToRemove);
  mySelectInTargets.remove(idToRemove);
  viewSelectionChanged();
}
项目:intellij-ce-playground    文件:RunnerLayoutUiImpl.java   
@Override
@NotNull
public Content createContent(@NotNull final String contentId, @NotNull final ComponentWithActions withActions, @NotNull final String displayName,
                             @Nullable final Icon icon,
                             @Nullable final JComponent toFocus) {
  final Content content = getContentFactory().createContent(withActions.getComponent(), displayName, false);
  content.putUserData(CONTENT_TYPE, contentId);
  content.putUserData(ViewImpl.ID, contentId);
  content.setIcon(icon);
  if (toFocus != null) {
    content.setPreferredFocusableComponent(toFocus);
  }

  if (!withActions.isContentBuiltIn()) {
    content.setSearchComponent(withActions.getSearchComponent());
    content.setActions(withActions.getToolbarActions(), withActions.getToolbarPlace(), withActions.getToolbarContextComponent());
  }

  return content;
}
项目:intellij-ce-playground    文件:ExecutionHelper.java   
private static void removeContents(@Nullable final Content notToRemove,
                                   @NotNull final Project myProject,
                                   @NotNull final String tabDisplayName) {
  MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
  Content[] contents = messageView.getContentManager().getContents();
  for (Content content : contents) {
    LOG.assertTrue(content != null);
    if (content.isPinned()) continue;
    if (tabDisplayName.equals(content.getDisplayName()) && content != notToRemove) {
      ErrorTreeView listErrorView = (ErrorTreeView)content.getComponent();
      if (listErrorView != null) {
        if (messageView.getContentManager().removeContent(content, true)) {
          content.release();
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:CopyHandler.java   
static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) {
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  if (id != null) {
    ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id);
    Content selectedContent = window.getContentManager().getSelectedContent();
    if (selectedContent != null) {
      JComponent component = selectedContent.getComponent();
      if (component instanceof TwoPaneIdeView) {
        ((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel);
        return;
      }
    }
  }
  if (ToolWindowId.PROJECT_VIEW.equals(id)) {
    ProjectView.getInstance(project).selectPsiElement(newElement, true);
  }
  else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) {
    VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile();
    FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile);
    StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true);
  }
}
项目:intellij-ce-playground    文件:PyEduDebugRunner.java   
@Override
protected void initSession(XDebugSession session, RunProfileState state, Executor executor) {
  XDebugSessionTab tab = ((XDebugSessionImpl)session).getSessionTab();
  if (tab != null) {
    RunnerLayoutUi ui = tab.getUi();
    ContentManager contentManager = ui.getContentManager();
    Content content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.watches.title"));
    if (content != null) {
      contentManager.removeContent(content, true);
    }
    content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.console.content.name"));
    if (content != null) {
      contentManager.removeContent(content, true);
    }
    initEduConsole(session, ui);
  }
}
项目:intellij-ce-playground    文件:AndroidRunningState.java   
protected static void clearLogcatAndConsole(@NotNull final Project project, @NotNull final IDevice device) {
  ApplicationManager.getApplication().invokeAndWait(new Runnable() {
    @Override
    public void run() {
      final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(AndroidToolWindowFactory.TOOL_WINDOW_ID);
      if (toolWindow == null) {
        return;
      }

      for (Content content : toolWindow.getContentManager().getContents()) {
        final AndroidLogcatView view = content.getUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY);

        if (view != null) {
          view.clearLogcat(device);
        }
      }
    }
  }, ModalityState.defaultModalityState());
}
项目:intellij-ce-playground    文件:ContentsUtil.java   
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);
  }
}
项目:intellij-ce-playground    文件:ConsoleManager.java   
private void createConsole(@NotNull final NetService netService) {
  TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(netService.getProject());
  netService.configureConsole(consoleBuilder);
  console = consoleBuilder.getConsole();

  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      ActionGroup actionGroup = netService.getConsoleToolWindowActions();
      ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false);

      SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true);
      toolWindowPanel.setContent(console.getComponent());
      toolWindowPanel.setToolbar(toolbar.getComponent());

      ToolWindow toolWindow = ToolWindowManager.getInstance(netService.getProject())
        .registerToolWindow(netService.getConsoleToolWindowId(), false, ToolWindowAnchor.BOTTOM, netService.getProject(), true);
      toolWindow.setIcon(netService.getConsoleToolWindowIcon());

      Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel, "", false);
      Disposer.register(content, console);

      toolWindow.getContentManager().addContent(content);
    }
  }, netService.getProject().getDisposed());
}
项目:intellij-ce-playground    文件:ToolWindowFixture.java   
@Nullable
protected Content getContent(@NotNull final TextMatcher displayNameMatcher) {
  activateAndWaitUntilIsVisible();
  final Ref<Content> contentRef = new Ref<Content>();
  pause(new Condition("finding content matching " + displayNameMatcher.formattedValues()) {
    @Override
    public boolean test() {
      Content[] contents = getContents();
      for (Content content : contents) {
        String displayName = content.getDisplayName();
        if (displayNameMatcher.isMatching(displayName)) {
          contentRef.set(content);
          return true;
        }
      }
      return false;
    }
  }, SHORT_TIMEOUT);
  return contentRef.get();
}
项目:intellij-ce-playground    文件:DebuggerSessionTabBase.java   
protected void attachNotificationTo(final Content content) {
  if (myConsole instanceof ObservableConsoleView) {
    ObservableConsoleView observable = (ObservableConsoleView)myConsole;
    observable.addChangeListener(new ObservableConsoleView.ChangeListener() {
      @Override
      public void contentAdded(final Collection<ConsoleViewContentType> types) {
        if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
          content.fireAlert();
        }
      }
    }, content);
    RunProfile profile = getRunProfile();
    if (profile instanceof RunConfigurationBase && !ApplicationManager.getApplication().isUnitTestMode()) {
      observable.addChangeListener(new RunContentBuilder.ConsoleToFrontListener((RunConfigurationBase)profile,
                                                                                myProject,
                                                                                DefaultDebugExecutor.getDebugExecutorInstance(),
                                                                                myRunContentDescriptor,
                                                                                myUi),
                                   content);
    }
  }
}
项目:intellij-ce-playground    文件:GridCellImpl.java   
public void minimize(Content[] contents) {
  myContext.saveUiState();

  for (final Content each : contents) {
    myMinimizedContents.add(each);
    remove(each);
    boolean isShowing = myTabs.getComponent().getRootPane() != null;
    updateSelection(isShowing);
    myContainer.minimize(each, new CellTransform.Restore() {
      @Override
      public ActionCallback restoreInGrid() {
        return restore(each);
      }
    });
  }
}
项目:intellij-ce-playground    文件:GitShowExternalLogAction.java   
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;
}
项目:intellij-ce-playground    文件:ContentUtilEx.java   
/**
 * 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;
}
项目:intellij-ce-playground    文件:MvcConsole.java   
private Content setUpToolWindow() {
  //Create runner UI layout
  final RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(myProject);
  final RunnerLayoutUi layoutUi = factory.create("", "", "session", myProject);

  // Adding actions
  DefaultActionGroup group = new DefaultActionGroup();
  group.add(myKillAction);
  group.addSeparator();

  layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);

  final Content console = layoutUi.createContent(CONSOLE_ID, myConsole.getComponent(), "", null, null);
  layoutUi.addContent(console, 0, PlaceInGrid.right, false);

  final JComponent uiComponent = layoutUi.getComponent();
  myPanel.add(uiComponent, BorderLayout.CENTER);

  final ContentManager manager = myToolWindow.getContentManager();
  final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
  final Content content = contentFactory.createContent(uiComponent, null, true);
  manager.addContent(content);
  return content;
}
项目:intellij-ce-playground    文件:DesignerToolWindowManager.java   
@Override
protected void initToolWindow() {
  myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer.name"),
                                                                             false, getAnchor(), myProject, true);
  myToolWindow.setIcon(UIDesignerIcons.ToolWindowUIDesigner);

  if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
    myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
  }

  initGearActions();

  ContentManager contentManager = myToolWindow.getContentManager();
  Content content =
    contentManager.getFactory()
      .createContent(myToolWindowPanel.getToolWindowPanel(), UIDesignerBundle.message("toolwindow.ui.designer.title"), false);
  content.setCloseable(false);
  content.setPreferredFocusableComponent(myToolWindowPanel.getComponentTree());
  contentManager.addContent(content);
  contentManager.setSelectedContent(content, true);
  myToolWindow.setAvailable(false, null);
}
项目:intellij-ce-playground    文件:LafManagerImpl.java   
public static void updateToolWindows() {
  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    for (String id : toolWindowManager.getToolWindowIds()) {
      final ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
      for (Content content : toolWindow.getContentManager().getContents()) {
        final JComponent component = content.getComponent();
        if (component != null) {
          IJSwingUtilities.updateComponentTreeUI(component);
        }
      }
      final JComponent c = toolWindow.getComponent();
      if (c != null) {
        IJSwingUtilities.updateComponentTreeUI(c);
      }
    }
  }
}
项目:intellij-ce-playground    文件:MinimizeViewAction.java   
public static boolean isEnabled(ViewContext context, Content[] content, String place) {
  if (!context.isMinimizeActionEnabled() || content.length == 0) {
    return false;
  }

  if (ViewContext.TAB_TOOLBAR_PLACE.equals(place) || ViewContext.TAB_POPUP_PLACE.equals(place)) {
    Tab tab = getTabFor(context, content);
    if (tab == null) {
      return false;
    }
    return !tab.isDefault() && content.length == 1;
  }
  else {
    return getTabFor(context, content) != null;
  }
}
项目:react-native-console    文件:ReactNativeConsole.java   
public void initTerminal(final ToolWindow toolWindow) {
        toolWindow.setToHideOnEmptyContent(true);
        toolWindow.setStripeTitle("RN Console");
        toolWindow.setIcon(PluginIcons.React);
        Content content = createConsoleTabContent(toolWindow, true, "Welcome", null);
//        toolWindow.getContentManager().addContent(content);
//        toolWindow.getContentManager().addContent(new ContentImpl(new JButton("Test"), "Build2", false));

        // ======= test a terminal create ======
//        LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
//        Content testTerminalContent = createTerminalInContentPanel(terminalRunner, toolWindow);
//        toolWindow.getContentManager().addContent(testTerminalContent);

//        SimpleTerminal term  = new SimpleTerminal();
//        term.sendString("ls\n");
//        toolWindow.getContentManager().addContent(new ContentImpl(term.getComponent(), "terminal", false));
        toolWindow.setShowStripeButton(true);// if set to false, then sometimes the window will be hidden from the dock area for ever 2017-05-26
//        toolWindow.setTitle(" - ");
        ((ToolWindowManagerEx) ToolWindowManager.getInstance(this.myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
            @Override
            public void toolWindowRegistered(@NotNull String s) {
            }

            @Override
            public void stateChanged() {
                ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
                if (window != null) {
                    boolean visible = window.isVisible();
                    if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                        initTerminal(window);
                    }
                }
            }
        });
        toolWindow.show(null);
    }
项目:react-native-console    文件:ReactNativeTerminal.java   
public void initTerminal(final ToolWindow toolWindow) {
    toolWindow.setToHideOnEmptyContent(true);
    LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
    myTerminalRunner = terminalRunner;
    toolWindow.setStripeTitle("React Native");
    Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
    toolWindow.getContentManager().addContent(content);
    toolWindow.setShowStripeButton(true);
    toolWindow.setTitle("Console");
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(this.myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
        @Override
        public void toolWindowRegistered(@NotNull String s) {

        }

        @Override
        public void stateChanged() {
            ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
            if (window != null) {
                boolean visible = window.isVisible();
                if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                    initTerminal(window);
                }
            }
        }
    });
    toolWindow.show(null);
    JBTabbedTerminalWidget terminalWidget = getTerminalWidget(toolWindow);
    if (terminalWidget != null && terminalWidget.getCurrentSession() != null) {
        Terminal terminal = terminalWidget.getCurrentSession().getTerminal();
        if (terminal != null) {
            terminal.setCursorVisible(true);// 是否启用光标 BeanSoft
        }
    }
}
项目:react-native-console    文件:ReactNativeTerminal.java   
private void openSession(@NotNull ToolWindow toolWindow, @NotNull AbstractTerminalRunner terminalRunner) {
    if (this.myTerminalWidget == null) {
        toolWindow.getContentManager().removeAllContents(true);
        Content content = this.createTerminalInContentPanel(terminalRunner, toolWindow);
        toolWindow.getContentManager().addContent(content);
    } else {
        terminalRunner.openSession(this.myTerminalWidget);
    }

    toolWindow.activate(() -> {
    }, true);
}
项目:react-native-console    文件:RNUtil.java   
public static void addAdditionalConsoleEditorActions(final ConsoleView console, final Content consoleContent) {
    final DefaultActionGroup consoleActions = new DefaultActionGroup();
        for (AnAction action : console.createConsoleActions()) {
            consoleActions.add(action);
        }

    consoleContent.setActions(consoleActions, ActionPlaces.RUNNER_TOOLBAR, console.getComponent());
}
项目:intellij-circleci-integration    文件:RecentBuildsToolWindowFactory.java   
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(pnlMain, "", false);
    toolWindow.getContentManager().addContent(content);
    toolWindow.setIcon(Icons.PLUGIN_ICON);

    addBtnRefreshListener();
    addBtnGroupProjectListener();
    addBtnGroupCommitterListener();
    addBtnResetListener();
}
项目:reasonml-idea-plugin    文件:BucklescriptProjectComponent.java   
private BsConsole getBsbConsole() {
    BsConsole console = null;

    ToolWindow window = ToolWindowManager.getInstance(m_project).getToolWindow("Bucklescript");
    Content windowContent = window.getContentManager().getContent(0);
    if (windowContent != null) {
        SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent();
        JComponent panelComponent = component.getComponent();
        if (panelComponent != null) {
            console = (BsConsole) panelComponent.getComponent(0);
        }
    }

    return console;
}
项目:SmartQQ4IntelliJ    文件:IMWindowFactory.java   
private void createContents(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    SmartQQPanel qqPanel = new SmartQQPanel(project, toolWindow);
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(qqPanel, "SmartQQ", false);
    toolWindow.getContentManager().addContent(content, 0);

    WechatPanel wechatPanel = new WechatPanel(project, toolWindow);
    content = contentFactory.createContent(wechatPanel, "Wechat", false);
    toolWindow.getContentManager().addContent(content, 1);
}
项目:SmartQQ4IntelliJ    文件:IMWindowFactory.java   
private Content createContentPanel(Project project, ToolWindow toolWindow) {
    System.out.println("project:" + project);
    panel = new SmartQQPanel(project, toolWindow);
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(panel, "", false);
    return content;
}
项目:date-time-converter-plugin    文件:DateTimeConverterWindowFactory.java   
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    final DateTimeConverterView view = project.getComponent(DateTimeConverterView.class);
    view.getModel().addRow(DateTimeUtil.nowGasDay());

    final Content content = ContentFactory.SERVICE.getInstance().createContent(view.getComponent(), "", false);
    content.setCloseable(true);

    toolWindow.getContentManager().addContent(content);
}
项目:Gherkin-TS-Runner    文件:GherkinIconRenderer.java   
private void callProtractor() {
    try {
        Config config = Config.getInstance(project);

        if (config == null) {
            return;
        }

        GeneralCommandLine command = getProtractorRunCommand(config);
        Process p = command.createProcess();

        if (project != null) {
            ToolWindowManager manager = ToolWindowManager.getInstance(project);
            String id = "Gherkin Runner";
            TextConsoleBuilderFactory factory = TextConsoleBuilderFactory.getInstance();
            TextConsoleBuilder builder = factory.createBuilder(project);
            ConsoleView view = builder.getConsole();

            ColoredProcessHandler handler = new ColoredProcessHandler(p, command.getPreparedCommandLine());
            handler.startNotify();
            view.attachToProcess(handler);

            ToolWindow window = manager.getToolWindow(id);
            Icon cucumberIcon = IconLoader.findIcon("/resources/icons/cucumber.png");

            if (window == null) {
                window = manager.registerToolWindow(id, true, ToolWindowAnchor.BOTTOM);
                window.setIcon(cucumberIcon);
            }

            ContentFactory cf = window.getContentManager().getFactory();
            Content c = cf.createContent(view.getComponent(), "Run " + (window.getContentManager().getContentCount() + 1), true);

            window.getContentManager().addContent(c);
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}
项目:MCPluginDebuggerforIDEA    文件:DebugToolWindowFactory.java   
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    this.project = project;
    this.config = PluginDataConfig.getInstance(project);
    if (this.config != null) this.config.init(project);
    processManager = new ServerProcessManager(this.config, line -> {
        if (line.equals("STX")) outTextArea.setText("");
        else outTextArea.append(line + "\n");
    });
    ((DefaultCaret) outTextArea.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    Content content = ContentFactory.SERVICE.getInstance().createContent(mainPanel, "", false);
    toolWindow.getContentManager().addContent(content);
    setValues();
    setListeners();
}