@Override
 public Object getPropertyValue(Object id) {
   if (TRACE_CHANNEL_NAME_PROPERTY_ID.equals(id)) {
     return fChannel.getName();
   }
   if (TRACE_CHANNEL_STATE_PROPERTY_ID.equals(id)) {
     return fChannel.getState().name();
   }
   if (TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID.equals(id)) {
     return String.valueOf(fChannel.isOverwriteMode());
   }
   if (TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID.equals(id)) {
     return String.valueOf(fChannel.getSubBufferSize());
   }
   if (TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID.equals(id)) {
     return String.valueOf(fChannel.getNumberOfSubBuffers());
   }
   if (TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID.equals(id)) {
     return String.valueOf(fChannel.getSwitchTimer());
   }
   if (TRACE_CHANNEL_READ_TIMER_PROPERTY_ID.equals(id)) {
     return String.valueOf(fChannel.getReadTimer());
   }
   if (TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID.equals(id)) {
     return fChannel.getOutputType().getInName();
   }
   if (TRACE_CHANNEL_TRACE_FILE_COUNT_PROPERTY_ID.equals(id)) {
     return fChannel.getMaxNumberTraceFiles();
   }
   if (TRACE_CHANNEL_TRACE_FILE_SIZE_PROPERTY_ID.equals(id)) {
     return fChannel.getMaxSizeTraceFiles();
   }
   return null;
 }
  @Override
  public IPropertyDescriptor[] getPropertyDescriptors() {
    List<IPropertyDescriptor> properties = new ArrayList<>();
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_NAME_PROPERTY_ID, TRACE_CHANNEL_NAME_PROPERTY_NAME));
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_STATE_PROPERTY_ID, TRACE_CHANNEL_STATE_PROPERTY_NAME));
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID, TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME));
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID, TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME));
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID, TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME));
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID, TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME));
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_READ_TIMER_PROPERTY_ID, TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME));
    properties.add(
        new ReadOnlyTextPropertyDescriptor(
            TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID, TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME));

    if (fChannel.getTargetNode().isVersionSupported("2.5.0")) { // $NON-NLS-1$
      properties.add(
          new ReadOnlyTextPropertyDescriptor(
              TRACE_CHANNEL_TRACE_FILE_COUNT_PROPERTY_ID,
              TRACE_CHANNEL_TRACE_FILE_COUNT_PROPERTY_NAME));
      properties.add(
          new ReadOnlyTextPropertyDescriptor(
              TRACE_CHANNEL_TRACE_FILE_SIZE_PROPERTY_ID,
              TRACE_CHANNEL_TRACE_FILE_SIZE_PROPERTY_NAME));
    }
    return properties.toArray(new IPropertyDescriptor[0]);
  }
  @Override
  public boolean isEnabled() {
    // Get workbench page for the Control View
    IWorkbenchPage page = getWorkbenchPage();
    if (page == null) {
      return false;
    }

    // Check if one or more session are selected
    ISelection selection = page.getSelection(ControlView.ID);

    TraceChannelComponent channel = null;
    List<TraceEventComponent> events = new ArrayList<>();

    if (selection instanceof StructuredSelection) {
      StructuredSelection structered = ((StructuredSelection) selection);
      String sessionName = null;
      String channelName = null;

      for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
        Object element = iterator.next();

        if (element instanceof TraceEventComponent) {

          TraceEventComponent event = (TraceEventComponent) element;
          if (sessionName == null) {
            sessionName = String.valueOf(event.getSessionName());
          }

          if (channel == null) {
            channel = (TraceChannelComponent) event.getParent();
          }

          if (channelName == null) {
            channelName = event.getChannelName();
          }

          // Enable command only for events of same session, same channel and domain
          if ((!sessionName.equals(event.getSessionName()))
              || (!channelName.equals(event.getChannelName()))
              || (channel.isKernel() != event.isKernel())) {
            events.clear();
            break;
          }

          if ((event.getState() != getNewState())) {
            events.add(event);
          }
        }
      }
    }
    boolean isEnabled = !events.isEmpty();

    fLock.lock();
    try {
      fParam = null;
      if (isEnabled) {
        fParam = new Parameter(channel, events);
      }
    } finally {
      fLock.unlock();
    }
    return isEnabled;
  }