com.intellij.ui.content.Content Java Examples

The following examples show how to use com.intellij.ui.content.Content. 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: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
static FlutterConsole create(@NotNull Project project, @Nullable Module module) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.setViewer(true);
  if (module != null) {
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  final ConsoleView view = builder.getConsole();

  final SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
  panel.setContent(view.getComponent());

  final String title = module != null ? "[" + module.getName() + "] Flutter" : "Flutter";
  final Content content = ContentFactory.SERVICE.getInstance().createContent(panel.getComponent(), title, true);
  Disposer.register(content, view);

  return new FlutterConsole(view, content, project, module);
}
 
Example #2
Source File: TabContentLayout.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void contentAdded(ContentManagerEvent event) {
  final Content content = event.getContent();
  final ContentTabLabel tab;
  if (content instanceof TabbedContent) {
    tab = new TabbedContentTabLabel((TabbedContent)content, this);
  }
  else {
    tab = new ContentTabLabel(content, this);
  }
  myTabs.add(event.getIndex(), tab);
  myContent2Tabs.put(content, tab);
  if (content instanceof DnDTarget) {
    DnDTarget target = (DnDTarget)content;
    DnDSupport.createBuilder(tab).setDropHandler(target).setTargetChecker(target).setCleanUpOnLeaveCallback(target::cleanUpOnLeave).install();
  }
}
 
Example #3
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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());
}
 
Example #4
Source File: TodoCheckinHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void showTodo(TodoCheckinHandlerWorker worker) {
  String title = "For commit (" + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ")";
  ServiceManager.getService(myProject, TodoView.class).addCustomTodoView(new TodoTreeBuilderFactory() {
    @Override
    public TodoTreeBuilder createTreeBuilder(JTree tree, Project project) {
      return new CustomChangelistTodosTreeBuilder(tree, myProject, title, worker.inOneList());
    }
  }, title, new TodoPanelSettings(myConfiguration.myTodoPanelSettings));

  ApplicationManager.getApplication().invokeLater(() -> {
    ToolWindowManager manager = ToolWindowManager.getInstance(myProject);
    if (manager != null) {
      ToolWindow window = manager.getToolWindow("TODO");
      if (window != null) {
        window.show(() -> {
          ContentManager cm = window.getContentManager();
          Content[] contents = cm.getContents();
          if (contents.length > 0) {
            cm.setSelectedContent(contents[contents.length - 1], true);
          }
        });
      }
    }
  }, ModalityState.NON_MODAL, myProject.getDisposed());
}
 
Example #5
Source File: AbstractAutoTestManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void setAutoTestEnabled(@Nonnull RunContentDescriptor descriptor, @Nonnull ExecutionEnvironment environment, boolean enabled) {
  Content content = descriptor.getAttachedContent();
  if (content != null) {
    if (enabled) {
      myEnabledRunProfiles.add(environment.getRunProfile());
      myWatcher.activate();
    }
    else {
      myEnabledRunProfiles.remove(environment.getRunProfile());
      if (!hasEnabledAutoTests()) {
        myWatcher.deactivate();
      }
      ProcessHandler processHandler = descriptor.getProcessHandler();
      if (processHandler != null) {
        clearRestarterListener(processHandler);
      }
    }
  }
}
 
Example #6
Source File: ReviewDialog.java    From SmartIM4IntelliJ with Apache License 2.0 6 votes vote down vote up
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()) {
                        targetPanel.add(new GroupPanel(content.getDisplayName(), chats));
                    }
                }
            }
        }
    }
}
 
Example #7
Source File: DuneCompiler.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public ConsoleView getConsoleView() {
    ORToolWindowProvider windowProvider = ORToolWindowProvider.getInstance(project);
    ToolWindow duneToolWindow = windowProvider.getDuneToolWindow();
    Content windowContent = duneToolWindow.getContentManager().getContent(0);
    if (windowContent == null) {
        return null;
    }
    SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent();
    JComponent panelComponent = component.getComponent();
    if (panelComponent == null) {
        return null;
    }
    return (ConsoleView) panelComponent.getComponent(0);
}
 
