X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.lttng2.ui%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Finternal%2Flttng2%2Fui%2Fviews%2Fcontrol%2Fdialogs%2FEnableUstEventsComposite.java;h=c3090d91246b9bb19b146e6c3e23aafb8c97b360;hb=152ba1a7fabe7175ba1a6f267eda2b3891cbcb63;hp=8b3ff8628f203c1b6490a2426cb1c8d04a6f463a;hpb=7a6e4bfd8357a1e45a9bce92f1b43408389d307c;p=deliverable%2Ftracecompass.git
diff --git a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java
index 8b3ff8628f..c3090d9124 100644
--- a/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java
+++ b/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
@@ -8,6 +8,8 @@
*
* Contributors:
* Bernd Hufmann - Initial API and implementation
+ * Bernd Hufmann - Updated for support of LTTng Tools 2.1
+ * Marc-Andre Laperle - Add filtering textbox
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
@@ -20,6 +22,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
@@ -42,6 +45,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
/**
*
@@ -98,6 +103,11 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
* A button for selecting the specified log level only.
*/
private Button fLogLevelOnlyButton;
+ /**
+ * The filter text
+ */
+ private Text fFilterText;
+
/**
* The referenced trace provider group containing the UST providers
* component which contains a list of available tracepoints.
@@ -139,6 +149,10 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
* The actual selected log level.
*/
private TraceLogLevel fLogLevel;
+ /**
+ * The filter expression
+ */
+ private String fFilterExpression;
// ------------------------------------------------------------------------
// Constructors
@@ -158,87 +172,56 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
// Accessors
// ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isTracepoints()
- */
@Override
public boolean isTracepoints() {
return fIsTracepoints;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isAllTracePoints()
- */
@Override
public boolean isAllTracePoints() {
return fIsAllTracepoints;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getEventNames()
- */
@Override
public List getEventNames() {
- return new ArrayList(fSelectedEvents);
+ return new ArrayList<>(fSelectedEvents);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isWildcard()
- */
@Override
public boolean isWildcard() {
return fIsWildcard;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getWildcard()
- */
@Override
public String getWildcard() {
return fWildcard;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isLogLevel()
- */
@Override
public boolean isLogLevel() {
return fIsLogLevel;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelType()
- */
@Override
public LogLevelType getLogLevelType() {
return fLogLevelType;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevel()
- */
@Override
public TraceLogLevel getLogLevel() {
return fLogLevel;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelEventName()
- */
@Override
public String getLogLevelEventName() {
return fLogLevelEventName;
}
+ @Override
+ public String getFilterExpression() {
+ return fFilterExpression;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@@ -257,14 +240,18 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
// Log Level Group
createLogLevelGroup();
+ // Filter Group
+ createFilterGroup();
+
// Set default enablements
setEnablements(GroupEnum.TRACEPOINTS);
}
/**
- * Validates the UST composite input data.
- * @return true if configured data is valid and can be retrieved.
- */
+ * Validates the UST composite input data.
+ *
+ * @return true if configured data is valid and can be retrieved.
+ */
public boolean isValid() {
fIsTracepoints = fTracepointsActivateButton.getSelection();
@@ -273,10 +260,10 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
// initialize tracepoint fields
fIsAllTracepoints = false;
- fSelectedEvents = new ArrayList();
+ fSelectedEvents = new ArrayList<>();
if (fIsTracepoints) {
fIsAllTracepoints = fTracepointsViewer.getChecked(fProviderGroup);
- Set set = new HashSet();
+ Set set = new HashSet<>();
Object[] checkedElements = fTracepointsViewer.getCheckedElements();
for (int i = 0; i < checkedElements.length; i++) {
ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
@@ -299,7 +286,9 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
}
String temp = fLogLevelEventNameText.getText();
- if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (temp.isEmpty() ||
+ temp.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_InvalidLogLevelEventNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -307,9 +296,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
return false;
}
- if(!temp.matches("\\s*")) { //$NON-NLS-1$
- fLogLevelEventName = temp;
- }
+ fLogLevelEventName = temp;
TraceLogLevel[] levels = TraceLogLevel.values();
int id = fLogLevelCombo.getSelectionIndex();
@@ -324,11 +311,13 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
fLogLevel = levels[id];
}
- // initialize wildcard with the event name string
+ // initialize wildcard with null
fWildcard = null;
if (fIsWildcard) {
String tempWildcard = fWildcardText.getText();
- if (!tempWildcard.matches("^[\\s]{0,}$") && !tempWildcard.matches("^[a-zA-Z0-9\\-\\_\\*]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (tempWildcard.isEmpty() ||
+ tempWildcard.matches("\\s*") || //$NON-NLS-1$
+ (!tempWildcard.matches("^[\\s]{0,}$") && !tempWildcard.matches("^[a-zA-Z0-9\\-\\_\\*]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
MessageDialog.openError(getShell(),
Messages.TraceControl_EnableEventsDialogTitle,
Messages.TraceControl_InvalidWildcardError + " (" + tempWildcard + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -336,8 +325,16 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
return false;
}
- if(!tempWildcard.matches("\\s*")) { //$NON-NLS-1$
- fWildcard = tempWildcard;
+ fWildcard = tempWildcard;
+ }
+
+ // initialize filter with null
+ fFilterExpression = null;
+ if (fProviderGroup.isEventFilteringSupported()) {
+ String tempFilter = fFilterText.getText();
+
+ if(!tempFilter.isEmpty() && !tempFilter.matches("\\s*")) { //$NON-NLS-1$
+ fFilterExpression = tempFilter;
}
}
@@ -382,16 +379,21 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
tpGroup.setLayout(layout);
data = new GridData(GridData.FILL_BOTH);
tpGroup.setLayoutData(data);
+ new FilteredTree(tpGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true) {
+ @Override
+ protected TreeViewer doCreateTreeViewer(Composite aparent, int style) {
+ fTracepointsViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip);
+ fTracepointsViewer.setContentProvider(new UstContentProvider());
- fTracepointsViewer = new CheckboxTreeViewer(tpGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip);
- fTracepointsViewer.setContentProvider(new UstContentProvider());
-
- fTracepointsViewer.setLabelProvider(new UstLabelProvider());
- fTracepointsViewer.addCheckStateListener(new UstCheckStateListener());
+ fTracepointsViewer.setLabelProvider(new UstLabelProvider());
+ fTracepointsViewer.addCheckStateListener(new UstCheckStateListener());
- fTracepointsViewer.setInput(fProviderGroup.getParent());
- fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ fTracepointsViewer.setInput(fProviderGroup.getParent());
+ fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ return fTracepointsViewer;
+ }
+ };
}
/**
@@ -511,6 +513,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
fLogLevelButton.setToolTipText(Messages.TraceControl_EnableEventsLogLevelTypeTooltip);
data = new GridData(GridData.FILL_BOTH);
fLogLevelButton.setLayoutData(data);
+ fLogLevelButton.setSelection(true);
fLogLevelOnlyButton = new Button(logLevelGroup, SWT.RADIO);
fLogLevelOnlyButton.setText(Messages.TraceControl_EnableEventsLogLevelOnlyTypeName);
@@ -519,6 +522,22 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
fLogLevelButton.setLayoutData(data);
}
+ void createFilterGroup() {
+ if (fProviderGroup.isEventFilteringSupported()) {
+ Group filterMainGroup = new Group(this, SWT.SHADOW_NONE);
+ filterMainGroup.setText(Messages.TraceControl_EnableEventsFilterGroupName);
+ GridLayout layout = new GridLayout(3, false);
+ filterMainGroup.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ filterMainGroup.setLayoutData(data);
+
+ fFilterText = new Text(filterMainGroup, SWT.LEFT);
+ fFilterText.setToolTipText(Messages.TraceControl_EnableEventsFilterTooltip);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fFilterText.setLayoutData(data);
+ }
+ }
+
/**
* Enable/selects widgets depending on the group specified.
* @param group - group to enable.
@@ -547,7 +566,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
/**
* Content provider for the tracepoints tree.
*/
- final static public class UstContentProvider extends TraceControlContentProvider {
+ public static final class UstContentProvider extends TraceControlContentProvider {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TargetNodeComponent) {
@@ -568,7 +587,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
/**
* Content label for the tracepoints tree.
*/
- final static public class UstLabelProvider extends TraceControlLabelProvider {
+ public static final class UstLabelProvider extends TraceControlLabelProvider {
@Override
public Image getImage(Object element) {
return null;
@@ -589,7 +608,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
/**
* Check state listener for the tracepoints tree.
*/
- final public class UstCheckStateListener implements ICheckStateListener {
+ public final class UstCheckStateListener implements ICheckStateListener {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getChecked()) {