Search in sources :

Example 16 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiAspectTest method lamiTimeRangeDurationAspectTest.

/**
 * Test the time range duration aspect
 *
 * @throws JSONException
 *             won't happen
 */
@Test
public void lamiTimeRangeDurationAspectTest() throws JSONException {
    LamiTableEntryAspect aspect = new LamiTimeRangeDurationAspect(ASPECT_NAME, 5);
    LamiTableEntry entry1 = createLamiData(1);
    LamiTableEntry entry2 = createLamiData(2);
    assertEquals(ASPECT_NAME + " (duration) (ns)", aspect.getLabel());
    assertEquals(ASPECT_NAME + " (duration)", aspect.getName());
    assertEquals(-1, aspect.getComparator().compare(entry1, entry2));
    String timeRangeString = aspect.resolveString(entry1);
    assertNotNull(timeRangeString);
    assertEquals("11", timeRangeString);
    assertEquals(11L, aspect.resolveNumber(entry1));
}
Also used : LamiTimeRangeDurationAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeDurationAspect) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) Test(org.junit.Test)

Example 17 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiAspectTest method lamiMixedAspectTest.

/**
 * Test the mixed aspect
 *
 * @throws JSONException
 *             won't happen
 */
@Test
public void lamiMixedAspectTest() throws JSONException {
    LamiTableEntryAspect aspect = new LamiMixedAspect(ASPECT_NAME, 0);
    LamiTableEntry entry1 = createLamiData(1);
    LamiTableEntry entry2 = createLamiData(2);
    assertEquals(ASPECT_NAME, aspect.getLabel());
    assertEquals(ASPECT_NAME, aspect.getName());
    assertEquals(0, aspect.getComparator().compare(entry1, entry2));
    assertNull(aspect.resolveString(entry1));
    assertNull(aspect.resolveNumber(entry1));
}
Also used : LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) LamiMixedAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiMixedAspect) Test(org.junit.Test)

Example 18 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiAspectTest method testAspectEquality.

/**
 * Test the equivalence of aspects, for aggregating in views.
 */
@Test
public void testAspectEquality() {
    LamiTableEntryAspect aspect1 = new LamiTimestampAspect(ASPECT_NAME, 0);
    LamiTableEntryAspect aspect2 = new LamiTimeRangeEndAspect(ASPECT_NAME, 5);
    LamiTableEntryAspect aspect3 = new LamiProcessTIDAspect(ASPECT_NAME, 0);
    assertTrue(aspect1.arePropertiesEqual(aspect1));
    assertTrue(aspect1.arePropertiesEqual(aspect2));
    assertFalse(aspect1.arePropertiesEqual(aspect3));
    assertTrue(aspect2.arePropertiesEqual(aspect1));
    assertTrue(aspect2.arePropertiesEqual(aspect2));
    assertFalse(aspect2.arePropertiesEqual(aspect3));
    assertFalse(aspect3.arePropertiesEqual(aspect1));
    assertFalse(aspect3.arePropertiesEqual(aspect2));
    assertTrue(aspect3.arePropertiesEqual(aspect3));
}
Also used : LamiProcessTIDAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessTIDAspect) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTimestampAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimestampAspect) LamiTimeRangeEndAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeEndAspect) Test(org.junit.Test)

Example 19 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiAnalysis method getAspectsFromColumnDescriptions.

private static List<LamiTableEntryAspect> getAspectsFromColumnDescriptions(JSONArray columnDescriptions) throws JSONException {
    ImmutableList.Builder<LamiTableEntryAspect> aspectsBuilder = new ImmutableList.Builder<>();
    for (int j = 0; j < columnDescriptions.length(); j++) {
        JSONObject column = columnDescriptions.getJSONObject(j);
        DataType columnDataType;
        String columnClass = column.optString(LamiStrings.CLASS, null);
        if (columnClass == null) {
            columnDataType = DataType.MIXED;
        } else {
            columnDataType = getDataTypeFromString(columnClass);
        }
        String columnTitle = column.optString(LamiStrings.TITLE, null);
        if (columnTitle == null) {
            // $NON-NLS-1$
            columnTitle = String.format("%s #%d", columnDataType.getTitle(), j + 1);
        }
        final int colIndex = j;
        switch(columnDataType) {
            case TIME_RANGE:
                /*
                 * We will add 3 aspects, to represent the start, end and
                 * duration of this time range.
                 */
                aspectsBuilder.add(new LamiTimeRangeBeginAspect(columnTitle, colIndex));
                aspectsBuilder.add(new LamiTimeRangeEndAspect(columnTitle, colIndex));
                aspectsBuilder.add(new LamiTimeRangeDurationAspect(columnTitle, colIndex));
                break;
            case TIMESTAMP:
                aspectsBuilder.add(new LamiTimestampAspect(columnTitle, colIndex));
                break;
            case PROCESS:
                aspectsBuilder.add(new LamiProcessNameAspect(columnTitle, colIndex));
                aspectsBuilder.add(new LamiProcessPIDAspect(columnTitle, colIndex));
                aspectsBuilder.add(new LamiProcessTIDAspect(columnTitle, colIndex));
                break;
            case IRQ:
                aspectsBuilder.add(new LamiIRQTypeAspect(columnTitle, colIndex));
                aspectsBuilder.add(new LamiIRQNameAspect(columnTitle, colIndex));
                aspectsBuilder.add(new LamiIRQNumberAspect(columnTitle, colIndex));
                break;
            case DURATION:
                aspectsBuilder.add(new LamiDurationAspect(columnTitle, colIndex));
                break;
            case MIXED:
                aspectsBuilder.add(new LamiMixedAspect(columnTitle, colIndex));
                break;
            // $CASES-OMITTED$
            default:
                String units = column.optString(LamiStrings.UNIT, null);
                if (units == null) {
                    units = columnDataType.getUnits();
                }
                /* We will add only one aspect representing the element */
                LamiTableEntryAspect aspect = new LamiGenericAspect(columnTitle, units, colIndex, columnDataType.isContinuous(), false);
                aspectsBuilder.add(aspect);
                break;
        }
    }
    /*
         * SWT quirk : we need an empty column at the end or else the last data
         * column will clamp to the right edge of the view if it is
         * right-aligned.
         */
    aspectsBuilder.add(LamiEmptyAspect.INSTANCE);
    return aspectsBuilder.build();
}
Also used : LamiProcessNameAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessNameAspect) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTimestampAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimestampAspect) ImmutableList(com.google.common.collect.ImmutableList) LamiMixedAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiMixedAspect) LamiGenericAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiGenericAspect) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) LamiProcessPIDAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessPIDAspect) LamiDurationAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiDurationAspect) LamiTimeRangeDurationAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeDurationAspect) LamiProcessTIDAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessTIDAspect) JSONObject(org.json.JSONObject) LamiIRQNameAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQNameAspect) LamiTimeRangeEndAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeEndAspect) DataType(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData.DataType) LamiIRQNumberAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQNumberAspect) LamiTimeRangeBeginAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeBeginAspect) LamiIRQTypeAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQTypeAspect)

