use of org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent in project tracecompass by tracecompass.
the class AddContextOnDomainHandler method isEnabled.
@Override
public boolean isEnabled() {
// Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
}
TraceDomainComponent domain = null;
TraceSessionComponent session = null;
// Check if one domain is selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
Object element = iterator.next();
if (element instanceof TraceDomainComponent) {
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())) {
domain = tmpDomain;
}
}
}
}
boolean isEnabled = domain != null;
if (TraceDomainType.JUL.equals(domain)) {
isEnabled = false;
}
fLock.lock();
try {
fParam = null;
if (isEnabled) {
fParam = new DomainCommandParameter(checkNotNull(session), checkNotNull(domain));
}
} finally {
fLock.unlock();
}
return isEnabled;
}
use of org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent in project tracecompass by tracecompass.
the class AddContextOnEventHandler method isEnabled.
@Override
public boolean isEnabled() {
// Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
}
TraceEventComponent event = null;
TraceSessionComponent session = null;
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
Object element = iterator.next();
if (element instanceof TraceEventComponent) {
// Add only if corresponding TraceSessionComponents is inactive and not destroyed
TraceEventComponent tmpEvent = (TraceEventComponent) element;
session = tmpEvent.getSession();
if (session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
event = tmpEvent;
}
}
}
}
boolean isEnabled = (event != null);
fLock.lock();
try {
fParam = null;
if (isEnabled) {
fParam = new EventCommandParameter(checkNotNull(session), checkNotNull(event));
}
} finally {
fLock.unlock();
}
return isEnabled;
}
use of org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent in project tracecompass by tracecompass.
the class AssignEventHandler method isEnabled.
@Override
public boolean isEnabled() {
@NonNull ArrayList<@NonNull BaseEventComponent> events = new ArrayList<>();
@NonNull TraceSessionComponent[] sessions = null;
TraceDomainType domain = null;
TraceEventType eventType = null;
// Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
}
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
Object element = iterator.next();
if (element instanceof BaseEventComponent) {
BaseEventComponent event = (BaseEventComponent) element;
ITraceControlComponent provider = event.getParent();
// check for the domain provider
TraceDomainType temp = null;
if (provider instanceof KernelProviderComponent) {
temp = TraceDomainType.KERNEL;
} else if (provider instanceof UstProviderComponent) {
// Loggers are under the UST domain
temp = TraceDomainType.UST;
} else {
return false;
}
if (domain == null) {
domain = temp;
} else {
// don't mix events from Kernel and UST provider
if (!domain.equals(temp)) {
return false;
}
}
// The events have to be the same type
if (eventType == null) {
eventType = event.getEventType();
} else if (!eventType.equals(event.getEventType())) {
events.clear();
break;
}
// Add BaseEventComponents
events.add(event);
if (sessions == null) {
TargetNodeComponent root = (TargetNodeComponent) event.getParent().getParent().getParent();
sessions = root.getSessions();
}
}
}
}
boolean isEnabled = ((!events.isEmpty()) && (sessions != null) && (sessions.length > 0));
// To avoid compiler warnings check for null even if isKernel is always not null when used below
if (domain == null) {
return false;
}
fLock.lock();
try {
fParam = null;
if (isEnabled) {
fParam = new Parameter(NonNullUtils.checkNotNull(sessions), events, domain);
}
} finally {
fLock.unlock();
}
return isEnabled;
}
use of org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent in project tracecompass by tracecompass.
the class AssignEventHandler method execute.
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Make a copy for thread safety
Parameter tmpParam = null;
fLock.lock();
try {
tmpParam = fParam;
if (tmpParam == null) {
return null;
}
tmpParam = new Parameter(tmpParam);
} finally {
fLock.unlock();
}
final Parameter param = tmpParam;
// Open dialog box to retrieve the session and channel where the events should be enabled in.
final IGetEventInfoDialog dialog = TraceControlDialogFactory.getInstance().getGetEventInfoDialog();
dialog.setDomain(param.getDomain());
dialog.setSessions(param.getSessions());
if (dialog.open() != Window.OK) {
return null;
}
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();
// Find the type of the events (all the events in the list are the same type)
TraceEventType eventType = !events.isEmpty() ? events.get(0).getEventType() : null;
// Create list of event names
for (Iterator<BaseEventComponent> iterator = events.iterator(); iterator.hasNext(); ) {
BaseEventComponent baseEvent = iterator.next();
eventNames.add(baseEvent.getName());
}
TraceChannelComponent channel = dialog.getChannel();
if (TraceEventType.TRACEPOINT.equals(eventType)) {
if (channel == null) {
// enable events on default channel (which will be created by lttng-tools)
session.enableEvents(eventNames, param.getDomain(), dialog.getFilterExpression(), null, monitor);
} else {
channel.enableEvents(eventNames, dialog.getFilterExpression(), null, monitor);
}
} else if (TraceEventType.SYSCALL.equals(eventType)) {
if (channel == null) {
session.enableSyscalls(eventNames, monitor);
} else {
channel.enableSyscalls(eventNames, monitor);
}
}
} catch (ExecutionException e) {
error = e;
}
// refresh in all cases
if (session != null) {
refresh(new CommandParameter(session));
}
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;
}
use of org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent in project tracecompass by tracecompass.
the class AssignLoggerHandler method isEnabled.
@Override
public boolean isEnabled() {
@NonNull ArrayList<@NonNull BaseLoggerComponent> loggers = new ArrayList<>();
@NonNull TraceSessionComponent[] sessions = null;
TraceDomainType domain = null;
// Get workbench page for the Control View
IWorkbenchPage page = getWorkbenchPage();
if (page == null) {
return false;
}
// Check if one or more session are selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
Object element = iterator.next();
if (element instanceof BaseLoggerComponent) {
BaseLoggerComponent logger = (BaseLoggerComponent) element;
// The loggers have to be the same domain (multiple selection)
if (domain == null) {
domain = logger.getDomain();
} else if (!domain.equals(logger.getDomain())) {
loggers.clear();
break;
}
// Add BaseLoggerComponents
loggers.add(logger);
if (sessions == null) {
TargetNodeComponent root = (TargetNodeComponent) logger.getParent().getParent().getParent();
sessions = root.getSessions();
}
}
}
}
boolean isEnabled = ((!loggers.isEmpty()) && (sessions != null) && (sessions.length > 0));
if (domain == null) {
return false;
}
fLock.lock();
try {
fParam = null;
if (isEnabled) {
fParam = new Parameter(NonNullUtils.checkNotNull(sessions), loggers, domain);
}
} finally {
fLock.unlock();
}
return isEnabled;
}
Aggregations