Search in sources :

Example 11 with TmfSelectionRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal in project tracecompass by tracecompass.

the class HistogramView method updateSelectionTime.

// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/**
 * Broadcast TmfSignal about new current selection time range.
 * @param beginTime the begin time of current selection.
 * @param endTime the end time of current selection.
 */
void updateSelectionTime(long beginTime, long endTime) {
    updateDisplayedSelectionTime(beginTime, endTime);
    ITmfTimestamp beginTs = TmfTimestamp.fromNanos(beginTime);
    ITmfTimestamp endTs = TmfTimestamp.fromNanos(endTime);
    TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(this, beginTs, endTs, fTrace);
    fTimeSyncThrottle.queue(signal);
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)

Example 12 with TmfSelectionRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal in project tracecompass by tracecompass.

the class AbstractTimeGraphView method createPartControl.

// ------------------------------------------------------------------------
// ViewPart
// ------------------------------------------------------------------------
@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    TimeGraphViewer timeGraphViewer = new TimeGraphViewer(parent, SWT.NONE);
    fTimeGraphViewer = timeGraphViewer;
    if (fLabelProvider != null) {
        timeGraphViewer.setTimeGraphLabelProvider(fLabelProvider);
    }
    if (fLegendProvider != null) {
        timeGraphViewer.setLegendProvider(fLegendProvider);
    }
    if (fColumns != null) {
        timeGraphViewer.setColumns(fColumns);
        if (fColumnComparators != null) {
            createColumnSelectionListener(timeGraphViewer.getTree());
        }
    }
    timeGraphViewer.setTimeGraphContentProvider(fTimeGraphContentProvider);
    timeGraphViewer.setFilterContentProvider(fFilterContentProvider != null ? fFilterContentProvider : fTimeGraphContentProvider);
    timeGraphViewer.setFilterLabelProvider(fFilterLabelProvider);
    timeGraphViewer.setFilterColumns(fFilterColumns);
    timeGraphViewer.addSelectionListener(fMetadataSelectionListener);
    ITimeGraphPresentationProvider presentationProvider = getPresentationProvider();
    timeGraphViewer.setTimeGraphProvider(presentationProvider);
    presentationProvider.addColorListener(stateItems -> TimeGraphStyleUtil.loadValues(getPresentationProvider()));
    presentationProvider.refresh();
    timeGraphViewer.setAutoExpandLevel(fAutoExpandLevel);
    timeGraphViewer.setWeights(fWeight);
    TimeGraphControl timeGraphControl = timeGraphViewer.getTimeGraphControl();
    Action timeEventFilterAction = new Action() {

        @Override
        public void run() {
            int xCoord = timeGraphControl.toControl(timeGraphControl.getDisplay().getCursorLocation()).x;
            if ((timeGraphViewer.getNameSpace() < xCoord) && (xCoord < timeGraphControl.getSize().x)) {
                if (fTimeEventFilterDialog != null) {
                    fTimeEventFilterDialog.close();
                    fTimeEventFilterDialog = null;
                }
                fTimeEventFilterDialog = new TimeEventFilterDialog(timeGraphControl.getShell(), AbstractTimeGraphView.this, getTimeGraphViewer().getTimeGraphControl());
                fTimeEventFilterDialog.open();
            }
        }
    };
    fTimeEventFilterAction = timeEventFilterAction;
    timeGraphViewer.addRangeListener(event -> {
        final long startTime = event.getStartTime();
        final long endTime = event.getEndTime();
        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime));
        broadcast(new TmfWindowRangeUpdatedSignal(AbstractTimeGraphView.this, range, fTrace));
        startZoomThread(startTime, endTime);
    });
    timeGraphViewer.addTimeListener(event -> {
        ITmfTimestamp startTime = TmfTimestamp.fromNanos(event.getBeginTime());
        ITmfTimestamp endTime = TmfTimestamp.fromNanos(event.getEndTime());
        broadcast(new TmfSelectionRangeUpdatedSignal(AbstractTimeGraphView.this, startTime, endTime, fTrace));
    });
    timeGraphViewer.addBookmarkListener(new ITimeGraphBookmarkListener() {

        @Override
        public void bookmarkAdded(final TimeGraphBookmarkEvent event) {
            try {
                ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {

                    @Override
                    public void run(IProgressMonitor monitor) throws CoreException {
                        IMarkerEvent bookmark = event.getBookmark();
                        IFile editorFile = fEditorFile;
                        if (editorFile == null) {
                            return;
                        }
                        IMarker marker = editorFile.createMarker(IMarker.BOOKMARK);
                        marker.setAttribute(IMarker.MESSAGE, bookmark.getLabel());
                        marker.setAttribute(ITmfMarker.MARKER_TIME, Long.toString(bookmark.getTime()));
                        if (bookmark.getDuration() > 0) {
                            marker.setAttribute(ITmfMarker.MARKER_DURATION, Long.toString(bookmark.getDuration()));
                            marker.setAttribute(IMarker.LOCATION, NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTimeRange, TmfTimestamp.fromNanos(bookmark.getTime()), TmfTimestamp.fromNanos(bookmark.getTime() + bookmark.getDuration())));
                        } else {
                            marker.setAttribute(IMarker.LOCATION, NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTime, TmfTimestamp.fromNanos(bookmark.getTime())));
                        }
                        marker.setAttribute(ITmfMarker.MARKER_COLOR, bookmark.getColor().toString());
                    }
                }, null);
            } catch (CoreException e) {
                Activator.getDefault().logError(e.getMessage());
            }
        }

        @Override
        public void bookmarkRemoved(TimeGraphBookmarkEvent event) {
            try {
                IMarkerEvent bookmark = event.getBookmark();
                IFile editorFile = fEditorFile;
                if (editorFile == null) {
                    return;
                }
                IMarker[] markers = editorFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO);
                for (IMarker marker : markers) {
                    if (bookmark.getLabel().equals(marker.getAttribute(IMarker.MESSAGE)) && Long.toString(bookmark.getTime()).equals(marker.getAttribute(ITmfMarker.MARKER_TIME, (String) null)) && Long.toString(bookmark.getDuration()).equals(marker.getAttribute(ITmfMarker.MARKER_DURATION, Long.toString(0))) && bookmark.getColor().toString().equals(marker.getAttribute(ITmfMarker.MARKER_COLOR))) {
                        marker.delete();
                        break;
                    }
                }
            } catch (CoreException e) {
                Activator.getDefault().logError(e.getMessage());
            }
        }
    });
    fTimeGraphViewer.addMarkerListener(() -> restartZoomThread());
    timeGraphControl.addPaintListener(new PaintListener() {

        /**
         * This paint control allows the virtual time graph refresh to occur on paint
         * events instead of just scrolling the time axis or zooming. To avoid
         * refreshing the model on every paint event, we use a TmfUiRefreshHandler to
         * coalesce requests and only execute the last one, we also check if the entries
         * have changed to avoid useless model refresh.
         *
         * @param e
         *            paint event on the visible area
         */
        @Override
        public void paintControl(PaintEvent e) {
            TmfUiRefreshHandler.getInstance().queueUpdate(this, () -> {
                if (timeGraphControl.isDisposed()) {
                    return;
                }
                int timeSpace = getTimeGraphViewer().getTimeSpace();
                Set<@NonNull TimeGraphEntry> newSet = getVisibleItems(DEFAULT_BUFFER_SIZE);
                if (fPrevTimeSpace != timeSpace || !fVisibleEntries.equals(newSet)) {
                    /*
                         * Start a zoom thread if the set of visible entries has changed. We do not use
                         * lists as the order is not important. We cannot use the start index / size of
                         * the visible entries as we can collapse / reorder events.
                         */
                    fVisibleEntries = newSet;
                    fPrevTimeSpace = timeSpace;
                    startZoomThread(getTimeGraphViewer().getTime0(), getTimeGraphViewer().getTime1());
                }
            });
        }
    });
    IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
    timeGraphControl.setStatusLineManager(statusLineManager);
    // View Action Handling
    makeActions();
    contributeToActionBars();
    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    if (trace != null) {
        traceSelected(new TmfTraceSelectedSignal(this, trace));
    }
    // make selection available to other views
    IWorkbenchPartSite site = getSite();
    site.setSelectionProvider(timeGraphViewer.getSelectionProvider());
    ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
    createContextMenu();
    fPartListener = new TimeGraphPartListener();
    site.getPage().addPartListener(fPartListener);
    fPartListener2 = new TimeGraphPartListener2();
    site.getPage().addPartListener(fPartListener2);
    fOriginalTabLabel = getPartName();
    fContextService = site.getWorkbenchWindow().getService(IContextService.class);
    if (timeGraphControl.isInFocus()) {
        activateContextService();
    }
    timeGraphControl.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            deactivateContextService();
        }

        @Override
        public void focusGained(FocusEvent e) {
            activateContextService();
        }
    });
    updateTimeFormat();
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IFile(org.eclipse.core.resources.IFile) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) ImmutableSet(com.google.common.collect.ImmutableSet) MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) HashSet(java.util.HashSet) IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent) TimeEventFilterDialog(org.eclipse.tracecompass.internal.tmf.ui.views.timegraph.TimeEventFilterDialog) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) FocusEvent(org.eclipse.swt.events.FocusEvent) ITimeGraphPresentationProvider(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) TimeGraphBookmarkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphBookmarkEvent) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) IContextService(org.eclipse.ui.contexts.IContextService) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) Point(org.eclipse.swt.graphics.Point) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) CoreException(org.eclipse.core.runtime.CoreException) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITimeGraphBookmarkListener(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphBookmarkListener) TimeGraphViewer(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) IMarker(org.eclipse.core.resources.IMarker) FocusListener(org.eclipse.swt.events.FocusListener)

