Java Code Examples for com.intellij.openapi.wm.ToolWindow

The following examples show how to use com.intellij.openapi.wm.ToolWindow. These examples are extracted from open source projects.
Example 1
Project: intellij-pants-plugin   File: PantsSystemProjectResolver.java    License: 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 2
Project: mypy-PyCharm-plugin   File: NextError.java    License: 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
Project: mypy-PyCharm-plugin   File: PrevError.java    License: 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 4
Project: jetbrains-plugin-graph-database-support   File: DataSourcesView.java    License: 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 5
Project: SmartIM4IntelliJ   File: IMWindowFactory.java    License: 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 6
Project: reasonml-idea-plugin   File: DuneCompiler.java    License: 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 7
Project: consulo   File: RemoteServersViewImpl.java    License: 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 8
Project: reasonml-idea-plugin   File: ORToolWindowManager.java    License: 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 9
Project: needsmoredojo   File: FindCyclicDependenciesAction.java    License: 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 10
Project: flutter-intellij   File: FlutterView.java    License: 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 11
Project: consulo   File: PredefinedSearchScopeProviderImpl.java    License: 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 12
Project: embeddedlinux-jvmdebugger-intellij   File: EmbeddedLinuxJVMConsoleView.java    License: 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 13
Project: IntelliJDeodorant   File: RefactoringsToolWindowFactory.java    License: 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 14
Project: consulo   File: InspectionManagerEx.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public InspectionManagerEx(final Project project) {
  super(project);
  if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
    myContentManager = new NotNullLazyValue<ContentManager>() {
      @Nonnull
      @Override
      protected ContentManager compute() {
        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        toolWindowManager.registerToolWindow(ToolWindowId.INSPECTION, true, ToolWindowAnchor.BOTTOM, project);
        return ContentFactory.getInstance().createContentManager(new TabbedPaneContentUI(), true, project);
      }
    };
  }
  else {
    myContentManager = new NotNullLazyValue<ContentManager>() {
      @Nonnull
      @Override
      protected ContentManager compute() {
        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        ToolWindow toolWindow =
                toolWindowManager.registerToolWindow(ToolWindowId.INSPECTION, true, ToolWindowAnchor.BOTTOM, project);
        ContentManager contentManager = toolWindow.getContentManager();
        toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowInspection);
        new ContentManagerWatcher(toolWindow, contentManager);
        return contentManager;
      }
    };
  }
}
 
Example 15
Project: Crucible4IDEA   File: CompleteReviewAction.java    License: 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 16
Project: Crucible4IDEA   File: AddCommentAction.java    License: 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 17
Project: leetcode-editor   File: WindowFactory.java    License: 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 18
Project: consulo   File: Mock.java    License: 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 19
Project: mypy-PyCharm-plugin   File: MypyTerminal.java    License: Apache License 2.0 5 votes vote down vote up
public void runMypyDaemonUIWrapper(@Nullable String command, @Nullable VirtualFile vf) {

        setWaiting();
        FileDocumentManager.getInstance().saveAllDocuments();
        // Invoke mypy daemon runner script in a sub-thread,
        // it looks like UI is blocked on it otherwise.
        Executors.newSingleThreadExecutor().execute(() -> {
            Thread.currentThread().setName("MypyRunnerThread");
            MypyResult result = MypyTerminal.this.runner.runMypyDaemon(command, vf);
            if (result == null) return;
            // Access UI is prohibited from non-dispatch thread.
            ApplicationManager.getApplication().invokeLater(() -> {
                MypyTerminal.this.setReady(result);
                ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(
                        MypyToolWindowFactory.MYPY_PLUGIN_ID);
                if (!tw.isVisible()) {
                    String suffix = result.getErrCount() != 1 ? "s" : "";
                    NotificationType n_type =
                            result.getRetCode() != 0 ? NotificationType.WARNING : NotificationType.INFORMATION;
                    Notification completed = new Notification("Indexing", "Mypy Daemon",
                            String.format("Type checking completed: %d error%s found",
                                    result.getErrCount(), suffix),
                            n_type);
                    Notifications.Bus.notify(completed);
                }
                if (result.getErrCount() == 0 & result.getNoteCount() == 0) {
                    return;
                }
                if (result.getRetCode() != 0) {
                    MypyTerminal.this.makeErrorMap(result);
                    MypyTerminal.this.generateMarkers(result);
                    MypyTerminal.this.collapsed = new HashSet<>();
                    MypyTerminal.this.renderList();
                    MypyTerminal.this.errorsList.setSelectedIndex(0);
                }
            });
        });
    }
 
