com.intellij.openapi.wm.ToolWindow Java Examples

The following examples show how to use com.intellij.openapi.wm.ToolWindow. 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: 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 #2
Source File: NextError.java    From mypy-PyCharm-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    if (project == null) {
        return;
    }
    ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(
            MypyToolWindowFactory.MYPY_PLUGIN_ID);
    if (!tw.isVisible()) {
        tw.show(null);
    }
    MypyTerminal terminal = MypyToolWindowFactory.getMypyTerminal(project);
    if (terminal == null) {
        return;
    }
    if (terminal.getRunner().isRunning()) {
        return;
    }
    int total = terminal.getErrorsList().getItemsCount();
    int current = terminal.getErrorsList().getSelectedIndex();
    if (current < total) {
        terminal.getErrorsList().setSelectedIndex(current + 1);
    }
}
 
Example #3
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
public void asyncViewSwitch() {
  /**
   * Make sure the project view opened so the view switch will follow.
   */
  final ToolWindow projectWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
  if (projectWindow == null) {
    return;
  }
  ApplicationManager.getApplication().invokeLater(() -> {
    // Show Project Pane, and switch to ProjectFilesViewPane right after.
    projectWindow.show(() -> {
      ProjectView.getInstance(myProject).changeView(ProjectFilesViewPane.ID);
      // Disable directory focus as it may cause too much stress when
      // there is heavy indexing load right after project import.
      // https://youtrack.jetbrains.com/issue/IDEA-204959
      // queueFocusOnImportDirectory();
    });
  });
}
 
Example #4
Source File: PrevError.java    From mypy-PyCharm-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    if (project == null) {
        return;
    }
    ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(
            MypyToolWindowFactory.MYPY_PLUGIN_ID);
    if (!tw.isVisible()) {
        tw.show(null);
    }
    MypyTerminal terminal = MypyToolWindowFactory.getMypyTerminal(project);
    if (terminal == null) {
        return;
    }
    if (terminal.getRunner().isRunning()) {
        return;
    }
    int current = terminal.getErrorsList().getSelectedIndex();
    if (current > 0) {
        terminal.getErrorsList().setSelectedIndex(current - 1);
    }
}
 
Example #5
Source File: DataSourcesView.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 6 votes vote down vote up
public void initToolWindow(Project project, ToolWindow toolWindow) {
    if (!initialized) {
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        Content content = contentFactory.createContent(toolWindowContent, "", false);
        toolWindow.getContentManager().addContent(content);

        component = project.getComponent(DataSourcesComponent.class);
        componentMetadata = project.getComponent(DataSourcesComponentMetadata.class);
        dataSourceMetadataUi = new DataSourceMetadataUi(componentMetadata);
        treeRoot = new PatchedDefaultMutableTreeNode(new RootTreeNodeModel());
        treeModel = new DefaultTreeModel(treeRoot, false);
        decorator = ToolbarDecorator.createDecorator(dataSourceTree);
        decorator.addExtraAction(new RefreshDataSourcesAction(this));

        configureDataSourceTree();
        decorateDataSourceTree();

        interactions = new DataSourceInteractions(project, this);

        replaceTreeWithDecorated();
        showDataSources();
        refreshDataSourcesMetadata();

        initialized = true;
    }
}
 
Example #6
Source File: IMWindowFactory.java    From SmartIM4IntelliJ with Apache License 2.0 6 votes vote down vote up
private void createContents(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    File dir = new File(getWorkDir(), "SmartIM");
    if (dir.exists()) {
        dir.mkdirs();
    }
    System.setProperty("log.home", dir.getAbsolutePath());
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = null;

    WechatPanel wechatPanel = new WechatPanel(project, toolWindow);
    content = contentFactory.createContent(wechatPanel, "Wechat", false);
    toolWindow.getContentManager().addContent(content, 0);

    SmartQQPanel qqPanel = new SmartQQPanel(project, toolWindow);
    content = contentFactory.createContent(qqPanel, "SmartQQ", false);
    toolWindow.getContentManager().addContent(content, 1);

}
 
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: RemoteServersViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void showDeployment(@Nonnull final ServerConnection<?> connection, @Nonnull final String deploymentName) {
  ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
  final ToolWindow toolWindow = toolWindowManager.getToolWindow(ServersToolWindowManager.ID);
  if (toolWindow != null) {
    toolWindowManager.invokeLater(new Runnable() {
      @Override
      public void run() {
        ServersToolWindowContent component = getServersViewComponent(toolWindow);
        if (component != null) {
          component.select(connection, deploymentName);
        }
      }
    });
  }
}
 
