Search in sources :

Example 1 with TmfEventsTable

use of org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable in project tracecompass by tracecompass.

the class TmfEventsEditor method createEventsTable.

/**
 * Create the event table
 *
 * @param parent
 *            The parent composite
 * @param cacheSize
 *            The cache size
 * @return The event table instance
 */
@NonNull
protected TmfEventsTable createEventsTable(final Composite parent, final int cacheSize) {
    ITmfTrace trace = fTrace;
    /*
         * Check if the trace (or experiment type) defines a specific event
         * table in its extension point.
         */
    TmfEventsTable table = TmfTraceTypeUIUtils.getEventTable(trace, parent, cacheSize);
    if (table != null) {
        return table;
    }
    /*
         * Use the aspects defined by the trace type (or each trace type in an
         * experiment) to build a table consisting of these.
         */
    Iterable<ITmfEventAspect<?>> aspects = getTraceAspects(trace);
    if (Iterables.isEmpty(aspects)) {
        /* Couldn't find any event aspects, use a default table */
        return new TmfEventsTable(parent, cacheSize);
    }
    return new TmfEventsTable(parent, cacheSize, aspects);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEventAspect(org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect) TmfEventsTable(org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 2 with TmfEventsTable

use of org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable in project tracecompass by tracecompass.

the class TmfEventsEditor method createAndInitializeTable.

private void createAndInitializeTable() {
    if (fTrace != null) {
        fEventsTable = createEventsTable(fParent, fTrace.getCacheSize());
        fEventsTable.registerContextMenus(getSite());
        fEventsTable.addSelectionChangedListener(this);
        fEventsTable.setTrace(fTrace, true);
        fEventsTable.refreshBookmarks(fFile);
        loadState();
        /* ensure start time is set */
        final ITmfContext context = fTrace.seekEvent(0);
        fTrace.getNext(context);
        context.dispose();
        broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile));
        if (fTraceSelected) {
            broadcast(new TmfTraceSelectedSignal(this, fTrace));
        }
        /* update part name only after trace manager notified */
        setPartName(TmfTraceManager.getInstance().getTraceUniqueName(fTrace));
        /* go to marker after trace opened */
        if (fPendingGotoMarker != null) {
            fEventsTable.gotoMarker(fPendingGotoMarker);
            fPendingGotoMarker = null;
        }
    } else {
        fEventsTable = new TmfEventsTable(fParent, 0);
        fEventsTable.addSelectionChangedListener(this);
    }
    IStatusLineManager statusLineManager = getEditorSite().getActionBars().getStatusLineManager();
    fEventsTable.setStatusLineManager(statusLineManager);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TmfEventsTable(org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable)

Example 3 with TmfEventsTable

use of org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable in project tracecompass by tracecompass.

the class TmfTraceTypeUIUtils method getEventTable.

/**
 * Get the Event Table type specified by the trace type's extension point,
 * if there is one.
 *
 * @param trace
 *            The trace for which we want the events table.
 * @param parent
 *            The parent composite that the event table will have
 * @param cacheSize
 *            The cache size to use with this event table. Should be defined
 *            by the trace type.
 * @return The corresponding Event Table, or 'null' if this trace type did
 *         not specify any.
 */
@Nullable
public static TmfEventsTable getEventTable(ITmfTrace trace, Composite parent, int cacheSize) {
    final String traceType = getTraceType(trace);
    if (traceType == null) {
        return null;
    }
    TraceElementType elType = (trace instanceof TmfExperiment) ? TraceElementType.EXPERIMENT : TraceElementType.TRACE;
    for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements(elType)) {
        if (ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR).equals(traceType)) {
            final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceTypeUIUtils.EVENTS_TABLE_TYPE_ELEM);
            if (eventsTableTypeCE.length != 1) {
                break;
            }
            final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceTypeUIUtils.CLASS_ATTR);
            final boolean useTraceAspects = Boolean.parseBoolean(eventsTableTypeCE[0].getAttribute(TmfTraceTypeUIUtils.USE_TRACE_ASPECTS_ATTR));
            if ((eventsTableType == null) || eventsTableType.isEmpty()) {
                break;
            }
            try {
                final Bundle bundle = Platform.getBundle(ce.getContributor().getName());
                final Class<?> c = bundle.loadClass(eventsTableType);
                Class<?>[] constructorArgs = null;
                Object[] args = null;
                if (useTraceAspects) {
                    args = new Object[] { parent, cacheSize, trace.getEventAspects() };
                    constructorArgs = new Class[] { Composite.class, int.class, Iterable.class };
                } else {
                    args = new Object[] { parent, cacheSize };
                    constructorArgs = new Class[] { Composite.class, int.class };
                }
                final Constructor<?> constructor = c.getConstructor(constructorArgs);
                return (TmfEventsTable) constructor.newInstance(args);
            } catch (NoSuchMethodException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                return null;
            }
        }
    }
    return null;
}
Also used : TraceElementType(org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType.TraceElementType) Bundle(org.osgi.framework.Bundle) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) InvocationTargetException(java.lang.reflect.InvocationTargetException) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TmfEventsTable(org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 4 with TmfEventsTable

use of org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable in project tracecompass by tracecompass.

the class CustomParserOutputWizardPage method createControl.

@Override
public void createControl(final Composite parent) {
    container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout());
    sash = new SashForm(container, SWT.VERTICAL);
    sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
    outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);
    outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);
    final GridLayout outputsLayout = new GridLayout(4, false);
    outputsLayout.marginHeight = 10;
    outputsLayout.marginWidth = 0;
    outputsContainer.setLayout(outputsLayout);
    outputsScrolledComposite.setContent(outputsContainer);
    outputsScrolledComposite.setExpandHorizontal(true);
    outputsScrolledComposite.setExpandVertical(true);
    outputsContainer.layout();
    outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 5);
    tableContainer = new Composite(sash, SWT.NONE);
    final GridLayout tableLayout = new GridLayout();
    tableLayout.marginHeight = 0;
    tableLayout.marginWidth = 0;
    tableContainer.setLayout(tableLayout);
    previewTable = new TmfEventsTable(tableContainer, 0, new ArrayList<>());
    previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    if (fDefinition != null) {
        loadDefinition(fDefinition);
    }
    setControl(container);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TmfEventsTable(org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable)

