Search in sources :

Example 1 with ITmfTimeAligned

use of org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned in project tracecompass by tracecompass.

the class TmfAlignmentSynchronizer method getReferenceView.

/**
 * Get a view that corresponds to the alignment information. The view is
 * meant to be used as a "reference" for other views to align on. Heuristics
 * are applied to choose the best view. For example, the view has to be
 * visible. It also will prioritize the view with lowest time axis offset
 * because most of the interesting data should be in the time widget.
 *
 * @param alignmentInfo
 *            alignment information
 * @param blackListedView
 *            an optional black listed view that will not be used as
 *            reference (useful for a view that just got created)
 * @return the reference view
 */
private static ITmfTimeAligned getReferenceView(TmfTimeViewAlignmentInfo alignmentInfo, TmfView blackListedView) {
    IWorkbenchWindow workbenchWindow = getWorkbenchWindow(alignmentInfo.getShell());
    if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
        // Only time aligned views that are part of a workbench window are supported
        return null;
    }
    IWorkbenchPage page = workbenchWindow.getActivePage();
    int lowestTimeAxisOffset = Integer.MAX_VALUE;
    ITmfTimeAligned referenceView = null;
    for (IViewReference ref : page.getViewReferences()) {
        IViewPart view = ref.getView(false);
        if (view != blackListedView && isTimeAlignedView(view)) {
            if (isCandidateForReferenceView((TmfView) view, alignmentInfo, lowestTimeAxisOffset)) {
                referenceView = (ITmfTimeAligned) view;
                lowestTimeAxisOffset = getClampedTimeAxisOffset(referenceView.getTimeViewAlignmentInfo());
            }
        }
    }
    return referenceView;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) ITmfTimeAligned(org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Point(org.eclipse.swt.graphics.Point)

Example 2 with ITmfTimeAligned

use of org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned in project tracecompass by tracecompass.

the class TmfAlignmentSynchronizer method isCandidateForNarrowestView.

private static boolean isCandidateForNarrowestView(TmfView tmfView, TmfTimeViewAlignmentInfo alignmentInfo, int narrowestWidth) {
    ITmfTimeAligned alignedView = (ITmfTimeAligned) tmfView;
    TmfTimeViewAlignmentInfo timeViewAlignmentInfo = alignedView.getTimeViewAlignmentInfo();
    if (timeViewAlignmentInfo == null) {
        return false;
    }
    if (isDisposedView(tmfView)) {
        return false;
    }
    Composite parentComposite = tmfView.getParentComposite();
    boolean isVisible = parentComposite != null && parentComposite.isVisible();
    if (isVisible) {
        if (isViewLocationNear(getViewLocation(tmfView), alignmentInfo.getViewLocation())) {
            int availableWidth = alignedView.getAvailableWidth(getClampedTimeAxisOffset(alignmentInfo));
            availableWidth = getClampedTimeAxisWidth(alignmentInfo, availableWidth);
            boolean isNarrower = availableWidth < narrowestWidth && availableWidth > 0;
            return isNarrower;
        }
    }
    return false;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ITmfTimeAligned(org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned) TmfTimeViewAlignmentInfo(org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo) Point(org.eclipse.swt.graphics.Point)

Example 3 with ITmfTimeAligned

use of org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned in project tracecompass by tracecompass.

the class Histogram method modelUpdated.

/**
 * Refresh the histogram display
 */
@Override
public void modelUpdated() {
    if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) {
        fCanvas.getDisplay().asyncExec(() -> {
            if (!fCanvas.isDisposed()) {
                // Retrieve and normalize the data
                final int canvasWidth = fCanvas.getBounds().width;
                final int canvasHeight = fCanvas.getBounds().height;
                if (canvasWidth <= 0 || canvasHeight <= 0) {
                    return;
                }
                fDataModel.setSelection(fSelectionBegin, fSelectionEnd);
                fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1);
                synchronized (fDataModel) {
                    if (fScaledData != null) {
                        fCanvas.redraw();
                        HistogramTimeAdapter adapter = (HistogramTimeAdapter) fTimeLineScale.getTimeProvider();
                        adapter.setTimeSpace(canvasWidth);
                        // Display histogram and update X-,Y-axis labels
                        long maxNbEvents = HistogramScaledData.hideLostEvents ? fScaledData.fMaxValue : fScaledData.fMaxCombinedValue;
                        String old = fMaxNbEventsLabel.getText();
                        fMaxNbEventsLabel.setText(Long.toString(maxNbEvents));
                        // The Y-axis area might need to be re-sized
                        GridData gd = (GridData) fMaxNbEventsLabel.getLayoutData();
                        gd.widthHint = Math.max(gd.widthHint, fMaxNbEventsLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
                        fMaxNbEventsLabel.getParent().layout();
                        if (old.length() < fMaxNbEventsLabel.getText().length()) {
                            if ((fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) {
                                TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true));
                            }
                        }
                    }
                    fTimeLineScale.redraw();
                }
            }
        });
    }
}
Also used : ITmfTimeAligned(org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned) GridData(org.eclipse.swt.layout.GridData) TmfTimeViewAlignmentSignal(org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal) HistogramTimeAdapter(org.eclipse.tracecompass.internal.tmf.ui.views.histogram.HistogramTimeAdapter) Point(org.eclipse.swt.graphics.Point)