Example #8
Source File: EmbeddedLinuxJVMConsoleView.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Creats the tool window content
 * @param toolWindow
 */
public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
    //Create runner UI layout
    RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(project);
    RunnerLayoutUi layoutUi = factory.create("", "", "session", project);

    // Adding actions
    DefaultActionGroup group = new DefaultActionGroup();
    layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);

    Content console = layoutUi.createContent(EmbeddedLinuxJVMToolWindowFactory.ID, consoleView.getComponent(), "", null, null);
    AnAction[] consoleActions = consoleView.createConsoleActions();
    for (AnAction action : consoleActions) {
        if (!shouldIgnoreAction(action)) {
            group.add(action);
        }
    }
    layoutUi.addContent(console, 0, PlaceInGrid.right, false);

    JComponent layoutComponent = layoutUi.getComponent();
    myConsolePanel.add(layoutComponent, BorderLayout.CENTER);
    Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
    toolWindow.getContentManager().addContent(content);
}
 
Example #9
Source File: MuleFacet.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void initFacet() {

    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            ToolWindowManager manager = ToolWindowManager.getInstance(MuleFacet.this.getModule().getProject());
            List<String> ids = Arrays.asList(manager.getToolWindowIds());

            if (manager.getToolWindow("Global Configs") == null && !ids.contains("Global Configs")) {

                try {
                    ToolWindow toolWindow = manager.registerToolWindow("Global Configs", true, ToolWindowAnchor.LEFT, false);
                    toolWindow.setIcon(MuleIcons.MuleIcon);

                    GlobalConfigsToolWindowPanel toolWindowPanel = new GlobalConfigsToolWindowPanel(MuleFacet.this.getModule().getProject());
                    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
                    Content content = contentFactory.createContent(toolWindowPanel, "", true);
                    toolWindow.getContentManager().addContent(content);
                } catch (Exception e) {
                    logger.error("Unable to initialize toolWindow: ", e);
                }
            }
        }
    });
}
 
Example #10
Source File: ProjectLevelVcsManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private Content getOrCreateConsoleContent(final ContentManager contentManager) {
  final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name");
  Content content = contentManager.findContent(displayName);
  if (content == null) {
    releaseConsole();

    myConsole = TextConsoleBuilderFactory.getInstance().createBuilder(myProject).getConsole();

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(myConsole.getComponent(), BorderLayout.CENTER);

    ActionToolbar toolbar = ActionManager.getInstance()
            .createActionToolbar("VcsManager", new DefaultActionGroup(myConsole.createConsoleActions()), false);
    panel.add(toolbar.getComponent(), BorderLayout.WEST);

    content = ContentFactory.getInstance().createContent(panel, displayName, true);
    content.setDisposer(myConsoleDisposer);
    contentManager.addContent(content);

    for (Pair<String, ConsoleViewContentType> pair : myPendingOutput) {
      printToConsole(pair.first, pair.second);
    }
    myPendingOutput.clear();
  }
  return content;
}
 
Example #11
Source File: QuickDocUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static DocumentationComponent getActiveDocComponent(@Nonnull Project project) {
  DocumentationManager documentationManager = DocumentationManager.getInstance(project);
  DocumentationComponent component;
  JBPopup hint = documentationManager.getDocInfoHint();
  if (hint != null) {
    component = (DocumentationComponent)((AbstractPopup)hint).getComponent();
  }
  else if (documentationManager.hasActiveDockedDocWindow()) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION);
    Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent();
    component = selectedContent == null ? null : (DocumentationComponent)selectedContent.getComponent();
  }
  else {
    component = EditorMouseHoverPopupManager.getInstance().getDocumentationComponent();
  }
  return component;
}
 
Example #12
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
static FlutterConsole create(@NotNull Project project, @Nullable Module module) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.setViewer(true);
  if (module != null) {
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  final ConsoleView view = builder.getConsole();

  final SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
  panel.setContent(view.getComponent());

  final String title = module != null ? "[" + module.getName() + "] Flutter" : "Flutter";
  final Content content = ContentFactory.SERVICE.getInstance().createContent(panel.getComponent(), title, true);
  Disposer.register(content, view);

  return new FlutterConsole(view, content, project, module);
}
 
