Search in sources :

Example 36 with TmfSelectionRangeUpdatedSignal

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

the class FlameChartViewTest method goToTime.

private static void goToTime(long timestamp) {
    ITmfTimestamp time = TmfTimestamp.fromNanos(timestamp);
    SWTBotTable table = sfBot.activeEditor().bot().table();
    table.setFocus();
    WaitUtils.waitForJobs();
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, time));
    sfBot.waitUntil(ConditionHelpers.selectionInEventsTable(sfBot, timestamp));
    final SWTBotView viewBot = sfBot.viewById(FlameChartView.ID);
    IWorkbenchPart part = viewBot.getViewReference().getPart(false);
    sfBot.waitUntil(ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, new TmfTimeRange(time, time), time));
}
Also used : AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 37 with TmfSelectionRangeUpdatedSignal

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

the class BookmarksViewTest method bookmarkTest.

private static void bookmarkTest(String editorName) throws IOException {
    SWTBotView fViewBot = fBot.viewByPartName("Bookmarks");
    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    assertEquals("Failed to show the Bookmarks View", "Bookmarks", fViewBot.getTitle());
    /**
     * Add a bookmark: a) Double click to select an event in the event
     * editor b) Go to the Edit > Add Bookmark... menu c) Enter the bookmark
     * description in dialog box
     */
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, editorName);
    SWTBotTable tableBot = editorBot.bot().table();
    SWTBotTableItem tableItem = tableBot.getTableItem(7);
    String expectedTimeStamp = tableItem.getText(1);
    assertNull("The image should not be bookmarked yet", getBookmarkImage(tableItem));
    tableItem.select();
    tableItem.doubleClick();
    fBot.menu("Edit").menu("Add Bookmark...").click();
    WaitUtils.waitForJobs();
    SWTBotShell addBookmarkShell = fBot.shell("Add Bookmark");
    addBookmarkShell.bot().text().setText(BOOKMARK_NAME);
    addBookmarkShell.bot().button("OK").click();
    assertNotNull("Failed to add bookmark in event editor", getBookmarkImage(tableItem));
    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    SWTBotTree bookmarkTree = fViewBot.bot().tree();
    WaitUtils.waitForJobs();
    /**
     * throws WidgetNotFoundException - if the node was not found, nothing
     * to assert
     */
    SWTBotTreeItem bookmark = bookmarkTree.getTreeItem(BOOKMARK_NAME);
    assertEquals(BOOKMARK_NAME, bookmark.cell(0));
    /**
     * Scroll within event table so that bookmark is not visible anymore and
     * then double-click on bookmark in Bookmarks View
     */
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(null, TmfTimestamp.fromMicros(22))));
    bookmark.doubleClick();
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    TableCollection selection = tableBot.selection();
    TableRow row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));
    /**
     * Open another trace #2 and then double-click on bookmark in Bookmarks
     * view
     */
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/E-Test-10K")).getPath(), TRACE_TYPE);
    WaitUtils.waitForJobs();
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));
    /**
     * Close the trace #1 and then double-click on bookmark in Bookmarks
     * view
     */
    editorBot.close();
    WaitUtils.waitUntil(eb -> !eb.isActive(), editorBot, "Waiting for the editor to close");
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(eb -> eb.bot().table().selection().rowCount() > 0, editorBot, "Selection is still empty");
    tableBot = editorBot.bot().table();
    WaitUtils.waitUntil(tb -> !Objects.equal(tb.selection().get(0).get(1), "<srch>"), tableBot, "Header is still selected");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));
    /**
     * Select bookmarks icon in bookmark view right-click on icon and select
     * "Remove Bookmark"
     */
    bookmark.select();
    bookmark.contextMenu("Delete").click();
    SWTBotShell deleteBookmarkShell = fBot.shell("Delete Selected Entries");
    SWTBotUtils.anyButtonOf(deleteBookmarkShell.bot(), "Delete", "Yes").click();
    fBot.waitUntil(Conditions.treeHasRows(bookmarkTree, 0));
    tableItem = editorBot.bot().table().getTableItem(7);
    assertNull("Bookmark not deleted from event table", getBookmarkImage(tableItem));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) TableRow(org.eclipse.swtbot.swt.finder.utils.TableRow) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TableCollection(org.eclipse.swtbot.swt.finder.utils.TableCollection) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) SWTBotTableItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem)

Example 38 with TmfSelectionRangeUpdatedSignal

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

the class AbstractSegmentsStatisticsViewer method appendToTablePopupMenu.

