import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IConfirmDialog;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IGetEventInfoDialog;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
// ------------------------------------------------------------------------
// Create Channel on UST global domain
// ------------------------------------------------------------------------
- TraceControlDialogFactory.getInstance().setCreateChannelOnSessionDialog(new CreateChannelOnSessionDialogStub());
+ TraceControlDialogFactory.getInstance().setCreateChannelDialog(new CreateChannelDialogStub());
fFacility.getControlView().setSelection(session);
// Give GUI time to actually execute refresh
}
}
- public class CreateChannelOnSessionDialogStub implements ICreateChannelOnSessionDialog {
+ public class CreateChannelDialogStub implements ICreateChannelDialog {
@Override
public IChannelInfo getChannelInfo() {
public static String TraceControl_InvalidProbeNameError;
public static String TraceControl_InvalidWildcardError;
public static String TraceControl_InvalidLogLevelEventNameError;
+ public static String TraceControl_InvalidLogLevel;
// Tree structure strings
* Dialog box for collecting channel creation information.
* </p>
*/
-public class CreateChannelDialog extends Dialog implements ICreateChannelOnSessionDialog {
+public class CreateChannelDialog extends Dialog implements ICreateChannelDialog {
// ------------------------------------------------------------------------
// Constants
/**
* The overwrite mode of the channel.
*/
- private Button fOverwriteModeButton;
+ private Button fOverwriteModeButton = null;
/**
* The sub-buffer size of the channel.
*/
- private Text fSubBufferSizeText;
+ private Text fSubBufferSizeText = null;
/**
* The number of sub-buffers of the channel.
*/
- private Text fNumberOfSubBuffersText;
+ private Text fNumberOfSubBuffersText = null;
/**
* The switch timer interval of the channel.
*/
- private Text fSwitchTimerText;
+ private Text fSwitchTimerText = null;
/**
* The read timer interval of the channel.
*/
- private Text fReadTimerText;
+ private Text fReadTimerText = null;
/**
* Group composite for domain selection.
*/
/**
* Radio button for selecting kernel domain.
*/
- private Button fKernelButton;
+ private Button fKernelButton = null;
/**
* Radio button for selecting UST domain.
*/
- private Button fUstButton;
+ private Button fUstButton = null;
/**
* The parent domain component where the channel node should be added.
* Null in case of creation on session level.
*/
- private TraceDomainComponent fDomain;
+ private TraceDomainComponent fDomain = null;
/**
* Common verify listener for numeric text input.
*/
- private VerifyListener fVerifyListener;
+ private VerifyListener fVerifyListener = null;
/**
* Output channel information.
*/
- private IChannelInfo fChannelInfo;
+ private IChannelInfo fChannelInfo = null;
/**
* Output domain information. True in case of Kernel domain. False for UST.
*/
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelOnSessionDialog#isKernel()
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog#isKernel()
*/
@Override
public boolean isKernel() {
fChannelInfo.setReadTimer(Long.parseLong(fReadTimerText.getText()));
fChannelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
- if (fKernelButton.getSelection() == true) {
- fIsKernel = true;
- } else {
- fIsKernel = false;
- }
+ fIsKernel = fKernelButton.getSelection();
// Check for invalid names
if (!fChannelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
/**
* The parent where the new node should be added.
*/
- private TraceSessionGroup fParent;
+ private TraceSessionGroup fParent = null;
/**
* The session name string.
*/
*/
@Override
protected void okPressed() {
- if (fKernelButton.getSelection() == true) {
- fIsKernel = true;
- } else {
- fIsKernel = false;
- }
+ fIsKernel = fKernelButton.getSelection();
// Validate kernel composite in case of kernel domain
if (fKernelComposite != null && !fKernelComposite.isValid()) {
/**
* Content provider for the tracepoints tree.
*/
- final public class KernelContentProvider extends TraceControlContentProvider {
+ final static public class KernelContentProvider extends TraceControlContentProvider {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TraceProviderGroup) {
/**
* Content label for the tracepoints tree.
*/
- final public class KernelLabelProvider extends TraceControlLabelProvider {
+ final static public class KernelLabelProvider extends TraceControlLabelProvider {
@Override
public Image getImage(Object element) {
return null;
}
/**
- * Validates the kernel composite input data.
+ * Validates the UST composite input data.
* @return true if configured data is valid and can be retrieved.
*/
public boolean isValid() {
fLogLevelEventName = temp;
}
+ TraceLogLevel[] levels = TraceLogLevel.values();
+ int id = fLogLevelCombo.getSelectionIndex();
+ if ((id < 0) && fIsLogLevel) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_InvalidLogLevel + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return false;
+ } else {
+ fLogLevel = levels[id];
+ }
+
// initialize log level event name string
fWildcard = null;
temp = fWildcardText.getText();
/**
* Content provider for the tracepoints tree.
*/
- final public class UstContentProvider extends TraceControlContentProvider {
+ final static public class UstContentProvider extends TraceControlContentProvider {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TargetNodeComponent) {
/**
* Content label for the tracepoints tree.
*/
- final public class UstLabelProvider extends TraceControlLabelProvider {
+ final static public class UstLabelProvider extends TraceControlLabelProvider {
@Override
public Image getImage(Object element) {
return null;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
public void widgetDefaultSelected(SelectionEvent e) {
}
});
+
+ getShell().setMinimumSize(new Point(300, 200));
+
return fDialogComposite;
}
*/
public void setDomainComponent(TraceDomainComponent domain);
+ /**
+ * @return true for Kernel domain. False for UST.
+ */
+ public boolean isKernel();
+
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+++ /dev/null
-/**********************************************************************
- * 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:
- * Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
-
-
-/**
- * <b><u>ICreateChannelOnSessionDialog</u></b>
- * <p>
- * Interface for the create channel dialog when domain is known, i.e. dialog
- * was opened on session level.
- * </p>
- */
-public interface ICreateChannelOnSessionDialog extends ICreateChannelDialog {
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- /**
- * @return true for Kernel domain. False for UST.
- */
- public boolean isKernel();
-
-}
import org.eclipse.ui.PlatformUI;
-public class TraceControlDialogFactory {
+final public class TraceControlDialogFactory {
// ------------------------------------------------------------------------
// Members
*/
private ICreateChannelDialog fCreateChannelDialog;
- /**
- * The create channel dialog (on session level)
- */
- private ICreateChannelOnSessionDialog fCreateChannelOnSessionDialog;
-
/**
* The create session dialog.
*/
/**
* @return TraceControlDialogFactory instance
*/
- public static TraceControlDialogFactory getInstance() {
- if (null == fInstance) {
+ public synchronized static TraceControlDialogFactory getInstance() {
+ if (fInstance == null) {
fInstance = new TraceControlDialogFactory();
}
return fInstance;
* @return new connection dialog
*/
public INewConnectionDialog getNewConnectionDialog() {
- if (null == fNewConnectionDialog) {
+ if (fNewConnectionDialog == null) {
fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
}
return fNewConnectionDialog;
* @return create channel dialog (on domain level)
*/
public ICreateChannelDialog getCreateChannelDialog() {
- if (null == fCreateChannelDialog) {
+ if (fCreateChannelDialog == null) {
fCreateChannelDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
}
return fCreateChannelDialog;
fCreateChannelDialog = createChannelDialog;
}
- /**
- * @return create channel dialog (on session level)
- */
- public ICreateChannelOnSessionDialog getCreateChannelOnSessionDialog() {
- if (null == fCreateChannelOnSessionDialog) {
- fCreateChannelOnSessionDialog = new CreateChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
- }
- return fCreateChannelOnSessionDialog;
- }
-
- /**
- * Sets a create channel dialog implementation (on domain level).
- * @param createChannelDialog - a create channel dialog implementation
- */
- public void setCreateChannelOnSessionDialog(ICreateChannelOnSessionDialog createChannelDialog) {
- fCreateChannelOnSessionDialog = createChannelDialog;
- }
-
/**
* @return create session dialog implementation
*/
public ICreateSessionDialog getCreateSessionDialog() {
- if (null == fCreateSessionDialog) {
+ if (fCreateSessionDialog == null) {
fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
}
return fCreateSessionDialog;
* @return enable events dialog implementation.
*/
public IEnableEventsDialog getEnableEventsDialog() {
- if (null == fEnableEventsDialog) {
+ if (fEnableEventsDialog == null) {
fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
}
return fEnableEventsDialog;
* @return get events info dialog implementation.
*/
public IGetEventInfoDialog getGetEventInfoDialog() {
- if (null == fGetEventInfoDialog) {
+ if (fGetEventInfoDialog == null) {
fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
}
return fGetEventInfoDialog;
* @return the confirmation dialog implementation
*/
public IConfirmDialog getConfirmDialog() {
- if (null == fConfirmDialog) {
+ if (fConfirmDialog == null) {
fConfirmDialog = new ConfirmDialog();
}
return fConfirmDialog;
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.ui.IWorkbenchPage;
/**
- * <b><u>EnableEventHandler</u></b>
+ * <b><u>AssignEventHandler</u></b>
* <p>
* Command handler implementation to assign events to a session and channel and enable/configure them.
* This is done on the trace provider level.
// Attributes
// ------------------------------------------------------------------------
/**
- * The list of event components the command is to be executed on.
+ * The command execution parameter.
*/
- private List<BaseEventComponent> fEvents = new ArrayList<BaseEventComponent>();
-
- /**
- * The list of available sessions.
- */
- private TraceSessionComponent[] fSessions;
-
- /**
- * Flag for indicating Kernel or UST.
- */
- Boolean fIsKernel = null;
+ private Parameter fParam;
// ------------------------------------------------------------------------
// Operations
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- // Open dialog box to retrieve the session and channel where the events should be enabled in.
- final IGetEventInfoDialog dialog = TraceControlDialogFactory.getInstance().getGetEventInfoDialog();
- dialog.setIsKernel(fIsKernel);
- dialog.setSessions(fSessions);
+ fLock.lock();
+ try {
+ // Make a copy for thread safety
+ final Parameter param = new Parameter(fParam);
- if (dialog.open() != Window.OK) {
- return null;
- }
+ // Open dialog box to retrieve the session and channel where the events should be enabled in.
+ final IGetEventInfoDialog dialog = TraceControlDialogFactory.getInstance().getGetEventInfoDialog();
+ dialog.setIsKernel(param.isKernel());
+ dialog.setSessions(param.getSessions());
- Job job = new Job(Messages.TraceControl_EnableEventsJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
-
- String errorString = null;
- try {
- List<String> eventNames = new ArrayList<String>();
- // Create list of event names
- for (Iterator<BaseEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
- BaseEventComponent event = (BaseEventComponent) iterator.next();
- eventNames.add(event.getName());
- }
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
- TraceChannelComponent channel = dialog.getChannel();
- if (channel == null) {
- // enable events on default channel (which will be created by lttng-tools)
- dialog.getSession().enableEvents(eventNames, fIsKernel, monitor);
- } else {
- channel.enableEvents(eventNames, monitor);
- }
+ Job job = new Job(Messages.TraceControl_EnableEventsJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
- } catch (ExecutionException e) {
- errorString = e.toString() + "\n"; //$NON-NLS-1$
- }
+ StringBuffer errorString = new StringBuffer();
+ try {
+ List<String> eventNames = new ArrayList<String>();
+ List<BaseEventComponent> events = param.getEvents();
+ // Create list of event names
+ for (Iterator<BaseEventComponent> iterator = events.iterator(); iterator.hasNext();) {
+ BaseEventComponent event = (BaseEventComponent) iterator.next();
+ eventNames.add(event.getName());
+ }
- // get session configuration in all cases
- try {
- dialog.getSession().getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
+ TraceChannelComponent channel = dialog.getChannel();
+ if (channel == null) {
+ // enable events on default channel (which will be created by lttng-tools)
+ dialog.getSession().enableEvents(eventNames, param.isKernel(), monitor);
+ } else {
+ channel.enableEvents(eventNames, monitor);
+ }
+
+ } catch (ExecutionException e) {
+ errorString.append(e.toString());
+ errorString.append('\n');
}
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ // get session configuration in all cases
+ try {
+ dialog.getSession().getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ errorString.append(Messages.TraceControl_ListSessionFailure);
+ errorString.append(": "); //$NON-NLS-1$
+ errorString.append(e.toString());
+ }
+
+ if (errorString.length() > 0) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString.toString());
+ }
+ return Status.OK_STATUS;
}
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
+
return null;
}
*/
@Override
public boolean isEnabled() {
- fEvents.clear();
- fSessions = null;
- fIsKernel = null;
+ ArrayList<BaseEventComponent> events = new ArrayList<BaseEventComponent>();
+ TraceSessionComponent[] sessions = null;
+ Boolean isKernel = null;
- // Get workbench page for the Control View
+ // Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
} else {
return false;
}
- if (fIsKernel == null) {
- fIsKernel = Boolean.valueOf(temp);
+ if (isKernel == null) {
+ isKernel = Boolean.valueOf(temp);
} else {
// don't mix events from Kernel and UST provider
- if (fIsKernel.booleanValue() != temp) {
+ if (isKernel.booleanValue() != temp) {
return false;
}
}
// Add BaseEventComponents
- fEvents.add(event);
+ events.add(event);
- if (fSessions == null) {
+ if (sessions == null) {
TargetNodeComponent root = (TargetNodeComponent)event.getParent().getParent().getParent();
- fSessions = root.getSessions();
+ sessions = root.getSessions();
}
}
}
}
- return ((fEvents.size() > 0) && (fSessions != null) && (fSessions.length > 0));
+
+ boolean isEnabled = ((!events.isEmpty()) && (sessions != null) && (sessions.length > 0));
+ fLock.lock();
+ try {
+ fParam = null;
+ if(isEnabled) {
+ fParam = new Parameter(sessions, events, isKernel);
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
+ }
+
+ /**
+ * Class containing parameter for the command execution.
+ */
+ final static private class Parameter {
+
+ /**
+ * The list of event components the command is to be executed on.
+ */
+ private List<BaseEventComponent> fEvents;
+
+ /**
+ * The list of available sessions.
+ */
+ final private TraceSessionComponent[] fSessions;
+
+ /**
+ * Flag for indicating Kernel or UST.
+ */
+ final private boolean fIsKernel;
+
+ /**
+ * Constructor
+ *
+ * @param sessions - a array of trace sessions
+ * @param events - a lists of events to enable
+ * @param isKernel - domain (true for kernel or UST)
+ */
+ public Parameter(TraceSessionComponent[] sessions, List<BaseEventComponent> events, boolean isKernel) {
+ fSessions = Arrays.copyOf(sessions, sessions.length);
+ fEvents = new ArrayList<BaseEventComponent>();
+ fEvents.addAll(events);
+ fIsKernel = isKernel;
+ }
+
+ /**
+ * Copy constructor
+ * @param other - a parameter to copy
+ */
+ public Parameter(Parameter other) {
+ this(other.fSessions, other.fEvents, other.fIsKernel);
+ }
+
+ public TraceSessionComponent[] getSessions() {
+ return fSessions;
+ }
+
+ public List<BaseEventComponent> getEvents() {
+ return fEvents;
+ }
+
+ public boolean isKernel() {
+ return fIsKernel;
+ }
}
}
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+import java.util.concurrent.locks.ReentrantLock;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
import org.eclipse.ui.IWorkbenchPage;
*/
abstract public class BaseControlViewHandler extends AbstractHandler {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The synchronization lock.
+ */
+ protected ReentrantLock fLock = new ReentrantLock();
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+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.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <b><u>BaseCreateChannelHandler</u></b>
+ * <p>
+ * Base implementation of aCommand handler implementation to create a trace channel.
+ * </p>
+ */
+abstract class BaseCreateChannelHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ protected CommandParameter fParam;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param - a parameter instance with data for the command execution
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * @param - a parameter instance with data for the command execution
+ * @return returns the relevant domain (null if domain is not known)
+ */
+ abstract public TraceDomainComponent getDomain(CommandParameter param);
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ fLock.lock();
+ try {
+ final CommandParameter param = fParam.clone();
+
+ final ICreateChannelDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelDialog();
+ dialog.setDomainComponent(getDomain(param));
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ StringBuffer errorString = new StringBuffer();
+
+ List<String> channelNames = new ArrayList<String>();
+ channelNames.add(dialog.getChannelInfo().getName());
+
+ try {
+ enableChannel(param, channelNames, dialog.getChannelInfo(), dialog.isKernel(), monitor);
+ } catch (ExecutionException e) {
+ errorString.append(e.toString());
+ errorString.append("\n"); //$NON-NLS-1$
+ }
+
+ // 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());
+ }
+
+ if (errorString.length() > 0) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
+ return null;
+ }
+
+}
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;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
// Attributes
// ------------------------------------------------------------------------
/**
- * The session component the command is to be executed on.
+ * The command execution parameter.
*/
- protected TraceSessionComponent fSession = null;
+ protected CommandParameter fParam = null;
// ------------------------------------------------------------------------
// 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
* @throws ExecutionException
*/
- abstract public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+ 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
* @throws ExecutionException
*/
- abstract public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException;
+ 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
* @throws ExecutionException
*/
- abstract public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException;
+ 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
* @throws ExecutionException
*/
- abstract public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException;
+ 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
* @return returns the relevant domain (null if domain is not known)
*/
- abstract TraceDomainComponent getDomain();
+ abstract TraceDomainComponent getDomain(CommandParameter param);
/*
* (non-Javadoc)
if (window == null) {
return false;
}
+ fLock.lock();
+ try {
+ // Make a copy for thread safety
+ final CommandParameter param = fParam.clone();
- TargetNodeComponent node = fSession.getTargetNode();
- List<ITraceControlComponent> providers = node.getChildren(TraceProviderGroup.class);
+ TargetNodeComponent node = param.getSession().getTargetNode();
+ List<ITraceControlComponent> providers = node.getChildren(TraceProviderGroup.class);
- final IEnableEventsDialog dialog = TraceControlDialogFactory.getInstance().getEnableEventsDialog();
- dialog.setTraceProviderGroup((TraceProviderGroup)providers.get(0));
- dialog.setTraceDomainComponent(getDomain());
+ final IEnableEventsDialog dialog = TraceControlDialogFactory.getInstance().getEnableEventsDialog();
+ dialog.setTraceProviderGroup((TraceProviderGroup)providers.get(0));
+ dialog.setTraceDomainComponent(getDomain(param));
- if (dialog.open() != Window.OK) {
- return null;
- }
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
- Job job = new Job(Messages.TraceControl_ChangeEventStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- try {
- // Enable tracepoint events
- if (dialog.isTracepoints()) {
- if (dialog.isAllTracePoints()) {
- enableEvents(null, dialog.isKernel(), monitor);
- } else {
- List<String> eventNames = dialog.getEventNames();
- if (eventNames.size() > 0) {
- enableEvents(eventNames, dialog.isKernel(), monitor);
+ Job job = new Job(Messages.TraceControl_ChangeEventStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ StringBuffer errorString = new StringBuffer();
+
+ try {
+ // Enable tracepoint events
+ if (dialog.isTracepoints()) {
+ if (dialog.isAllTracePoints()) {
+ enableEvents(param, null, dialog.isKernel(), monitor);
+ } else {
+ List<String> eventNames = dialog.getEventNames();
+ if (!eventNames.isEmpty()) {
+ enableEvents(param, eventNames, dialog.isKernel(), monitor);
+ }
}
}
- }
- // Enable syscall events
- if (dialog.isAllSysCalls()) {
+ // Enable syscall events
if (dialog.isAllSysCalls()) {
- enableSyscalls(monitor);
- }
- }
+ enableSyscalls(param, monitor);
+ }
- // Enable dynamic probe
- if (dialog.isDynamicProbe()) {
- if ((dialog.getProbeEventName() != null && dialog.getProbeName() != null)) {
- enableProbe(dialog.getProbeEventName(), false, dialog.getProbeName(), monitor);
- }
- }
+ // Enable dynamic probe
+ if (dialog.isDynamicProbe() && (dialog.getProbeEventName() != null) && (dialog.getProbeName() != null)) {
+ enableProbe(param, dialog.getProbeEventName(), false, dialog.getProbeName(), monitor);
+ }
- // Enable dynamic function probe
- if (dialog.isDynamicFunctionProbe()) {
- if ((dialog.getFunctionEventName() != null) && (dialog.getFunction() != null)) {
- enableProbe(dialog.getFunctionEventName(), true, dialog.getFunction(), monitor);
- }
- }
+ // Enable dynamic function probe
+ if (dialog.isDynamicFunctionProbe() && (dialog.getFunctionEventName() != null) && (dialog.getFunction() != null)) {
+ enableProbe(param, dialog.getFunctionEventName(), true, dialog.getFunction(), monitor);
+ }
- // Enable event using a wildcard
- if (dialog.isWildcard()) {
- List<String> eventNames = dialog.getEventNames();
- eventNames.add(dialog.getWildcard());
+ // Enable event using a wildcard
+ if (dialog.isWildcard()) {
+ List<String> eventNames = dialog.getEventNames();
+ eventNames.add(dialog.getWildcard());
- if (eventNames.size() > 0) {
- enableEvents(eventNames, dialog.isKernel(), monitor);
+ if (!eventNames.isEmpty()) {
+ enableEvents(param, eventNames, dialog.isKernel(), monitor);
+ }
}
- }
-
- // Enable events using log level
- if (dialog.isLogLevel()) {
- enableLogLevel(dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), monitor);
+
+ // Enable events using log level
+ if (dialog.isLogLevel()) {
+ enableLogLevel(param, dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), monitor);
+ }
+
+ } catch (ExecutionException e) {
+ errorString.append(e.toString());
+ errorString.append('\n');
}
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
+ // 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());
}
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
- // get session configuration in all cases
- try {
- fSession.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
+ if (errorString.length() > 0) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString.toString());
}
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ return Status.OK_STATUS;
}
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
return null;
}
}
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;
}
// Attributes
// ------------------------------------------------------------------------
/**
- * Kernel domain component reference.
+ * The command execution parameter.
*/
- protected TraceDomainComponent fKernelDomain = null;
- /**
- * UST domain component reference.
- */
- protected TraceDomainComponent fUstDomain = null;
- /**
- * The list of kernel channel components the command is to be executed on.
- */
- protected List<TraceChannelComponent> fKernelChannels = new ArrayList<TraceChannelComponent>();
- /**
- * The list of UST channel components the command is to be executed on.
- */
- protected List<TraceChannelComponent> fUstChannels = new ArrayList<TraceChannelComponent>();
+ protected Parameter fParam;
// ------------------------------------------------------------------------
// Accessors
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ fLock.lock();
+ try {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- return false;
- }
+ if (window == null) {
+ return false;
+ }
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- TraceSessionComponent session = null;
-
- try {
- if (fKernelDomain != null) {
- session = (TraceSessionComponent)fKernelDomain.getParent();
- List<String> channelNames = new ArrayList<String>();
- for (Iterator<TraceChannelComponent> iterator = fKernelChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channelNames.add(channel.getName());
- }
-
- changeState(fKernelDomain, channelNames, monitor);
+ final Parameter param = new Parameter(fParam);
- for (Iterator<TraceChannelComponent> iterator = fKernelChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channel.setState(getNewState());
- }
- }
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
- if (fUstDomain != null) {
- if (session == null) {
- session = (TraceSessionComponent)fUstDomain.getParent();
- }
+ TraceSessionComponent session = null;
+
+ try {
+ TraceDomainComponent kernelDomain = param.getKernelDomain();
+ List<TraceChannelComponent> kernelChannels = param.getKernelChannels();
+
+ if (kernelDomain != null) {
+ session = (TraceSessionComponent)kernelDomain.getParent();
+ List<String> channelNames = new ArrayList<String>();
+ for (Iterator<TraceChannelComponent> iterator = kernelChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channelNames.add(channel.getName());
+ }
+
+ changeState(kernelDomain, channelNames, monitor);
- List<String> channelNames = new ArrayList<String>();
- for (Iterator<TraceChannelComponent> iterator = fUstChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channelNames.add(channel.getName());
+ for (Iterator<TraceChannelComponent> iterator = kernelChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channel.setState(getNewState());
+ }
}
- changeState(fUstDomain, channelNames, monitor);
-
- for (Iterator<TraceChannelComponent> iterator = fUstChannels.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
- channel.setState(getNewState());
+ TraceDomainComponent ustDomain = param.getUstDomain();
+ List<TraceChannelComponent> ustChannels = param.getUstChannels();
+ if (ustDomain != null) {
+ if (session == null) {
+ session = (TraceSessionComponent)ustDomain.getParent();
+ }
+
+ List<String> channelNames = new ArrayList<String>();
+ for (Iterator<TraceChannelComponent> iterator = ustChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channelNames.add(channel.getName());
+ }
+
+ changeState(ustDomain, channelNames, monitor);
+
+ for (Iterator<TraceChannelComponent> iterator = ustChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channel.setState(getNewState());
+ }
}
+ } catch (ExecutionException e) {
+ errorString = e.toString() + "\n"; //$NON-NLS-1$
}
- } catch (ExecutionException e) {
- errorString = e.toString() + "\n"; //$NON-NLS-1$
- }
- // In all cases notify listeners
- session.fireComponentChanged(session);
+ // In all cases notify listeners
+ session.fireComponentChanged(session);
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
+ if (errorString != null) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
+ }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
return null;
}
*/
@Override
public boolean isEnabled() {
- reset();
// Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
}
+
+ TraceDomainComponent kernelDomain = null;
+ TraceDomainComponent ustDomain = null;
+ List<TraceChannelComponent> kernelChannels = new ArrayList<TraceChannelComponent>();
+ List<TraceChannelComponent> ustChannels = new ArrayList<TraceChannelComponent>();
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);
// Enable command only for channels of same session
if (!sessionName.equals(channel.getSessionName())) {
- reset();
+ kernelChannels.clear();
+ ustChannels.clear();
break;
}
if ((channel.getState() != getNewState())) {
if (channel.isKernel()) {
- fKernelChannels.add(channel);
- if (fKernelDomain == null) {
- fKernelDomain = (TraceDomainComponent) channel.getParent();
+ kernelChannels.add(channel);
+ if (kernelDomain == null) {
+ kernelDomain = (TraceDomainComponent) channel.getParent();
}
} else {
- fUstChannels.add(channel);
- if (fUstDomain == null) {
- fUstDomain = (TraceDomainComponent) channel.getParent();
+ ustChannels.add(channel);
+ if (ustDomain == null) {
+ ustDomain = (TraceDomainComponent) channel.getParent();
}
}
}
}
}
}
- return fKernelChannels.size() + fUstChannels.size() > 0;
+
+ boolean isEnabled = (!kernelChannels.isEmpty() || !ustChannels.isEmpty());
+ fLock.lock();
+ try {
+ if (isEnabled) {
+ fParam = new Parameter(kernelDomain, ustDomain, kernelChannels, ustChannels);
+ }
+ } finally {
+ fLock.unlock();
+ }
+
+ return isEnabled;
}
-
+
/**
- * Reset members
+ * Class containing parameter for the command execution.
*/
- private void reset() {
- fKernelDomain = null;
- fUstDomain = null;
- fKernelChannels.clear();
- fUstChannels.clear();
+ static protected class Parameter {
+ /**
+ * Kernel domain component reference.
+ */
+ final protected TraceDomainComponent fKernelDomain;
+ /**
+ * UST domain component reference.
+ */
+ final protected TraceDomainComponent fUstDomain;
+ /**
+ * The list of kernel channel components the command is to be executed on.
+ */
+ final protected List<TraceChannelComponent> fKernelChannels;
+ /**
+ * The list of UST channel components the command is to be executed on.
+ */
+ final protected List<TraceChannelComponent> fUstChannels;
+
+ /**
+ * Constructor
+ * @param kernelDomain - a kernel domain component
+ * @param ustDomain - a UST domain component
+ * @param kernelChannels - list of available kernel channels
+ * @param ustChannels - list of available UST channels
+ */
+ public Parameter(TraceDomainComponent kernelDomain, TraceDomainComponent ustDomain, List<TraceChannelComponent> kernelChannels, List<TraceChannelComponent> ustChannels) {
+ fKernelDomain = kernelDomain;
+ fUstDomain = ustDomain;
+ fKernelChannels = new ArrayList<TraceChannelComponent>();
+ fKernelChannels.addAll(kernelChannels);
+ fUstChannels = new ArrayList<TraceChannelComponent>();
+ fUstChannels.addAll(ustChannels);
+ }
+
+ /**
+ * Copy constructor
+ * @param other a parameter to copy
+ */
+ public Parameter(Parameter other) {
+ this(other.fKernelDomain, other.fUstDomain, other.fKernelChannels, other.fUstChannels);
+ }
+
+ /**
+ * @return the kernel domain component.
+ */
+ public TraceDomainComponent getKernelDomain() {
+ return fKernelDomain;
+ }
+
+ /**
+ * @return the UST domain component.
+ */
+ public TraceDomainComponent getUstDomain() {
+ return fUstDomain;
+ }
+
+ /**
+ * @return the list of kernel channel components.
+ */
+ public List<TraceChannelComponent> getKernelChannels() {
+ return fKernelChannels;
+ }
+
+ /**
+ * @return the list of UST channel components.
+ */
+ public List<TraceChannelComponent> getUstChannels() {
+ return fUstChannels;
+ }
}
}
// Attributes
// ------------------------------------------------------------------------
/**
- * Channel component reference.
+ * The command execution parameter.
*/
- protected TraceChannelComponent fChannel = null;
- /**
- * The list of kernel channel components the command is to be executed on.
- */
- protected List<TraceEventComponent> fEvents = new ArrayList<TraceEventComponent>();
+ protected Parameter fParam;
// ------------------------------------------------------------------------
// Accessors
return false;
}
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- TraceSessionComponent session = null;
-
- try {
- boolean isAll = false;
- if (fChannel != null) {
- session = fChannel.getSession();
- List<String> eventNames = new ArrayList<String>();
- for (Iterator<TraceEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
- // Enable/disable all selected channels which are disabled
- TraceEventComponent event = (TraceEventComponent) iterator.next();
+ fLock.lock();
+ try {
+
+ final Parameter param = new Parameter(fParam);
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ StringBuffer errorString = new StringBuffer();
+
+ TraceSessionComponent session = null;
+
+ try {
+ boolean isAll = false;
+ if (param.getChannel() != null) {
+ session = param.getChannel().getSession();
+ List<String> eventNames = new ArrayList<String>();
+ List<TraceEventComponent> events = param.getEvents();
- // Workaround for wildcard handling in lttng-tools
- if ("*".equals(event.getName())) { //$NON-NLS-1$
- isAll = true;
- } else {
- eventNames.add(event.getName());
+ for (Iterator<TraceEventComponent> iterator = events.iterator(); iterator.hasNext();) {
+ // Enable/disable all selected channels which are disabled
+ TraceEventComponent event = (TraceEventComponent) iterator.next();
+
+ // Workaround for wildcard handling in lttng-tools
+ if ("*".equals(event.getName())) { //$NON-NLS-1$
+ isAll = true;
+ } else {
+ eventNames.add(event.getName());
+ }
+ }
+ if (isAll) {
+ changeState(param.getChannel(), null, monitor);
}
- }
- if (isAll) {
- changeState(fChannel, null, monitor);
- }
- if (eventNames.size() > 0) {
- changeState(fChannel, eventNames, monitor);
- }
+ if (!eventNames.isEmpty()) {
+ changeState(param.getChannel(), eventNames, monitor);
+ }
- for (Iterator<TraceEventComponent> iterator = fEvents.iterator(); iterator.hasNext();) {
- // Enable all selected channels which are disabled
- TraceEventComponent ev = (TraceEventComponent) iterator.next();
- ev.setState(getNewState());
+ for (Iterator<TraceEventComponent> iterator = events.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceEventComponent ev = (TraceEventComponent) iterator.next();
+ ev.setState(getNewState());
+ }
}
+ } catch (ExecutionException e) {
+ errorString.append(e.toString());
+ errorString.append('\n');
}
- } catch (ExecutionException e) {
- errorString = e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // In all cases notify listeners
- session.fireComponentChanged(session);
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
+ if (session != null) {
+ // In all cases notify listeners
+ session.fireComponentChanged(session);
+ }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
+ if (errorString.length() > 0) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
return null;
}
return false;
}
- reset();
-
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);
+
+ TraceChannelComponent channel = null;
+ List<TraceEventComponent> events = new ArrayList<TraceEventComponent>();
+
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
String sessionName = null;
sessionName = String.valueOf(event.getSessionName());
}
- if (fChannel == null) {
- fChannel = (TraceChannelComponent)event.getParent();
+ if (channel == null) {
+ channel = (TraceChannelComponent)event.getParent();
}
if (channelName == null) {
// Enable command only for events of same session, same channel and domain
if ((!sessionName.equals(event.getSessionName())) ||
(!channelName.equals(event.getChannelName())) ||
- (fChannel.isKernel() != event.isKernel())) {
- reset();
+ (channel.isKernel() != event.isKernel())) {
+ events.clear();
break;
}
if ((event.getState() != getNewState())) {
- fEvents.add(event);
+ events.add(event);
}
}
}
}
- return fEvents.size() > 0;
+ boolean isEnabled = !events.isEmpty();
+
+ fLock.lock();
+ try {
+ fParam = null;
+ if (isEnabled) {
+ fParam = new Parameter(channel, events);
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
}
/**
- * Reset members
+ * Class containing parameter for the command execution.
*/
- private void reset() {
- fChannel = null;
- fEvents.clear();
+ protected class Parameter {
+ /**
+ * Channel component reference.
+ */
+ final private TraceChannelComponent fChannel;
+ /**
+ * The list of kernel channel components the command is to be executed on.
+ */
+ final private List<TraceEventComponent> fEvents = new ArrayList<TraceEventComponent>();
+
+ public Parameter(TraceChannelComponent channel, List<TraceEventComponent> events) {
+ fChannel = channel;
+ fEvents.addAll(events);
+ }
+
+ /**
+ * Copy constructor
+ * @param other - a parameter to copy
+ */
+ public Parameter(Parameter other) {
+ this(other.fChannel, other.fEvents);
+ }
+
+ /**
+ * @return the trace channel component.
+ */
+ public TraceChannelComponent getChannel() {
+ return fChannel;
+ }
+
+ /**
+ * @return a list of trace event components.
+ */
+ public List<TraceEventComponent> getEvents() {
+ return fEvents;
+ }
}
}
return false;
}
- Job job = new Job(Messages.TraceControl_StartSessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- for (Iterator<TraceSessionComponent> iterator = fSessions.iterator(); iterator.hasNext();) {
+ fLock.lock();
+ try {
+
+ final List<TraceSessionComponent> sessions = new ArrayList<TraceSessionComponent>();
+ sessions.addAll(fSessions);
- // Start all selected sessions
- TraceSessionComponent session = (TraceSessionComponent) iterator.next();
- changeState(session, monitor);
+ Job job = new Job(Messages.TraceControl_StartSessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ for (Iterator<TraceSessionComponent> iterator = sessions.iterator(); iterator.hasNext();) {
- // Set Session state
- session.setSessionState(getNewState());
- session.fireComponentChanged(session);
- }
- } catch (ExecutionException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
+ // Start all selected sessions
+ TraceSessionComponent session = (TraceSessionComponent) iterator.next();
+ changeState(session, monitor);
+
+ // Set Session state
+ session.setSessionState(getNewState());
+ session.fireComponentChanged(session);
+ }
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
return null;
}
return false;
}
- fSessions.clear();
+ List<TraceSessionComponent> sessions = new ArrayList<TraceSessionComponent>(0);
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);
// Add only TraceSessionComponents that are inactive and not destroyed
TraceSessionComponent session = (TraceSessionComponent) element;
if ((session.getSessionState() != getNewState()) && (!session.isDestroyed())) {
- fSessions.add((TraceSessionComponent)element);
+ sessions.add(session);
}
}
}
}
- return fSessions.size() > 0;
+ boolean isEnabled = !sessions.isEmpty();
+ fLock.lock();
+ try {
+ fSessions = null;
+ if (isEnabled) {
+ fSessions = sessions;
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
}
}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * Class containing parameter for the command execution.
+ */
+public class ChannelCommandParameter extends CommandParameter implements Cloneable {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private TraceChannelComponent fChannel;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param session - a trace session component.
+ * @param channel - a trace channel component
+ */
+ public ChannelCommandParameter(TraceSessionComponent session, TraceChannelComponent channel) {
+ super(session);
+ fChannel = channel;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the trace channel component
+ */
+ public TraceChannelComponent getChannel() {
+ return fChannel;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public ChannelCommandParameter clone() {
+ ChannelCommandParameter clone = (ChannelCommandParameter) super.clone();
+ clone.fChannel = fChannel;
+ return clone;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * Class containing parameter for the command execution.
+ */
+public class CommandParameter implements Cloneable {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The trace session component.
+ */
+ private TraceSessionComponent fSession;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param session a trace session component.
+ */
+ public CommandParameter(TraceSessionComponent session) {
+ fSession = session;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the session component.
+ */
+ public TraceSessionComponent getSession() {
+ return fSession;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public CommandParameter clone() {
+ CommandParameter clone = null;
+ try {
+ clone = (CommandParameter) super.clone();
+ clone.fSession = fSession;
+ } catch (CloneNotSupportedException e) {
+ }
+ return clone;
+ }
+}
\ No newline at end of file
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- fTargetNode.connect();
+ fLock.lock();
+ try {
+ fTargetNode.connect();
+ } finally {
+ fLock.unlock();
+ }
return null;
}
*/
@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;
}
}
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelDialog;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
* Command handler implementation to create a trace channel for known domain.
* </p>
*/
-public class CreateChannelOnDomainHandler extends BaseControlViewHandler {
+public class CreateChannelOnDomainHandler extends BaseCreateChannelHandler {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- /**
- * The the domain component the command is to be executed on.
- */
- private TraceDomainComponent fDomain;
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#enableChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // Get channel information from user
- final ICreateChannelDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelDialog();
- dialog.setDomainComponent(fDomain);
-
- if (dialog.open() != Window.OK) {
- return null;
+ public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof DomainCommandParameter) {
+ ((DomainCommandParameter)param).getDomain().enableChannels(channelNames, info, monitor);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
+ */
+ @Override
+ public TraceDomainComponent getDomain(CommandParameter param) {
+ if (param instanceof DomainCommandParameter) {
+ return ((DomainCommandParameter)param).getDomain();
}
-
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- List<String> channelNames = new ArrayList<String>();
- channelNames.add(dialog.getChannelInfo().getName());
-
- try {
- fDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // get session configuration in all cases
- try {
- fDomain.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
- return Status.OK_STATUS;
- }
- };
-
- job.setUser(true);
- job.schedule();
-
return null;
}
if (page == null) {
return false;
}
- fDomain = null;
-
+
+ TraceDomainComponent domain = null;
+ TraceSessionComponent session = null;
+
// Check if one domain is selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
Object element = (Object) iterator.next();
if (element instanceof TraceDomainComponent) {
- TraceDomainComponent domain = (TraceDomainComponent) element;
- TraceSessionComponent session = (TraceSessionComponent) domain.getParent();
+ TraceDomainComponent tmpDomain = (TraceDomainComponent) element;
+ session = (TraceSessionComponent) tmpDomain.getParent();
+
// Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
- fDomain = domain;
+ domain = tmpDomain;
}
}
}
}
- return fDomain != null;
+
+ boolean isEnabled = domain != null;
+
+ fLock.lock();
+ try {
+ fParam = null;
+ if (isEnabled) {
+ fParam = new DomainCommandParameter(session, domain);
+ }
+ } finally {
+ fLock.unlock();
+ }
+
+ return isEnabled;
}
+
}
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
* (on session level).
* </p>
*/
-public class CreateChannelOnSessionHandler extends BaseControlViewHandler {
+public class CreateChannelOnSessionHandler extends BaseCreateChannelHandler {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- /**
- * The session component the command is to be executed on.
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#enableChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
- private TraceSessionComponent fSession = null;
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
+ @Override
+ public void enableChannel(CommandParameter param, List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ param.getSession().enableChannels(channelNames, info, isKernel, monitor);
+ }
+
/*
* (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseCreateChannelHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
*/
@Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- final ICreateChannelOnSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateChannelOnSessionDialog();
-
- if (dialog.open() != Window.OK) {
- return null;
- }
-
- Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- List<String> channelNames = new ArrayList<String>();
- TraceDomainComponent newDomain = new TraceDomainComponent("dummy", fSession); //$NON-NLS-1$
- channelNames.add(dialog.getChannelInfo().getName());
- newDomain.setIsKernel(dialog.isKernel());
-
- try {
- newDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
-
- // get session configuration in all cases
- try {
- fSession.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
- }
-
- if (errorString != null) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
+ public TraceDomainComponent getDomain(CommandParameter param) {
return null;
}
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
return false;
}
- fSession = null;
-
+ TraceSessionComponent session = null;
// Check if one session is selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
Object element = (Object) iterator.next();
if (element instanceof TraceSessionComponent) {
// Add only TraceSessionComponents that are inactive and not destroyed
- TraceSessionComponent session = (TraceSessionComponent) element;
- if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
- fSession = session;
+ TraceSessionComponent tmpSession = (TraceSessionComponent) element;
+ if ((tmpSession.getSessionState() == TraceSessionState.INACTIVE) && (!tmpSession.isDestroyed())) {
+ session = tmpSession;
}
}
}
}
- return fSession != null;
+ boolean isEnabled = session != null;
+
+ fLock.lock();
+ try {
+ fParam = null;
+ if (isEnabled) {
+ fParam = new CommandParameter(session);
+ }
+ } finally {
+ fLock.unlock();
+ }
+
+ return isEnabled;
}
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- // Open dialog box for the node name and address
- ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
- dialog.setTraceSessionGroup(fSessionGroup);
+ fLock.lock();
+ try {
+ final TraceSessionGroup sessionGroup = fSessionGroup;
+
+ // Open dialog box for the node name and address
+ ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
+ dialog.setTraceSessionGroup(sessionGroup);
- if (dialog.open() != Window.OK) {
- return null;
- }
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
- final String sessionName = dialog.getSessionName();
- final String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath();
+ final String sessionName = dialog.getSessionName();
+ final String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath();
- Job job = new Job(Messages.TraceControl_CreateSessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- fSessionGroup.createSession(sessionName, sessionPath, monitor);
- } catch (ExecutionException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
-
+ Job job = new Job(Messages.TraceControl_CreateSessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ sessionGroup.createSession(sessionName, sessionPath, monitor);
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
return null;
}
return false;
}
- fSessionGroup = null;
+ TraceSessionGroup sessionGroup = null;
// Check if the session group project is selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
Object element = ((StructuredSelection) selection).getFirstElement();
- fSessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+ sessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+ }
+
+ boolean isEnabled = sessionGroup != null;
+ fLock.lock();
+ try {
+ fSessionGroup = null;
+ if(isEnabled) {
+ fSessionGroup = sessionGroup;
+ }
+ } finally {
+ fLock.unlock();
}
- return fSessionGroup != null;
+ return isEnabled;
}
}
*/
@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();
+ root.removeChild(fTargetNode);
+ } finally {
+ fLock.unlock();
+ }
return null;
}
*/
@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;
}
}
}
}
}
- return fSessions.size() > 0;
+ return !fSessions.isEmpty();
}
}
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TargetNodeState;
/**
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- fTargetNode.disconnect();
+ fLock.lock();
+ try {
+ ITraceControlComponent root = fTargetNode.getParent();
+ fTargetNode.disconnect();
+ root.removeChild(fTargetNode);
+ } finally {
+ fLock.unlock();
+ }
return null;
}
*/
@Override
public boolean isEnabled() {
- return super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.CONNECTED);
+ boolean isEnabled = false;
+ fLock.lock();
+ try {
+ isEnabled = super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.CONNECTED);
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
}
}
--- /dev/null
+/**********************************************************************
+ * 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:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * Class containing parameter for the command execution.
+ */
+public class DomainCommandParameter extends CommandParameter {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private TraceDomainComponent fDomain;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param session - a trace session component.
+ * @param domain - a trace domain component
+ */
+ public DomainCommandParameter(TraceSessionComponent session, TraceDomainComponent domain) {
+ super(session);
+ fDomain = domain;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the trace domain component
+ */
+ public TraceDomainComponent getDomain() {
+ return fDomain;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public DomainCommandParameter clone() {
+ DomainCommandParameter clone = (DomainCommandParameter) super.clone();
+ clone.fDomain = fDomain;
+ return clone;
+ }
+}
\ No newline at end of file
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- /**
- * The channel component the command is to be executed on.
- */
- private TraceChannelComponent fChannel = null;
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableEvents(eventNames, monitor);
+ public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof ChannelCommandParameter) {
+ ((ChannelCommandParameter)param).getChannel().enableEvents(eventNames, monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableSyscalls(monitor);
+ public void enableSyscalls(CommandParameter param, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof ChannelCommandParameter) {
+ ((ChannelCommandParameter)param).getChannel().enableSyscalls(monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableProbe(eventName, isFunction, probe, monitor);
+ public void enableProbe(CommandParameter param, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof ChannelCommandParameter) {
+ ((ChannelCommandParameter)param).getChannel().enableProbe(eventName, isFunction, probe, monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- fChannel.enableLogLevel(eventName, logLevelType, level, monitor);
+ public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof ChannelCommandParameter) {
+ ((ChannelCommandParameter)param).getChannel().enableLogLevel(eventName, logLevelType, level, monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
*/
@Override
- public TraceDomainComponent getDomain() {
- return (TraceDomainComponent) fChannel.getParent();
+ public TraceDomainComponent getDomain(CommandParameter param) {
+ if (param instanceof ChannelCommandParameter) {
+ return (TraceDomainComponent) ((ChannelCommandParameter)param).getChannel().getParent();
+ }
+ return null;
}
/*
return false;
}
- fChannel = null;
+ TraceChannelComponent channel = null;
+ TraceSessionComponent session = null;
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
Object element = (Object) iterator.next();
if (element instanceof TraceChannelComponent) {
// Add only if corresponding TraceSessionComponents is inactive and not destroyed
- TraceChannelComponent channel = (TraceChannelComponent) element;
- TraceSessionComponent session = channel.getSession();
+ TraceChannelComponent tmpChannel = (TraceChannelComponent) element;
+ session = tmpChannel.getSession();
if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
- fChannel = channel;
- fSession = session;
+ channel = tmpChannel;
}
}
}
}
- return fChannel != null;
+
+ boolean isEnabled = (channel != null);
+ fLock.lock();
+ try {
+ fParam = null;
+ if(isEnabled) {
+ fParam = new ChannelCommandParameter(session, channel);
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
}
-
}
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- /**
- * The domain component the command is to be executed on.
- */
- private TraceDomainComponent fDomain = null;
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableEvents(eventNames, monitor);
+ public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof DomainCommandParameter) {
+ ((DomainCommandParameter)param).getDomain().enableEvents(eventNames, monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableSyscalls(monitor);
+ public void enableSyscalls(CommandParameter param, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof DomainCommandParameter) {
+ ((DomainCommandParameter)param).getDomain().enableSyscalls(monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableProbe(eventName, isFunction, probe, monitor);
+ public void enableProbe(CommandParameter param, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof DomainCommandParameter) {
+ ((DomainCommandParameter)param).getDomain().enableProbe(eventName, isFunction, probe, monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- fDomain.enableLogLevel(eventName, logLevelType, level, monitor);
+ public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof DomainCommandParameter) {
+ ((DomainCommandParameter)param).getDomain().enableLogLevel(eventName, logLevelType, level, monitor);
+ }
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
*/
@Override
- public TraceDomainComponent getDomain() {
- return fDomain;
+ public TraceDomainComponent getDomain(CommandParameter param) {
+ if (param instanceof DomainCommandParameter) {
+ return ((DomainCommandParameter)param).getDomain();
+ }
+ return null;
}
+
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
return false;
}
- fDomain = null;
+ TraceDomainComponent domain = null;
+ TraceSessionComponent session = null;
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
Object element = (Object) iterator.next();
if (element instanceof TraceDomainComponent) {
// Add only if corresponding TraceSessionComponents is inactive and not destroyed
- TraceDomainComponent domain = (TraceDomainComponent) element;
- TraceSessionComponent session = domain.getSession();
+ TraceDomainComponent tmpDomain = (TraceDomainComponent) element;
+ session = tmpDomain.getSession();
if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
- fDomain = domain;
- fSession = session;
+ domain = tmpDomain;
}
}
}
}
- return fDomain != null;
+
+ boolean isEnabled = (domain != null);
+ fLock.lock();
+ try {
+ fParam = null;
+ if(isEnabled) {
+ fParam = new DomainCommandParameter(session, domain);
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
}
}
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableEvents(eventNames, isKernel, monitor);
+ public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ param.getSession().enableEvents(eventNames, isKernel, monitor);
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
- fSession.enableSyscalls(monitor);
+ public void enableSyscalls(CommandParameter param, IProgressMonitor monitor) throws ExecutionException {
+ param.getSession().enableSyscalls(monitor);
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableProbe(eventName, isFunction, probe, monitor);
+ public void enableProbe(CommandParameter param, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ param.getSession().enableProbe(eventName, isFunction, probe, monitor);
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
- fSession.enableLogLevel(eventName, logLevelType, level, monitor);
+ public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ param.getSession().enableLogLevel(eventName, logLevelType, level, monitor);
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
*/
@Override
- public TraceDomainComponent getDomain() {
+ public TraceDomainComponent getDomain(CommandParameter param) {
return null;
}
return false;
}
- fSession = null;
-
+ TraceSessionComponent session = null;
// Check if one session is selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
Object element = (Object) iterator.next();
if (element instanceof TraceSessionComponent) {
// Add only if corresponding TraceSessionComponents is inactive and not destroyed
- TraceSessionComponent session = (TraceSessionComponent) element;
- if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
- fSession = session;
+ TraceSessionComponent tmpSession = (TraceSessionComponent) element;
+ if(tmpSession.getSessionState() == TraceSessionState.INACTIVE && !tmpSession.isDestroyed()) {
+ session = tmpSession;
}
}
}
}
- return fSession != null;
+ boolean isEnabled = (session != null);
+ fLock.lock();
+ try {
+ fParam = null;
+ if(isEnabled) {
+ fParam = new CommandParameter(session);
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
}
}
return null;
}
}
-
+
if (host != null) {
- // successful creation of host
- TargetNodeComponent node = null;
- if (!fRoot.containsChild(hostName)) {
- node = new TargetNodeComponent(hostName, fRoot, host);
- fRoot.addChild(node);
- }
- else {
- node = (TargetNodeComponent)fRoot.getChild(hostName);
+ fLock.lock();
+ try {
+ // successful creation of host
+ TargetNodeComponent node = null;
+ if (!fRoot.containsChild(hostName)) {
+ node = new TargetNodeComponent(hostName, fRoot, host);
+ fRoot.addChild(node);
+ }
+ else {
+ node = (TargetNodeComponent)fRoot.getChild(hostName);
+ }
+
+ node.connect();
+ } finally {
+ fLock.unlock();
}
-
- node.connect();
}
return null;
}
return false;
}
- fRoot = null;
+ ITraceControlComponent root = null;
// no need to verify part because it has been already done in getWorkbenchPage()
IWorkbenchPart part = page.getActivePart();
- fRoot = ((ControlView) part).getTraceControlRoot();
+ root = ((ControlView) part).getTraceControlRoot();
+
+ boolean isEnabled = root != null;
+
+ fLock.lock();
+ try {
+ fRoot = null;
+ if (isEnabled) {
+ fRoot = root;
+ }
+ } finally {
+ fLock.unlock();
+ }
- return (fRoot != null);
+ return isEnabled;
}
}
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- fNode.refresh();
+ fLock.lock();
+ try {
+ fNode.refresh();
+ } finally {
+ fLock.unlock();
+ }
return null;
}
*/
@Override
public boolean isEnabled() {
- fNode = null;
// Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
return false;
}
+ TargetNodeComponent node = null;
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
component = (TraceControlComponent) component.getParent();
}
if (component != null) {
- fNode = (TargetNodeComponent) component;
+ node = (TargetNodeComponent) component;
}
}
}
}
}
- return fNode != null;
+
+ boolean isEnabled = node != null;
+
+ fLock.lock();
+ try {
+ fNode = null;
+ if (isEnabled) {
+ fNode = node;
+ }
+ } finally {
+ fLock.unlock();
+ }
+
+ return isEnabled;
}
}
TraceControl_InvalidProbeNameError=The probe name is invalid
TraceControl_InvalidWildcardError=The wild card name is invalid
TraceControl_InvalidLogLevelEventNameError=The event name for log level is invalid
+TraceControl_InvalidLogLevel=No log level selected
# Tree structure strings
TraceControl_KernelDomainDisplayName=Kernel
}
output.append(" (type: ");
output.append(fEventType.getInName());
- output.append(")");
+ output.append(')');
return output.toString();
}
output.append(event.formatString());
}
}
- output.append("\n");
+ output.append('\n');
return output.toString();
}
output.append(channel.formatString());
}
}
- output.append("\n");
+ output.append('\n');
return output.toString();
}
output.append(super.formatString());
output.append(" [");
output.append(fState.getInName());
- output.append("]");
+ output.append(']');
return output.toString();
}
} else {
output.append("\n offset: ");
output.append(fOffset);
- output.append("\n");
+ output.append('\n');
output.append(" symbol: ");
output.append(fSymbol);
}
// Trace path: /home/user/lttng-traces/mysession-20120129-084256
output.append(" Trace path: ");
output.append(getSessionPath());
- output.append("\n");
+ output.append('\n');
for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
IDomainInfo domain = (IDomainInfo) iterator.next();
import org.eclipse.core.runtime.NullProgressMonitor;
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.model.IChannelInfo;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
getControlService().stopSession(getName(), monitor);
}
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @throws ExecutionException
+ */
+ public void enableChannels(List<String> channelNames, IChannelInfo info, boolean isKernel) throws ExecutionException {
+ enableChannels(channelNames, info, isKernel, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableChannels(List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableChannels(getName(), channelNames, isKernel, info, monitor);
+ }
+
/**
* Enables a list of events with no additional parameters.
* @param eventNames - a list of event names to enabled.
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
- List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
- for (int i = 0; i < superProperties.length; i++) {
- list.add(superProperties[i]);
- }
-
+
+ List<IPropertyDescriptor> superList = Arrays.asList(superProperties);
+ ArrayList<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
+ list.addAll(superList);
+
if (fEvent instanceof TraceProbeEventComponent) {
TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
if (event.getAddress() != null) {
private final static String COMMAND_DISABLE_EVENT = CONTROL_COMMAND + " disable-event "; //$NON-NLS-1$
// Command options constants
+ /**
+ * Command line option for output path.
+ */
+ private final static String OPTION_OUTPUT_PATH = " -o "; //$NON-NLS-1$
/**
* Command line option for kernel tracer.
*/
String command = COMMAND_LIST + sessionName;
ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
-
+
if (isError(result)) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
}
String newName = formatParameter(sessionName);
String newPath = formatParameter(sessionPath);
- String command = COMMAND_CREATE_SESSION + newName;
+ StringBuffer command = new StringBuffer();
+ command.append(COMMAND_CREATE_SESSION);
+ command.append(newName);
+
if (newPath != null && !"".equals(newPath)) { //$NON-NLS-1$
- command += " -o " + newPath; //$NON-NLS-1$
+ command.append(OPTION_OUTPUT_PATH);
+ command.append(newPath);
}
- ICommandResult result = fCommandShell.executeCommand(command, monitor);
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
if (isError(result)) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
ICommandResult result = fCommandShell.executeCommand(command, monitor);
String[] output = result.getOutput();
- if (isError(result)) {
- // In case "session not found" treat it as success
- if ((output == null) || (!SESSION_NOT_FOUND_ERROR_PATTERN.matcher(output[0]).matches())) {
+ if (isError(result) && ((output == null) || (!SESSION_NOT_FOUND_ERROR_PATTERN.matcher(output[0]).matches()))) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ }
//Session <sessionName> destroyed
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#startSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
// no channels to enable
- if (channelNames.size() == 0) {
+ if (channelNames.isEmpty()) {
return;
}
String channel = (String) iterator.next();
command.append(channel);
if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
+ command.append(',');
}
}
public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
// no channels to enable
- if (channelNames.size() == 0) {
+ if (channelNames.isEmpty()) {
return;
}
String channel = (String) iterator.next();
command.append(channel);
if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
+ command.append(',');
}
}
StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
- if (eventNames == null || eventNames.size() == 0) {
+ if (eventNames == null || eventNames.isEmpty()) {
command.append(OPTION_ALL);
} else {
String event = (String) iterator.next();
command.append(event);
if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
+ command.append(',');
}
}
}
command.append(OPTION_ALL);
} else {
// no events to enable
- if (eventNames.size() == 0) {
+ if (eventNames.isEmpty()) {
return;
}
String event = (String) iterator.next();
command.append(event);
if (iterator.hasNext()) {
- command.append(","); //$NON-NLS-1$
+ command.append(',');
}
}
}
*/
private String formatParameter(String parameter) {
if (parameter != null) {
- String newString = String.valueOf(parameter);
+ StringBuffer newString = new StringBuffer();
+ newString.append(parameter);
if (parameter.contains(" ")) { //$NON-NLS-1$
- newString = "\"" + newString + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ newString.insert(0, "\""); //$NON-NLS-1$
+ newString.append("\""); //$NON-NLS-1$
}
- return newString;
+ return newString.toString();
}
return null;
}