1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexis Cabana-Loriaux - Initial API and implementation
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.piecharts
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.widgets
.Display
;
20 * Implementation of the IPieChartViewerState interface to represent the state
21 * of the layout when there is no content currently selected.
23 * @author Alexis Cabana-Loriaux
27 public class PieChartViewerStateNoContentSelected
implements IPieChartViewerState
{
35 public PieChartViewerStateNoContentSelected(final TmfPieChartViewer context
) {
36 if (context
.isDisposed()) {
40 Display
.getDefault().asyncExec(new Runnable() {
43 synchronized (context
) {
44 if (!context
.isDisposed()) {
45 // Have to get rid of the time-range PieChart
46 if (context
.getTimeRangePC() != null) {
47 if (!context
.getTimeRangePC().isDisposed()) {
48 context
.getTimeRangePC().dispose();
50 context
.setTimeRangePC(null);
53 context
.updateGlobalPieChart();
54 // update the global chart so it takes all the place
55 context
.getGlobalPC().getLegend().setPosition(SWT
.RIGHT
);
64 public void newSelection(final TmfPieChartViewer context
) {
65 context
.setCurrentState(new PieChartViewerStateContentSelected(context
));
69 public void newEmptySelection(final TmfPieChartViewer context
) {
74 public void newGlobalEntries(final TmfPieChartViewer context
) {
75 Display
.getDefault().asyncExec(new Runnable() {
78 synchronized (context
) {
79 if (!context
.isDisposed()) {
80 context
.updateGlobalPieChart();
81 context
.getGlobalPC().redraw();