Example 5 with TmfEventsTable

use of org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable in project tracecompass by tracecompass.

the class CustomParserOutputWizardPage method updatePreviewTable.

private void updatePreviewTable() {
    final int CACHE_SIZE = 50;
    definition.outputs = extractOutputs();
    // $NON-NLS-1$
    tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile();
    try (final FileWriter writer = new FileWriter(tmpFile)) {
        writer.write(inputPage.getInputText());
    } catch (final IOException e) {
        // $NON-NLS-1$ //$NON-NLS-2$
        Activator.getDefault().logError("Error creating " + fTraceType + ". File:" + tmpFile.getAbsolutePath(), e);
    }
    TraceParams tp = new TraceParams(definition, tmpFile, CACHE_SIZE);
    final ITmfTrace trace = fBuilder.apply(tp);
    if (trace == null) {
        return;
    }
    previewTable.dispose();
    previewTable = new TmfEventsTable(tableContainer, CACHE_SIZE, CustomEventAspects.generateAspects(definition));
    previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    previewTable.setTrace(trace, true);
    tableContainer.layout();
    container.layout();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) FileWriter(java.io.FileWriter) GridData(org.eclipse.swt.layout.GridData) IOException(java.io.IOException) TmfEventsTable(org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable)

Aggregations

TmfEventsTable (org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable)6 GridData (org.eclipse.swt.layout.GridData)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)1 SashForm (org.eclipse.swt.custom.SashForm)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ITmfEventAspect (org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect)1 TraceElementType (org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType.TraceElementType)1 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)1