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

The following examples show how to use com.intellij.openapi.wm.ToolWindow#activate() . 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: VcsLogContentProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static VcsLogUiImpl openLogTab(@Nonnull VcsLogManager logManager,
                                      @Nonnull Project project,
                                      @Nonnull String shortName,
                                      @Nullable VcsLogFilter filter) {
  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);

  String name = ContentUtilEx.getFullName(TAB_NAME, shortName);

  VcsLogUiImpl logUi = logManager.createLogUi(name, name, filter);

  ContentUtilEx
          .addTabbedContent(toolWindow.getContentManager(), new VcsLogPanel(logManager, logUi), TAB_NAME, shortName, true, logUi);
  toolWindow.activate(null);

  logManager.scheduleInitialization();
  return logUi;
}
 
Example 2
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 3
Source File: Switcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
private boolean keyEvent(KeyEvent event) {
  if (isPinnedMode()) return false;
  if (event.getID() == KEY_RELEASED && event.getKeyCode() == myBaseModifier) {
    event.consume();
    ApplicationManager.getApplication().invokeLater(() -> navigate(null), ModalityState.current());
    return true;
  }
  if (event.getID() == KEY_PRESSED) {
    ToolWindow tw = twShortcuts.get(String.valueOf((char)event.getKeyCode()));
    if (tw != null) {
      event.consume();
      myPopup.closeOk(null);
      tw.activate(null, true, true);
      return true;
    }
  }
  return false;
}
 
Example 4
Source File: FileHistorySessionPartner.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void createOrSelectContentIfNeeded() {
  ToolWindow toolWindow = getToolWindow(myVcs.getProject());
  if (myRefresherI.isFirstTime()) {
    ContentManager manager = toolWindow.getContentManager();
    boolean selectedExistingContent = ContentUtilEx.selectContent(manager, myFileHistoryPanel, true);
    if (!selectedExistingContent) {
      String tabName = myPath.getName();
      if (myStartingRevisionNumber != null) {
        tabName += " (";
        if (myStartingRevisionNumber instanceof ShortVcsRevisionNumber) {
          tabName += ((ShortVcsRevisionNumber)myStartingRevisionNumber).toShortString();
        }
        else {
          tabName += myStartingRevisionNumber.asString();
        }
        tabName += ")";
      }
      ContentUtilEx.addTabbedContent(manager, myFileHistoryPanel, "History", tabName, true);
    }
    toolWindow.activate(null);
  }
}
 
Example 5
Source File: IssueOutputFilter.java    From intellij with Apache License 2.0 6 votes vote down vote up
private Navigatable openConsoleToHyperlink(HyperlinkInfo link, int originalOffset) {
  return new Navigatable() {
    @Override
    public void navigate(boolean requestFocus) {
      BlazeConsoleView consoleView = BlazeConsoleView.getInstance(project);
      ToolWindow toolWindow =
          ToolWindowManager.getInstance(project).getToolWindow(BlazeConsoleToolWindowFactory.ID);
      toolWindow.activate(() -> consoleView.navigateToHyperlink(link, originalOffset), true);
    }

    @Override
    public boolean canNavigate() {
      return true;
    }

    @Override
    public boolean canNavigateToSource() {
      return true;
    }
  };
}
 
Example 6
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 7
Source File: AppCommandLineState.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Closes old session only for debug mode
 *
 * @param project
 * @param parameters
 */
private void closeOldSession(final Project project, EmbeddedLinuxJVMRunConfigurationRunnerParameters parameters) {
    final String configurationName = AppCommandLineState.getRunConfigurationName(parameters.getPort());
    final Collection<RunContentDescriptor> descriptors =
            ExecutionHelper.findRunningConsoleByTitle(project, configurationName::equals);

    if (descriptors.size() > 0) {
        final RunContentDescriptor descriptor = descriptors.iterator().next();
        final ProcessHandler processHandler = descriptor.getProcessHandler();
        final Content content = descriptor.getAttachedContent();

        if (processHandler != null && content != null) {
            final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();

            if (processHandler.isProcessTerminated()) {
                ExecutionManager.getInstance(project).getContentManager()
                        .removeRunContent(executor, descriptor);
            } else {
                content.getManager().setSelectedContent(content);
                ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(executor.getToolWindowId());
                window.activate(null, false, true);
            }
        }
    }
}
 
Example 8
Source File: TestErrorViewAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void openView(Project project, JComponent component) {
  final MessageView messageView = MessageView.SERVICE.getInstance(project);
  final Content content = ContentFactory.getInstance().createContent(component, getContentName(), true);
  messageView.getContentManager().addContent(content);
  messageView.getContentManager().setSelectedContent(content);
  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
  if (toolWindow != null) {
    toolWindow.activate(null);
  }
}
 
Example 9
Source File: ProblemsView.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void showCurrentFileProblems(@Nonnull Project project) {
  ToolWindow window = getToolWindow(project);
  if (window == null) return; // does not exist
  selectContent(window.getContentManager(), 0);
  window.setAvailable(true, null);
  window.activate(null, true);
}
 
Example 10
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);
  }
}
 
Example 11
Source File: RemoteServersViewImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void showServerConnection(@Nonnull final ServerConnection<?> connection) {
  final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ServersToolWindowManager.ID);
  if (toolWindow != null) {
    toolWindow.activate(new Runnable() {
      @Override
      public void run() {
        ServersToolWindowContent content = getServersViewComponent(toolWindow);
        if (content != null) {
          content.select(connection);
        }
      }
    });
  }
}
 
Example 12
Source File: EmbeddedLinuxJVMDebugger.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a Console Logger From The Remote App
 *
 * @param p
 */
private void setupConsole(Project p) {
    ToolWindow window = ToolWindowManager.getInstance(p).getToolWindow(EmbeddedLinuxJVMToolWindowFactory.ID);
    if (window != null) {
        window.activate(null, true);
        EmbeddedLinuxJVMConsoleView.getInstance(p).clear();
    }
}
 
Example 13
Source File: EmbeddedLinuxJVMRunner.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a Console Logger From The Remote App
 *
 * @param p
 */
private void setupConsole(Project p) {
    ToolWindow window = ToolWindowManager.getInstance(p).getToolWindow(EmbeddedLinuxJVMToolWindowFactory.ID);
    if (window != null) {
        window.activate(null, true);
        EmbeddedLinuxJVMConsoleView.getInstance(p).clear();
    }
}
 
Example 14
Source File: BlazeConsoleServiceImpl.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void activateConsoleWindow() {
  ToolWindow toolWindow =
      ToolWindowManager.getInstance(project).getToolWindow(BlazeConsoleToolWindowFactory.ID);
  if (toolWindow != null) {
    toolWindow.activate(/* runnable= */ null, /* autoFocusContents= */ false);
  }
}
 
Example 15
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 16
Source File: FreelineTerminal.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void initAndExecute(final String[] shell) {
    ToolWindow toolWindow = getToolWindow();
    if (toolWindow.isActive()) {
        executeShell(shell);
    } else {
        toolWindow.activate(new Runnable() {
            @Override
            public void run() {
                executeShell(shell);
            }
        });
    }
}
 
Example 17
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 18
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 19
Source File: ReactNativeConsole.java    From react-native-console with 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 20
Source File: ReactNativeConsole.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initAndActive() {
    ToolWindow toolWindow = getToolWindow();
    if (!toolWindow.isActive()) {
        toolWindow.activate(null);
    }
}