use of com.intellij.openapi.wm.ex.ToolWindowEx in project intellij-community by JetBrains.
the class ContentManagerUtil method getContentManagerFromContext.
/**
* This is utility method. It returns <code>ContentManager</code> from the current context.
*/
public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return null;
}
ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
String id = mgr.getActiveToolWindowId();
if (id == null) {
if (mgr.isEditorComponentActive()) {
id = mgr.getLastActiveToolWindowId();
}
}
ToolWindowEx toolWindow = id != null ? (ToolWindowEx) mgr.getToolWindow(id) : null;
if (requiresVisibleToolWindow && (toolWindow == null || !toolWindow.isVisible())) {
return null;
}
ContentManager fromToolWindow = toolWindow != null ? toolWindow.getContentManager() : null;
ContentManager fromContext = PlatformDataKeys.CONTENT_MANAGER.getData(dataContext);
return ObjectUtils.chooseNotNull(fromContext, fromToolWindow);
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project intellij-community by JetBrains.
the class BaseToolWindowToggleAction method setSelected.
@Override
public final void setSelected(AnActionEvent e, boolean state) {
Project project = e.getProject();
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);
setSelected(toolWindow, state);
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project android by JetBrains.
the class FloatingToolWindow method createToolWindow.
private ToolWindowEx createToolWindow(@NotNull ToolWindowManager toolWindowManager, @NotNull ToolWindowDefinition<T> definition) {
String id = definition.getTitle();
ToolWindowEx window = (ToolWindowEx) toolWindowManager.getToolWindow(id);
if (window == null) {
ToolWindowAnchor anchor = definition.getSide().isLeft() ? ToolWindowAnchor.LEFT : ToolWindowAnchor.RIGHT;
window = (ToolWindowEx) toolWindowManager.registerToolWindow(id, false, anchor, this, true);
window.setIcon(definition.getIcon());
window.setType(ToolWindowType.FLOATING, null);
window.setAutoHide(false);
setToolWindowContent(window);
setAdditionalGearPopupActions(window);
setAdditionalActions(window);
}
return window;
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project android by JetBrains.
the class CaptureEditorLightToolWindowManager method initToolWindow.
@Override
protected void initToolWindow() {
myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(getManagerName(), false, getAnchor(), myProject, true);
myToolWindow.setIcon(getIcon());
if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
}
((ToolWindowEx) myToolWindow).setTitleActions(createActions());
initGearActions();
ContentManager contentManager = myToolWindow.getContentManager();
Content content = contentManager.getFactory().createContent(getContent(), getToolWindowTitleBarText(), false);
content.setCloseable(false);
content.setPreferredFocusableComponent(getFocusedComponent());
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
myToolWindow.setAvailable(false, null);
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project azure-tools-for-java by Microsoft.
the class ServerExplorerToolWindowFactory method addToolbarItems.
private void addToolbarItems(ToolWindow toolWindow, final AzureModule azureModule) {
if (toolWindow instanceof ToolWindowEx) {
ToolWindowEx toolWindowEx = (ToolWindowEx) toolWindow;
try {
Runnable forceRefreshTitleActions = () -> {
try {
toolWindowEx.setTitleActions(new AnAction("Refresh", "Refresh Azure Nodes List", null) {
@Override
public void actionPerformed(AnActionEvent event) {
azureModule.load(true);
}
@Override
public void update(AnActionEvent e) {
boolean isDarkTheme = DefaultLoader.getUIHelper().isDarkTheme();
e.getPresentation().setIcon(UIHelperImpl.loadIcon(isDarkTheme ? RefreshableNode.REFRESH_ICON_DARK : RefreshableNode.REFRESH_ICON_LIGHT));
}
}, new AzureSignInAction(), new SelectSubscriptionsAction());
} catch (Exception e) {
AzurePlugin.log(e.getMessage(), e);
}
};
AuthMethodManager.getInstance().addSignInEventListener(forceRefreshTitleActions);
AuthMethodManager.getInstance().addSignOutEventListener(forceRefreshTitleActions);
forceRefreshTitleActions.run();
} catch (Exception e) {
AzurePlugin.log(e.getMessage(), e);
}
}
}
Aggregations