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

The following examples show how to use com.intellij.openapi.wm.ex.ToolWindowManagerEx#getInstanceEx() . 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: 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 2
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 3
Source File: ToggleWindowedModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void setSelected(AnActionEvent event, boolean flag) {
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  if (id == null) {
    return;
  }
  ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
  ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id);
  ToolWindowType type = toolWindow.getType();
  if (ToolWindowType.WINDOWED == type) {
    toolWindow.setType(toolWindow.getInternalType(), null);
  }
  else {
    toolWindow.setType(ToolWindowType.WINDOWED, null);
  }
}
 
Example 4
Source File: ToolWindowManagerBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void runActivity(@Nonnull UIAccess uiAccess, @Nonnull Project project) {
  ToolWindowManagerEx ex = ToolWindowManagerEx.getInstanceEx(project);
  if (ex instanceof ToolWindowManagerBase) {
    ToolWindowManagerBase manager = (ToolWindowManagerBase)ex;
    List<FinalizableCommand> list = new ArrayList<>();
    manager.registerToolWindowsFromBeans(list);
    manager.initAll(list);

    list.add(((ToolWindowManagerBase)ex).connectModuleExtensionListener());

    uiAccess.give(() -> {
      manager.execute(list);
      manager.flushCommands();
    });
  }
}
 
Example 5
Source File: ToggleFloatingModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void setSelected(AnActionEvent event, boolean flag) {
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  if (id == null) {
    return;
  }
  ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
  ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id);
  ToolWindowType type = toolWindow.getType();
  if (ToolWindowType.FLOATING == type) {
    toolWindow.setType(toolWindow.getInternalType(), null);
  }
  else {
    toolWindow.setType(ToolWindowType.FLOATING, null);
  }
}
 
Example 6
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 7
Source File: DockablePopupManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void restorePopupBehavior() {
  if (myToolWindow != null) {
    PropertiesComponent.getInstance().setValue(getShowInToolWindowProperty(), Boolean.FALSE.toString());
    ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(myProject);
    toolWindowManagerEx.hideToolWindow(getToolwindowId(), false);
    toolWindowManagerEx.unregisterToolWindow(getToolwindowId());
    Disposer.dispose(myToolWindow.getContentManager());
    myToolWindow = null;
    restartAutoUpdate(false);
  }
}
 
Example 8
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
static boolean storeToolWindows(@Nullable Project project) {
  if (project == null) return false;
  ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);

  ToolWindowLayout layout = new ToolWindowLayout();
  layout.copyFrom(manager.getLayout());
  boolean hasVisible = hideAllToolWindows(manager);

  if (hasVisible) {
    manager.setLayoutToRestoreLater(layout);
    manager.activateEditorComponent();
  }
  return hasVisible;
}
 
Example 9
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 10
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 11
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 12
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 13
Source File: HideAllToolWindowsAction.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 toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  String[] ids = toolWindowManager.getToolWindowIds();
  for (String id : ids) {
    if (toolWindowManager.getToolWindow(id).isVisible()) {
      presentation.setEnabled(true);
      presentation.setText(IdeBundle.message("action.hide.all.windows"), true);
      return;
    }
  }

  final ToolWindowLayout layout = toolWindowManager.getLayoutToRestoreLater();
  if (layout != null) {
    presentation.setEnabled(true);
    presentation.setText(IdeBundle.message("action.restore.windows"));
    return;
  }

  presentation.setEnabled(false);
}
 
Example 14
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
static void restoreToolWindows(Project project, boolean needsRestore, boolean inPresentation) {
  if (project == null || !needsRestore) return;
  ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
  ToolWindowLayout restoreLayout = manager.getLayoutToRestoreLater();
  if (!inPresentation && restoreLayout != null) {
    manager.setLayout(restoreLayout);
  }
}
 
Example 15
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 16
Source File: VcsLogTabsWatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
public VcsLogTabsWatcher(@Nonnull Project project, @Nonnull PostponableLogRefresher refresher, @Nonnull Disposable parentDisposable) {
  myRefresher = refresher;
  myToolWindowManager = ToolWindowManagerEx.getInstanceEx(project);

  myPostponedEventsListener = new MyRefreshPostponedEventsListener();
  myToolWindowManager.addToolWindowManagerListener(myPostponedEventsListener);
  installContentListener();

  Disposer.register(parentDisposable, this);
}
 
Example 17
Source File: SlingPluginToolWindowFactory.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
public void createToolWindowContent(final Project project, final ToolWindow toolWindow) {
    // Plugin is now placed into a Tabbed Pane to add additional views to it
    JBTabbedPane master = new JBTabbedPane(SwingConstants.BOTTOM);
    SlingPluginExplorer explorer = new SlingPluginExplorer(project);
    LOGGER.debug("CTWC: Explorer: '" + explorer + "'");
    master.insertTab("Plugin", null, explorer, "Plugin Windows", 0);

    WebContentFXPanel info = new WebContentFXPanel();
    master.insertTab("Info", null, info, "Plugin Info", 1);

    final AemdcPanel aemdcPanel = ComponentProvider.getComponent(project, AemdcPanel.class);
    LOGGER.debug("AEMDC Panel found: '{}'", aemdcPanel);
    aemdcPanel.setContainer(master);

    final ContentManager contentManager = toolWindow.getContentManager();
    final Content content = contentManager.getFactory().createContent(master, null, false);
    contentManager.addContent(content);
    Disposer.register(project, explorer);

    final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {
        boolean wasVisible = false;

        @Override
        public void stateChanged() {
            if (toolWindow.isDisposed()) {
                return;
            }
            boolean visible = toolWindow.isVisible();
            // If the Plugin became visible then we let the AEMDC Panel know to recrate the JFX Panel
            // to avoid the double buffering
            if(!wasVisible && visible) {
                aemdcPanel.reset();
            }
            wasVisible = visible;
        }
    };
    final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
    manager.addToolWindowManagerListener(listener, project);
}
 
Example 18
Source File: ToolWindowTracker.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ToolWindowTracker(@NotNull Project project, @NotNull Analytics analytics) {
  myAnalytics = analytics;

  myToolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  myToolWindowManager.addToolWindowManagerListener(this);

  update();
}
 
Example 19
Source File: ToolWindowTracker.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ToolWindowTracker(@NotNull Project project, @NotNull Analytics analytics) {
  myAnalytics = analytics;

  myToolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  myToolWindowManager.addToolWindowManagerListener(this);

  update();
}
 
Example 20
Source File: DesktopEditorImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean toolWindowIsNotEmpty() {
  if (myProject == null) return false;
  ToolWindowManagerEx m = ToolWindowManagerEx.getInstanceEx(myProject);
  return m != null && !m.getIdsOn(ToolWindowAnchor.TOP).isEmpty();
}