private void initialize() {
    if (myIsInitialized) {
      return;
    }

    myIsInitialized = true;
    myIsDisposed = false;

    myContentManager = ContentFactory.SERVICE.getInstance().createContentManager(true, myProject);
    myContentManager.addContentManagerListener(
        new ContentManagerAdapter() {
          public void contentRemoved(ContentManagerEvent event) {
            JComponent component = event.getContent().getComponent();
            JComponent removedComponent =
                component instanceof CvsTabbedWindowComponent
                    ? ((CvsTabbedWindowComponent) component).getComponent()
                    : component;
            if (removedComponent == myErrorsView) {
              myErrorsView.dispose();
              myErrorsView = null;
            } else if (myOutput != null && removedComponent == myOutput.getComponent()) {
              EditorFactory.getInstance().releaseEditor(myOutput);
              myOutput = null;
            }
          }
        });

    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
    ToolWindow toolWindow =
        toolWindowManager.registerToolWindow(
            ToolWindowId.CVS, myContentManager.getComponent(), ToolWindowAnchor.BOTTOM);
    toolWindow.setIcon(AllIcons.Providers.Cvs);
    toolWindow.installWatcher(myContentManager);
  }
 private CloseListener(Content content, ContentManager contentManager, Project project) {
   myContent = content;
   myContentManager = contentManager;
   myProject = project;
   contentManager.addContentManagerListener(this);
   ProjectManager.getInstance().addProjectManagerListener(myProject, this);
 }
  private void registerToolwindow(@NotNull final Executor executor) {
    final String toolWindowId = executor.getToolWindowId();
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
    if (toolWindowManager == null) return; // headless environment
    if (toolWindowManager.getToolWindow(toolWindowId) != null) {
      return;
    }

    final ToolWindow toolWindow =
        toolWindowManager.registerToolWindow(
            toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true);

    final ContentManager contentManager = toolWindow.getContentManager();
    class MyDataProvider implements DataProvider {
      private int myInsideGetData = 0;

      public Object getData(String dataId) {
        myInsideGetData++;
        try {
          if (PlatformDataKeys.HELP_ID.is(dataId)) {
            return executor.getHelpId();
          } else {
            return myInsideGetData == 1
                ? DataManager.getInstance()
                    .getDataContext(contentManager.getComponent())
                    .getData(dataId)
                : null;
          }
        } finally {
          myInsideGetData--;
        }
      }
    }
    contentManager.addDataProvider(new MyDataProvider());

    toolWindow.setIcon(executor.getToolWindowIcon());
    new ContentManagerWatcher(toolWindow, contentManager);
    contentManager.addContentManagerListener(
        new ContentManagerAdapter() {
          public void selectionChanged(final ContentManagerEvent event) {
            final Content content = event.getContent();
            final RunContentDescriptor descriptor =
                content != null ? getRunContentDescriptorByContent(content) : null;
            getSyncPublisher().contentSelected(descriptor, executor);
          }
        });
    myToolwindowIdToContentManagerMap.put(toolWindowId, contentManager);
    Disposer.register(
        contentManager,
        new Disposable() {
          public void dispose() {
            unregisterToolwindow(toolWindowId);
          }
        });
    myToolwindowIdZbuffer.addLast(toolWindowId);
  }
  public PanelWithActionsAndCloseButton(
      ContentManager contentManager, @NonNls String helpId, final boolean verticalToolbar) {
    super(new BorderLayout());
    myContentManager = contentManager;
    myHelpId = helpId;
    myVerticalToolbar = verticalToolbar;
    myCloseEnabled = true;

    if (myContentManager != null) {
      myContentManager.addContentManagerListener(
          new ContentManagerAdapter() {
            public void contentRemoved(ContentManagerEvent event) {
              if (event.getContent().getComponent() == PanelWithActionsAndCloseButton.this) {
                dispose();
                myContentManager.removeContentManagerListener(this);
              }
            }
          });
    }
  }
 private void initialize() {
   if (!_isInitialized) {
     _isInitialized = true;
     _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();
   }
 }
Exemple #6
0
 public void setContent(Content content, ContentManager contentManager) {
   myContent = content;
   myContentManager = contentManager;
   contentManager.addContentManagerListener(this);
 }