use of com.intellij.openapi.wm.impl.ToolWindowManagerImpl in project intellij-community by JetBrains.
the class PreviewManagerImpl method checkGlobalState.
protected void checkGlobalState() {
ToolWindowManagerImpl toolWindowManager = (ToolWindowManagerImpl) ToolWindowManager.getInstance(myProject);
if (!isAvailable() && toolWindowManager.getToolWindow(ToolWindowId.PREVIEW) != null) {
myHistory.clear();
myContentManager.removeAllContents(true);
toolWindowManager.unregisterToolWindow(ToolWindowId.PREVIEW);
return;
}
if (isAvailable() && toolWindowManager.getToolWindow(ToolWindowId.PREVIEW) == null) {
myToolWindow = (ToolWindowImpl) toolWindowManager.registerToolWindow(ToolWindowId.PREVIEW, myEmptyStatePanel, ToolWindowAnchor.RIGHT, myProject, false);
myContentManager = myToolWindow.getContentManager();
myToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowPreview);
myToolWindow.setContentUiType(ToolWindowContentUiType.COMBO, null);
myToolWindow.setAutoHide(true);
myEmptyStateContent = myContentManager.getContent(0);
final MoveToStandardViewAction moveToStandardViewAction = new MoveToStandardViewAction();
myContentManager.addContentManagerListener(new ContentManagerAdapter() {
@Override
public void selectionChanged(ContentManagerEvent event) {
if (myInnerSelectionChange || event.getOperation() != ContentManagerEvent.ContentOperation.add)
return;
PreviewInfo previewInfo = event.getContent().getUserData(INFO_KEY);
if (previewInfo != null) {
preview(previewInfo, false);
myToolWindow.setTitleActions(previewInfo.supportsStandardPlace() ? moveToStandardViewAction : null);
}
}
});
moveToStandardViewAction.registerCustomShortcutSet(new ShortcutSet() {
@NotNull
@Override
public Shortcut[] getShortcuts() {
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
return keymap.getShortcuts("ShowContent");
}
}, myToolWindow.getComponent());
myToolWindow.setTitleActions(moveToStandardViewAction);
ArrayList<AnAction> myGearActions = new ArrayList<>();
for (PreviewPanelProvider provider : myProviders) {
myGearActions.add(new ContentTypeToggleAction(provider));
}
myToolWindow.setAdditionalGearActions(new DefaultActionGroup("Preview", myGearActions));
myToolWindow.activate(() -> myToolWindow.activate(null));
}
}
Aggregations