Example 13 with TmfSelectionRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal in project tracecompass by tracecompass.

the class AbstractSegmentStoreTableViewer method appendToTablePopupMenu.

@Override
protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
    final ISegment segment = (ISegment) sel.getFirstElement();
    if (segment != null) {
        IAction gotoStartTime = new Action(Messages.SegmentStoreTableViewer_goToStartEvent) {

            @Override
            public void run() {
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getStart()), TmfTimestamp.fromNanos(segment.getStart()), fTrace));
            }
        };
        IAction gotoEndTime = new Action(Messages.SegmentStoreTableViewer_goToEndEvent) {

            @Override
            public void run() {
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getEnd()), TmfTimestamp.fromNanos(segment.getEnd()), fTrace));
            }
        };
        manager.add(gotoStartTime);
        manager.add(gotoEndTime);
        if (segment instanceof ITmfSourceLookup) {
            IContributionItem openCallsiteAction = OpenSourceCodeAction.create(Messages.SegmentStoreTableViewer_lookup, (ITmfSourceLookup) segment, getTableViewer().getTable().getShell());
            if (openCallsiteAction != null) {
                manager.add(openCallsiteAction);
            }
        }
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) OpenSourceCodeAction(org.eclipse.tracecompass.tmf.ui.actions.OpenSourceCodeAction) IAction(org.eclipse.jface.action.IAction) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) IContributionItem(org.eclipse.jface.action.IContributionItem) ITmfSourceLookup(org.eclipse.tracecompass.tmf.core.event.lookup.ITmfSourceLookup) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment)

