Search in sources :

Example 1 with TmfXYChartViewer

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.

the class TmfChartView method coupleSelectViewer.

/**
 * Method to couple {@link AbstractSelectTreeViewer2} and
 * {@link TmfFilteredXYChartViewer} so that they use the same legend and that
 * the chart listens to selected items in the tree
 */
private void coupleSelectViewer() {
    TmfViewer tree = getLeftChildViewer();
    TmfXYChartViewer chart = getChartViewer();
    if (tree instanceof AbstractSelectTreeViewer2 && chart instanceof TmfFilteredXYChartViewer) {
        ILegendImageProvider2 legendImageProvider = new XYChartLegendImageProvider((TmfCommonXAxisChartViewer) chart);
        AbstractSelectTreeViewer2 selectTree = (AbstractSelectTreeViewer2) tree;
        selectTree.addTreeListener((TmfFilteredXYChartViewer) chart);
        selectTree.setLegendImageProvider(legendImageProvider);
        TriStateFilteredCheckboxTree checkboxTree = selectTree.getTriStateFilteredCheckboxTree();
        checkboxTree.addPreCheckStateListener(new ManyEntriesSelectedDialogPreCheckedListener(checkboxTree));
    }
}
Also used : TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) AbstractSelectTreeViewer2(org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractSelectTreeViewer2) ILegendImageProvider2(org.eclipse.tracecompass.tmf.ui.viewers.ILegendImageProvider2) XYChartLegendImageProvider(org.eclipse.tracecompass.tmf.ui.viewers.xychart.XYChartLegendImageProvider) ManyEntriesSelectedDialogPreCheckedListener(org.eclipse.tracecompass.tmf.ui.views.ManyEntriesSelectedDialogPreCheckedListener) TmfViewer(org.eclipse.tracecompass.tmf.ui.viewers.TmfViewer) TriStateFilteredCheckboxTree(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.TriStateFilteredCheckboxTree) TmfFilteredXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfFilteredXYChartViewer)

Example 2 with TmfXYChartViewer

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.

the class TmfChartView method getZoomOutAction.

private Action getZoomOutAction() {
    Action zoomOutAction = fZoomOutAction;
    if (zoomOutAction == null) {
        zoomOutAction = new Action() {

            @Override
            public void run() {
                TmfXYChartViewer viewer = getChartViewer();
                if (viewer == null) {
                    return;
                }
                Chart chart = viewer.getSwtChart();
                if (chart == null) {
                    return;
                }
                TmfXyUiUtils.zoom(viewer, XYAxis.create(chart.getAxisSet().getXAxis(0)), false);
            }
        };
        zoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText);
        zoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText);
        zoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU));
    }
    return zoomOutAction;
}
Also used : TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) Chart(org.eclipse.swtchart.Chart)

Example 3 with TmfXYChartViewer

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.

the class PatternScatterChartViewTest method testWithTrace.

/**
 * Test the pattern latency scatter graph. This method test if the chart has one
 * series and the series has data
 */
@Test
public void testWithTrace() {
    // Get the chart viewer and wait for the view to be ready
    WaitUtils.waitForJobs();
    TmfXYChartViewer chartViewer = getChartViewer();
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    // Check all the items in the tree
    final Chart chart = fScatterChart;
    assertNotNull(chart);
    SWTBotView viewBot = fBot.viewById(VIEW_ID);
    SWTBotTreeItem[] items = viewBot.bot().tree().getAllItems();
    for (SWTBotTreeItem item : items) {
        item.check();
    }
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
    // Look at the presence of data in the chart
    SWTBotChart chartBot = new SWTBotChart(chart);
    assertVisible(chartBot);
    final Range range = chart.getAxisSet().getXAxes()[0].getRange();
    assertEquals(100000000, range.upper - range.lower, 0);
    ISeriesSet seriesSet = fScatterChart.getSeriesSet();
    assertNotNull(seriesSet);
    ISeries<?>[] series = seriesSet.getSeries();
    assertNotNull(series);
    // Verify that the chart has more than 1 series
    assertTrue(series.length > 1);
    // Verify that each series has data
    for (int i = 0; i < series.length; i++) {
        assertTrue("Verifying series " + i, ((IndexedSeriesModel<?>) series[i].getDataModel()).size() > 0);
    }
}
Also used : TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) ISeriesSet(org.eclipse.swtchart.ISeriesSet) IndexedSeriesModel(org.eclipse.swtchart.model.IndexedSeriesModel) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Range(org.eclipse.swtchart.Range) ISeries(org.eclipse.swtchart.ISeries) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test)

