aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Medeiros Teixeira2012-07-02 16:15:08 (EDT)
committerRoland Grunberg2012-08-08 16:23:43 (EDT)
commit8dbc15ccfdb9c7a7e33adca18b6923839735c4ab (patch)
treeb79bd6ef1eb3e6843cd57649d26e12439bc8877b
parent63bb24096aab57f1f685e0e05c91a8acd76cb0e9 (diff)
downloadorg.eclipse.linuxtools-8dbc15ccfdb9c7a7e33adca18b6923839735c4ab.zip
org.eclipse.linuxtools-8dbc15ccfdb9c7a7e33adca18b6923839735c4ab.tar.gz
org.eclipse.linuxtools-8dbc15ccfdb9c7a7e33adca18b6923839735c4ab.tar.bz2
Oprofile: Added text filter for events in the oprofile configuration tab
Change-Id: I1f3821fd4d2ae3ca049a244f35d357897343355c Reviewed-on: https://git.eclipse.org/r/7080 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java109
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties1
2 files changed, 92 insertions, 18 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java
index 9c7f585..17d0410 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java
@@ -40,6 +40,7 @@ import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider;
import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider2;
import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException;
@@ -104,22 +105,26 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
private void createCounterTabs(Composite top){
//tabs for each of the counters
counters = OprofileCounter.getCounters(null);
- TabItem[] counterTabs = new TabItem[counters.length];
- counterSubTabs = new CounterSubTab[counters.length];
+ TabItem[] counterTabs = new TabItem[counters.length];
+ counterSubTabs = new CounterSubTab[counters.length];
+
+ TabFolder tabFolder = new TabFolder(top, SWT.NONE);
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+
+ for (int i = 0; i < counters.length; i++) {
+ Composite c = new Composite(tabFolder, SWT.NONE);
+ CounterSubTab currentTab = new CounterSubTab(c, counters[i]);
+ counterSubTabs[i] = currentTab;
- TabFolder tabFolder = new TabFolder(top, SWT.NONE);
- tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-
- for (int i = 0; i < counters.length; i++) {
- Composite c = new Composite(tabFolder, SWT.NONE);
- CounterSubTab currentTab = new CounterSubTab(c, counters[i]);
- counterSubTabs[i] = currentTab;
-
- counterTabs[i] = new TabItem(tabFolder, SWT.NONE);
- counterTabs[i].setControl(c);
- counterTabs[i].setText(OprofileLaunchMessages.getString("tab.event.counterTab.counterText") + String.valueOf(i)); //$NON-NLS-1$
- }
+ counterTabs[i] = new TabItem(tabFolder, SWT.NONE);
+ counterTabs[i].setControl(c);
+ counterTabs[i].setText(OprofileLaunchMessages.getString("tab.event.counterTab.counterText") + String.valueOf(i)); //$NON-NLS-1$
+ }
+
+ for (int i = 0; i < counters.length; i++) {
+ counterSubTabs[i].createEventsFilter();
+ }
getTabFolderComposite();
}
@@ -272,6 +277,13 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
for (int i = 0; i < counters.length; i++) {
counters[i] = new OprofileCounter(i);
counters[i].loadConfiguration(config);
+
+ for (CounterSubTab counterSubTab : counterSubTabs){
+ if(counterSubTab.enabledCheck.getSelection() && counterSubTab.eventList.getList().getSelectionIndex() == -1){
+ valid = false;
+ }
+ }
+
if (counters[i].getEnabled()) {
++numEnabledEvents;
@@ -485,6 +497,7 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
private Text eventDescText;
private UnitMaskViewer unitMaskViewer;
private ListViewer eventList;
+ private Text eventFilterText;
private OprofileCounter counter;
private ScrolledComposite scrolledTop;
@@ -608,6 +621,19 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
* @param parent composite these widgets will be created in
*/
private void createLeftCell(Composite parent) {
+ // Text box used to filter the event list
+ eventFilterText = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.ICON_CANCEL | SWT.SEARCH);
+ eventFilterText.setMessage(OprofileLaunchMessages.getString("tab.event.eventfilter.message"));
+ GridData eventFilterLayout = new GridData();
+ eventFilterLayout.horizontalAlignment = SWT.FILL;
+ eventFilterLayout.grabExcessHorizontalSpace = true;
+ eventFilterText.setLayoutData(eventFilterLayout);
+ eventFilterText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ eventList.refresh(false);
+ }
+ });
+
eventList = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
eventList.getList().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
@@ -690,6 +716,41 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
}
/**
+ * Creates a text filter for the events list widget
+ */
+ private void createEventsFilter(){
+ // Event Filter
+ ViewerFilter eventFilter = new ViewerFilter() {
+
+ @Override
+ public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
+ Object[] filteredElements = super.filter(viewer,parent,elements);
+ handleEventListSelectionChange();
+ return filteredElements;
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ String[] filterTerms = eventFilterText.getText().trim().toLowerCase().split(" ");
+ String eventName = ((OpEvent)element).getText().toLowerCase();
+ String eventDescription = ((OpEvent)element).getTextDescription().toLowerCase();
+
+ boolean contains = true;
+
+ for (String filterTerm : filterTerms) {
+ if(contains){
+ contains = eventName.contains(filterTerm) || eventDescription.contains(filterTerm);
+ }
+ }
+ return contains;
+ }
+ };
+ if(eventList != null){
+ eventList.addFilter(eventFilter);
+ }
+ }
+
+ /**
* Initializes the tab on first creation.
* @param config default configuration for the counter and the associated widgets
*/
@@ -758,6 +819,7 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
eventDescText.setEnabled(state);
unitMaskViewer.setEnabled(state);
eventList.getList().setEnabled(state);
+ eventFilterText.setEnabled(state);
}
/**
@@ -778,6 +840,12 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
if (counter.getCount() < min) {
setErrorMessage(getMinCountErrorMessage(min));
}
+ } else {
+ counter.setEvent(null);
+ eventDescText.setText("");
+ if(unitMaskViewer != null){
+ unitMaskViewer.displayEvent(null);
+ }
}
updateLaunchConfigurationDialog();
@@ -906,13 +974,18 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab {
* @param oe the event
*/
public void displayEvent(OpEvent oe) {
- OpUnitMask mask = oe.getUnitMask();
- int totalMasks = mask.getNumMasks();
-
if (maskListComp != null) {
maskListComp.dispose();
}
+ if(oe == null){
+ return;
+ }
+
+
+ OpUnitMask mask = oe.getUnitMask();
+ int totalMasks = mask.getNumMasks();
+
Composite newMaskComp = new Composite(top, SWT.NONE);
newMaskComp.setLayout(new GridLayout());
newMaskComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties
index 5b7ca9c..ea648f1 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/oprofilelaunch.properties
@@ -27,6 +27,7 @@ tab.event.counterSettings.count.too-small=Minimum count must be at least {0,numb
tab.event.counterSettings.count.invalid=Invalid count value, must be an integer
tab.event.defaultevent.button.text=Use default event
tab.event.counterTab.counterText=Ctr
+tab.event.eventfilter.message=type filter text
tab.event.timermode.no.options=OProfile is running in timer mode; no event options can be specified.
tab.global.name=Global