package com.intellij.debugger.streams.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;

/**
 * @author Vitaliy.Bibaev
 */
public class TraceStreamAction extends AnAction {
  private static class Holder {
    private static final JvmStreamDebuggerActionHandler HANDLER = new JvmStreamDebuggerActionHandler();
  }

  @Override
  public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project != null && Holder.HANDLER.isEnabled(project)) {
      Holder.HANDLER.perform(project);
    }
  }
}

package com.intellij.debugger.streams.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;

/**
 * @author Vitaliy.Bibaev
 */
public class TraceStreamAction extends AnAction {
  private static class Holder {
    private static final JvmStreamDebuggerActionHandler HANDLER = new JvmStreamDebuggerActionHandler();
  }

  @Override
  public void update(AnActionEvent e) {
    final Project project = e.getProject();
    if (project != null) {
      e.getPresentation().setEnabled(Holder.HANDLER.isEnabled(project));
      return;
    }
    e.getPresentation().setEnabled(false);
  }

  @Override
  public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project != null && Holder.HANDLER.isEnabled(project)) {
      Holder.HANDLER.perform(project);
    }
  }
}

Disable the action on the debug toolbar if there is no stream call
Disable the action on the debug toolbar if there is no stream call
