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

The following examples show how to use com.intellij.openapi.wm.ToolWindow#hide() . 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: 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 2
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 3
Source File: CloseActiveTabAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true);
  boolean processed = false;
  if (contentManager != null && contentManager.canCloseContents()) {
    final Content selectedContent = contentManager.getSelectedContent();
    if (selectedContent != null && selectedContent.isCloseable()) {
      contentManager.removeContent(selectedContent, true);
      processed = true;
    }
  }

  if (!processed && contentManager != null) {
    final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent());
    final ToolWindow tw = context.getData(PlatformDataKeys.TOOL_WINDOW);
    if (tw != null) {
      tw.hide(null);
    }
  }
}
 
Example 4
Source File: VcsShowToolWindowTabAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  ToolWindow toolWindow = assertNotNull(getToolWindow(project));
  final ChangesViewContentManager changesViewContentManager = (ChangesViewContentManager)ChangesViewContentManager.getInstance(project);
  final String tabName = getTabName();

  boolean contentAlreadySelected = changesViewContentManager.isContentSelected(tabName);
  if (toolWindow.isActive() && contentAlreadySelected) {
    toolWindow.hide(null);
  }
  else {
    Runnable runnable = contentAlreadySelected ? null : new Runnable() {
      @Override
      public void run() {
        changesViewContentManager.selectContent(tabName, true);
      }
    };
    toolWindow.activate(runnable, true, true);
  }
}
 
Example 5
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 6
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 7
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 8
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 9
Source File: Switcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void closeTabOrToolWindow() {
  final JBList selectedList = getSelectedList();
  final int[] selected = selectedList.getSelectedIndices();
  Arrays.sort(selected);
  int selectedIndex = 0;
  for (int i = selected.length - 1; i >= 0; i--) {
    selectedIndex = selected[i];
    Object value = selectedList.getModel().getElementAt(selectedIndex);
    if (value instanceof FileInfo) {
      final FileInfo info = (FileInfo)value;
      final VirtualFile virtualFile = info.first;
      final FileEditorManagerImpl editorManager = (FileEditorManagerImpl)FileEditorManager.getInstance(project);
      final JList jList = getSelectedList();
      final EditorWindow wnd = findAppropriateWindow(info);
      if (wnd == null) {
        editorManager.closeFile(virtualFile, false, false);
      }
      else {
        editorManager.closeFile(virtualFile, wnd, false);
      }

      final IdeFocusManager focusManager = IdeFocusManager.getInstance(project);
      myAlarm.cancelAllRequests();
      myAlarm.addRequest(() -> {
        JComponent focusTarget = selectedList;
        if (selectedList.getModel().getSize() == 0) {
          focusTarget = selectedList == files ? toolWindows : files;
        }
        focusManager.requestFocus(focusTarget, true);
      }, 300);
      if (jList.getModel().getSize() == 1) {
        removeElementAt(jList, selectedIndex);
        this.remove(jList);
        final Dimension size = toolWindows.getSize();
        myPopup.setSize(new Dimension(size.width, myPopup.getSize().height));
      }
      else {
        removeElementAt(jList, selectedIndex);
        jList.setSize(jList.getPreferredSize());
      }
      if (isPinnedMode()) {
        EditorHistoryManager.getInstance(project).removeFile(virtualFile);
      }
    }
    else if (value instanceof ToolWindow) {
      final ToolWindow toolWindow = (ToolWindow)value;
      if (twManager instanceof ToolWindowManagerEx) {
        ToolWindowManagerEx manager = (ToolWindowManagerEx)twManager;
        manager.hideToolWindow(toolWindow.getId(), false, false);
      }
      else {
        toolWindow.hide(null);
      }
    }
  }
  pack();
  myPopup.getContent().revalidate();
  myPopup.getContent().repaint();
  if (getSelectedList().getModel().getSize() > selectedIndex) {
    getSelectedList().setSelectedIndex(selectedIndex);
    getSelectedList().ensureIndexIsVisible(selectedIndex);
  }
}