Example #13
Source File: FlutterDebugProcess.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Turn off debug-only views (variables and frames).
 */
private static void suppressDebugViews(@Nullable RunnerLayoutUi ui) {
  if (ui == null) {
    return;
  }

  for (Content c : ui.getContents()) {
    if (!Objects.equals(c.getTabName(), "Console")) {
      try {
        GuiUtils.runOrInvokeAndWait(() -> ui.removeContent(c, false /* dispose? */));
      }
      catch (InvocationTargetException | InterruptedException e) {
        FlutterUtils.warn(LOG, e);
      }
    }
  }
}
 
Example #14
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void removeContents(Content notToRemove, final String tabDisplayName) {
  MessageView messageView = MessageView.SERVICE.getInstance(myProject);
  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();
        }
      }
    }
  }
}
 
Example #15
Source File: FindInProjectUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void showSettings() {
  Content selectedContent = UsageViewContentManager.getInstance(myProject).getSelectedContent(true);
  JComponent component = selectedContent == null ? null : selectedContent.getComponent();
  FindInProjectManager findInProjectManager = FindInProjectManager.getInstance(myProject);
  findInProjectManager.findInProject(DataManager.getInstance().getDataContext(component), myFindModel);
}
 
Example #16
Source File: GridCellImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
void add(final Content content) {
  if (myContents.containsKey(content)) return;
  myContents.put(content, null);

  revalidateCell(() -> myTabs.addTab(createTabInfoFor(content)));

  updateSelection(myTabs.getComponent().getRootPane() != null);
}
 
Example #17
Source File: VcsDockedComponent.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
public boolean addVcsTab(@NotNull @NonNls String title,
        @NotNull JComponent component,
        boolean showTab,
        boolean replaceExistingComponent) {
    if (component instanceof Disposable) {
        Disposer.register(this, (Disposable) component);
    }
    final ToolWindow toolW = getToolWindow();
    if (toolW == null) {
        // cannot do anything
        return false;
    }
    final ContentManager contentManager = getToolWindow().getContentManager();
    final Content existingContent = contentManager.findContent(title);
    if (existingContent != null) {
        if (!replaceExistingComponent) {
            contentManager.setSelectedContent(existingContent);
            return true;
        }
        else if (!existingContent.isPinned()) {
            contentManager.removeContent(existingContent, true);
            existingContent.release();
        }
    }

    final Content content = contentManager.getFactory().createContent(component, title, false);
    contentManager.addContent(content);
    if (showTab) {
        getToolWindow().activate(null, false);
    }

    return true;
}
 
Example #18
Source File: DWToolWindowFactory.java    From intellij-demandware with MIT License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    DWConsoleService consoleService = ServiceManager.getService(project, DWConsoleService.class);
    ConsoleView consoleView = consoleService.getConsoleView();
    Content content = toolWindow.getContentManager().getFactory().createContent(consoleView.getComponent(), "", true);
    toolWindow.getContentManager().addContent(content);
}
 
Example #19
Source File: PinActiveTabAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Content getToolWindowContent(@Nonnull AnActionEvent e) {
  // note to future readers: TW tab "pinned" icon is shown when content.getUserData(TW.SHOW_CONTENT_ICON) is true
  ToolWindow window = e.getData(PlatformDataKeys.TOOL_WINDOW);
  Content result = window != null ? window.getContentManager().getSelectedContent() : null;
  return result != null && result.isPinnable() ? result : null;
}
 
Example #20
Source File: ServersToolWindowFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@Nonnull Project project, @Nonnull ToolWindow toolWindow) {
  ContentManager contentManager = toolWindow.getContentManager();

  final ServersToolWindowContent serversContent = new ServersToolWindowContent(project);

  Content content = contentManager.getFactory().createContent(serversContent, null, false);
  content.setDisposer(serversContent);
  
  contentManager.addContent(content);
}
 