Example 14 with TmfSelectionRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal in project tracecompass by tracecompass.

the class TmfSchedulerTest method TestMultiRequest3.

/**
 * Test two foreground request, one to select a time range and one to select
 * an event in this time range
 */
@Test
public void TestMultiRequest3() {
    ForegroundRequest foreground3 = new ForegroundRequest(TmfTimeRange.ETERNITY);
    fixture.sendRequest(foreground3);
    TmfSelectionRangeUpdatedSignal signal3 = new TmfSelectionRangeUpdatedSignal(this, fForegroundTimeRange.getStartTime());
    fixture.broadcast(signal3);
    try {
        foreground3.waitForCompletion();
    } catch (InterruptedException e) {
        fail();
    }
    assertEquals(NB_EVENTS_TRACE, foreground3.getNbEvents());
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) Test(org.junit.Test)

Example 15 with TmfSelectionRangeUpdatedSignal

use of org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal in project tracecompass by tracecompass.

the class AbstractImportAndReadSmokeTest method testHistogramView.

/**
 * Verifies the Histogram View
 *
 * @param vp
 *            the view part
 * @param tmfEd
 *            the events editor
 */
protected void testHistogramView(IViewPart vp, final TmfEventsEditor tmfEd) {
    final CtfTmfEvent desiredEvent1 = getEvent(100);
    UIThreadRunnable.syncExec(new VoidResult() {

        @Override
        public void run() {
            tmfEd.setFocus();
            tmfEd.selectionChanged(new SelectionChangedEvent(tmfEd, new StructuredSelection(desiredEvent1)));
        }
    });
    WaitUtils.waitForJobs();
    SWTBotUtils.delay(1000);
    final CtfTmfEvent desiredEvent2 = getEvent(10000);
    SWTBotView hvBot = fBot.viewById(HistogramView.ID);
    List<SWTBotToolbarButton> hvTools = hvBot.getToolbarButtons();
    for (SWTBotToolbarButton hvTool : hvTools) {
        if (hvTool.getToolTipText().toLowerCase().contains("lost")) {
            hvTool.click();
        }
    }
    HistogramView hv = (HistogramView) vp;
    final TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(hv, desiredEvent1.getTimestamp());
    final TmfSelectionRangeUpdatedSignal signal2 = new TmfSelectionRangeUpdatedSignal(hv, desiredEvent2.getTimestamp());
    hv.updateTimeRange(100000);
    WaitUtils.waitForJobs();
    hv.selectionRangeUpdated(signal);
    hv.broadcast(signal);
    WaitUtils.waitForJobs();
    SWTBotUtils.delay(1000);
    hv.updateTimeRange(1000000000);
    WaitUtils.waitForJobs();
    hv.selectionRangeUpdated(signal2);
    hv.broadcast(signal2);
    WaitUtils.waitForJobs();
    SWTBotUtils.delay(1000);
    assertNotNull(hv);
}
Also used : CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) VoidResult(org.eclipse.swtbot.swt.finder.results.VoidResult) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) HistogramView(org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramView) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)

Aggregations

TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)41 Test (org.junit.Test)22 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)18 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)11 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)11 SWTBotTimeGraph (org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph)11 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)9 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 Action (org.eclipse.jface.action.Action)4 IAction (org.eclipse.jface.action.IAction)4 Point (org.eclipse.swt.graphics.Point)3 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)3 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)3 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)3 ISelection (org.eclipse.jface.viewers.ISelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)2 DefaultCondition (org.eclipse.swtbot.swt.finder.waits.DefaultCondition)2 SWTBotCheckBox (org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox)2 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)2