import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.IMarkerAxisListener;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeDataProviderCyclesConverter;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphMarkerAxis;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphScale;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphTooltipHandler;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
*
* @author Patrick Tasse, and others
*/
-public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
+public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener, SelectionListener {
/** Constant indicating that all levels of the time graph should be expanded */
public static final int ALL_LEVELS = AbstractTreeViewer.ALL_LEVELS;
private TimeGraphControl fTimeGraphCtrl;
private TimeGraphScale fTimeScaleCtrl;
+ private TimeGraphMarkerAxis fMarkerAxisCtrl;
private Slider fHorizontalScrollBar;
private Slider fVerticalScrollBar;
- private TimeGraphColorScheme fColorScheme;
+ private @NonNull TimeGraphColorScheme fColorScheme = new TimeGraphColorScheme();
private Object fInputElement;
private ITimeGraphContentProvider fTimeGraphContentProvider;
private ITimeGraphPresentationProvider fTimeGraphProvider;
- private ITimeDataProvider fTimeDataProvider = this;
+ private @NonNull ITimeDataProvider fTimeDataProvider = this;
private TimeGraphTooltipHandler fToolTipHandler;
private List<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<>();
*/
protected Control createDataViewer(Composite parent, int style) {
loadOptions();
- fColorScheme = new TimeGraphColorScheme();
fDataViewer = new Composite(parent, style) {
@Override
public void redraw() {
fTimeScaleCtrl.redraw();
fTimeGraphCtrl.redraw();
+ fMarkerAxisCtrl.redraw();
super.redraw();
}
};
fTimeScaleCtrl.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
+ if (e.count == 0) {
+ return;
+ }
fTimeGraphCtrl.zoom(e.count > 0);
}
});
fTimeGraphCtrl.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent e) {
+ if (e.count == 0) {
+ return;
+ }
adjustVerticalScrollBar();
}
});
}
});
+ fMarkerAxisCtrl = createTimeGraphMarkerAxis(fTimeAlignedComposite, fColorScheme, this);
+ fMarkerAxisCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
+ fMarkerAxisCtrl.addMarkerAxisListener(this);
+ fMarkerAxisCtrl.addMouseWheelListener(new MouseWheelListener() {
+ @Override
+ public void mouseScrolled(MouseEvent e) {
+ if (e.count == 0) {
+ return;
+ }
+ fTimeGraphCtrl.zoom(e.count > 0);
+ }
+ });
+
fVerticalScrollBar = new Slider(fDataViewer, SWT.VERTICAL | SWT.NO_FOCUS);
fVerticalScrollBar.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true, 1, 1));
fVerticalScrollBar.addSelectionListener(new SelectionAdapter() {
fHorizontalScrollBar.addListener(SWT.MouseWheel, new Listener() {
@Override
public void handleEvent(Event event) {
+ // don't handle the immediately following SWT.Selection event
+ event.doit = false;
+ if (event.count == 0) {
+ return;
+ }
if ((event.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL) {
getTimeGraphControl().zoom(event.count > 0);
} else {
getTimeGraphControl().horizontalScroll(event.count > 0);
}
- // don't handle the immediately following SWT.Selection event
- event.doit = false;
}
});
fHorizontalScrollBar.addListener(SWT.Selection, new Listener() {
return new TimeGraphControl(parent, colors);
}
+ /**
+ * Create a new time graph marker axis.
+ *
+ * @param parent
+ * The parent composite object
+ * @param colorScheme
+ * The color scheme to use
+ * @param timeProvider
+ * The time data provider
+ * @return The new TimeGraphMarkerAxis
+ * @since 2.0
+ */
+ protected TimeGraphMarkerAxis createTimeGraphMarkerAxis(Composite parent,
+ @NonNull TimeGraphColorScheme colorScheme, @NonNull ITimeDataProvider timeProvider) {
+ return new TimeGraphMarkerAxis(parent, colorScheme, timeProvider);
+ }
+
/**
* Resize the controls
*/
}
fTimeGraphCtrl.refreshData(traces);
fTimeScaleCtrl.redraw();
+ fMarkerAxisCtrl.redraw();
updateMarkerActions();
adjustVerticalScrollBar();
}
}
fTimeGraphCtrl.redraw();
fTimeScaleCtrl.redraw();
+ fMarkerAxisCtrl.redraw();
+ /* force update the controls to keep them aligned */
+ fTimeScaleCtrl.update();
+ fMarkerAxisCtrl.update();
+ fTimeGraphCtrl.update();
}
@Override
adjustHorizontalScrollBar();
fTimeGraphCtrl.redraw();
fTimeScaleCtrl.redraw();
+ fMarkerAxisCtrl.redraw();
+ /* force update the controls to keep them aligned */
+ fTimeScaleCtrl.update();
+ fMarkerAxisCtrl.update();
+ fTimeGraphCtrl.update();
}
@Override
fTimeGraphCtrl.redraw();
fTimeScaleCtrl.redraw();
+ fMarkerAxisCtrl.redraw();
updateMarkerActions();
if ((time0 != fTime0) || (time1 != fTime1)) {
*/
public void setMarkerCategories(List<String> categories) {
fMarkerCategories.clear();
- fMarkerCategories.add(IMarkerEvent.BOOKMARKS);
if (categories != null) {
fMarkerCategories.addAll(categories);
}
- Collections.sort(fMarkerCategories);
+ fMarkerCategories.add(IMarkerEvent.BOOKMARKS);
+ fMarkerAxisCtrl.setMarkerCategories(fMarkerCategories);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void setMarkerCategoryVisible(String category, boolean visible) {
+ boolean changed = false;
+ if (visible) {
+ changed = fHiddenMarkerCategories.remove(category);
+ } else {
+ changed = fHiddenMarkerCategories.add(category);
+ }
+ if (changed) {
+ updateMarkerList();
+ updateMarkerActions();
+ getControl().redraw();
+ }
}
/**
final Action action = new Action(category, IAction.AS_CHECK_BOX) {
@Override
public void runWithEvent(Event event) {
- if (isChecked()) {
- fHiddenMarkerCategories.remove(getText());
- } else {
- fHiddenMarkerCategories.add(getText());
- }
- updateMarkerList();
- updateMarkerActions();
- getControl().redraw();
+ setMarkerCategoryVisible(getText(), isChecked());
}
};
action.setChecked(!fHiddenMarkerCategories.contains(category));
markers.addAll(fBookmarks);
}
Collections.sort(markers, new MarkerComparator());
- getTimeGraphControl().setMarkers(markers);
+ fTimeGraphCtrl.setMarkers(markers);
+ fMarkerAxisCtrl.setMarkers(markers);
}
private void adjustHorizontalScrollBar() {