Java Code Examples for com.intellij.openapi.wm.ToolWindow#show()

The following examples show how to use com.intellij.openapi.wm.ToolWindow#show() . 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: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
private static void processConsole(Project project, ProcessHandler processHandler) {
    ConsoleView consoleView = FreeUIManager.getInstance(project).getConsoleView(project);
    consoleView.clear();
    consoleView.attachToProcess(processHandler);

    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow toolWindow;
    toolWindow = toolWindowManager.getToolWindow(TOOL_ID);

    // if already exist tool window then show it
    if (toolWindow != null) {
        toolWindow.show(null);
        return;
    }

    toolWindow = toolWindowManager.registerToolWindow(TOOL_ID, true, ToolWindowAnchor.BOTTOM);
    toolWindow.setTitle("free....");
    toolWindow.setStripeTitle("Free Console");
    toolWindow.setShowStripeButton(true);
    toolWindow.setIcon(PluginIcons.ICON_TOOL_WINDOW);
    toolWindow.getContentManager().addContent(new ContentImpl(consoleView.getComponent(), "Build", true));
    toolWindow.show(null);
}
 
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: FavoritesViewSelectInTarget.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static ActionCallback select(@Nonnull Project project, Object toSelect, VirtualFile virtualFile, boolean requestFocus) {
  final ActionCallback result = new ActionCallback();

  ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  final ToolWindow favoritesToolWindow = windowManager.getToolWindow(ToolWindowId.FAVORITES_VIEW);

  if (favoritesToolWindow != null) {
    final Runnable runnable = () -> {
      final FavoritesTreeViewPanel panel = UIUtil.findComponentOfType(favoritesToolWindow.getComponent(), FavoritesTreeViewPanel.class);
      if (panel != null) {
        panel.selectElement(toSelect, virtualFile, requestFocus);
        result.setDone();
      }
    };

    if (requestFocus) {
      favoritesToolWindow.activate(runnable, false);
    }
    else {
      favoritesToolWindow.show(runnable);
    }
  }

  return result;
}
 
Example 4
Source File: EditorPerfDecorations.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns the action executed when the icon is left-clicked.
 *
 * @return the action instance, or null if no action is required.
 */
@Nullable
public AnAction getClickAction() {
  return new AnAction() {
    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {
      if (isActive()) {

        final ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(getApp().getProject());
        final ToolWindow flutterPerfToolWindow = toolWindowManager.getToolWindow(FlutterPerformanceView.TOOL_WINDOW_ID);
        if (flutterPerfToolWindow.isVisible()) {
          showPerfViewMessage();
          return;
        }
        flutterPerfToolWindow.show(() -> showPerfViewMessage());
      }
    }
  };
}
 
Example 5
Source File: OpenFlutterViewAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
  final Project project = e.getProject();
  if (project == null) {
    return;
  }

  FlutterInitializer.sendAnalyticsAction(this);

  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(FlutterView.TOOL_WINDOW_ID);
  if (toolWindow == null) {
    FlutterMessages.showError("Unable to open view", "Unable to open the Flutter tool window - no Flutter modules found");
  }
  else {
    toolWindow.show(null);
  }
}
 
Example 6
Source File: EditorPerfDecorations.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns the action executed when the icon is left-clicked.
 *
 * @return the action instance, or null if no action is required.
 */
@Nullable
public AnAction getClickAction() {
  return new AnAction() {
    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {
      if (isActive()) {

        final ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(getApp().getProject());
        final ToolWindow flutterPerfToolWindow = toolWindowManager.getToolWindow(FlutterPerformanceView.TOOL_WINDOW_ID);
        if (flutterPerfToolWindow.isVisible()) {
          showPerfViewMessage();
          return;
        }
        flutterPerfToolWindow.show(() -> showPerfViewMessage());
      }
    }
  };
}
 
Example 7
Source File: OpenFlutterViewAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
  final Project project = e.getProject();
  if (project == null) {
    return;
  }

  FlutterInitializer.sendAnalyticsAction(this);

  final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(FlutterView.TOOL_WINDOW_ID);
  if (toolWindow == null) {
    FlutterMessages.showError("Unable to open view", "Unable to open the Flutter tool window - no Flutter modules found");
  }
  else {
    toolWindow.show(null);
  }
}
 