Example #9
Source File: ORToolWindowManager.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
public void showHideToolWindows() {
    ToolWindow bsToolWindow = m_toolWindowProvider.getBsToolWindow();
    if (bsToolWindow != null) {
        bsToolWindow.setAvailable(shouldShowBsToolWindow(m_project), null);
    }

    ToolWindow duneToolWindow = m_toolWindowProvider.getDuneToolWindow();
    if (duneToolWindow != null) {
        duneToolWindow.setAvailable(shouldShowDuneToolWindow(m_project), null);
    }

    ToolWindow esyToolWindow = m_toolWindowProvider.getEsyToolWindow();
    if (esyToolWindow != null) {
        esyToolWindow.setAvailable(shouldShowEsyToolWindow(m_project), null);
    }
}
 
Example #10
Source File: FindCyclicDependenciesAction.java    From needsmoredojo with Apache License 2.0 6 votes vote down vote up
private void updateToolWindow(int count, final Project project, final CyclicDependencyDetector detector)
{
    final int finalCount = count;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            ToolWindowManager.getInstance(project).unregisterToolWindow("Find Cyclic AMD Dependencies");
            ToolWindow window = ToolWindowManager.getInstance(project).registerToolWindow("Find Cyclic AMD Dependencies", true, ToolWindowAnchor.BOTTOM);
            window.setTitle("Find Cyclic AMD Dependencies");
            window.setDefaultState(ToolWindowAnchor.BOTTOM, ToolWindowType.DOCKED, null);
            window.show(null);
            window.activate(null);

            Map<String, List<String>> incriminatingModules = detector.getIncriminatingModules();
            new FindCyclicDependenciesToolWindow().createContent(project, window, incriminatingModules, finalCount);
        }
    });
}
 
Example #11
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void listenForRenderTreeActivations(@NotNull ToolWindow toolWindow) {
  final ContentManager contentManager = toolWindow.getContentManager();
  contentManager.addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(@NotNull ContentManagerEvent event) {
      final ContentManagerEvent.ContentOperation operation = event.getOperation();
      if (operation == ContentManagerEvent.ContentOperation.add) {
        final String name = event.getContent().getTabName();
        if (Objects.equals(name, RENDER_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "renderTreeSelected");
        }
        else if (Objects.equals(name, WIDGET_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "widgetTreeSelected");
        }
      }
    }
  });
}
 
Example #12
Source File: PredefinedSearchScopeProviderImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void addHierarchyScope(@Nonnull Project project, Collection<SearchScope> result) {
  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY);
  if (toolWindow == null) {
    return;
  }
  final ContentManager contentManager = toolWindow.getContentManager();
  final Content content = contentManager.getSelectedContent();
  if (content == null) {
    return;
  }
  final String name = content.getDisplayName();
  final JComponent component = content.getComponent();
  if (!(component instanceof HierarchyBrowserBase)) {
    return;
  }
  final HierarchyBrowserBase hierarchyBrowserBase = (HierarchyBrowserBase)component;
  final PsiElement[] elements = hierarchyBrowserBase.getAvailableElements();
  if (elements.length > 0) {
    result.add(new LocalSearchScope(elements, "Hierarchy '" + name + "' (visible nodes only)"));
  }
}
 
Example #13
Source File: ExecutionHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void descriptorToFront(final Project project, final RunContentDescriptor descriptor) {
  ApplicationManager.getApplication().invokeLater(() -> {
    RunContentManager manager = ExecutionManager.getInstance(project).getContentManager();
    ToolWindow toolWindow = manager.getToolWindowByDescriptor(descriptor);
    if (toolWindow != null) {
      toolWindow.show(null);
      manager.selectRunContent(descriptor);
    }
  }, project.getDisposed());
}
 
