Ejemplo n.º 1
0
  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
   */
  @Override
  public void run(IAction arg0) {
    int size = fSelectedTraces.size();
    for (int i = 0; i < size; i++) {

      final TraceResource trace = (TraceResource) fSelectedTraces.get(i);
      TraceSubSystem subSystem = (TraceSubSystem) trace.getSubSystem();

      try {
        final ILttControllerService service = subSystem.getControllerService();

        // Create future task
        @SuppressWarnings("unused")
        Boolean success =
            new TCFTask<Boolean>() {
              @Override
              public void run() {

                // Setup trace  using Lttng controller service proxy
                service.destroyTrace(
                    trace.getParent().getParent().getName(),
                    trace.getParent().getName(),
                    trace.getName(),
                    new ILttControllerService.DoneDestroyTrace() {

                      @Override
                      public void doneDestroyTrace(IToken token, Exception error, Object str) {
                        if (error != null) {
                          // Notify with error
                          error(error);
                          return;
                        }

                        // Notify about success
                        done(Boolean.valueOf(true));
                      }
                    });
              }
            }.get(TraceControlConstants.DEFAULT_TCF_TASK_TIMEOUT, TimeUnit.SECONDS);

        trace.setTraceState(TraceState.STOPPED);

        ISystemRegistry registry = SystemStartHere.getSystemRegistry();
        registry.fireRemoteResourceChangeEvent(
            ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED,
            trace,
            trace.getParent(),
            subSystem,
            null);

      } catch (Exception e) {
        SystemMessageException sysExp;
        if (e instanceof SystemMessageException) {
          sysExp = (SystemMessageException) e;
        } else {
          sysExp = new SystemMessageException(LTTngUiPlugin.getDefault().getMessage(e));
        }
        SystemBasePlugin.logError(
            Messages.Lttng_Control_ErrorStop
                + " ("
                + //$NON-NLS-1$
                Messages.Lttng_Resource_Trace
                + ": "
                + trace.getName()
                + ")",
            sysExp); //$NON-NLS-1$ //$NON-NLS-2$
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * Returns the active workbench shell of this plug-in.
  *
  * @return active workbench shell.
  */
 protected Shell getShell() {
   return SystemBasePlugin.getActiveWorkbenchShell();
 }