use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class HideSideWindowsAction method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
Project project = event.getProject();
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;
}
presentation.setEnabled(HideToolWindowAction.shouldBeHiddenByShortCut(toolWindowManager, id));
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class HideToolWindowAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
return;
}
ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
String id = toolWindowManager.getActiveToolWindowId();
if (id == null) {
id = toolWindowManager.getLastActiveToolWindowId();
}
if (shouldBeHiddenByShortCut(toolWindowManager, id)) {
toolWindowManager.getToolWindow(id).hide(null);
}
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class MavenProjectsNavigator method initToolWindow.
private void initToolWindow() {
initTree();
JPanel panel = new MavenProjectsNavigatorPanel(myProject, myTree);
AnAction removeAction = EmptyAction.wrap(ActionManager.getInstance().getAction("Maven.RemoveRunConfiguration"));
removeAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree, myProject);
AnAction editSource = EmptyAction.wrap(ActionManager.getInstance().getAction("Maven.EditRunConfiguration"));
editSource.registerCustomShortcutSet(CommonShortcuts.getEditSource(), myTree, myProject);
final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
myToolWindow = (ToolWindowEx) manager.registerToolWindow(TOOL_WINDOW_ID, false, ToolWindowAnchor.RIGHT, myProject, true);
myToolWindow.setIcon(MavenIcons.ToolWindowMaven);
final ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
final Content content = contentFactory.createContent(panel, "", false);
ContentManager contentManager = myToolWindow.getContentManager();
contentManager.addContent(content);
contentManager.setSelectedContent(content, false);
final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {
boolean wasVisible = false;
@Override
public void stateChanged() {
if (myToolWindow.isDisposed())
return;
boolean visible = myToolWindow.isVisible();
if (!visible || wasVisible) {
return;
}
scheduleStructureUpdate();
wasVisible = true;
}
};
manager.addToolWindowManagerListener(listener, myProject);
ActionManager actionManager = ActionManager.getInstance();
DefaultActionGroup group = new DefaultActionGroup();
group.add(actionManager.getAction("Maven.GroupProjects"));
group.add(actionManager.getAction("Maven.ShowIgnored"));
group.add(actionManager.getAction("Maven.ShowBasicPhasesOnly"));
group.add(actionManager.getAction("Maven.AlwaysShowArtifactId"));
group.add(actionManager.getAction("Maven.ShowVersions"));
myToolWindow.setAdditionalGearActions(group);
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-community by JetBrains.
the class PyDataView method init.
public void init(@NotNull ToolWindow toolWindow) {
myTabs = new PyDataViewTabs(myProject);
myTabs.setPopupGroup(new DefaultActionGroup(new ColoredAction()), ActionPlaces.UNKNOWN, true);
myTabs.setTabDraggingEnabled(true);
final Content content = ContentFactory.SERVICE.getInstance().createContent(myTabs, "", false);
content.setCloseable(true);
toolWindow.getContentManager().addContent(content);
((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {
@Override
public void stateChanged() {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(DATA_VIEWER_ID);
if (window == null) {
return;
}
if (toolWindow.isAvailable() && toolWindow.getType().equals(ToolWindowType.FLOATING) && !toolWindow.isVisible()) {
toolWindow.setShowStripeButton(false);
myTabs.removeAllTabs();
}
}
});
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project android by JetBrains.
the class AndroidUtils method activateConsoleToolWindow.
public static void activateConsoleToolWindow(@NotNull Project project, @NotNull final Runnable runAfterActivation) {
final ToolWindowManager manager = ToolWindowManager.getInstance(project);
final String toolWindowId = AndroidBundle.message("android.console.tool.window.title");
ToolWindow toolWindow = manager.getToolWindow(toolWindowId);
if (toolWindow != null) {
runAfterActivation.run();
return;
}
toolWindow = manager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM);
final ConsoleView console = new ConsoleViewImpl(project, false);
project.putUserData(CONSOLE_VIEW_KEY, console);
toolWindow.getContentManager().addContent(new ContentImpl(console.getComponent(), "", false));
final ToolWindowManagerListener listener = new ToolWindowManagerListener() {
@Override
public void toolWindowRegistered(@NotNull String id) {
}
@Override
public void stateChanged() {
ToolWindow window = manager.getToolWindow(toolWindowId);
if (window != null && !window.isVisible()) {
((ToolWindowManagerEx) manager).removeToolWindowManagerListener(this);
getApplication().invokeLater(() -> manager.unregisterToolWindow(toolWindowId));
}
}
};
toolWindow.show(() -> {
runAfterActivation.run();
((ToolWindowManagerEx) manager).addToolWindowManagerListener(listener);
});
}
Aggregations