Search in sources :

Example 1 with PreviewPanelProvider

use of com.intellij.openapi.preview.PreviewPanelProvider in project intellij-community by JetBrains.

the class PreviewManagerImpl method getState.

@Nullable
@Override
public PreviewManagerState getState() {
    PreviewManagerState state = new PreviewManagerState();
    state.myArtifactFilesMap = new HashMap<>();
    for (PreviewPanelProvider provider : myProviders) {
        state.myArtifactFilesMap.put(provider.toString(), myActiveProviderIds.contains(provider.getId()));
    }
    return state;
}
Also used : PreviewPanelProvider(com.intellij.openapi.preview.PreviewPanelProvider) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PreviewPanelProvider

use of com.intellij.openapi.preview.PreviewPanelProvider 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));
    }
}
Also used : ToolWindowManagerImpl(com.intellij.openapi.wm.impl.ToolWindowManagerImpl) PreviewPanelProvider(com.intellij.openapi.preview.PreviewPanelProvider) ContentManagerAdapter(com.intellij.ui.content.ContentManagerAdapter) NotNull(org.jetbrains.annotations.NotNull) PreviewInfo(com.intellij.openapi.preview.PreviewInfo) ContentManagerEvent(com.intellij.ui.content.ContentManagerEvent) Keymap(com.intellij.openapi.keymap.Keymap)

Aggregations

PreviewPanelProvider (com.intellij.openapi.preview.PreviewPanelProvider)2 Keymap (com.intellij.openapi.keymap.Keymap)1 PreviewInfo (com.intellij.openapi.preview.PreviewInfo)1 ToolWindowManagerImpl (com.intellij.openapi.wm.impl.ToolWindowManagerImpl)1 ContentManagerAdapter (com.intellij.ui.content.ContentManagerAdapter)1 ContentManagerEvent (com.intellij.ui.content.ContentManagerEvent)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1