Example 20 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiTableViewer method fillData.

/**
 * Update the data in the table viewer
 *
 * @param dataInput
 *            New data input
 */
private void fillData() {
    final TableViewer tableViewer = getTableViewer();
    Display.getDefault().asyncExec(() -> {
        if (tableViewer.getTable().isDisposed()) {
            return;
        }
        // Go to the top of the table
        tableViewer.getTable().setTopIndex(0);
        // Reset selected row
        tableViewer.setSelection(StructuredSelection.EMPTY);
        /* Fill the table data */
        tableViewer.setInput(fPage.getResultTable().getEntries());
        LamiTableContentProvider latencyContentProvider = (LamiTableContentProvider) getTableViewer().getContentProvider();
        tableViewer.setItemCount(latencyContentProvider.getNbEntries());
        /* Set the column's alignment and pack them */
        TableColumn[] cols = tableViewer.getTable().getColumns();
        for (int i = 0; i < cols.length; i++) {
            LamiTableEntryAspect colAspect = fPage.getResultTable().getTableClass().getAspects().get(i);
            int alignment = (colAspect.isContinuous() ? SWT.RIGHT : SWT.LEFT);
            cols[i].setAlignment(alignment);
        }
        /*
             * On creation check if there is selections if so update the table
             * selections here. Selections needs the ContentProvider for valid
             * index lookup and since the content provider is set in an
             * asynchronous task we cannot use the normal signal handler since
             * we have no guarantee of time of execution of the fill data.
             */
        if (!fSelection.isEmpty()) {
            LamiTableContentProvider provider = (LamiTableContentProvider) getTableViewer().getContentProvider();
            /* Find the indexes in the UI table of the selected objects */
            int[] selectionsIndexes = fSelection.stream().map(obj -> (LamiTableEntry) obj).mapToInt(entry -> provider.getIndexOf(checkNotNull(entry))).toArray();
            /* Update the selection in the UI table */
            Display.getDefault().asyncExec(() -> {
                getTableViewer().getTable().setSelection(selectionsIndexes);
                getTableViewer().getTable().redraw();
            });
        }
    });
    Display.getDefault().asyncExec(() -> {
        if (tableViewer.getTable().isDisposed()) {
            return;
        }
        TableColumn[] cols = tableViewer.getTable().getColumns();
        for (int i = 0; i < cols.length; i++) {
            cols[i].pack();
        }
    });
}
Also used : TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) ExportToTsvUtils(org.eclipse.tracecompass.internal.tmf.ui.commands.ExportToTsvUtils) Table(org.eclipse.swt.widgets.Table) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TmfSimpleTableViewer(org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer) HashSet(java.util.HashSet) Nullable(org.eclipse.jdt.annotation.Nullable) Composite(org.eclipse.swt.widgets.Composite) ChartSelectionUpdateSignal(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.signal.ChartSelectionUpdateSignal) NonNullUtils.checkNotNull(org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull) OutputStream(java.io.OutputStream) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) LamiReportViewTabPage(org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage) Set(java.util.Set) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) LamiReportView(org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportView) List(java.util.List) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) TableViewer(org.eclipse.jface.viewers.TableViewer) TmfSimpleTableViewer(org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Aggregations

LamiTableEntryAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect)20 Test (org.junit.Test)16 LamiTableEntry (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry)15 NonNullUtils.nullToEmptyString (org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString)3 LamiProcessTIDAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessTIDAspect)3 LamiTimeRangeEndAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeEndAspect)3 LamiTimestampAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimestampAspect)3 LamiAnalysisStub (org.eclipse.tracecompass.analysis.lami.core.tests.shared.analysis.LamiAnalysisStub)2 LamiDurationAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiDurationAspect)2 LamiGenericAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiGenericAspect)2 LamiIRQNameAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQNameAspect)2 LamiIRQNumberAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQNumberAspect)2 LamiMixedAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiMixedAspect)2 LamiProcessNameAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessNameAspect)2 LamiProcessPIDAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessPIDAspect)2 LamiTimeRangeBeginAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeBeginAspect)2 LamiTimeRangeDurationAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeDurationAspect)2 LamiTableClass (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableClass)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1