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;
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.
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
*/
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);
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);
if (trace != null) {
traceSelected(new TmfTraceSelectedSignal(this, trace));
}
+
+ fillToolBar() ;
+
}
// ------------------------------------------------------------------------
* Create the initial tree from a trace.
*/
private synchronized void createTable() {
+
+ long ts = fCurrentTimestamp;
+
if (fTrace == null) {
return;
}
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 */
item.setExpanded(true);
}
packColumns();
+
+ if (filterStatus) {
+ filterChildren(traceRoot);
+ }
}
});
}
* 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;
}
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();
*/
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()) {
public void run() {
ITmfTimestamp currentTime = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
fCurrentTimestamp = currentTime.getValue();
- updateTable();
+
+ if (filterStatus) {
+ createTable();
+ } else {
+ updateTable();
+ }
}
};
thread.start();
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();
+ }
+ }
+ }
}