lttng: Fix most compiler warnings as per the new settings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / BaseAddContextHandler.java
index 339e0b5a08f3fa989077a844ae3be9dff9735632..04633e118c387a8638e807b3c03d3c11e65433a8 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;
@@ -21,18 +21,19 @@ 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.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IAddContextDialog;
 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.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.progress.UIJob;
 
 /**
- * <b><u>BaseAddContextHandler</u></b>
  * <p>
  * Base command handler implementation to add contexts.
  * </p>
+ *
+ * @author Bernd Hufmann
  */
 abstract public class BaseAddContextHandler extends BaseControlViewHandler {
 
@@ -47,16 +48,21 @@ abstract public class BaseAddContextHandler extends BaseControlViewHandler {
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
-    
+
     /**
-     * Adds contexts to channel(s) and/or event(s) 
-     * @param param - a parameter instance with data for the command execution
-     * @param contextNames - list contexts to add
-     * @param monitor - a progress monitor
+     * Adds contexts to channel(s) and/or event(s)
+     *
+     * @param param
+     *            - a parameter instance with data for the command execution
+     * @param contextNames
+     *            - list contexts to add
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If something goes wrong
      */
     abstract public void addContexts(CommandParameter param, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException;
-    
+
     /*
      * (non-Javadoc)
      * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
@@ -81,7 +87,7 @@ abstract public class BaseAddContextHandler extends BaseControlViewHandler {
                     try {
                         final List<String> availableContexts = param.getSession().getContextList(monitor);
                         final IAddContextDialog dialog = TraceControlDialogFactory.getInstance().getAddContextDialog();
-                        dialog.setAvalibleContexts(availableContexts); 
+                        dialog.setAvalibleContexts(availableContexts);
 
                         if ((dialog.open() != Window.OK) || (dialog.getContexts().isEmpty())) {
                             return Status.OK_STATUS;
@@ -89,29 +95,22 @@ abstract public class BaseAddContextHandler extends BaseControlViewHandler {
 
                         Job addJob = new Job(Messages.TraceControl_AddContextJob) {
                             @Override
-                            protected IStatus run(IProgressMonitor monitor) {
-                                StringBuffer errorString = new StringBuffer();
+                            protected IStatus run(IProgressMonitor monitor2) {
+                                Exception error = null;
 
                                 try {
                                     List<String> contextNames = dialog.getContexts();
-                                    addContexts(param, contextNames, monitor);
+                                    addContexts(param, contextNames, monitor2);
 
                                 } 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(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_AddContextFailure, error);
                                 }
                                 return Status.OK_STATUS;
                             }
@@ -119,7 +118,7 @@ abstract public class BaseAddContextHandler extends BaseControlViewHandler {
                         addJob.setUser(true);
                         addJob.schedule();
                     } catch (ExecutionException e) {
-                        return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
+                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_GetContextFailure, e);
                     }
 
                     return Status.OK_STATUS;
This page took 0.029058 seconds and 5 git commands to generate.