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);
}
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);
}
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;
}
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);
}
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();
}
Aggregations