コード例 #1
0
 private void removeAllContents(Project project, Content notRemove) {
   if (project.isDisposed()) {
     return;
   }
   final MessageView messageView = MessageView.SERVICE.getInstance(project);
   Content[] contents = messageView.getContentManager().getContents();
   for (Content content : contents) {
     if (content.isPinned()) {
       continue;
     }
     if (content == notRemove) {
       continue;
     }
     boolean toRemove = CONTENT_ID_KEY.get(content) == myContentId;
     if (!toRemove) {
       final Object contentSessionId = SESSION_ID_KEY.get(content);
       toRemove =
           contentSessionId != null
               && contentSessionId != mySessionId; // the content was added by previous compilation
     }
     if (toRemove) {
       messageView.getContentManager().removeContent(content, true);
     }
   }
 }
コード例 #2
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;
     }
   }
 }
コード例 #3
0
 public void contentRemoved(ContentManagerEvent event) {
   if (event.getContent() == myContent) {
     myContentManager.removeContentManagerListener(this);
     AntBuildMessageView buildMessageView = myContent.getUserData(KEY);
     if (!myCloseAllowed) {
       buildMessageView.stopProcess();
     }
     ProjectManager.getInstance().removeProjectManagerListener(myProject, this);
     myContent.release();
     myContent = null;
     buildMessageView.myBuildFile = null;
     buildMessageView.myPlainTextView.dispose();
   }
 }
コード例 #4
0
ファイル: CompilerTask.java プロジェクト: Zeratyl-SK/consulo
 public void showCompilerContent() {
   synchronized (myMessageViewLock) {
     if (myErrorTreeView != null) {
       final MessageView messageView = MessageView.SERVICE.getInstance(myProject);
       Content[] contents = messageView.getContentManager().getContents();
       for (Content content : contents) {
         if (content.getUserData(myContentIdKey) != null) {
           messageView.getContentManager().setSelectedContent(content);
           return;
         }
       }
     }
   }
 }
コード例 #5
0
    /** @return true if content can be closed */
    private boolean closeQuery() {
      if (myContent == null) {
        return true;
      }

      AntBuildMessageView messageView = myContent.getUserData(KEY);

      if (messageView.isStoppedOrTerminateRequested()) {
        return true;
      }

      if (myCloseAllowed) return true;

      int result =
          Messages.showYesNoCancelDialog(
              AntBundle.message("ant.process.is.active.terminate.confirmation.text"),
              AntBundle.message("close.ant.build.messages.dialog.title"),
              Messages.getQuestionIcon());
      if (result == 0) { // yes
        messageView.stopProcess();
        myCloseAllowed = true;
        return true;
      }

      if (result == 1) { // no
        // close content and leave the process running
        myCloseAllowed = true;
        return true;
      }

      return false;
    }
コード例 #6
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);
       }
     }
   }
 }
コード例 #7
0
ファイル: CompilerTask.java プロジェクト: Zeratyl-SK/consulo
 public void contentRemoved(ContentManagerEvent event) {
   if (event.getContent() == myContent) {
     synchronized (myMessageViewLock) {
       if (myErrorTreeView != null) {
         myErrorTreeView.dispose();
         myErrorTreeView = null;
         if (myIndicator.isRunning()) {
           cancel();
         }
         if (AppIcon.getInstance().hideProgress(myProject, "compiler")) {
           AppIcon.getInstance().setErrorBadge(myProject, null);
         }
       }
     }
     myContentManager.removeContentManagerListener(this);
     myContent.release();
     myContent = null;
   }
 }
コード例 #8
0
  /** @return can be null if user cancelled operation */
  @Nullable
  public static AntBuildMessageView openBuildMessageView(
      Project project, AntBuildFileBase buildFile, String[] targets) {
    final VirtualFile antFile = buildFile.getVirtualFile();
    if (!LOG.assertTrue(antFile != null)) {
      return null;
    }

    // check if there are running instances of the same build file

    MessageView ijMessageView = MessageView.SERVICE.getInstance(project);
    Content[] contents = ijMessageView.getContentManager().getContents();
    for (Content content : contents) {
      if (content.isPinned()) {
        continue;
      }
      AntBuildMessageView buildMessageView = content.getUserData(KEY);
      if (buildMessageView == null) {
        continue;
      }

      if (!antFile.equals(buildMessageView.getBuildFile().getVirtualFile())) {
        continue;
      }

      if (buildMessageView.isStopped()) {
        ijMessageView.getContentManager().removeContent(content, true);
        continue;
      }

      int result =
          Messages.showYesNoCancelDialog(
              AntBundle.message("ant.is.active.terminate.confirmation.text"),
              AntBundle.message("starting.ant.build.dialog.title"),
              Messages.getQuestionIcon());

      switch (result) {
        case 0: // yes
          buildMessageView.stopProcess();
          ijMessageView.getContentManager().removeContent(content, true);
          continue;
        case 1: // no
          continue;
        default: // cancel
          return null;
      }
    }

    final AntBuildMessageView messageView = new AntBuildMessageView(project, buildFile, targets);
    String contentName = buildFile.getPresentableName();
    contentName = BUILD_CONTENT_NAME + " (" + contentName + ")";

    final Content content =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(messageView.getComponent(), contentName, true);
    content.putUserData(KEY, messageView);
    ijMessageView.getContentManager().addContent(content);
    ijMessageView.getContentManager().setSelectedContent(content);
    content.setDisposer(
        new Disposable() {
          @Override
          public void dispose() {
            Disposer.dispose(messageView.myAlarm);
          }
        });
    new CloseListener(content, ijMessageView.getContentManager(), project);
    // Do not inline next two variabled. Seeking for NPE.
    ToolWindow messageToolWindow =
        ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
    messageToolWindow.activate(null, false);
    return messageView;
  }