From: Florian Wininger Date: Wed, 22 May 2013 23:14:44 +0000 (-0400) Subject: tmf: Add filtering and highlighting to the State System Explorer X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=278aa2475e94f71fd553f391d17ee7b33a2dce79;p=deliverable%2Ftracecompass.git tmf: Add filtering and highlighting to the State System Explorer Highlight on state changes. Add a filter button to filter out non-changes completely. Add a column with the value's type. Change-Id: I0d206ef15e84707d9556c609ca86eda606689ff1 Signed-off-by: Florian Wininger Reviewed-on: https://git.eclipse.org/r/13366 IP-Clean: Alexandre Montplaisir Tested-by: Alexandre Montplaisir Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir --- diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/Messages.java index 7746870295..add80d906e 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/Messages.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/Messages.java @@ -45,6 +45,10 @@ public class Messages extends NLS { /** Label for the "value" column */ public static String ValueColumnLabel; + /** Label for the "type" column + * @since 2.1*/ + public static String TypeColumnLabel; + /** Label for the "start time" column */ public static String StartTimeColumLabel; @@ -59,4 +63,20 @@ public class Messages extends NLS { * outside of the SS's range. */ public static String OutOfRangeMsg; + + /** Label for the Filter button + * @since 2.1*/ + public static String FilterButton; + + /** Label for the type Interger + * @since 2.1*/ + public static String TypeInteger; + + /** Label for the type Long + * @since 2.1*/ + public static String TypeLong; + + /** Label for the type String + * @since 2.1*/ + public static String TypeString; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java index 126e0fc623..f40f33f129 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java @@ -14,10 +14,15 @@ package org.eclipse.linuxtools.tmf.ui.views.statesystem; +import java.io.File; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.linuxtools.internal.tmf.ui.Activator; import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException; import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException; import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException; @@ -36,12 +41,15 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager; import org.eclipse.linuxtools.tmf.ui.views.TmfView; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IActionBars; /** * Displays the State System at a current time. @@ -56,19 +64,25 @@ public class TmfStateSystemExplorer extends TmfView { public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.ssview"; //$NON-NLS-1$ private static final String emptyString = ""; //$NON-NLS-1$ + private static final String FS = File.separator; + private static final Image FILTER_IMAGE = + Activator.getDefault().getImageFromPath(FS + "icons" + FS + "elcl16" + FS + "filter_items.gif"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ /* Order of columns */ private static final int ATTRIBUTE_NAME_COL = 0; private static final int QUARK_COL = 1; private static final int VALUE_COL = 2; - private static final int START_TIME_COL = 3; - private static final int END_TIME_COL = 4; - private static final int ATTRIBUTE_FULLPATH_COL = 5; + private static final int TYPE_COL = 3; + private static final int START_TIME_COL = 4; + private static final int END_TIME_COL = 5; + private static final int ATTRIBUTE_FULLPATH_COL = 6; private ITmfTrace fTrace; private Tree fTree; private volatile long fCurrentTimestamp = -1L; + private boolean filterStatus = false ; + /** * Default constructor */ @@ -86,6 +100,7 @@ public class TmfStateSystemExplorer extends TmfView { TreeColumn nameCol = new TreeColumn(fTree, SWT.NONE, ATTRIBUTE_NAME_COL); TreeColumn quarkCol = new TreeColumn(fTree, SWT.NONE, QUARK_COL); TreeColumn valueCol = new TreeColumn(fTree, SWT.NONE, VALUE_COL); + TreeColumn typeCol = new TreeColumn(fTree, SWT.NONE, TYPE_COL); TreeColumn startCol = new TreeColumn(fTree, SWT.NONE, START_TIME_COL); TreeColumn endCol = new TreeColumn(fTree, SWT.NONE, END_TIME_COL); TreeColumn pathCol = new TreeColumn(fTree, SWT.NONE, ATTRIBUTE_FULLPATH_COL); @@ -93,6 +108,7 @@ public class TmfStateSystemExplorer extends TmfView { nameCol.setText(Messages.TreeNodeColumnLabel); quarkCol.setText(Messages.QuarkColumnLabel); valueCol.setText(Messages.ValueColumnLabel); + typeCol.setText(Messages.TypeColumnLabel); startCol.setText(Messages.StartTimeColumLabel); endCol.setText(Messages.EndTimeColumLabel); pathCol.setText(Messages.AttributePathColumnLabel); @@ -116,6 +132,9 @@ public class TmfStateSystemExplorer extends TmfView { if (trace != null) { traceSelected(new TmfTraceSelectedSignal(this, trace)); } + + fillToolBar() ; + } // ------------------------------------------------------------------------ @@ -126,6 +145,9 @@ public class TmfStateSystemExplorer extends TmfView { * Create the initial tree from a trace. */ private synchronized void createTable() { + + long ts = fCurrentTimestamp; + if (fTrace == null) { return; } @@ -150,11 +172,13 @@ public class TmfStateSystemExplorer extends TmfView { String ssName = entry.getKey(); ITmfStateSystem ss = entry.getValue(); ss.waitUntilBuilt(); - long startTime = ss.getStartTime(); + if (ts == -1 || ts < ss.getStartTime() || ts > ss.getCurrentEndTime()) { + ts = ss.getStartTime(); + } try { - fullStates.put(ssName, ss.queryFullState(startTime)); + fullStates.put(ssName, ss.queryFullState(ts)); } catch (TimeRangeException e) { - /* Should not happen since we're querying at start time */ + /* We already checked the limits ourselves */ throw new RuntimeException(); } catch (StateSystemDisposedException e) { /* Probably shutting down, cancel and return */ @@ -192,6 +216,10 @@ public class TmfStateSystemExplorer extends TmfView { item.setExpanded(true); } packColumns(); + + if (filterStatus) { + filterChildren(traceRoot); + } } }); } @@ -312,24 +340,29 @@ public class TmfStateSystemExplorer extends TmfView { * Populate an 'item' (a row in the tree) with the information found in the * interval. This method should only be called by the UI thread. */ - private static void populateColumns(TreeItem item, ITmfStateInterval interval) { + private void populateColumns(TreeItem item, ITmfStateInterval interval) { try { ITmfStateValue state = interval.getStateValue(); + String value ; // add the value in the 2nd column switch (state.getType()) { case INTEGER: - item.setText(VALUE_COL, String.valueOf(state.unboxInt())); + value = String.valueOf(state.unboxInt()); + item.setText(TYPE_COL, Messages.TypeInteger); break; case LONG: - item.setText(VALUE_COL, String.valueOf(state.unboxLong())); + value = String.valueOf(state.unboxLong()); + item.setText(TYPE_COL, Messages.TypeLong); break; case STRING: - item.setText(VALUE_COL, state.unboxStr()); + value = state.unboxStr(); + item.setText(TYPE_COL, Messages.TypeString); break; case NULL: default: - item.setText(VALUE_COL, emptyString); + value = emptyString ; + item.setText(TYPE_COL, emptyString); break; } @@ -339,6 +372,16 @@ public class TmfStateSystemExplorer extends TmfView { TmfTimestamp endTime = new TmfTimestamp(interval.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE); item.setText(END_TIME_COL, endTime.toString()); + item.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)) ; + + if (!filterStatus) { + if (!value.equals(item.getText(VALUE_COL)) || fCurrentTimestamp == startTime.getValue()) { + item.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_YELLOW)); + } + } + + item.setText(VALUE_COL, value) ; + } catch (StateValueTypeException e) { /* Should not happen, we're case-switching on the specific types */ throw new RuntimeException(); @@ -356,6 +399,7 @@ public class TmfStateSystemExplorer extends TmfView { */ private void markOutOfRange(TreeItem root) { root.setText(VALUE_COL, Messages.OutOfRangeMsg); + root.setText(TYPE_COL, emptyString); root.setText(START_TIME_COL, emptyString); root.setText(END_TIME_COL, emptyString); for (TreeItem item : root.getItems()) { @@ -439,7 +483,12 @@ public class TmfStateSystemExplorer extends TmfView { public void run() { ITmfTimestamp currentTime = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE); fCurrentTimestamp = currentTime.getValue(); - updateTable(); + + if (filterStatus) { + createTable(); + } else { + updateTable(); + } } }; thread.start(); @@ -455,4 +504,50 @@ public class TmfStateSystemExplorer extends TmfView { thread.start(); } + /** + * Function for the delete TreeItem + */ + private boolean filterChildren(TreeItem root) { + boolean valid = false ; + TmfTimestamp startTime = new TmfTimestamp(fCurrentTimestamp, ITmfTimestamp.NANOSECOND_SCALE); + valid = root.getText(START_TIME_COL).equals(startTime.toString()); + root.setExpanded(true); + + for (TreeItem item : root.getItems()) { + /* Update children recursively */ + valid = filterChildren(item) || valid; + } + + if (!valid) { + root.dispose(); + } + return valid; + } + + // ------------------------------------------------------------------------ + // Part For Button Action + // ------------------------------------------------------------------------ + + + + private void fillToolBar() { + Action fFilterAction = new FilterAction(); + fFilterAction.setImageDescriptor(ImageDescriptor.createFromImage(FILTER_IMAGE)); + fFilterAction.setToolTipText(Messages.FilterButton) ; + fFilterAction.setChecked(false); + + IActionBars bars = getViewSite().getActionBars(); + IToolBarManager manager = bars.getToolBarManager(); + manager.add(fFilterAction); + } + + private class FilterAction extends Action { + @Override + public void run() { + filterStatus = !filterStatus; + if (!filterStatus) { + createTable(); + } + } + } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/messages.properties index 3f50faa950..25c1f55a64 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/messages.properties +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/messages.properties @@ -14,9 +14,14 @@ TreeNodeColumnLabel=State System / Attribute QuarkColumnLabel=Quark ValueColumnLabel=Value at timestamp +TypeColumnLabel=Type StartTimeColumLabel=Start time EndTimeColumLabel=End time AttributePathColumnLabel=Full attribute path # Other messages -OutOfRangeMsg=Out of range \ No newline at end of file +OutOfRangeMsg=Out of range +FilterButton=Display Only Change +TypeInteger=Int +TypeLong=Long +TypeString=String \ No newline at end of file