Search in sources :

Example 6 with Activatable

use of com.intellij.util.ui.update.Activatable 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);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) Activatable(com.intellij.util.ui.update.Activatable) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 7 with Activatable

use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.

the class AbstractProjectViewPSIPane method createComponent.

@Override
public JComponent createComponent() {
    if (myComponent != null)
        return myComponent;
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    myTree = createTree(treeModel);
    enableDnD();
    myComponent = ScrollPaneFactory.createScrollPane(myTree);
    if (Registry.is("error.stripe.enabled")) {
        ErrorStripePainter painter = new ErrorStripePainter(true);
        Disposer.register(this, new TreeUpdater<ErrorStripePainter>(painter, myComponent, myTree) {

            @Override
            protected void update(ErrorStripePainter painter, int index, Object object) {
                if (object instanceof DefaultMutableTreeNode) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
                    object = node.getUserObject();
                }
                if (object instanceof PsiDirectoryNode && !myTree.isCollapsed(index)) {
                    object = null;
                }
                super.update(painter, index, object);
            }

            @Override
            protected ErrorStripe getErrorStripe(Object object) {
                if (object instanceof PresentableNodeDescriptor) {
                    PresentableNodeDescriptor node = (PresentableNodeDescriptor) object;
                    PresentationData presentation = node.getPresentation();
                    TextAttributesKey key = presentation.getTextAttributesKey();
                    if (key != null) {
                        TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
                        if (attributes != null && EffectType.WAVE_UNDERSCORE == attributes.getEffectType()) {
                            return ErrorStripe.create(attributes.getEffectColor(), 1);
                        }
                    }
                }
                return null;
            }
        });
    }
    myTreeStructure = createStructure();
    BaseProjectTreeBuilder treeBuilder = createBuilder(treeModel);
    installComparator(treeBuilder);
    setTreeBuilder(treeBuilder);
    initTree();
    Disposer.register(getTreeBuilder(), new UiNotifyConnector(myTree, new Activatable() {

        private boolean showing;

        @Override
        public void showNotify() {
            if (!showing) {
                showing = true;
                restoreExpandedPaths();
            }
        }

        @Override
        public void hideNotify() {
            if (showing) {
                showing = false;
                saveExpandedPaths();
            }
        }
    }));
    return myComponent;
}
Also used : ErrorStripe(com.intellij.ui.stripe.ErrorStripe) PresentableNodeDescriptor(com.intellij.ide.util.treeView.PresentableNodeDescriptor) PresentationData(com.intellij.ide.projectView.PresentationData) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Activatable(com.intellij.util.ui.update.Activatable) ErrorStripePainter(com.intellij.ui.stripe.ErrorStripePainter) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) BaseProjectTreeBuilder(com.intellij.ide.projectView.BaseProjectTreeBuilder)

Example 8 with Activatable

use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.

the class MouseDragHelper method start.

public void start() {
    if (myGlassPane != null)
        return;
    new UiNotifyConnector(myDragComponent, new Activatable() {

        @Override
        public void showNotify() {
            attach();
        }

        @Override
        public void hideNotify() {
            detach(true);
        }
    });
    Disposer.register(myParentDisposable, new Disposable() {

        @Override
        public void dispose() {
            stop();
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) Activatable(com.intellij.util.ui.update.Activatable) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector)

Example 9 with Activatable

use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.

the class ActionToolbarImpl method updateWhenFirstShown.

private static void updateWhenFirstShown(JComponent targetComponent, final ToolbarReference ref) {
    Activatable activatable = new Activatable.Adapter() {

        public void showNotify() {
            ActionToolbarImpl toolbar = ref.get();
            if (toolbar != null) {
                toolbar.myUpdater.updateActions(false, false);
            }
        }
    };
    ref.myDisposable = new UiNotifyConnector(targetComponent, activatable) {

        @Override
        protected void showNotify() {
            super.showNotify();
            ref.disposeReference();
        }
    };
}
Also used : Activatable(com.intellij.util.ui.update.Activatable) ComponentAdapter(java.awt.event.ComponentAdapter) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector)

Aggregations

Activatable (com.intellij.util.ui.update.Activatable)9 UiNotifyConnector (com.intellij.util.ui.update.UiNotifyConnector)8 Disposable (com.intellij.openapi.Disposable)3 UiActivity (com.intellij.ide.UiActivity)1 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)1 PresentationData (com.intellij.ide.projectView.PresentationData)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 PresentableNodeDescriptor (com.intellij.ide.util.treeView.PresentableNodeDescriptor)1 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)1 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 ToolWindowEx (com.intellij.openapi.wm.ex.ToolWindowEx)1 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)1 CollectionComboBoxModel (com.intellij.ui.CollectionComboBoxModel)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 ErrorStripe (com.intellij.ui.stripe.ErrorStripe)1 ErrorStripePainter (com.intellij.ui.stripe.ErrorStripePainter)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 MouseEvent (java.awt.event.MouseEvent)1