com.intellij.openapi.wm.ToolWindowId Java Examples

The following examples show how to use com.intellij.openapi.wm.ToolWindowId. 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: CopyHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) {
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  if (id != null) {
    ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id);
    Content selectedContent = window.getContentManager().getSelectedContent();
    if (selectedContent != null) {
      JComponent component = selectedContent.getComponent();
      if (component instanceof TwoPaneIdeView) {
        ((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel);
        return;
      }
    }
  }
  if (ToolWindowId.PROJECT_VIEW.equals(id)) {
    ProjectView.getInstance(project).selectPsiElement(newElement, true);
  }
  else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) {
    VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile();
    FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile);
    StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true);
  }
}
 
Example #2
Source File: FlutterReloadManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Notification showRunNotification(@NotNull FlutterApp app, @Nullable String title, @NotNull String content, boolean isError) {
  final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
  final NotificationGroup notificationGroup = getNotificationGroup(toolWindowId);
  final Notification notification;
  if (title == null) {
    notification = notificationGroup.createNotification(content, isError ? NotificationType.ERROR : NotificationType.INFORMATION);
  }
  else {
    notification =
      notificationGroup.createNotification(title, content, isError ? NotificationType.ERROR : NotificationType.INFORMATION, null);
  }
  notification.setIcon(FlutterIcons.Flutter);
  notification.notify(myProject);

  lastNotification = notification;

  return notification;
}
 
Example #3
Source File: FlutterReloadManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Notification showRunNotification(@NotNull FlutterApp app, @Nullable String title, @NotNull String content, boolean isError) {
  final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
  final NotificationGroup notificationGroup = getNotificationGroup(toolWindowId);
  final Notification notification;
  if (title == null) {
    notification = notificationGroup.createNotification(content, isError ? NotificationType.ERROR : NotificationType.INFORMATION);
  }
  else {
    notification =
      notificationGroup.createNotification(title, content, isError ? NotificationType.ERROR : NotificationType.INFORMATION, null);
  }
  notification.setIcon(FlutterIcons.Flutter);
  notification.notify(myProject);

  lastNotification = notification;

  return notification;
}
 
Example #4
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void openMessagesView(final VcsErrorViewPanel errorTreeView, final String tabDisplayName) {
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(myProject, new Runnable() {
    @Override
    public void run() {
      final MessageView messageView = MessageView.SERVICE.getInstance(myProject);
      messageView.runWhenInitialized(new Runnable() {
        @Override
        public void run() {
          final Content content =
                  ContentFactory.getInstance().createContent(errorTreeView, tabDisplayName, true);
          messageView.getContentManager().addContent(content);
          Disposer.register(content, errorTreeView);
          messageView.getContentManager().setSelectedContent(content);
          removeContents(content, tabDisplayName);

          ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null);
        }
      });
    }
  }, VcsBundle.message("command.name.open.error.message.view"), null);
}
 
Example #5
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with 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 #6
Source File: TestsUIUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void notifyByBalloon(@Nonnull final Project project, final AbstractTestProxy root, final TestConsoleProperties properties, TestResultPresentation testResultPresentation) {
  if (project.isDisposed()) return;
  if (properties == null) return;

  TestStatusListener.notifySuiteFinished(root, properties.getProject());

  final String testRunDebugId = properties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN;
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);

  final String title = testResultPresentation.getTitle();
  final String text = testResultPresentation.getText();
  final String balloonText = testResultPresentation.getBalloonText();
  final MessageType type = testResultPresentation.getType();

  if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
    toolWindowManager.notifyByBalloon(testRunDebugId, type, balloonText, null, null);
  }

  NOTIFICATION_GROUP.createNotification(balloonText, type).notify(project);
  SystemNotifications.getInstance().notify("TestRunner", title, text);
}
 
Example #7
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 #8
Source File: MessageViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public MessageViewImpl(final Project project, final StartupManager startupManager, final ToolWindowManager toolWindowManager) {
  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      myToolWindow = toolWindowManager.registerToolWindow(ToolWindowId.MESSAGES_WINDOW, true, ToolWindowAnchor.BOTTOM, project, true);
      myToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowMessages);
      new ContentManagerWatcher(myToolWindow, getContentManager());
      for (Runnable postponedRunnable : myPostponedRunnables) {
        postponedRunnable.run();
      }
      myPostponedRunnables.clear();
    }
  };
  if (project.isInitialized()) {
    runnable.run();
  }
  else {
    startupManager.registerPostStartupActivity(runnable::run);
  }

}
 
Example #9
Source File: GlobalInspectionContextImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public synchronized void addView(@Nonnull InspectionResultsView view, @Nonnull String title) {
  if (myContent != null) return;
  myContentManager.getValue().addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void contentRemoved(ContentManagerEvent event) {
      if (event.getContent() == myContent) {
        if (myView != null) {
          close(false);
        }
        myContent = null;
      }
    }
  });

  myView = view;
  myContent = ContentFactory.getInstance().createContent(view, title, false);

  myContent.setDisposer(myView);

  ContentManager contentManager = getContentManager();
  contentManager.addContent(myContent);
  contentManager.setSelectedContent(myContent);

  ToolWindowManager.getInstance(getProject()).getToolWindow(ToolWindowId.INSPECTION).activate(null);
}
 
