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

The following examples show how to use com.intellij.openapi.wm.ToolWindow#isVisible() . 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: ConsoleLog.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
public static void toggleLog(@Nullable final Project project, @Nullable final Notification notification) {
    final ToolWindow eventLog = getLogWindow(project);
    if(eventLog != null) {
        if(!eventLog.isVisible()) {
            eventLog.activate(new Runnable() {
                @Override
                public void run() {
                    if(notification == null) {
                        return;
                    }
                    String contentName = getContentName(notification);
                    Content content = eventLog.getContentManager().findContent(contentName);
                    if(content != null) {
                        eventLog.getContentManager().setSelectedContent(content);
                    }
                }
            }, true);
        } else {
            eventLog.hide(null);
        }
    }
}
 
Example 2
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 3
Source File: ShelvedChangesViewManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void activateView(final ShelvedChangeList list) {
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      if (list != null) {
        TreeUtil.selectNode(myTree, TreeUtil.findNodeWithObject(myRoot, list));
      }
      myContentManager.setSelectedContent(myContent);
      ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
      if (!window.isVisible()) {
        window.activate(null);
      }
    }
  };
  if (myUpdatePending) {
    myPostUpdateRunnable = runnable;
  }
  else {
    runnable.run();
  }
}
 
Example 4
Source File: MetadataAction.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    Project project = getEventProject(e);
    MessageBus messageBus = project.getMessageBus();

    ExecuteQueryEvent executeQueryEvent = messageBus.syncPublisher(ExecuteQueryEvent.EXECUTE_QUERY_TOPIC);

    ExecuteQueryPayload payload = new ExecuteQueryPayload(getQuery(data));

    DataSourcesComponent dataSourcesComponent = project.getComponent(DataSourcesComponent.class);
    Optional<DataSourceApi> dataSource = dataSourcesComponent.getDataSourceContainer().findDataSource(dataSourceUuid);

    dataSource.ifPresent(dataSourceApi -> executeQueryEvent.executeQuery(dataSourceApi, payload));

    ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CONSOLE_TOOL_WINDOW);
    if (!toolWindow.isVisible()) {
        ConsoleToolWindow.ensureOpen(project);
        messageBus.syncPublisher(OpenTabEvent.OPEN_TAB_TOPIC).openTab(Tabs.TABLE);
    }
}
 
Example 5
Source File: OpenToolWindowAction.java    From tmc-intellij with MIT License 6 votes vote down vote up
public void openToolWindow(Project project) {
    logger.info("Opening tool window. @OpenToolWindowAction");
    if (project == null) {
        logger.warn("project was null ending openToolWindow @OpenToolWindowAction");
        return;
    }
    ToolWindow projectList = null;

    if (ToolWindowManager.getInstance(project).getToolWindow("Project") != null) {
        projectList = ToolWindowManager.getInstance(project).getToolWindow("TMC Project List");
    }

    if (projectList == null) {
        logger.warn("ToolWindow was null ending openToolWindow @OpenToolwindowAction");
        return;
    }

    if (projectList.isVisible()) {
        projectList.hide(null);
    } else {
        ToolWindowManager.getInstance(project).getToolWindow("TMC Project List").show(null);
        ToolWindowManager.getInstance(project);
    }
}
 
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: ExecutionHelper.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static Collection<RunContentDescriptor> findRunningConsole(final Project project,
                                                                  @Nonnull final NotNullFunction<RunContentDescriptor, Boolean> descriptorMatcher) {
  final ExecutionManager executionManager = ExecutionManager.getInstance(project);

  final RunContentDescriptor selectedContent = executionManager.getContentManager().getSelectedContent();
  if (selectedContent != null) {
    final ToolWindow toolWindow = ExecutionManager.getInstance(project).getContentManager().getToolWindowByDescriptor(selectedContent);
    if (toolWindow != null && toolWindow.isVisible()) {
      if (descriptorMatcher.fun(selectedContent)) {
        return Collections.singletonList(selectedContent);
      }
    }
  }

  final ArrayList<RunContentDescriptor> result = ContainerUtil.newArrayList();
  for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
    if (descriptorMatcher.fun(runContentDescriptor)) {
      result.add(runContentDescriptor);
    }
  }
  return result;
}
 
Example 8
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void openCommittedChangesTab(final CommittedChangesProvider provider,
                                    final RepositoryLocation location,
                                    final ChangeBrowserSettings settings,
                                    final int maxCount,
                                    String title) {
  DefaultActionGroup extraActions = new DefaultActionGroup();
  CommittedChangesPanel panel = new CommittedChangesPanel(myProject, provider, settings, location, extraActions);
  panel.setMaxCount(maxCount);
  panel.refreshChanges(false);
  final ContentFactory factory = ContentFactory.getInstance();
  if (title == null && location != null) {
    title = VcsBundle.message("browse.changes.content.title", location.toPresentableString());
  }
  final Content content = factory.createContent(panel, title, false);
  final ChangesViewContentI contentManager = ChangesViewContentManager.getInstance(myProject);
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  extraActions.add(new CloseTabToolbarAction() {
    @Override
    public void actionPerformed(final AnActionEvent e) {
      contentManager.removeContent(content);
    }
  });

  ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
  if (!window.isVisible()) {
    window.activate(null);
  }
}
 
Example 9
Source File: NewElementToolbarAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent event) {
  super.update(event);
  if (event.getData(LangDataKeys.IDE_VIEW) == null) {
    Project project = event.getData(CommonDataKeys.PROJECT);
    PsiFile psiFile = event.getData(LangDataKeys.PSI_FILE);
    if (project != null && psiFile != null) {
      final ToolWindow projectViewWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW);
      if (projectViewWindow.isVisible()) {
        event.getPresentation().setEnabled(true);
      }
    }
  }
}
 
