/**********************************************************************
- * Copyright (c) 2012 Ericsson
- *
+ * Copyright (c) 2012, 2013 Ericsson
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlContentProvider;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlLabelProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlContentProvider;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlLabelProvider;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.widgets.Text;
/**
- * <b><u>EnableKernelEventsComposite</u></b>
* <p>
* A composite for collecting information about kernel events to be enabled.
* </p>
+ *
+ * @author Bernd Hufmann
*/
public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents {
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
- private enum KernelGroupEnum { TRACEPOINTS, SYSCALLS, PROBE, FUNCTION };
+ private enum KernelGroupEnum { TRACEPOINTS, SYSCALLS, PROBE, FUNCTION }
// ------------------------------------------------------------------------
// Attributes
*/
private Button fProbeActivateButton;
/**
- * The text field for the event name for the dynamic probe.
+ * The text field for the event name for the dynamic probe.
*/
private Text fProbeEventNameText;
/**
*/
private Button fFunctionActivateButton;
/**
- * The text field for the event name for the dynamic probe.
+ * The text field for the event name for the dynamic probe.
*/
private Text fFunctionEventNameText;
/**
*/
private Text fFunctionText;
/**
- * The referenced trace provider group containing the kernel provider
+ * The referenced trace provider group containing the kernel provider
* component which contains a list of available tracepoints.
*/
- private TraceProviderGroup fProviderGroup;
+ private final TraceProviderGroup fProviderGroup;
/**
* The flag indicating that tracepoints are selected.
*/
*/
private boolean fIsDynamicProbe;
/**
- * The event name of the dynamic probe.
+ * The event name of the dynamic probe.
*/
private String fProbeEventName;
/**
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param parent
+ * The parent composite
+ * @param style
+ * The index of the style for this event composite
+ * @param providerGroup
+ * The trace provider group
+ */
public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) {
super(parent, style);
fProviderGroup = providerGroup;
// ------------------------------------------------------------------------
// Acessors
// ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints()
- */
+
@Override
public boolean isTracepoints() {
return fIsTracepoints;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints()
- */
+
@Override
public boolean isAllTracePoints() {
return fIsAllTracepoints;
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls()
- */
+
@Override
public boolean isSysCalls() {
return fIsSysCalls;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls()
- */
+
@Override
public boolean isAllSysCalls() {
return fIsSysCalls;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getEventNames()
- */
+
@Override
public List<String> getEventNames() {
return new ArrayList<String>(fSelectedEvents);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe()
- */
+
@Override
public boolean isDynamicProbe() {
return fIsDynamicProbe;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeName()
- */
+
@Override
public String getProbeName() {
return fProbeString;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName()
- */
+
@Override
public String getProbeEventName() {
return fProbeEventName;
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe()
- */
+
@Override
public boolean isDynamicFunctionProbe() {
return fIsDynamicFunctionProbe;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName()
- */
+
@Override
public String getFunctionEventName() {
return fFunctionEventName;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunction()
- */
+
@Override
public String getFunction() {
return fFunctionString;
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+
/**
* Creates the composite content
*/
public void createContent() {
-
- // Tracepoints Group
+
+ // Tracepoints Group
createTracepointsGroup();
- // Syscalls Group
+ // Syscalls Group
createSysCallsGroup();
-
- // Dynamic Probe Group
+
+ // Dynamic Probe Group
createDynamicProbeGroup();
- // Dynamic Function Probe Group
+ // Dynamic Function Probe Group
createDynamicFunctionPropeGroup();
-
+
// Set default enablements
setKernelEnablements(KernelGroupEnum.TRACEPOINTS);
}
-
+
/**
* Validates the kernel composite input data.
* @return true if configured data is valid and can be retrieved.
fIsDynamicProbe = fProbeActivateButton.getSelection();
fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection();
- List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class);
- fIsAllTracepoints = fTracepointsViewer.getChecked(comps.get(0));
-
- Object[] checkedElements = fTracepointsViewer.getCheckedElements();
+ // initialize tracepoint fields
+ fIsAllTracepoints = false;
fSelectedEvents = new ArrayList<String>();
- for (int i = 0; i < checkedElements.length; i++) {
- ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
- if (component instanceof BaseEventComponent) {
- fSelectedEvents.add(component.getName());
+
+ if (fIsTracepoints) {
+ List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class);
+ fIsAllTracepoints = fTracepointsViewer.getChecked(comps.get(0));
+
+ Object[] checkedElements = fTracepointsViewer.getCheckedElements();
+ for (int i = 0; i < checkedElements.length; i++) {
+ ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
+ if (component instanceof BaseEventComponent) {
+ fSelectedEvents.add(component.getName());
+ }
}
}
-
- // initialize probe string
- fProbeEventName = null;
- fProbeString = null;
- String temp = fProbeEventNameText.getText();
- if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return false;
- }
-
- if(!fProbeText.getText().matches("\\s*")) { //$NON-NLS-1$
+
+ if (fIsDynamicProbe) {
+ String temp = fProbeEventNameText.getText();
+ if (temp.isEmpty() ||
+ fProbeText.getText().matches("\\s*") || //$NON-NLS-1$
+ (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return false;
+ }
+
fProbeEventName = temp;
// fProbeString will be validated by lttng-tools
fProbeString = fProbeText.getText();
- }
+ }
// initialize function string
fFunctionEventName = null;
fFunctionString = null;
+ if (fIsDynamicFunctionProbe) {
+ String functionTemp = fFunctionEventNameText.getText();
+ if (functionTemp.isEmpty() ||
+ functionTemp.matches("\\s*") || //$NON-NLS-1$
+ (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_InvalidProbeNameError + " (" + functionTemp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return false;
+ }
- temp = fFunctionEventNameText.getText();
- if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
- MessageDialog.openError(getShell(),
- Messages.TraceControl_EnableEventsDialogTitle,
- Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return false;
- }
-
- if(!fFunctionText.getText().matches("\\s*")) { //$NON-NLS-1$
- fFunctionEventName = temp;
+ fFunctionEventName = functionTemp;
// fFunctionString will be validated by lttng-tools
fFunctionString = fFunctionText.getText();
}
return true;
}
-
+
/**
* Creates tracepoints group.
*/
// Local classes
// ------------------------------------------------------------------------
/**
- * Content provider for the tracepoints tree.
+ * Content provider for the tracepoints tree.
*/
- final static public class KernelContentProvider extends TraceControlContentProvider {
+ public static final class KernelContentProvider extends TraceControlContentProvider {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TraceProviderGroup) {
List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class);
- return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]);
+ return children.toArray(new ITraceControlComponent[children.size()]);
}
if (parentElement instanceof ITraceControlComponent) {
return ((ITraceControlComponent)parentElement).getChildren();
return new Object[0];
}
}
-
+
/**
- * Content label for the tracepoints tree.
+ * Content label for the tracepoints tree.
*/
- final static public class KernelLabelProvider extends TraceControlLabelProvider {
+ public static final class KernelLabelProvider extends TraceControlLabelProvider {
@Override
public Image getImage(Object element) {
return null;
return super.getText(element);
}
}
-
+
/**
- * Check state listener for the tracepoints tree.
+ * Check state listener for the tracepoints tree.
*/
- final public class KernelCheckListener implements ICheckStateListener {
+ public final class KernelCheckListener implements ICheckStateListener {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getChecked()) {
if (event.getElement() instanceof KernelProviderComponent) {
fTracepointsViewer.setSubtreeChecked(event.getElement(), true);
- }
- } else {
+ }
+ } else {
if (event.getElement() instanceof KernelProviderComponent) {
fTracepointsViewer.setSubtreeChecked(event.getElement(), false);
} else {