Example #10
Source File: QuickDocUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static DocumentationComponent getActiveDocComponent(@Nonnull Project project) {
  DocumentationManager documentationManager = DocumentationManager.getInstance(project);
  DocumentationComponent component;
  JBPopup hint = documentationManager.getDocInfoHint();
  if (hint != null) {
    component = (DocumentationComponent)((AbstractPopup)hint).getComponent();
  }
  else if (documentationManager.hasActiveDockedDocWindow()) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION);
    Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent();
    component = selectedContent == null ? null : (DocumentationComponent)selectedContent.getComponent();
  }
  else {
    component = EditorMouseHoverPopupManager.getInstance().getDocumentationComponent();
  }
  return component;
}
 
Example #11
Source File: DependenciesAnalyzeManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public DependenciesAnalyzeManager(final Project project, StartupManager startupManager) {
  myProject = project;
  startupManager.runWhenProjectIsInitialized(new Runnable() {
    @Override
    public void run() {
      ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
      ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.MODULES_DEPENDENCIES,
                                                                   true,
                                                                   ToolWindowAnchor.RIGHT,
                                                                   project);
      myContentManager = toolWindow.getContentManager();
      toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowModuleDependencies);
      new ContentManagerWatcher(toolWindow, myContentManager);
    }
  });
}
 
Example #12
Source File: PredefinedSearchScopeProviderImpl.java    From consulo with 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 #13
Source File: DependenciesToolWindow.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public DependenciesToolWindow(final Project project, StartupManager startupManager) {
  myProject = project;
  startupManager.runWhenProjectIsInitialized(new Runnable() {
    @Override
    public void run() {
      final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
      if (toolWindowManager == null) return;
      ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.DEPENDENCIES,
                                                                   true,
                                                                   ToolWindowAnchor.BOTTOM,
                                                                   project);
      myContentManager = toolWindow.getContentManager();

      toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowInspection);
      new ContentManagerWatcher(toolWindow, myContentManager);
    }
  });
}
 
Example #14
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 #15
Source File: RunConfigurationsSEContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static Executor findExecutor(@Nonnull RunnerAndConfigurationSettings settings, @MagicConstant(intValues = {RUN_MODE, DEBUG_MODE}) int mode) {
  Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();
  Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);

  Executor executor = mode == RUN_MODE ? runExecutor : debugExecutor;
  if (executor == null) {
    return null;
  }

  RunConfiguration runConf = settings.getConfiguration();
  if (ProgramRunner.getRunner(executor.getId(), runConf) == null) {
    executor = runExecutor == executor ? debugExecutor : runExecutor;
  }

  return executor;
}
 
Example #16
Source File: AbstractProjectViewPane.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void doSelectModuleOrGroup(@Nonnull Object toSelect, final boolean requestFocus) {
  ToolWindowManager windowManager = ToolWindowManager.getInstance(myProject);
  final Runnable runnable = () -> {
    if (requestFocus) {
      ProjectView projectView = ProjectView.getInstance(myProject);
      if (projectView != null) {
        projectView.changeView(getId(), getSubId());
      }
    }
    BaseProjectTreeBuilder builder = (BaseProjectTreeBuilder)getTreeBuilder();
    if (builder != null) {
      builder.selectInWidth(toSelect, requestFocus, node -> node instanceof AbstractModuleNode || node instanceof ModuleGroupNode || node instanceof AbstractProjectNode);
    }
  };
  if (requestFocus) {
    windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW).activate(runnable);
  }
  else {
    runnable.run();
  }
}
 
Example #17
Source File: StructureViewSelectInTarget.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
  final FileEditor fileEditor = context.getFileEditorProvider().get();

  ToolWindowManager windowManager=ToolWindowManager.getInstance(context.getProject());
  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      StructureViewFactoryEx.getInstanceEx(myProject).runWhenInitialized(new Runnable() {
        @Override
        public void run() {
          final StructureViewWrapper structureView = getStructureViewWrapper();
          structureView.selectCurrentElement(fileEditor, context.getVirtualFile(), requestFocus);
        }
      });
    }
  };
  if (requestFocus) {
    windowManager.getToolWindow(ToolWindowId.STRUCTURE_VIEW).activate(runnable);
  }
  else {
    runnable.run();
  }

}
 
Example #18
Source File: BrowseHierarchyActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static HierarchyBrowser createAndAddToPanel(@Nonnull Project project, @Nonnull final HierarchyProvider provider, @Nonnull PsiElement target) {
  final HierarchyBrowser hierarchyBrowser = provider.createHierarchyBrowser(target);

  final Content content;

  final HierarchyBrowserManager hierarchyBrowserManager = HierarchyBrowserManager.getInstance(project);

  final ContentManager contentManager = hierarchyBrowserManager.getContentManager();
  final Content selectedContent = contentManager.getSelectedContent();
  if (selectedContent != null && !selectedContent.isPinned()) {
    content = selectedContent;
    final Component component = content.getComponent();
    if (component instanceof Disposable) {
      Disposer.dispose((Disposable)component);
    }
    content.setComponent(hierarchyBrowser.getComponent());
  }
  else {
    content = ContentFactory.getInstance().createContent(hierarchyBrowser.getComponent(), null, true);
    contentManager.addContent(content);
  }
  contentManager.setSelectedContent(content);
  hierarchyBrowser.setContent(content);

  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      provider.browserActivated(hierarchyBrowser);
    }
  };
  ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY).activate(runnable);
  return hierarchyBrowser;
}
 
