Java Code Examples for com.intellij.openapi.wm.ex.ToolWindowManagerEx#getLastActiveToolWindowId()

The following examples show how to use com.intellij.openapi.wm.ex.ToolWindowManagerEx#getLastActiveToolWindowId() . 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: HideSideWindowsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }

  ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  String id = toolWindowManager.getActiveToolWindowId();
  if (id != null) {
    presentation.setEnabled(true);
    return;
  }

  id = toolWindowManager.getLastActiveToolWindowId();
  if (id == null) {
    presentation.setEnabled(false);
    return;
  }

  ToolWindowEx toolWindow = (ToolWindowEx)toolWindowManager.getToolWindow(id);
  presentation.setEnabled(toolWindow.isVisible());
}
 
Example 2
Source File: HideToolWindowAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }

  ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  String id = toolWindowManager.getActiveToolWindowId();
  if (id != null) {
    presentation.setEnabled(true);
    return;
  }

  id = toolWindowManager.getLastActiveToolWindowId();
  if (id == null) {
    presentation.setEnabled(false);
    return;
  }

  ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
  presentation.setEnabled(toolWindow.isVisible());
}
 
Example 3
Source File: ContentManagerUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * This is utility method. It returns <code>ContentManager</code> from the current context.
 */
public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow){
  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return null;
  }

  ToolWindowManagerEx mgr=ToolWindowManagerEx.getInstanceEx(project);

  String id = mgr.getActiveToolWindowId();
  if (id == null) {
    if(mgr.isEditorComponentActive()){
      id = mgr.getLastActiveToolWindowId();
    }
  }
  if(id == null){
    return null;
  }

  ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id);
  if (requiresVisibleToolWindow && !toolWindow.isVisible()) {
    return null;
  }

  final ContentManager fromContext = dataContext.getData(PlatformDataKeys.CONTENT_MANAGER);
  if (fromContext != null) return fromContext;

  return toolWindow != null ? toolWindow.getContentManager() : null;
}
 
Example 4
Source File: HideSideWindowsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }

  ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  String id = toolWindowManager.getActiveToolWindowId();
  if (id == null) {
    id = toolWindowManager.getLastActiveToolWindowId();
  }
  toolWindowManager.hideToolWindow(id, true);
}
 
Example 5
Source File: OccurenceNavigatorActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@RequiredUIAccess
private static Component getOccurenceNavigatorFromContext(DataContext dataContext) {
  Window window = TargetAWT.to(WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow());

  if (window != null) {
    Component component = window.getFocusOwner();
    for (Component c = component; c != null; c = c.getParent()) {
      if (c instanceof OccurenceNavigator) {
        return c;
      }
    }
  }

  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return null;
  }

  ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);

  String id = mgr.getLastActiveToolWindowId(component -> findNavigator(component) != null);
  if (id == null) {
    return null;
  }
  return (Component)findNavigator(mgr.getToolWindow(id).getComponent());
}
 
Example 6
Source File: HideToolWindowAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }

  ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  String id = toolWindowManager.getActiveToolWindowId();
  if (id == null) {
    id = toolWindowManager.getLastActiveToolWindowId();
  }
  toolWindowManager.getToolWindow(id).hide(null);
}
 
Example 7
Source File: JumpToLastWindowAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }
  ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
  String id = manager.getLastActiveToolWindowId();
  if(id==null||!manager.getToolWindow(id).isAvailable()){
    return;
  }
  manager.getToolWindow(id).activate(null);
}
 
Example 8
Source File: JumpToLastWindowAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void update(AnActionEvent event){
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }
  ToolWindowManagerEx manager=(ToolWindowManagerEx)ToolWindowManager.getInstance(project);
  String id = manager.getLastActiveToolWindowId();
  presentation.setEnabled(id != null && manager.getToolWindow(id).isAvailable());
}