Example 20
Project: consulo   File: HierarchyBrowserManager.java    License: 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 21
Project: consulo   File: Switcher.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private static String getSmartShortcut(ToolWindow window, Map<String, ToolWindow> keymap) {
  String title = window.getStripeTitle();
  if (StringUtil.isEmpty(title)) return null;
  for (int i = 0; i < title.length(); i++) {
    char c = title.charAt(i);
    if (Character.isUpperCase(c)) {
      String shortcut = String.valueOf(c);
      if (keymap.get(shortcut) == null) return shortcut;
    }
  }
  return null;
}
 
Example 22
Project: js-graphql-intellij-plugin   File: JSGraphQLLanguageUIProjectService.java    License: MIT License 5 votes vote down vote up
private void initToolWindow() {
    if (this.myToolWindowManager != null && !this.myProject.isDisposed()) {
        StartupManager.getInstance(this.myProject).runWhenProjectIsInitialized(() -> ApplicationManager.getApplication().invokeLater(() -> {

            myToolWindowManager.init();

            final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(GRAPH_QL_TOOL_WINDOW_NAME);
            if (toolWindow != null) {
                createToolWindowResultEditor(toolWindow);
            }
            myToolWindowManagerInitialized = true;
        }, myProject.getDisposed()));
    }
}
 
Example 23
Project: react-native-console   File: ReactNativeConsole.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void initAndActiveRunRefresh(InputEvent e) {
    ToolWindow toolWindow = getToolWindow();
    if (!toolWindow.isActive()) {
        toolWindow.activate(() -> ActionManager.getInstance().tryToExecute(new AndroidRefreshAction(ReactNativeConsole.this), e, null, ActionPlaces.UNKNOWN, true));
    } else {
        ActionManager.getInstance().tryToExecute(new AndroidRefreshAction(this), e, null, ActionPlaces.UNKNOWN, true);
    }
}
 
Example 24
Project: react-native-console   File: ReactNativeConsole.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void focusGained(FocusEvent e) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
    if (toolWindow != null) {
        try {
            ContentManager contentManager = toolWindow.getContentManager();
            JComponent component = contentManager.getSelectedContent().getComponent();
            if (component != null) {
                component.requestFocusInWindow();
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
}
 
Example 25
Project: tmc-intellij   File: TestResultPanelFactory.java    License: 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 26
Project: consulo   File: RunContentManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
private void registerToolWindow(@Nonnull final Executor executor, @Nonnull ToolWindowManagerEx toolWindowManager) {
  final String toolWindowId = executor.getToolWindowId();
  if (toolWindowManager.getToolWindow(toolWindowId) != null) {
    return;
  }

  final ToolWindow toolWindow = toolWindowManager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true);
  final ContentManager contentManager = toolWindow.getContentManager();
  contentManager.addDataProvider(new DataProvider() {
    private int myInsideGetData = 0;

    @Override
    public Object getData(@Nonnull Key<?> dataId) {
      myInsideGetData++;
      try {
        if (PlatformDataKeys.HELP_ID == dataId) {
          return executor.getHelpId();
        }
        else {
          return myInsideGetData == 1 ? DataManager.getInstance().getDataContext(contentManager.getComponent()).getData(dataId) : null;
        }
      }
      finally {
        myInsideGetData--;
      }
    }
  });

  toolWindow.setIcon(executor.getToolWindowIcon());
  new ContentManagerWatcher(toolWindow, contentManager);
  initToolWindow(executor, toolWindowId, executor.getToolWindowIcon(), contentManager);
}
 
Example 27
Project: consulo   File: RunDashboardManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@Nonnull ToolWindow toolWindow) {
  myDashboardContent = new RunDashboardContent(myProject, myContentManager, myGroupers);
  ContentManager contentManager = toolWindow.getContentManager();
  Content content = contentManager.getFactory().createContent(myDashboardContent, null, false);
  Disposer.register(content, myDashboardContent);
  Disposer.register(content, () -> myDashboardContent = null);
  toolWindow.getContentManager().addContent(content);
}
 