Example #19
Source File: FlutterReloadManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void removeRunNotifications(FlutterApp app) {
  final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
  final Balloon balloon = ToolWindowManager.getInstance(myProject).getToolWindowBalloon(toolWindowId);
  if (balloon != null) {
    balloon.hide();
  }
}
 
Example #20
Source File: AnalyzeDependenciesOnSpecifiedTargetHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean shouldShowDependenciesPanel(List<DependenciesBuilder> builders) {
  for (DependenciesBuilder builder : builders) {
    for (Set<PsiFile> files : builder.getDependencies().values()) {
      if (!files.isEmpty()) {
        return true;
      }
    }
  }
  final String source = StringUtil.decapitalize(builders.get(0).getScope().getDisplayName());
  final String target = StringUtil.decapitalize(myTargetScope.getDisplayName());
  final String message = AnalysisScopeBundle.message("no.dependencies.found.message", source, target);
  NotificationGroup.toolWindowGroup("Dependencies", ToolWindowId.DEPENDENCIES, true).createNotification(message, MessageType.INFO).notify(myProject);
  return false;
}
 
Example #21
Source File: HierarchyBrowserManager.java    From consulo with 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 #22
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 #23
Source File: DocumentationComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  if (myManager == null) {
    presentation.setEnabledAndVisible(false);
  }
  else {
    presentation.setIcon(ToolWindowManagerEx.getInstanceEx(myManager.myProject).getLocationIcon(ToolWindowId.DOCUMENTATION, consulo.ui.image.Image.empty(16)));
    presentation.setEnabledAndVisible(myToolwindowCallback != null);
  }
}
 
Example #24
Source File: InspectionManagerEx.java    From consulo with 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 #25
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 #26
Source File: CloneElementAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateForToolWindow(String id, DataContext dataContext,Presentation presentation) {
  // work only with single selection
  PsiElement[] elements = dataContext.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
  presentation.setEnabled(elements != null && elements.length == 1 && CopyHandler.canClone(elements));
  presentation.setVisible(true);
  if (!ToolWindowId.COMMANDER.equals(id)) {
    presentation.setVisible(false);
  }
}
 
Example #27
Source File: RunAnythingPopupUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Executor getExecutor() {
  final Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();
  final Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);

  return !SHIFT_IS_PRESSED.get() ? runExecutor : debugExecutor;
}
 
Example #28
Source File: ProjectLevelVcsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ContentManager getContentManager() {
  if (myContentManager == null) {
    ToolWindow changes = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS);
    myContentManager = changes == null ? null : changes.getContentManager();
  }
  return myContentManager;
}
 
Example #29
Source File: ChangeProjectViewAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent event){
  Presentation presentation = event.getPresentation();
  Project project = event.getDataContext().getData(CommonDataKeys.PROJECT);
  if (project == null){
    presentation.setEnabled(false);
    return;
  }
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  presentation.setEnabled(ToolWindowId.PROJECT_VIEW.equals(id));
}
 
Example #30
Source File: RunConfigurationsSEContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void fillExecutorInfo(ChooseRunConfigurationPopup.ItemWrapper wrapper, JList<?> list, boolean selected) {

      SimpleTextAttributes commandAttributes = selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getSelectionForeground()) : SimpleTextAttributes.GRAYED_ATTRIBUTES;
      SimpleTextAttributes shortcutAttributes = selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getSelectionForeground()) : SimpleTextAttributes.GRAY_ATTRIBUTES;

      String input = myCommandSupplier.get();
      if (isCommand(input, RUN_COMMAND)) {
        fillWithMode(wrapper, RUN_MODE, commandAttributes);
        return;
      }
      if (isCommand(input, DEBUG_COMMAND)) {
        fillWithMode(wrapper, DEBUG_MODE, commandAttributes);
        return;
      }

      Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);
      Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();

      KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
      KeyStroke shiftEnterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK);
      if (debugExecutor != null) {
        executorInfo.append(debugExecutor.getId(), commandAttributes);
        executorInfo.append("(" + KeymapUtil.getKeystrokeText(enterStroke) + ")", shortcutAttributes);
        if (runExecutor != null) {
          executorInfo.append(" / " + runExecutor.getId(), commandAttributes);
          executorInfo.append("(" + KeymapUtil.getKeystrokeText(shiftEnterStroke) + ")", shortcutAttributes);
        }
      }
      else {
        if (runExecutor != null) {
          executorInfo.append(runExecutor.getId(), commandAttributes);
          executorInfo.append("(" + KeymapUtil.getKeystrokeText(enterStroke) + ")", shortcutAttributes);
        }
      }
    }