X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tmf%2Forg.eclipse.tracecompass.tmf.ui%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Ftmf%2Fui%2Fwidgets%2Ftimegraph%2Fwidgets%2FTimeGraphControl.java;h=e8cee6feb5c15d52336ed1dec26606b08ec76cbb;hb=07cd9368393c12f9ec42a295b580623cc83e2713;hp=4705e72d9181feeb6405d092ab70b8fb772f7a3c;hpb=72f39a2e0b222d63241a2da86fa31b3891ef3a0f;p=deliverable%2Ftracecompass.git diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java index 4705e72d91..e8cee6feb5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java @@ -41,7 +41,9 @@ import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; @@ -843,19 +845,25 @@ public class TimeGraphControl extends TimeGraphBaseControl return super.setFocus(); } + /** + * Returns the current selection for this time graph. If a time graph entry + * is selected, it will be the first element in the selection. If a time + * event is selected, it will be the second element in the selection. + * + * @return the current selection + */ @Override public ISelection getSelection() { - TimeGraphSelection sel = new TimeGraphSelection(); - ITimeGraphEntry trace = getSelectedTrace(); - if (null != trace && null != fTimeProvider) { + ITimeGraphEntry entry = getSelectedTrace(); + if (null != entry && null != fTimeProvider) { long selectedTime = fTimeProvider.getSelectionBegin(); - ITimeEvent event = Utils.findEvent(trace, selectedTime, 0); - sel.add(trace); - if (event != null) { - sel.add(event); + ITimeEvent event = Utils.findEvent(entry, selectedTime, 0); + if (event == null) { + return new StructuredSelection(entry); } + return new StructuredSelection(new Object[] { entry, event }); } - return sel; + return StructuredSelection.EMPTY; } /** @@ -864,12 +872,11 @@ public class TimeGraphControl extends TimeGraphBaseControl * @return The selection */ public ISelection getSelectionTrace() { - TimeGraphSelection sel = new TimeGraphSelection(); - ITimeGraphEntry trace = getSelectedTrace(); - if (null != trace) { - sel.add(trace); + ITimeGraphEntry entry = getSelectedTrace(); + if (null != entry) { + return new StructuredSelection(entry); } - return sel; + return StructuredSelection.EMPTY; } /** @@ -3108,12 +3115,10 @@ public class TimeGraphControl extends TimeGraphBaseControl @Override public void setSelection(ISelection selection) { - if (selection instanceof TimeGraphSelection) { - TimeGraphSelection sel = (TimeGraphSelection) selection; - Object ob = sel.getFirstElement(); + if (selection instanceof IStructuredSelection) { + Object ob = ((IStructuredSelection) selection).getFirstElement(); if (ob instanceof ITimeGraphEntry) { - ITimeGraphEntry trace = (ITimeGraphEntry) ob; - selectItem(trace, false); + selectItem((ITimeGraphEntry) ob, false); } }