Example 28
Project: railways   File: RoutesViewPane.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a separate panel for Rails module.
 *
 * @param railsApp Rails module that will be represented by this pane.
 * @param toolWindow Parent tool window
 */
RoutesViewPane(RailsApp railsApp, ToolWindow toolWindow, Content content) {
    myModule = railsApp.getModule();
    myContent = content;

    myRoutesManager = ModuleServiceManager.getService(myModule, RoutesManager.class);
    myRoutesManager.initRouteList();

    myRoutesChangeListener = new MyPsiTreeChangeListener(railsApp.getRoutesFiles(), toolWindow);

    PsiManager.getInstance(myModule.getProject())
            .addPsiTreeChangeListener(myRoutesChangeListener);
}
 
Example 29
Project: consulo   File: ExternalSystemUtil.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
public static <T> T getToolWindowElement(@Nonnull Class<T> clazz,
                                         @Nonnull Project project,
                                         @Nonnull Key<T> key,
                                         @Nonnull ProjectSystemId externalSystemId) {
  if (project.isDisposed() || !project.isOpen()) {
    return null;
  }
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
  if (toolWindowManager == null) {
    return null;
  }
  final ToolWindow toolWindow = ensureToolWindowContentInitialized(project, externalSystemId);
  if (toolWindow == null) {
    return null;
  }

  final ContentManager contentManager = toolWindow.getContentManager();
  if (contentManager == null) {
    return null;
  }

  for (Content content : contentManager.getContents()) {
    final JComponent component = content.getComponent();
    if (component instanceof DataProvider) {
      final Object data = ((DataProvider)component).getData(key);
      if (data != null && clazz.isInstance(data)) {
        return (T)data;
      }
    }
  }
  return null;
}
 
Example 30
Project: consulo   File: ShowChangesViewAction.java    License: Apache License 2.0 5 votes vote down vote up
protected void actionPerformed(VcsContext e) {
  if (e.getProject() == null) return;
  final ToolWindowManager manager = ToolWindowManager.getInstance(e.getProject());
  if (manager != null) {
    final ToolWindow window = manager.getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
    if (window != null) {
      window.show(null);
    }
  }
}
 
Example 31
Project: tmc-intellij   File: OpenToolWindowAction.java    License: MIT License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    logger.info("Creating tool window content. @OpenToolWindowAction");
    ProjectListWindow window = new ProjectListWindow();
    ContentFactory cf = ContentFactory.SERVICE.getInstance();
    Content content = cf.createContent(window.getBasePanel(), "", true);
    toolWindow.getContentManager().addContent(content);
    ProjectListManagerHolder.get().addWindow(window);
}
 
Example 32
Project: consulo   File: VcsLogContentProvider.java    License: Apache License 2.0 5 votes vote down vote up
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);
      }
    }
  }
}
 
Example 33
Project: intellij-reference-diagram   File: ReferenceToolWindow.java    License: 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 34
Project: consulo   File: RunContentManagerImpl.java    License: 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 35
Project: consulo   File: ChooseByNameBase.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isDescendingFromTemporarilyFocusableToolWindow(@Nullable Component component) {
  if (component == null || myProject == null || myProject.isDisposed()) return false;

  ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
  ToolWindow toolWindow = toolWindowManager.getToolWindow(toolWindowManager.getActiveToolWindowId());
  JComponent toolWindowComponent = toolWindow != null ? toolWindow.getComponent() : null;
  return toolWindowComponent != null && toolWindowComponent.getClientProperty(TEMPORARILY_FOCUSABLE_COMPONENT_KEY) != null && SwingUtilities.isDescendingFrom(component, toolWindowComponent);
}
 
Example 36
Project: consulo   File: ExternalSystemUtil.java    License: 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 37
Project: flutter-intellij   File: PreviewViewFactory.java    License: 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 38
Project: railways   File: RoutesView.java    License: 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 39
Project: consulo   File: ExternalToolWindowManager.java    License: 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 40
Project: intellij   File: BlazeConsoleToolWindowFactory.java    License: 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);
}