use of com.intellij.openapi.wm.ex.ToolWindowEx in project intellij-community by JetBrains.
the class DockablePopupManager method createToolWindow.
public void createToolWindow(final PsiElement element, PsiElement originalElement) {
assert myToolWindow == null;
final T component = createComponent();
final ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(myProject);
final ToolWindow toolWindow = toolWindowManagerEx.getToolWindow(getToolwindowId());
myToolWindow = toolWindow == null ? toolWindowManagerEx.registerToolWindow(getToolwindowId(), true, ToolWindowAnchor.RIGHT, myProject) : toolWindow;
myToolWindow.setIcon(AllIcons.Toolwindows.Documentation);
myToolWindow.setAvailable(true, null);
myToolWindow.setToHideOnEmptyContent(false);
setToolwindowDefaultState();
((ToolWindowEx) myToolWindow).setTitleActions(createRestorePopupAction());
final ContentManager contentManager = myToolWindow.getContentManager();
final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
final Content content = contentFactory.createContent(component, getTitle(element), false);
contentManager.addContent(content);
contentManager.addContentManagerListener(new ContentManagerAdapter() {
@Override
public void contentRemoved(ContentManagerEvent event) {
restorePopupBehavior();
}
});
new UiNotifyConnector(component, new Activatable() {
@Override
public void showNotify() {
restartAutoUpdate(myAutoUpdateDocumentation);
}
@Override
public void hideNotify() {
restartAutoUpdate(false);
}
});
myToolWindow.show(null);
PropertiesComponent.getInstance().setValue(getShowInToolWindowProperty(), Boolean.TRUE.toString());
restartAutoUpdate(PropertiesComponent.getInstance().getBoolean(getAutoUpdateEnabledProperty(), true));
doUpdateComponent(element, originalElement, component);
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project intellij-community by JetBrains.
the class ProjectViewImpl method setupImpl.
// public for tests
public synchronized void setupImpl(@NotNull ToolWindow toolWindow, final boolean loadPaneExtensions) {
ApplicationManager.getApplication().assertIsDispatchThread();
myActionGroup = new DefaultActionGroup();
myAutoScrollFromSourceHandler.install();
myContentManager = toolWindow.getContentManager();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
toolWindow.setDefaultContentUiType(ToolWindowContentUiType.COMBO);
((ToolWindowEx) toolWindow).setAdditionalGearActions(myActionGroup);
toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
}
GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
SwingUtilities.invokeLater(() -> splitterProportions.restoreSplitterProportions(myPanel));
if (loadPaneExtensions) {
ensurePanesLoaded();
}
isInitialized = true;
doAddUninitializedPanes();
getContentManager().addContentManagerListener(new ContentManagerAdapter() {
@Override
public void selectionChanged(ContentManagerEvent event) {
if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
viewSelectionChanged();
}
}
});
viewSelectionChanged();
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project intellij-community by JetBrains.
the class ProjectViewImpl method createToolbarActions.
private void createToolbarActions() {
if (myActionGroup == null)
return;
List<AnAction> titleActions = ContainerUtil.newSmartList();
myActionGroup.removeAll();
if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) {
myActionGroup.addAction(new PaneOptionAction(myFlattenPackages, IdeBundle.message("action.flatten.packages"), IdeBundle.message("action.flatten.packages"), PlatformIcons.FLATTEN_PACKAGES_ICON, ourFlattenPackagesDefaults) {
@Override
public void setSelected(AnActionEvent event, boolean flag) {
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
final SelectionInfo selectionInfo = SelectionInfo.create(viewPane);
if (isGlobalOptions()) {
setFlattenPackages(flag, viewPane.getId());
}
super.setSelected(event, flag);
selectionInfo.apply(viewPane);
}
@Override
public boolean isSelected(AnActionEvent event) {
if (isGlobalOptions())
return getGlobalOptions().getFlattenPackages();
return super.isSelected(event);
}
}).setAsSecondary(true);
}
class FlattenPackagesDependableAction extends PaneOptionAction {
FlattenPackagesDependableAction(@NotNull Map<String, Boolean> optionsMap, @NotNull String text, @NotNull String description, @NotNull Icon icon, boolean optionDefaultValue) {
super(optionsMap, text, description, icon, optionDefaultValue);
}
@Override
public void setSelected(AnActionEvent event, boolean flag) {
if (isGlobalOptions()) {
getGlobalOptions().setFlattenPackages(flag);
}
super.setSelected(event, flag);
}
@Override
public void update(AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
presentation.setVisible(isFlattenPackages(myCurrentViewId));
}
}
if (ProjectViewDirectoryHelper.getInstance(myProject).supportsHideEmptyMiddlePackages()) {
myActionGroup.addAction(new HideEmptyMiddlePackagesAction()).setAsSecondary(true);
}
if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) {
myActionGroup.addAction(new FlattenPackagesDependableAction(myAbbreviatePackageNames, IdeBundle.message("action.abbreviate.qualified.package.names"), IdeBundle.message("action.abbreviate.qualified.package.names"), AllIcons.ObjectBrowser.AbbreviatePackageNames, ourAbbreviatePackagesDefaults) {
@Override
public boolean isSelected(AnActionEvent event) {
return isFlattenPackages(myCurrentViewId) && isAbbreviatePackageNames(myCurrentViewId);
}
@Override
public void setSelected(AnActionEvent event, boolean flag) {
if (isGlobalOptions()) {
setAbbreviatePackageNames(flag, myCurrentViewId);
}
setPaneOption(myOptionsMap, flag, myCurrentViewId, true);
}
@Override
public void update(AnActionEvent e) {
super.update(e);
if (ScopeViewPane.ID.equals(myCurrentViewId)) {
e.getPresentation().setEnabled(false);
}
}
}).setAsSecondary(true);
}
if (isShowMembersOptionSupported()) {
myActionGroup.addAction(new PaneOptionAction(myShowMembers, IdeBundle.message("action.show.members"), IdeBundle.message("action.show.hide.members"), AllIcons.ObjectBrowser.ShowMembers, ourShowMembersDefaults) {
@Override
public boolean isSelected(AnActionEvent event) {
if (isGlobalOptions())
return getGlobalOptions().getShowMembers();
return super.isSelected(event);
}
@Override
public void setSelected(AnActionEvent event, boolean flag) {
if (isGlobalOptions()) {
getGlobalOptions().setShowMembers(flag);
}
super.setSelected(event, flag);
}
}).setAsSecondary(true);
}
myActionGroup.addAction(myAutoScrollToSourceHandler.createToggleAction()).setAsSecondary(true);
myActionGroup.addAction(myAutoScrollFromSourceHandler.createToggleAction()).setAsSecondary(true);
myActionGroup.addAction(new ManualOrderAction()).setAsSecondary(true);
myActionGroup.addAction(new SortByTypeAction()).setAsSecondary(true);
myActionGroup.addAction(new FoldersAlwaysOnTopAction()).setAsSecondary(true);
if (!myAutoScrollFromSourceHandler.isAutoScrollEnabled()) {
titleActions.add(new ScrollFromSourceAction());
}
AnAction collapseAllAction = CommonActionsManager.getInstance().createCollapseAllAction(new TreeExpander() {
@Override
public void expandAll() {
}
@Override
public boolean canExpand() {
return false;
}
@Override
public void collapseAll() {
AbstractProjectViewPane pane = getCurrentProjectViewPane();
JTree tree = pane.myTree;
if (tree != null) {
TreeUtil.collapseAll(tree, 0);
}
}
@Override
public boolean canCollapse() {
return true;
}
}, getComponent());
collapseAllAction.getTemplatePresentation().setIcon(AllIcons.General.CollapseAll);
collapseAllAction.getTemplatePresentation().setHoveredIcon(AllIcons.General.CollapseAllHover);
titleActions.add(collapseAllAction);
getCurrentProjectViewPane().addToolbarActions(myActionGroup);
ToolWindowEx window = (ToolWindowEx) ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
if (window != null) {
window.setTitleActions(titleActions.toArray(new AnAction[titleActions.size()]));
}
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project intellij-community by JetBrains.
the class PyDataViewToolWindowFactory method createToolWindowContent.
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
PyDataView.getInstance(project).init(toolWindow);
final MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(XDebuggerManager.TOPIC, new ChangeContentXDebuggerManagerListener(project));
connection.subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() {
@Override
public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
if (!(executor instanceof DefaultDebugExecutor)) {
return;
}
if (descriptor == null) {
return;
}
ProcessHandler handler = descriptor.getProcessHandler();
if (handler == null) {
return;
}
PyDataView.getInstance(project).updateTabs(handler);
}
@Override
public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
}
});
addPythonConsoleListener(project);
((ToolWindowEx) toolWindow).setAdditionalGearActions(new DefaultActionGroup(new ColoredByDefaultAction()));
}
use of com.intellij.openapi.wm.ex.ToolWindowEx in project android by JetBrains.
the class NlAbstractWindowManager method createWindowContent.
protected void createWindowContent(@NotNull JComponent contentPane, @NotNull JComponent focusedComponent, @Nullable AnAction[] actions) {
ContentManager contentManager = myToolWindow.getContentManager();
Content content = contentManager.getFactory().createContent(contentPane, null, false);
content.setCloseable(false);
content.setPreferredFocusableComponent(focusedComponent);
if (actions != null) {
ToolWindowEx toolWindow = (ToolWindowEx) myToolWindow;
toolWindow.setTitleActions(actions);
}
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
}
Aggregations