Example #14
Source File: RefactoringsToolWindowFactory.java    From IntelliJDeodorant with MIT License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    ContentManager contentManager = toolWindow.getContentManager();
    AnalysisScope scope = new AnalysisScope(project);
    Content moveMethodPanel = contentManager.getFactory().createContent(new MoveMethodPanel(scope), IntelliJDeodorantBundle.message("feature.envy.smell.name"), false);
    Content extractMethodPanel = contentManager.getFactory().createContent(new ExtractMethodPanel(scope), IntelliJDeodorantBundle.message("long.method.smell.name"), false);
    Content godClassPanel = contentManager.getFactory().createContent(new GodClassPanel(scope), IntelliJDeodorantBundle.message("god.class.smell.name"), false);
    Content typeCheckPanel = contentManager.getFactory().createContent(new TypeCheckingPanel(scope), IntelliJDeodorantBundle.message("type.state.checking.smell.name"), false);
    contentManager.addContent(moveMethodPanel);
    contentManager.addContent(extractMethodPanel);
    contentManager.addContent(godClassPanel);
    contentManager.addContent(typeCheckPanel);
}
 
Example #15
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Moves this console to the end of the tool window's tab list, selects it, and shows the tool window.
 */
void bringToFront() {
  // Move the tab to be last and select it.
  final MessageView messageView = MessageView.SERVICE.getInstance(project);
  final ContentManager contentManager = messageView.getContentManager();
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  // Show the panel.
  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
  if (toolWindow != null) {
    toolWindow.activate(null, true);
  }
}
 
Example #16
Source File: SarosToolWindowFactory.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
  SarosMainPanelView sarosMainPanelView = new SarosMainPanelView(project);

  Content content =
      toolWindow
          .getContentManager()
          .getFactory()
          .createContent(
              sarosMainPanelView,
              PluginManager.getPlugin(PluginId.getId(SarosComponent.PLUGIN_ID)).getName(),
              false);
  toolWindow.getContentManager().addContent(content);
}
 
Example #17
Source File: FreelineTerminal.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 创建Terminal panel
 *
 * @param terminalRunner
 * @param toolWindow
 * @return
 */
private Content createTerminalInContentPanel(@NotNull AbstractTerminalRunner terminalRunner, @NotNull final ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);
    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(this);
    ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent());
    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());
    return content;
}
 
Example #18
Source File: BlazeConsoleToolWindowFactory.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
  String title = Blaze.buildSystemName(project) + " Console";
  toolWindow.setTitle(title);
  toolWindow.setStripeTitle(title);
  BlazeConsoleView.getInstance(project).createToolWindowContent(toolWindow);
}
 
Example #19
Source File: ExternalToolWindowManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
private static ToolWindow getToolWindow(@Nonnull Project project, @Nonnull ProjectSystemId externalSystemId) {
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
  if (toolWindowManager == null) {
    return null;
  }
  ToolWindow result = toolWindowManager.getToolWindow(externalSystemId.getReadableName());
  if (result instanceof ToolWindowBase) {
    ((ToolWindowBase)result).ensureContentInitialized();
  }
  return result;
}
 
Example #20
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void showForApp(@NotNull FlutterApp app) {
  final PerfViewAppState appState = perAppViewState.get(app);
  if (appState != null) {
    final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(TOOL_WINDOW_ID);
    toolWindow.getContentManager().setSelectedContent(appState.content);
  }
}
 
