コード例 #1
0
 private void close() {
   MessageView messageView = MessageView.SERVICE.getInstance(myProject);
   Content[] contents = messageView.getContentManager().getContents();
   for (Content content : contents) {
     if (content.getComponent() == this) {
       messageView.getContentManager().removeContent(content, true);
       return;
     }
   }
 }
コード例 #2
0
 public void actionPerformed(AnActionEvent e) {
   if (myContentManager != null) {
     Content content = myContentManager.getContent(PanelWithActionsAndCloseButton.this);
     if (content != null) {
       ContentsUtil.closeContentTab(myContentManager, content);
       if (content instanceof TabbedContent && ((TabbedContent) content).getTabs().size() > 1) {
         final TabbedContent tabbedContent = (TabbedContent) content;
         final JComponent component = content.getComponent();
         tabbedContent.removeContent(component);
         myContentManager.setSelectedContent(
             content, true, true); // we should request focus here
       } else {
         myContentManager.removeContent(content, true);
       }
     }
   }
 }
コード例 #3
0
  public int addTab(
      String s,
      JComponent component,
      boolean selectTab,
      boolean replaceContent,
      boolean lockable,
      boolean addDefaultToolbar,
      @Nullable final ActionGroup toolbarActions,
      @NonNls String helpId) {

    int existing = getComponentNumNamed(s);
    if (existing != -1) {
      Content existingContent = getContentManager().getContent(existing);
      final JComponent existingComponent = existingContent.getComponent();
      if (existingComponent instanceof DeactivateListener) {
        ((DeactivateListener) existingComponent).deactivated();
      }
      if (!replaceContent) {
        getContentManager().setSelectedContent(existingContent);
        return existing;
      } else if (!existingContent.isPinned()) {
        getContentManager().removeContent(existingContent, true);
        existingContent.release();
      }
    }

    CvsTabbedWindowComponent newComponent =
        new CvsTabbedWindowComponent(
            component, addDefaultToolbar, toolbarActions, getContentManager(), helpId);
    Content content =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(newComponent.getShownComponent(), s, lockable);
    newComponent.setContent(content);
    getContentManager().addContent(content);

    return getComponentAt(getContentManager().getContentCount() - 1, selectTab);
  }