Example usage for com.intellij.openapi.wm ToolWindow installWatcher

List of usage examples for com.intellij.openapi.wm ToolWindow installWatcher

Introduction

In this page you can find the example usage for com.intellij.openapi.wm ToolWindow installWatcher.

Prototype

void installWatcher(ContentManager contentManager);

Source Link

Usage

From source file:com.anecdote.ideaplugins.commitlog.CommitLogWindow.java

License:Apache License

private void initialize() {
    if (!_isInitialized) {
        _isInitialized = true;/*from   ww  w.  j a  va 2 s .c o  m*/
        _isDisposed = false;
        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(_project);
        ToolWindow toolWindow = toolWindowManager.registerToolWindow(COMMIT_LOGS_TOOLWINDOW_ID, true,
                ToolWindowAnchor.BOTTOM);
        toolWindow.setIcon(COMMIT_LOGS_SMALL_ICON);
        _contentManager = toolWindow.getContentManager();
        toolWindow.installWatcher(_contentManager);
        //      _contentManager = PeerFactory.getInstance().getContentFactory().createContentManager(true, _project);
        _contentManager.addContentManagerListener(new ContentManagerAdapter() {
            @Override
            public void contentRemoved(ContentManagerEvent event) {
                JComponent component = event.getContent().getComponent();
                JComponent removedComponent = (component instanceof CommitLogWindowComponent)
                        ? ((CommitLogWindowComponent) component).getComponent()
                        : component;
                //                    if (removedComponent == myErrorsView) {
                //                        myErrorsView.dispose();
                //                        myErrorsView = null;
                //                    } else
                for (Iterator iterator = _commitLogs.iterator(); iterator.hasNext();) {
                    Editor editor = (Editor) iterator.next();
                    if (removedComponent == editor.getComponent()) {
                        EditorFactory.getInstance().releaseEditor(editor);
                        iterator.remove();
                    }
                }
            }
        });
        //      final JComponent component = _contentManager.getComponent();
    }
}