Example #21
Source File: RoutesView.java    From railways with MIT License 5 votes vote down vote up
public void addModulePane(Module module) {
    // Skip if RoutesView is not initialized or if added module is not
    // Rails application.
    RailsApp railsApp = RailsApp.fromModule(module);
    if ((myContentManager == null) || railsApp == null)
        return;

    // Register content, so we'll have a combo-box instead tool window
    // title, and each item will represent a module.
    String contentTitle = module.getName();
    Content content = myContentManager.getFactory().createContent(getComponent(),
            contentTitle, false);
    content.setTabName(contentTitle);
    content.setIcon(ModuleType.get(module).getIcon());

    // Set tool window icon to be the same as selected module icon
    content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
    myContentManager.addContent(content);

    // Bind content with pane for further use
    RoutesViewPane pane = new RoutesViewPane(railsApp, myToolWindow, content);
    myPanes.add(pane);

    // Register contributor
    ChooseByRouteRegistry.getInstance(myProject)
            .addContributorFor(pane.getRoutesManager());

    // Subscribe to RoutesManager events.
    pane.getRoutesManager().addListener(new MyRoutesManagerListener());

    // And select pane if it's the first one.
    if (myPanes.size() == 1)
        setCurrentPane(pane);
}
 
Example #22
Source File: PreviewViewFactory.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
  //noinspection CodeBlock2Expr
  DumbService.getInstance(project).runWhenSmart(() -> {
    (ServiceManager.getService(project, PreviewView.class)).initToolWindow(toolWindow);
  });
}
 
Example #23
Source File: AddCommentAction.java    From Crucible4IDEA with MIT License 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = e.getData(PlatformDataKeys.PROJECT);
  if (project == null) return;
  final ToolWindow toolWindow = e.getData(PlatformDataKeys.TOOL_WINDOW);
  if (toolWindow != null) {
    addGeneralComment(project, dataContext);
  }
  else {
    addVersionedComment(project);
  }
}
 
Example #24
Source File: WindowFactory.java    From leetcode-editor with Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {

    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JComponent navigatorPanel=  new NavigatorPanel(toolWindow,project);
    navigatorPanel.addAncestorListener(new UpdatePluginListener());
    Content content = contentFactory.createContent(navigatorPanel, "", false);
    toolWindow.getContentManager().addContent(content);

}
 
Example #25
Source File: ExternalSystemUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static ToolWindow ensureToolWindowContentInitialized(@Nonnull Project project, @Nonnull ProjectSystemId externalSystemId) {
  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 ToolWindowBase) {
    ((ToolWindowBase)toolWindow).ensureContentInitialized();
  }
  return toolWindow;
}
 
Example #26
Source File: HierarchyBrowserManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public HierarchyBrowserManager(final Project project) {
  final ToolWindowManager toolWindowManager=ToolWindowManager.getInstance(project);
  final ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.HIERARCHY, true, ToolWindowAnchor.RIGHT, project);
  myContentManager = toolWindow.getContentManager();
  toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowHierarchy);
  new ContentManagerWatcher(toolWindow,myContentManager);
}
 
Example #27
Source File: RunContentManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public ToolWindow getToolWindowByDescriptor(@Nonnull RunContentDescriptor descriptor) {
  for (Map.Entry<String, ContentManager> entry : myToolwindowIdToContentManagerMap.entrySet()) {
    if (getRunContentByDescriptor(entry.getValue(), descriptor) != null) {
      return ToolWindowManager.getInstance(myProject).getToolWindow(entry.getKey());
    }
  }
  return null;
}
 
Example #28
Source File: ReferenceToolWindow.java    From intellij-reference-diagram with Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();

    create(toolWindow, contentFactory, ServiceManager.getService(project, ProjectService.class).getSamePackageReferences());
    create(toolWindow, contentFactory, ServiceManager.getService(project, ProjectService.class).getSameHierarchieReferences());
    create(toolWindow, contentFactory, ServiceManager.getService(project, ProjectService.class).getOtherHierarchieReferences());
}
 
Example #29
Source File: Mock.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredUIAccess
@Override
public ToolWindow registerToolWindow(@Nonnull String id,
                                     @Nonnull JComponent component,
                                     @Nonnull ToolWindowAnchor anchor,
                                     Disposable parentDisposable,
                                     boolean canWorkInDumbMode,
                                     boolean canCloseContents) {
  return null;
}
 
Example #30
Source File: Switcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected String getElementText(Object element) {
  if (element instanceof ToolWindow) {
    return ((ToolWindow)element).getStripeTitle();
  }
  else if (element instanceof FileInfo) {
    return ((FileInfo)element).getNameForRendering();
  }
  return "";
}