Example 8
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 9
Source File: ProjectViewSelectInTarget.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ActionCallback select(@Nonnull Project project,
                                    final Object toSelect,
                                    @Nullable final String viewId,
                                    @Nullable final String subviewId,
                                    final VirtualFile virtualFile,
                                    final boolean requestFocus) {
  final ActionCallback result = new ActionCallback();

  final ProjectView projectView = ProjectView.getInstance(project);
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    AbstractProjectViewPane pane = projectView.getProjectViewPaneById(ProjectViewPane.ID);
    pane.select(toSelect, virtualFile, requestFocus);
    return result;
  }

  ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  final ToolWindow projectViewToolWindow = windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
  final Runnable runnable = () -> {
    Runnable r = () -> projectView.selectCB(toSelect, virtualFile, requestFocus).notify(result);
    projectView.changeViewCB(ObjectUtils.chooseNotNull(viewId, ProjectViewPane.ID), subviewId).doWhenProcessed(r);
  };

  if (requestFocus) {
    projectViewToolWindow.activate(runnable, true);
  }
  else {
    projectViewToolWindow.show(runnable);
  }

  return result;
}
 
Example 10
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void updateToolWindowVisibility(ToolWindow flutterToolWindow) {
  if (flutterToolWindow.isVisible()) {
    return;
  }

  if (FlutterSettings.getInstance().isOpenInspectorOnAppLaunch()) {
    flutterToolWindow.show(null);
  }
}
 
Example 11
Source File: ReactNativeConsole.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
     * Init and show this console pane.
     * @param toolWindow
     */
    public void init(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(" - ");
        // TODO Change to Eventbus
        ((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) {
                        init(window);
                    }
                }
            }
        });
        toolWindow.show(null);
    }
 
Example 12
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Activate the tool window.
 */
private void activateToolWindow() {
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);

  final ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOL_WINDOW_ID);
  if (toolWindow.isVisible()) {
    return;
  }

  toolWindow.show(null);
}
 
Example 13
Source File: ShowChangesViewAction.java    From consulo with 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 14
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void updateToolWindowVisibility(ToolWindow flutterToolWindow) {
  if (flutterToolWindow.isVisible()) {
    return;
  }

  if (FlutterSettings.getInstance().isOpenInspectorOnAppLaunch()) {
    flutterToolWindow.show(null);
  }
}
 
Example 15
Source File: AskSuggestion.java    From mypy-PyCharm-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Editor editor = e.getData(PlatformDataKeys.EDITOR);
    if (editor == null)
        return;
    LogicalPosition pos = editor.getCaretModel().getPrimaryCaret().getLogicalPosition();
    int line = pos.line;
    FileDocumentManager.getInstance().saveAllDocuments();
    VirtualFile vf = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    if (vf == null)
        return;
    String command = "./mypy/mypy-suggest " + vf.getPath() + " " + String.valueOf(line + 1);

    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;
    }
    terminal.runMypyDaemonUIWrapper(command, vf);
    vf.refresh(false, false);
}
 
Example 16
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Activate the tool window.
 */
private void activateToolWindow() {
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);

  final ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOL_WINDOW_ID);
  if (toolWindow.isVisible()) {
    return;
  }

  toolWindow.show(null);
}
 
Example 17
Source File: FreelineTerminal.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public JBTabbedTerminalWidget getTerminalWidget(ToolWindow window) {
    window.show(null);
    if (myTerminalWidget == null) {
        JComponent parentPanel =  window.getContentManager().getContents()[0].getComponent();
        if (parentPanel instanceof SimpleToolWindowPanel) {
            SimpleToolWindowPanel panel = (SimpleToolWindowPanel) parentPanel;
            JPanel jPanel = (JPanel) panel.getComponents()[0];
            myTerminalWidget = (JBTabbedTerminalWidget) jPanel.getComponents()[0];
        } else {
            NotificationUtils.infoNotification("Wait for Freeline to initialize");
        }
    }
    return myTerminalWidget;
}
 
Example 18
Source File: FreelineTerminal.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void initTerminal(final ToolWindow toolWindow) {
    toolWindow.setToHideOnEmptyContent(true);
    LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
    toolWindow.setStripeTitle("Freeline");
    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(FreelineToolWindowFactory.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(false);
        }
    }
}
 
Example 19
Source File: ServersToolWindowManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateWindowAvailable(boolean showIfAvailable) {
  ToolWindow toolWindow = myToolWindowManager.getToolWindow(ID);

  boolean available = isAvailable();
  boolean doShow = !toolWindow.isAvailable() && available;
  if (toolWindow.isAvailable() && !available) {
    toolWindow.hide(null);
  }
  toolWindow.setAvailable(available, null);
  if (showIfAvailable && doShow) {
    toolWindow.show(null);
  }
}
 
Example 20
Source File: UsageViewManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
void showToolWindow(boolean activateWindow) {
  ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND);
  toolWindow.show(null);
  if (activateWindow && !toolWindow.isActive()) {
    toolWindow.activate(null);
  }
}