Example 4 with TmfXYChartViewer

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.

the class TmfChartView method createPartControl.

// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
    fClampAction = createClampAction();
    menuManager.add(new Separator());
    menuManager.add(fClampAction);
    fSashForm = new SashForm(parent, SWT.NONE);
    fTmfViewer = createLeftChildViewer(fSashForm);
    fXYViewerContainer = new Composite(fSashForm, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    fXYViewerContainer.setLayout(layout);
    fChartViewer = createChartViewer(fXYViewerContainer);
    fChartViewer.setSendTimeAlignSignals(true);
    fChartViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    fChartViewer.getSwtChart().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            super.mouseDoubleClick(e);
            resetStartFinishTime();
        }
    });
    fChartViewer.getControl().addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            // drag listener here
            if (fSashDragListener == null) {
                for (Control control : fSashForm.getChildren()) {
                    if (control instanceof Sash) {
                        fSashDragListener = event -> TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(fSashForm, getTimeViewAlignmentInfo()));
                        control.removePaintListener(this);
                        control.addListener(SWT.Selection, fSashDragListener);
                        // There should be only one sash
                        break;
                    }
                }
            }
        }
    });
    fSashForm.setWeights(DEFAULT_WEIGHTS);
    fZoomInAction = getZoomInAction();
    fZoomOutAction = getZoomOutAction();
    IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fResetScaleAction);
    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fZoomInAction);
    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fZoomOutAction);
    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    if (trace != null) {
        loadTrace();
    }
    IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
    fChartViewer.setStatusLineManager(statusLineManager);
    fOriginalTabLabel = getPartName();
    coupleSelectViewer();
    IWorkbenchPartSite site = getSite();
    fContextService = site.getWorkbenchWindow().getService(IContextService.class);
    TmfXYChartViewer chartViewer = getChartViewer();
    if (chartViewer != null) {
        chartViewer.getControl().addFocusListener(new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
                deactivateContextService();
            }

            @Override
            public void focusGained(FocusEvent e) {
                activateContextService();
            }
        });
    }
}
Also used : TmfViewer(org.eclipse.tracecompass.tmf.ui.viewers.TmfViewer) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TriStateFilteredCheckboxTree(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.TriStateFilteredCheckboxTree) XYChartLegendImageProvider(org.eclipse.tracecompass.tmf.ui.viewers.xychart.XYChartLegendImageProvider) SashForm(org.eclipse.swt.custom.SashForm) ResetUtil(org.eclipse.tracecompass.tmf.ui.views.ResetUtil) ITmfAllowMultiple(org.eclipse.tracecompass.tmf.ui.views.ITmfAllowMultiple) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) SaveImageUtil(org.eclipse.tracecompass.tmf.ui.views.SaveImageUtil) IAction(org.eclipse.jface.action.IAction) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) IToolBarManager(org.eclipse.jface.action.IToolBarManager) FocusEvent(org.eclipse.swt.events.FocusEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) Nullable(org.eclipse.jdt.annotation.Nullable) Composite(org.eclipse.swt.widgets.Composite) ITimeReset(org.eclipse.tracecompass.tmf.ui.views.ITimeReset) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) Separator(org.eclipse.jface.action.Separator) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IContextActivation(org.eclipse.ui.contexts.IContextActivation) Messages(org.eclipse.tracecompass.internal.tmf.ui.Messages) TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) LockRangeDialog(org.eclipse.tracecompass.internal.tmf.ui.views.xychart.LockRangeDialog) ITmfPinnable(org.eclipse.tracecompass.tmf.ui.views.ITmfPinnable) Sash(org.eclipse.swt.widgets.Sash) MouseEvent(org.eclipse.swt.events.MouseEvent) List(java.util.List) TmfTimeViewAlignmentInfo(org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo) SWT(org.eclipse.swt.SWT) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) NonNull(org.eclipse.jdt.annotation.NonNull) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ITmfTimeAligned(org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned) TmfXyUiUtils(org.eclipse.tracecompass.internal.tmf.ui.viewers.xychart.TmfXyUiUtils) PaintListener(org.eclipse.swt.events.PaintListener) Chart(org.eclipse.swtchart.Chart) FocusListener(org.eclipse.swt.events.FocusListener) ITmfImageConstants(org.eclipse.tracecompass.internal.tmf.ui.ITmfImageConstants) ArrayList(java.util.ArrayList) TmfTimeViewAlignmentSignal(org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal) TmfView(org.eclipse.tracecompass.tmf.ui.views.TmfView) Listener(org.eclipse.swt.widgets.Listener) ManyEntriesSelectedDialogPreCheckedListener(org.eclipse.tracecompass.tmf.ui.views.ManyEntriesSelectedDialogPreCheckedListener) TmfFilteredXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfFilteredXYChartViewer) GridData(org.eclipse.swt.layout.GridData) IWorkbenchActionConstants(org.eclipse.ui.IWorkbenchActionConstants) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) XYAxis(org.eclipse.tracecompass.internal.tmf.ui.viewers.xychart.XYAxis) ILegendImageProvider2(org.eclipse.tracecompass.tmf.ui.viewers.ILegendImageProvider2) Action(org.eclipse.jface.action.Action) AbstractSelectTreeViewer2(org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractSelectTreeViewer2) Activator(org.eclipse.tracecompass.internal.tmf.ui.Activator) TmfTimeViewer(org.eclipse.tracecompass.tmf.ui.viewers.TmfTimeViewer) IMenuManager(org.eclipse.jface.action.IMenuManager) IContextService(org.eclipse.ui.contexts.IContextService) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) Sash(org.eclipse.swt.widgets.Sash) PaintListener(org.eclipse.swt.events.PaintListener) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) MouseAdapter(org.eclipse.swt.events.MouseAdapter) FocusEvent(org.eclipse.swt.events.FocusEvent) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) SashForm(org.eclipse.swt.custom.SashForm) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) IToolBarManager(org.eclipse.jface.action.IToolBarManager) GridData(org.eclipse.swt.layout.GridData) TmfTimeViewAlignmentSignal(org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal) IContextService(org.eclipse.ui.contexts.IContextService) IMenuManager(org.eclipse.jface.action.IMenuManager) FocusListener(org.eclipse.swt.events.FocusListener) Separator(org.eclipse.jface.action.Separator)

