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 / DeleteHandler.java
index ffff78ef780293046da5ac66166ad750691ffe30..8ef4676d3b0158cc73db17cb4443173609c6b9a7 100644 (file)
@@ -1,50 +1,57 @@
 /**********************************************************************
- * 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;
 
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
 
 /**
- * <b><u>DeleteHandler</u></b>
  * <p>
  * Command handler implementation to delete a target host.
  * </p>
+ *
+ * @author Bernd Hufmann
  */
 public class DeleteHandler extends BaseNodeHandler {
 
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-     */
+
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
-        ITraceControlComponent root = fTargetNode.getParent();
-        fTargetNode.removeAllChildren();
-        root.removeChild(fTargetNode);
+        fLock.lock();
+        try {
+            ITraceControlComponent root = fTargetNode.getParent();
+            fTargetNode.removeAllChildren();
+            fTargetNode.deregister();
+            root.removeChild(fTargetNode);
+        } finally {
+            fLock.unlock();
+        }
         return null;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseNodeHandler#isEnabled()
-     */
     @Override
     public boolean isEnabled() {
-        return (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));    
+        boolean isEnabled = false;
+        fLock.lock();
+        try {
+           isEnabled = (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
+        } finally {
+            fLock.unlock();
+        }
+        return isEnabled;
      }
 }
This page took 0.025953 seconds and 5 git commands to generate.