lttng: Add a diagram showing the dependencies between plugins
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / BaseNodeHandler.java
index b22ac58994c97776e2236e975bb0654d51f07923..e922fb203e50bef00133ec2fcec1eb6afb18cad7 100644 (file)
@@ -1,12 +1,12 @@
 /**********************************************************************
- * Copyright (c) 2012 Ericsson
- * 
+ * Copyright (c) 2012, 2013 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;
@@ -18,28 +18,26 @@ import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.Target
 import org.eclipse.ui.IWorkbenchPage;
 
 /**
- * <b><u>BaseNodeHandler</u></b>
  * <p>
  * Command handler implementation to delete a target host.
  * </p>
+ *
+ * @author Bernd Hufmann
  */
-abstract public class BaseNodeHandler extends BaseControlViewHandler {
+public abstract class BaseNodeHandler extends BaseControlViewHandler {
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
     /**
-     * The target node component the command is to be executed on. 
+     * The target node component the command is to be executed on.
      */
     protected TargetNodeComponent fTargetNode = null;
-    
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
-     */
+
     @Override
     public boolean isEnabled() {
 
@@ -49,16 +47,24 @@ abstract public class BaseNodeHandler extends BaseControlViewHandler {
             return false;
         }
 
-        fTargetNode = null;
-        
+        TargetNodeComponent node = null;
         // Check if the node component is selected
         ISelection selection = page.getSelection(ControlView.ID);
         if (selection instanceof StructuredSelection) {
             Object element = ((StructuredSelection) selection).getFirstElement();
-            fTargetNode = (element instanceof TargetNodeComponent) ? (TargetNodeComponent) element : null;
+            node = (element instanceof TargetNodeComponent) ? (TargetNodeComponent) element : null;
         }
-        return fTargetNode != null;
+        boolean isEnabled = node != null;
+        fLock.lock();
+        try {
+            if (isEnabled) {
+                fTargetNode = node;
+            }
+        } finally {
+            fLock.unlock();
+        }
+        return isEnabled;
     }
 
-    
+
 }
\ No newline at end of file
This page took 0.025378 seconds and 5 git commands to generate.