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