/**********************************************************************
- * 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.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 {
// 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() {
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