Example 10
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean hideAllToolWindows(ToolWindowManagerEx manager) {
  // to clear windows stack
  manager.clearSideStack();

  String[] ids = manager.getToolWindowIds();
  boolean hasVisible = false;
  for (String id : ids) {
    final ToolWindow toolWindow = manager.getToolWindow(id);
    if (toolWindow.isVisible()) {
      toolWindow.hide(null);
      hasVisible = true;
    }
  }
  return hasVisible;
}
 
Example 11
Source File: ConsoleToolWindow.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 5 votes vote down vote up
public static void ensureOpen(Project project) {
    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow toolWindow = toolWindowManager.getToolWindow(GraphConstants.ToolWindow.CONSOLE_TOOL_WINDOW);

    if (!toolWindow.isActive()) {
        toolWindow.activate(null, false);
        return;
    }

    if (!toolWindow.isVisible()) {
        toolWindow.show(null);
    }
}
 
Example 12
Source File: EventLogToolWindowFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void ancestorAdded(AncestorEvent event) {
  ToolWindow log = EventLog.getEventLog(myProject);
  if (log != null && log.isVisible()) {
    EventLog.getLogModel(myProject).logShown();
  }
}
 
Example 13
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 14
Source File: MoveChangesToAnotherListAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void selectAndShowFile(@Nonnull final Project project, @Nonnull final VirtualFile file) {
  ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);

  if (!window.isVisible()) {
    window.activate(new Runnable() {
      public void run() {
        ChangesViewManager.getInstance(project).selectFile(file);
      }
    });
  }
}
 
Example 15
Source File: ShowMypyWindow.java    From mypy-PyCharm-plugin with Apache License 2.0 5 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.hide(null);
    } else {
        tw.show(null);
    }
}
 
Example 16
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 17
Source File: HideAllToolWindowsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void performAction(final Project project) {
  ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);

  ToolWindowLayout layout = new ToolWindowLayout();
  layout.copyFrom(toolWindowManager.getLayout());

  // to clear windows stack
  toolWindowManager.clearSideStack();
  //toolWindowManager.activateEditorComponent();


  String[] ids = toolWindowManager.getToolWindowIds();
  boolean hasVisible = false;
  for (String id : ids) {
    ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
    if (toolWindow.isVisible()) {
      toolWindow.hide(null);
      hasVisible = true;
    }
  }

  if (hasVisible) {
    toolWindowManager.setLayoutToRestoreLater(layout);
    toolWindowManager.activateEditorComponent();
  }
  else {
    final ToolWindowLayout restoredLayout = toolWindowManager.getLayoutToRestoreLater();
    if (restoredLayout != null) {
      toolWindowManager.setLayoutToRestoreLater(null);
      toolWindowManager.setLayout(restoredLayout);
    }
  }
}
 
Example 18
Source File: EditorEmptyTextPainter.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected static boolean isToolwindowVisible(@Nonnull JComponent splitters, @Nonnull String toolwindowId) {
  Window frame = SwingUtilities.getWindowAncestor(splitters);

  IdeFrame ideFrameIfRoot = IdeFrameUtil.findRootIdeFrame(TargetAWT.from(frame));
  if (ideFrameIfRoot != null) {
    Project project = ideFrameIfRoot.getProject();
    if (project != null) {
      if (!project.isInitialized()) return true;
      ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(toolwindowId);
      return toolWindow != null && toolWindow.isVisible();
    }
  }
  return false;
}
 
Example 19
Source File: BuckToolWindowFactory.java    From Buck-IntelliJ-Plugin with Apache License 2.0 4 votes vote down vote up
public static boolean isToolWindowVisible(Project project) {
  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
  return toolWindow.isVisible();
}
 
Example 20
Source File: DesktopToolWindowPanelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
private Pair<Resizer, Component> findResizerAndComponent(@Nonnull ToolWindow wnd) {
  if (!wnd.isVisible()) return null;

  Resizer resizer = null;
  Component cmp = null;

  if (wnd.getType() == ToolWindowType.DOCKED) {
    cmp = getComponentAt(wnd.getAnchor());

    if (cmp != null) {
      if (wnd.getAnchor().isHorizontal()) {
        resizer = myVerticalSplitter.getFirstComponent() == cmp ? new Resizer.Splitter.FirstComponent(myVerticalSplitter) : new Resizer.Splitter.LastComponent(myVerticalSplitter);
      }
      else {
        resizer = myHorizontalSplitter.getFirstComponent() == cmp ? new Resizer.Splitter.FirstComponent(myHorizontalSplitter) : new Resizer.Splitter.LastComponent(myHorizontalSplitter);
      }
    }
  }
  else if (wnd.getType() == ToolWindowType.SLIDING) {
    cmp = wnd.getComponent();
    while (cmp != null) {
      if (cmp.getParent() == myLayeredPane) break;
      cmp = cmp.getParent();
    }

    if (cmp != null) {
      if (wnd.getAnchor() == ToolWindowAnchor.TOP) {
        resizer = new Resizer.LayeredPane.Top(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.BOTTOM) {
        resizer = new Resizer.LayeredPane.Bottom(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.LEFT) {
        resizer = new Resizer.LayeredPane.Left(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.RIGHT) {
        resizer = new Resizer.LayeredPane.Right(cmp);
      }
    }
  }

  return resizer != null ? Pair.create(resizer, cmp) : null;
}