Fix for bug 382684 (connection re-use)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / BaseEnableEventHandler.java
index e0772c68a713e4256bb1047f27e00fd826690b36..7b95a44306a722348cb4ac165fa62da87c8f6643 100644 (file)
@@ -1,12 +1,12 @@
 /**********************************************************************
  * Copyright (c) 2012 Ericsson
- * 
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
@@ -20,13 +20,13 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
@@ -34,10 +34,11 @@ import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 
 /**
- * <b><u>EnableEventOnSessionHandler</u></b>
  * <p>
  * Base command handler implementation to enable events.
  * </p>
+ *
+ * @author Bernd Hufmann
  */
 abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
 
@@ -52,48 +53,74 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
+
     /**
      * Enables a list of events for given parameters.
-     * @param - a parameter instance with data for the command execution
-     * @param eventNames - list of event names
-     * @param isKernel - true if kernel domain else false
-     * @param monitor - a progress monitor
+     *
+     * @param param
+     *            - a parameter instance with data for the command execution
+     * @param eventNames
+     *            - list of event names
+     * @param isKernel
+     *            - true if kernel domain else false
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails for some reason
      */
     abstract public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
 
     /**
      * Enables all syscall events.
-     * @param - a parameter instance with data for the command execution
-     * @param monitor - a progress monitor
+     *
+     * @param param
+     *            - a parameter instance with data for the command execution
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails for some reason
      */
     abstract public void enableSyscalls(CommandParameter param, IProgressMonitor monitor) throws ExecutionException;
-    
+
     /**
      * Enables a dynamic probe.
-     * @param - a parameter instance with data for the command execution
-     * @param eventName - a event name
-     * @param isFunction - true for dynamic function entry/return probe else false
-     * @param probe - a dynamic probe information
-     * @param monitor - a progress monitor
+     *
+     * @param param
+     *            - a parameter instance with data for the command execution
+     * @param eventName
+     *            - a event name
+     * @param isFunction
+     *            - true for dynamic function entry/return probe else false
+     * @param probe
+     *            - a dynamic probe information
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails for some reason
      */
     abstract public void enableProbe(CommandParameter param, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
-    
+
     /**
      * Enables events using log level
-     * @param - a parameter instance with data for the command execution
-     * @param eventName - a event name
-     * @param logLevelType - a log level type 
-     * @param level - a log level 
-     * @param monitor - a progress monitor  
+     *
+     * @param param
+     *            - a parameter instance with data for the command execution
+     * @param eventName
+     *            - a event name
+     * @param logLevelType
+     *            - a log level type
+     * @param level
+     *            - a log level
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
-     */    
+     *             If the command fails for some reason
+     */
     abstract public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException;
-    
+
     /**
-     * @param - a parameter instance with data for the command execution
+     * @param param
+     *            - a parameter instance with data for the command execution
      * @return returns the relevant domain (null if domain is not known)
      */
     abstract TraceDomainComponent getDomain(CommandParameter param);
@@ -129,7 +156,7 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
             Job job = new Job(Messages.TraceControl_ChangeEventStateJob) {
                 @Override
                 protected IStatus run(IProgressMonitor monitor) {
-                    StringBuffer errorString = new StringBuffer();
+                    Exception error = null;
 
                     try {
                         // Enable tracepoint events
@@ -175,21 +202,14 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
                         }
 
                     } catch (ExecutionException e) {
-                        errorString.append(e.toString());
-                        errorString.append('\n');
+                        error = e;
                     }
 
-                    // get session configuration in all cases
-                    try {
-                        param.getSession().getConfigurationFromNode(monitor);
-                    } catch (ExecutionException e) {
-                        errorString.append(Messages.TraceControl_ListSessionFailure);
-                        errorString.append(": "); //$NON-NLS-1$
-                        errorString.append(e.toString());
-                    } 
+                    // refresh in all cases
+                    refresh(param);
 
-                    if (errorString.length() > 0) {
-                        return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString.toString());
+                    if (error != null) {
+                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ChangeEventStateFailure, error);
                     }
                     return Status.OK_STATUS;
                 }
This page took 0.025329 seconds and 5 git commands to generate.