/**
 * Method to add commands to the context sensitive menu.
 *
 * @param manager
 *            the menu manager
 * @param sel
 *            the current selection
 */
protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
    Object element = sel.getFirstElement();
    if (element instanceof TmfGenericTreeEntry) {
        IAction gotoStartTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMinAction) {

            @Override
            public void run() {
                long start;
                long end;
                if (element instanceof TmfGenericTreeEntry) {
                    SegmentStoreStatisticsModel model = ((TmfGenericTreeEntry<SegmentStoreStatisticsModel>) element).getModel();
                    start = model.getMinStart();
                    end = model.getMinEnd();
                } else {
                    return;
                }
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentsStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end), getTrace()));
                updateContent(start, end, true);
            }
        };
        IAction gotoEndTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMaxAction) {

            @Override
            public void run() {
                long start;
                long end;
                if (element instanceof TmfGenericTreeEntry) {
                    SegmentStoreStatisticsModel model = ((TmfGenericTreeEntry<SegmentStoreStatisticsModel>) element).getModel();
                    start = model.getMaxStart();
                    end = model.getMaxEnd();
                } else {
                    return;
                }
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentsStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end), getTrace()));
                updateContent(start, end, true);
            }
        };
        manager.add(gotoStartTime);
        manager.add(gotoEndTime);
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) TmfGenericTreeEntry(org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry)

Example 39 with TmfSelectionRangeUpdatedSignal

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

the class TmfEventsTable method gotoMarker.

@Override
public void gotoMarker(final IMarker marker) {
    ITmfTimestamp tsBegin = null;
    ITmfTimestamp tsEnd = null;
    /* try location as an integer for backward compatibility */
    long rank = marker.getAttribute(IMarker.LOCATION, -1);
    if (rank == -1) {
        String rankString = marker.getAttribute(ITmfMarker.MARKER_RANK, (String) null);
        try {
            rank = Long.parseLong(rankString);
        } catch (NumberFormatException e) {
        /* ignored */
        }
    }
    try {
        String timeString = marker.getAttribute(ITmfMarker.MARKER_TIME, (String) null);
        long time = Long.parseLong(timeString);
        tsBegin = TmfTimestamp.fromNanos(time);
        String durationString = marker.getAttribute(ITmfMarker.MARKER_DURATION, (String) null);
        long duration = Long.parseLong(durationString);
        tsEnd = TmfTimestamp.fromNanos(time + duration);
    } catch (NumberFormatException e) {
    /* ignored */
    }
    if (rank == -1 && tsBegin != null) {
        final ITmfContext context = fTrace.seekEvent(tsBegin);
        rank = context.getRank();
        context.dispose();
    }
    if (rank != -1) {
        int index = (int) rank;
        if (fTable.getData(Key.FILTER_OBJ) != null) {
            // +1 for top filter status row
            index = fCache.getFilteredEventIndex(rank) + 1;
        } else if (rank >= fTable.getItemCount()) {
            fPendingGotoRank = rank;
        }
        fSelectedRank = rank;
        fSelectedBeginRank = fSelectedRank;
        // +1 for header row
        fTable.setSelection(index + 1);
        updateStatusLine(null);
        if (tsBegin != null) {
            if (tsEnd != null) {
                broadcast(new TmfSelectionRangeUpdatedSignal(TmfEventsTable.this, tsBegin, tsEnd, fTrace));
            } else {
                broadcast(new TmfSelectionRangeUpdatedSignal(TmfEventsTable.this, tsBegin, tsBegin, fTrace));
            }
        }
    }
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Point(org.eclipse.swt.graphics.Point)

Example 40 with TmfSelectionRangeUpdatedSignal

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

the class ImportAndReadPcapTest method testStreamView.

private void testStreamView(IViewReference viewPart) {
    SWTBotView botView = new SWTBotView(viewPart, fBot);
    StreamListView slv = (StreamListView) getViewPart("Stream List");
    botView.setFocus();
    SWTBotTree botTree = fBot.tree();
    assertNotNull(botTree);
    final TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(slv, fDesired1.getTimestamp());
    slv.broadcast(signal);
    WaitUtils.waitForJobs();
    // FIXME This is a race condition:
    // TmfEventsTable launches an async exec that may be run after the wait
    // for jobs. This last delay catches it.
    SWTBotUtils.delay(1000);
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) StreamListView(org.eclipse.tracecompass.internal.tmf.pcap.ui.stream.StreamListView) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)

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