Example 4 with ITmfTimeAligned

use of org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned in project tracecompass by tracecompass.

the class TmfAlignmentSynchronizer method isCandidateForReferenceView.

private static boolean isCandidateForReferenceView(TmfView tmfView, TmfTimeViewAlignmentInfo alignmentInfo, int lowestTimeAxisOffset) {
    ITmfTimeAligned alignedView = (ITmfTimeAligned) tmfView;
    TmfTimeViewAlignmentInfo timeViewAlignmentInfo = alignedView.getTimeViewAlignmentInfo();
    if (timeViewAlignmentInfo == null) {
        return false;
    }
    if (isDisposedView(tmfView)) {
        return false;
    }
    Composite parentComposite = tmfView.getParentComposite();
    boolean isVisible = parentComposite != null && parentComposite.isVisible();
    if (isVisible) {
        boolean isViewLocationNear = isViewLocationNear(alignmentInfo.getViewLocation(), getViewLocation(tmfView));
        boolean isLowestTimeAxisOffset = getClampedTimeAxisOffset(timeViewAlignmentInfo) < lowestTimeAxisOffset;
        if (isViewLocationNear && isLowestTimeAxisOffset) {
            int availableWidth = alignedView.getAvailableWidth(getClampedTimeAxisOffset(timeViewAlignmentInfo));
            availableWidth = getClampedTimeAxisWidth(timeViewAlignmentInfo, availableWidth);
            if (availableWidth > 0) {
                return true;
            }
        }
    }
    return false;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ITmfTimeAligned(org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned) TmfTimeViewAlignmentInfo(org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo) Point(org.eclipse.swt.graphics.Point)

Example 5 with ITmfTimeAligned

use of org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned in project tracecompass by tracecompass.

the class TmfAlignmentSynchronizer method restoreView.

private static void restoreView(IViewReference ref) {
    IViewPart view = ref.getView(false);
    if (isTimeAlignedView(view)) {
        ITmfTimeAligned alignedView = (ITmfTimeAligned) view;
        alignedView.performAlign(getClampedTimeAxisOffset(alignedView.getTimeViewAlignmentInfo()), Integer.MAX_VALUE);
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) ITmfTimeAligned(org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned)

Aggregations

ITmfTimeAligned (org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned)7 Point (org.eclipse.swt.graphics.Point)5 TmfTimeViewAlignmentInfo (org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo)4 IViewPart (org.eclipse.ui.IViewPart)3 Composite (org.eclipse.swt.widgets.Composite)2 IViewReference (org.eclipse.ui.IViewReference)2 GridData (org.eclipse.swt.layout.GridData)1 HistogramTimeAdapter (org.eclipse.tracecompass.internal.tmf.ui.views.histogram.HistogramTimeAdapter)1 TmfTimeViewAlignmentSignal (org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal)1 TmfView (org.eclipse.tracecompass.tmf.ui.views.TmfView)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1