/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Iterator;
import java.util.List;
try {
fParam = null;
if(isEnabled) {
- fParam = new ChannelCommandParameter(session, channel);
+ fParam = new ChannelCommandParameter(checkNotNull(session), checkNotNull(channel));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Iterator;
import java.util.List;
try {
fParam = null;
if (isEnabled) {
- fParam = new DomainCommandParameter(session, domain);
+ fParam = new DomainCommandParameter(checkNotNull(session), checkNotNull(domain));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Iterator;
import java.util.List;
try {
fParam = null;
if(isEnabled) {
- fParam = new EventCommandParameter(session, event);
+ fParam = new EventCommandParameter(checkNotNull(session), checkNotNull(event));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.IGetEventInfoDialog;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+ // Make a copy for thread safety
+ Parameter tmpParam = null;
fLock.lock();
try {
- // Make a copy for thread safety
- final Parameter param = new Parameter(fParam);
-
- // 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());
-
- if (dialog.open() != Window.OK) {
+ tmpParam = fParam;
+ if (tmpParam == null) {
return null;
}
+ tmpParam = new Parameter(tmpParam);
+ } finally {
+ fLock.unlock();
+ }
+ final Parameter param = tmpParam;
- Job job = new Job(Messages.TraceControl_EnableEventsJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
-
- Exception error = 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());
- try {
- List<String> eventNames = new ArrayList<>();
- List<BaseEventComponent> events = param.getEvents();
- // Create list of event names
- for (Iterator<BaseEventComponent> iterator = events.iterator(); iterator.hasNext();) {
- BaseEventComponent baseEvent = iterator.next();
- eventNames.add(baseEvent.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, param.isKernel(), dialog.getFilterExpression(), monitor);
- } else {
- channel.enableEvents(eventNames, dialog.getFilterExpression(), monitor);
- }
+ Job job = new Job(Messages.TraceControl_EnableEventsJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ Exception error = null;
+ TraceSessionComponent session = dialog.getSession();
+ try {
+ List<String> eventNames = new ArrayList<>();
+ List<BaseEventComponent> events = param.getEvents();
+ // Create list of event names
+ for (Iterator<BaseEventComponent> iterator = events.iterator(); iterator.hasNext();) {
+ BaseEventComponent baseEvent = iterator.next();
+ eventNames.add(baseEvent.getName());
+ }
- } catch (ExecutionException e) {
- error = e;
+ TraceChannelComponent channel = dialog.getChannel();
+ if (channel == null) {
+ // enable events on default channel (which will be created by lttng-tools)
+ session.enableEvents(eventNames, param.isKernel(), dialog.getFilterExpression(), monitor);
+ } else {
+ channel.enableEvents(eventNames, dialog.getFilterExpression(), monitor);
}
- // refresh in all cases
- refresh(new CommandParameter(dialog.getSession()));
+ } catch (ExecutionException e) {
+ error = e;
+ }
- if (error != null) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_EnableEventsFailure, error);
- }
- return Status.OK_STATUS;
+ // refresh in all cases
+ if (session != null) {
+ refresh(new CommandParameter(session));
}
- };
- job.setUser(true);
- job.schedule();
- } finally {
- fLock.unlock();
- }
+
+ if (error != null) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_EnableEventsFailure, error);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
return null;
}
try {
fParam = null;
if(isEnabled) {
- fParam = new Parameter(sessions, events, isKernel);
+ fParam = new Parameter(NonNullUtils.checkNotNull(sessions), events, isKernel);
}
} finally {
fLock.unlock();
/**
* Class containing parameter for the command execution.
*/
+ @NonNullByDefault
private static final class Parameter {
/**
* @param isKernel - domain (true for kernel or UST)
*/
public Parameter(TraceSessionComponent[] sessions, List<BaseEventComponent> events, boolean isKernel) {
- fSessions = Arrays.copyOf(sessions, sessions.length);
+ fSessions = NonNullUtils.checkNotNull(Arrays.copyOf(sessions, sessions.length));
fEvents = new ArrayList<>();
fEvents.addAll(events);
fIsKernel = isKernel;
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
}
fLock.lock();
try {
+
+ CommandParameter tmpParam = fParam;
+ if (tmpParam == null) {
+ return null;
+ }
+
// Make a copy for thread safety
- final CommandParameter param = fParam.clone();
+ final CommandParameter param = new CommandParameter(tmpParam);
UIJob getJob = new UIJob(Messages.TraceControl_GetContextJob) {
@Override
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
* Refreshes the session information based on given session (in CommandParameter)
* @param param - command parameter containing the session to refresh
*/
- protected void refresh(final CommandParameter param) {
+ protected void refresh(final @NonNull CommandParameter param) {
Job job = new Job(Messages.TraceControl_RetrieveNodeConfigurationJob) {
@Override
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+ CommandParameter tmpParam = null;
+
fLock.lock();
try {
- final CommandParameter param = fParam.clone();
-
- final IEnableChannelDialog dialog = TraceControlDialogFactory.getInstance().getEnableChannelDialog();
- dialog.setTargetNodeComponent(param.getSession().getTargetNode());
- dialog.setDomainComponent(getDomain(param));
- dialog.setHasKernel(param.getSession().hasKernelProvider());
-
- if (dialog.open() != Window.OK) {
+ tmpParam = fParam;
+ if (tmpParam == null) {
return null;
}
+ tmpParam = new CommandParameter(tmpParam);
+ } finally {
+ fLock.unlock();
+ }
+ final CommandParameter param = tmpParam;
- Job job = new Job(Messages.TraceControl_CreateChannelStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- Exception error = null;
+ final IEnableChannelDialog dialog = TraceControlDialogFactory.getInstance().getEnableChannelDialog();
+ dialog.setTargetNodeComponent(param.getSession().getTargetNode());
+ dialog.setDomainComponent(getDomain(param));
+ dialog.setHasKernel(param.getSession().hasKernelProvider());
- List<String> channelNames = new ArrayList<>();
- channelNames.add(dialog.getChannelInfo().getName());
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
- try {
- enableChannel(param, channelNames, dialog.getChannelInfo(), dialog.isKernel(), monitor);
- } catch (ExecutionException e) {
- error = e;
- }
+ Job job = new Job(Messages.TraceControl_CreateChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ Exception error = null;
- // refresh in all cases
- refresh(param);
+ List<String> channelNames = new ArrayList<>();
+ channelNames.add(dialog.getChannelInfo().getName());
- if (error != null) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateChannelStateFailure, error);
- }
- return Status.OK_STATUS;
+ try {
+ enableChannel(param, channelNames, dialog.getChannelInfo(), dialog.isKernel(), monitor);
+ } catch (ExecutionException e) {
+ error = e;
}
- };
- job.setUser(true);
- job.schedule();
- } finally {
- fLock.unlock();
- }
+
+ // refresh in all cases
+ refresh(param);
+
+ if (error != null) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateChannelStateFailure, error);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
return null;
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.window.Window;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
/**
* The command execution parameter.
*/
- protected CommandParameter fParam = null;
+ @Nullable protected CommandParameter fParam = null;
// ------------------------------------------------------------------------
// Operations
if (window == null) {
return false;
}
+
+ // Make a copy for thread safety
+ CommandParameter tmpParam = null;
fLock.lock();
try {
- // Make a copy for thread safety
- final CommandParameter param = fParam.clone();
-
- 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(param));
-
- if (dialog.open() != Window.OK) {
+ tmpParam = fParam;
+ if (tmpParam == null) {
return null;
}
+ tmpParam = new CommandParameter(tmpParam);
+ } finally {
+ fLock.unlock();
+ }
+ final CommandParameter param = tmpParam;
- Job job = new Job(Messages.TraceControl_ChangeEventStateJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- Exception error = null;
-
- try {
- String filter = dialog.getFilterExpression();
-
- // Enable tracepoint events
- if (dialog.isTracepoints()) {
- if (dialog.isAllTracePoints()) {
- enableEvents(param, null, dialog.isKernel(), filter, monitor);
- } else {
- List<String> eventNames = dialog.getEventNames();
- if (!eventNames.isEmpty()) {
- enableEvents(param, eventNames, dialog.isKernel(), filter, monitor);
- }
- }
- }
+ TargetNodeComponent node = param.getSession().getTargetNode();
+ List<ITraceControlComponent> providers = node.getChildren(TraceProviderGroup.class);
- // Enable syscall events
- if (dialog.isAllSysCalls()) {
- enableSyscalls(param, monitor);
- }
+ final IEnableEventsDialog dialog = TraceControlDialogFactory.getInstance().getEnableEventsDialog();
+ dialog.setTraceProviderGroup((TraceProviderGroup)providers.get(0));
+ dialog.setTraceDomainComponent(getDomain(param));
- // Enable dynamic probe
- if (dialog.isDynamicProbe() && (dialog.getProbeEventName() != null) && (dialog.getProbeName() != null)) {
- enableProbe(param, dialog.getProbeEventName(), false, dialog.getProbeName(), monitor);
- }
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
- // Enable dynamic function probe
- if (dialog.isDynamicFunctionProbe() && (dialog.getFunctionEventName() != null) && (dialog.getFunction() != null)) {
- enableProbe(param, dialog.getFunctionEventName(), true, dialog.getFunction(), monitor);
- }
+ Job job = new Job(Messages.TraceControl_ChangeEventStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ Exception error = null;
- // Enable event using a wildcard
- if (dialog.isWildcard()) {
- List<String> eventNames = dialog.getEventNames();
- eventNames.add(dialog.getWildcard());
+ try {
+ String filter = dialog.getFilterExpression();
+ // Enable tracepoint events
+ if (dialog.isTracepoints()) {
+ if (dialog.isAllTracePoints()) {
+ enableEvents(param, null, dialog.isKernel(), filter, monitor);
+ } else {
+ List<String> eventNames = dialog.getEventNames();
if (!eventNames.isEmpty()) {
enableEvents(param, eventNames, dialog.isKernel(), filter, monitor);
}
}
+ }
- // Enable events using log level
- if (dialog.isLogLevel()) {
- enableLogLevel(param, dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), filter, monitor);
- }
+ // Enable syscall events
+ if (dialog.isAllSysCalls()) {
+ enableSyscalls(param, monitor);
+ }
+
+ // Enable dynamic probe
+ if (dialog.isDynamicProbe() && (dialog.getProbeEventName() != null) && (dialog.getProbeName() != null)) {
+ enableProbe(param, dialog.getProbeEventName(), false, dialog.getProbeName(), monitor);
+ }
- } catch (ExecutionException e) {
- error = e;
+ // Enable dynamic function probe
+ if (dialog.isDynamicFunctionProbe() && (dialog.getFunctionEventName() != null) && (dialog.getFunction() != null)) {
+ enableProbe(param, dialog.getFunctionEventName(), true, dialog.getFunction(), monitor);
}
- // refresh in all cases
- refresh(param);
+ // Enable event using a wildcard
+ if (dialog.isWildcard()) {
+ List<String> eventNames = dialog.getEventNames();
+ eventNames.add(dialog.getWildcard());
- if (error != null) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ChangeEventStateFailure, error);
+ if (!eventNames.isEmpty()) {
+ enableEvents(param, eventNames, dialog.isKernel(), filter, monitor);
+ }
+ }
+
+ // Enable events using log level
+ if (dialog.isLogLevel()) {
+ enableLogLevel(param, dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), filter, monitor);
}
- return Status.OK_STATUS;
+
+ } catch (ExecutionException e) {
+ error = e;
}
- };
- job.setUser(true);
- job.schedule();
- } finally {
- fLock.unlock();
- }
+
+ // refresh in all cases
+ refresh(param);
+
+ if (error != null) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ChangeEventStateFailure, error);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
return null;
}
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
/**
* The target node component the command is to be executed on.
*/
- protected TargetNodeComponent fTargetNode = null;
+ @Nullable protected TargetNodeComponent fTargetNode = null;
// ------------------------------------------------------------------------
// Operations
boolean isEnabled = node != null;
fLock.lock();
try {
+ fTargetNode = null;
if (isEnabled) {
fTargetNode = node;
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Iterator;
import org.eclipse.core.commands.ExecutionEvent;
}
fLock.lock();
try {
+
+ DomainCommandParameter tmpParam = fParam;
+ if (tmpParam == null) {
+ return null;
+ }
+
// Make a copy for thread safety
- final DomainCommandParameter param = fParam.clone();
+ final DomainCommandParameter param = new DomainCommandParameter(tmpParam);
Job addJob = new Job(Messages.TraceControl_AddCalibrateJob) {
@Override
try {
fParam = null;
if (isEnabled) {
- fParam = new DomainCommandParameter(session, domain);
+ fParam = new DomainCommandParameter(checkNotNull(session), checkNotNull(domain));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- for (Iterator<TraceSessionComponent> iterator = sessions.iterator(); iterator.hasNext();) {
+ for (TraceSessionComponent session : sessions) {
- // Start all selected sessions
- TraceSessionComponent session = iterator.next();
+ // Change state of selected sessions
changeState(session, monitor);
// Set Session state
boolean isEnabled = !sessions.isEmpty();
fLock.lock();
try {
- fSessions = null;
+ fSessions.clear();
if (isEnabled) {
fSessions = sessions;
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceChannelComponent;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
*
* @author Bernd Hufmann
*/
+@NonNullByDefault
public class ChannelCommandParameter extends CommandParameter {
// ------------------------------------------------------------------------
fChannel = channel;
}
+ /**
+ * Copy constructor
+ *
+ * @param param
+ * a channel command parameter to copy
+ */
+ public ChannelCommandParameter(ChannelCommandParameter param) {
+ super(param);
+ fChannel = param.fChannel;
+ }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
return fChannel;
}
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public ChannelCommandParameter clone() {
- ChannelCommandParameter clone = (ChannelCommandParameter) super.clone();
- clone.fChannel = fChannel;
- return clone;
- }
}
\ No newline at end of file
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
/**
*
* @author Bernd Hufmann
*/
-public class CommandParameter implements Cloneable {
+@NonNullByDefault
+public class CommandParameter {
// ------------------------------------------------------------------------
// Attributes
fSession = session;
}
+ /**
+ * Copy constructor
+ *
+ * @param param
+ * a command parameter to copy
+ */
+ public CommandParameter(CommandParameter param) {
+ fSession = param.fSession;
+ }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
public TraceSessionComponent getSession() {
return fSession;
}
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @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
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
/**
* <p>
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
fLock.lock();
+ TargetNodeComponent node = null;
try {
- fTargetNode.connect();
+ node = fTargetNode;
} finally {
fLock.unlock();
}
+ if (node != null) {
+ node.connect();
+ }
return null;
}
boolean isEnabled = false;
fLock.lock();
try {
- isEnabled = (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
+ isEnabled = super.isEnabled();
+ TargetNodeComponent node = fTargetNode;
+ isEnabled &= ((node != null) && (node.getTargetNodeState() == TargetNodeState.DISCONNECTED));
} finally {
fLock.unlock();
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
-
+ // Make a copy for thread safety
+ TraceSessionGroup tmpSessionGroup = null;
fLock.lock();
try {
- final TraceSessionGroup sessionGroup = fSessionGroup;
+ tmpSessionGroup = fSessionGroup;
+ } finally {
+ fLock.unlock();
+ }
+ final TraceSessionGroup sessionGroup = tmpSessionGroup;
- // Open dialog box for the node name and address
- final ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
- dialog.initialize(sessionGroup);
+ if (sessionGroup == null) {
+ return null;
+ }
- if (dialog.open() != Window.OK) {
- return null;
- }
+ // Open dialog box for the node name and address
+ final ICreateSessionDialog dialog = TraceControlDialogFactory.getInstance().getCreateSessionDialog();
+ dialog.initialize(sessionGroup);
- Job job = new Job(Messages.TraceControl_CreateSessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- sessionGroup.createSession(dialog.getParameters(), monitor);
- } catch (ExecutionException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateSessionFailure, e);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- } finally {
- fLock.unlock();
+ if (dialog.open() != Window.OK) {
+ return null;
}
+
+ Job job = new Job(Messages.TraceControl_CreateSessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ sessionGroup.createSession(dialog.getParameters(), monitor);
+ } catch (ExecutionException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateSessionFailure, e);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
return null;
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
/**
* <p>
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
fLock.lock();
+ TargetNodeComponent node = null;
try {
- ITraceControlComponent root = fTargetNode.getParent();
- fTargetNode.removeAllChildren();
- root.removeChild(fTargetNode);
+ node = fTargetNode;
} finally {
fLock.unlock();
}
+
+ if (node != null) {
+ ITraceControlComponent root = node.getParent();
+ node.removeAllChildren();
+ root.removeChild(fTargetNode);
+ node.disconnect();
+ }
return null;
}
boolean isEnabled = false;
fLock.lock();
try {
- isEnabled = (super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.DISCONNECTED));
+ isEnabled = super.isEnabled();
+ TargetNodeComponent node = fTargetNode;
+ isEnabled &= ((node != null) && (node.getTargetNodeState() == TargetNodeState.DISCONNECTED));
} finally {
fLock.unlock();
}
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
/**
* The list of session components the command is to be executed on.
*/
- private final List<TraceSessionComponent> fSessions = new ArrayList<>();
+ @NonNull private final List<TraceSessionComponent> fSessions = new ArrayList<>();
// ------------------------------------------------------------------------
// Operations
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
/**
* <p>
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+
fLock.lock();
+ TargetNodeComponent node = null;
try {
- fTargetNode.disconnect();
+ node = fTargetNode;
} finally {
fLock.unlock();
}
+
+ if (node != null) {
+ node.disconnect();
+ }
return null;
}
boolean isEnabled = false;
fLock.lock();
try {
- isEnabled = super.isEnabled() && (fTargetNode.getTargetNodeState() == TargetNodeState.CONNECTED);
+ isEnabled = super.isEnabled();
+ TargetNodeComponent node = fTargetNode;
+ isEnabled &= ((node != null) && (node.getTargetNodeState() == TargetNodeState.CONNECTED));
} finally {
fLock.unlock();
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceDomainComponent;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
*
* @author Bernd Hufmann
*/
+@NonNullByDefault
public class DomainCommandParameter extends CommandParameter {
// ------------------------------------------------------------------------
return fDomain;
}
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public DomainCommandParameter clone() {
- DomainCommandParameter clone = (DomainCommandParameter) super.clone();
- clone.fDomain = fDomain;
- return clone;
+ /**
+ * Copy constructor
+ *
+ * @param param
+ * a domain command parameter to copy
+ */
+ public DomainCommandParameter(DomainCommandParameter param) {
+ super(param);
+ fDomain = param.fDomain;
}
+
}
\ No newline at end of file
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Iterator;
import java.util.List;
try {
fParam = null;
if (isEnabled) {
- fParam = new DomainCommandParameter(session, domain);
+ fParam = new DomainCommandParameter(checkNotNull(session), checkNotNull(domain));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
try {
fParam = null;
if (isEnabled) {
- fParam = new CommandParameter(session);
+ fParam = new CommandParameter(NonNullUtils.checkNotNull(session));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Iterator;
import java.util.List;
try {
fParam = null;
if(isEnabled) {
- fParam = new ChannelCommandParameter(session, channel);
+ fParam = new ChannelCommandParameter(checkNotNull(session), checkNotNull(channel));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.Iterator;
import java.util.List;
try {
fParam = null;
if(isEnabled) {
- fParam = new DomainCommandParameter(session, domain);
+ fParam = new DomainCommandParameter(checkNotNull(session), checkNotNull(domain));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
try {
fParam = null;
if(isEnabled) {
- fParam = new CommandParameter(session);
+ fParam = new CommandParameter(NonNullUtils.checkNotNull(session));
}
} finally {
fLock.unlock();
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
**********************************************************************/
package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceEventComponent;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
*
* @author Bernd Hufmann
*/
+@NonNullByDefault
public class EventCommandParameter extends CommandParameter {
// ------------------------------------------------------------------------
fEvent = event;
}
+ /**
+ * Copy constructor
+ *
+ * @param param
+ * a event command parameter to copy
+ */
+ public EventCommandParameter(EventCommandParameter param) {
+ super(param);
+ fEvent = param.fEvent;
+ }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
public TraceEventComponent getEvent() {
return fEvent;
}
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public EventCommandParameter clone() {
- EventCommandParameter clone = (EventCommandParameter) super.clone();
- clone.fEvent = fEvent;
- return clone;
- }
}
\ No newline at end of file
/**********************************************************************
- * Copyright (c) 2014 Ericsson
+ * Copyright (c) 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
/**
* The trace session group the command is to be executed on.
*/
- private TraceSessionGroup fSessionGroup = null;
+ @Nullable private TraceSessionGroup fSessionGroup = null;
// ------------------------------------------------------------------------
// Operations
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+ TraceSessionGroup tmpGroup = null;
+
fLock.lock();
try {
- final TraceSessionGroup sessionGroup = fSessionGroup;
+ tmpGroup = fSessionGroup;
+ } finally {
+ fLock.unlock();
+ }
- // Open dialog box for the node name and address
- final ISelectCommandScriptDialog dialog = TraceControlDialogFactory.getInstance().getCommandScriptDialog();
+ final TraceSessionGroup sessionGroup = tmpGroup;
+ if (sessionGroup == null) {
+ return null;
+ }
- if (dialog.open() != Window.OK) {
- return null;
- }
+ // Open dialog box for the node name and address
+ final ISelectCommandScriptDialog dialog = TraceControlDialogFactory.getInstance().getCommandScriptDialog();
- Job job = new Job(Messages.TraceControl_ExecuteScriptJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- sessionGroup.executeCommands(monitor, dialog.getCommands());
- } catch (ExecutionException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateSessionFailure, e);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- } finally {
- fLock.unlock();
+ if (dialog.open() != Window.OK) {
+ return null;
}
+
+ Job job = new Job(Messages.TraceControl_ExecuteScriptJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ sessionGroup.executeCommands(monitor, dialog.getCommands());
+ } catch (ExecutionException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateSessionFailure, e);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
return null;
}
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionHostService;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
import org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.LttngRelaydConnectionInfo;
CommandParameter param;
fLock.lock();
try {
- param = fParam.clone();
+ param = fParam;
+ if (param == null) {
+ return null;
+ }
+ param = new CommandParameter(param);
} finally {
fLock.unlock();
}
+
// create default project
IProject project = TmfProjectRegistry.createProject(RemoteFetchLogWizardRemotePage.DEFAULT_REMOTE_PROJECT_NAME, null, null);
try {
fParam = null;
if (isEnabled) {
- fParam = new CommandParameter(session);
+ fParam = new CommandParameter(NonNullUtils.checkNotNull(session));
}
} finally {
fLock.unlock();
IRemoteConnection connection = getConnection(event.getParameters());
if (connection != null) {
fLock.lock();
+ if (fRoot == null) {
+ return null;
+ }
try {
// successful creation of host
TargetNodeComponent node = null;
/**********************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
/**
* The node component reference.
*/
- private TargetNodeComponent fNode;
+ @Nullable private TargetNodeComponent fNode;
// ------------------------------------------------------------------------
// Operations
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+ TargetNodeComponent node;
fLock.lock();
try {
- fNode.refresh();
+ node = fNode;
} finally {
fLock.unlock();
}
+ if (node != null) {
+ node.refresh();
+ }
return null;
}
/**********************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
/**
* The list of session components the command is to be executed on.
*/
- protected List<TraceSessionComponent> fSessions = new ArrayList<>();
+ @NonNull protected List<TraceSessionComponent> fSessions = new ArrayList<>();
// ------------------------------------------------------------------------
// Operations
boolean isEnabled = !sessions.isEmpty();
fLock.lock();
try {
- fSessions = null;
+ fSessions.clear();
if (isEnabled) {
- fSessions = sessions;
+ fSessions.addAll(sessions);
}
} finally {
fLock.unlock();