Example 5 with TmfXYChartViewer

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer in project tracecompass by tracecompass.

the class TmfChartView method getZoomInAction.

private Action getZoomInAction() {
    Action zoomInAction = fZoomInAction;
    if (zoomInAction == null) {
        zoomInAction = new Action() {

            @Override
            public void run() {
                TmfXYChartViewer viewer = getChartViewer();
                if (viewer == null) {
                    return;
                }
                Chart chart = viewer.getSwtChart();
                if (chart == null) {
                    return;
                }
                TmfXyUiUtils.zoom(viewer, XYAxis.create(chart.getAxisSet().getXAxis(0)), true);
            }
        };
        zoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText);
        zoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText);
        zoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU));
    }
    return zoomInAction;
}
Also used : TmfXYChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) Chart(org.eclipse.swtchart.Chart)

Aggregations

TmfXYChartViewer (org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfXYChartViewer)9 Action (org.eclipse.jface.action.Action)4 IAction (org.eclipse.jface.action.IAction)4 Chart (org.eclipse.swtchart.Chart)4 TmfViewer (org.eclipse.tracecompass.tmf.ui.viewers.TmfViewer)4 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)3 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)2 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)2 TmfTraceSelectedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal)2 TmfTimeViewer (org.eclipse.tracecompass.tmf.ui.viewers.TmfTimeViewer)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 Separator (org.eclipse.jface.action.Separator)1