Example #21
Source File: LayoutAttractionPolicy.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void attract(final Content content, final RunnerLayoutUi ui) {
  if (!myWasAttracted) {
    myWasAttracted = true;
    ui.selectAndFocus(content, myRequestFocus, true, true);
  } else {
    ui.setBouncing(content, true);
  }
}
 
Example #22
Source File: ToolWindowHeadlessManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void addContent(@Nonnull Content content, int order) {
  myContents.add(order, content);
  Disposer.register(this, content);
  ContentManagerEvent e = new ContentManagerEvent(this, content, myContents.indexOf(content), ContentManagerEvent.ContentOperation.add);
  myDispatcher.getMulticaster().contentAdded(e);
  if (mySelected == null) setSelectedContent(content);
}
 
Example #23
Source File: CompleteReviewAction.java    From Crucible4IDEA with MIT License 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(PlatformDataKeys.PROJECT);
  if (project == null) return;
  CrucibleManager.getInstance(project).completeReview(myReview.getPermaId());
  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CrucibleBundle.message("crucible.toolwindow.id"));
  final ContentManager contentManager = toolWindow.getContentManager();
  final Content foundContent = contentManager.findContent("Details for " + myReview.getPermaId());
  contentManager.removeContent(foundContent, true);

  final Content dash = contentManager.findContent("Dashboard");
  if (dash.getComponent() instanceof CruciblePanel) {
    ((CruciblePanel)dash.getComponent()).getReviewModel().updateModel(CrucibleFilter.ToReview);
  }
}
 
Example #24
Source File: BlazeProblemsView.java    From intellij with Apache License 2.0 5 votes vote down vote up
private void createToolWindow(
    Project project, ToolWindowManager wm, BlazeProblemsViewPanel panel) {
  if (project.isDisposed()) {
    return;
  }
  ToolWindow toolWindow =
      wm.registerToolWindow(toolWindowId, false, ToolWindowAnchor.BOTTOM, project, true);
  Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
  toolWindow.getContentManager().addContent(content);
  Disposer.register(project, () -> toolWindow.getContentManager().removeAllContents(true));
  updateIcon(panel);
}
 
Example #25
Source File: CloseAllViewsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean isEnabled(ViewContext context, Content[] content, String place) {
  int closeable = 0;
  for (Content c : context.getContentManager().getContents()) {
    if (c.isCloseable()) closeable ++;
  }
  return closeable > 1;
}
 
Example #26
Source File: TestResultPanelFactory.java    From tmc-intellij with MIT License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    logger.info("Creating tool window content for test results. " + "@TestResultPanelFactory");

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

    panels.add(panel);
}
 
Example #27
Source File: XDebugSessionTab.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Content createWatchesContent(@Nonnull XDebugSessionImpl session) {
  myWatchesView = new XWatchesViewImpl(session, myWatchesInVariables);
  registerView(DebuggerContentInfo.WATCHES_CONTENT, myWatchesView);
  Content watchesContent =
          myUi.createContent(DebuggerContentInfo.WATCHES_CONTENT, myWatchesView.getPanel(), XDebuggerBundle.message("debugger.session.tab.watches.title"),
                             AllIcons.Debugger.Watches, null);
  watchesContent.setCloseable(false);
  return watchesContent;
}
 
Example #28
Source File: GridImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public Object getData(@Nonnull @NonNls final Key<?> dataId) {
  if (ViewContext.CONTEXT_KEY == dataId) {
    return myViewContext;
  }
  else if (ViewContext.CONTENT_KEY == dataId) {
    List<Content> contents = getContents();
    return contents.toArray(new Content[contents.size()]);
  }
  return null;
}
 
Example #29
Source File: VcsLogTabsWatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void contentRemoved(ContentManagerEvent event) {
  Content content = event.getContent();
  if (content instanceof TabbedContent) {
    content.removePropertyChangeListener(this);
  }
}
 
Example #30
Source File: RunnerLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 *   States of contents marked as "lightweight" won't be persisted
 */
public void setLightWeight(Content content) {
  if (myLightWeightIds == null) {
    myLightWeightIds = new HashSet<>();
  }
  myLightWeightIds.add(getOrCreateContentId(content));
}