/*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Alvaro Sanchez-Leon - Initial API and implementation
* Patrick Tasse - Refactoring
+ * Geneviève Bastien - Add drawing helper methods
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import org.eclipse.linuxtools.internal.tmf.ui.Messages;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITmfTimeGraphDrawingHelper;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
* @author Patrick Tasse
*
*/
-public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider {
+public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider2 {
+
+ private ITmfTimeGraphDrawingHelper fDrawingHelper;
+ private final String fStateTypeName;
+
+ // The list of listeners for graph color changes
+ private final List<ITimeGraphColorListener> fListeners = new ArrayList<>();
// ------------------------------------------------------------------------
// Constants
// Operations
// ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTypeName()
+ /**
+ * Constructor
+ * @param stateTypeName The state type name
+ * @since 2.1
+ */
+ public TimeGraphPresentationProvider(String stateTypeName) {
+ fStateTypeName = stateTypeName;
+ }
+
+ /**
+ * Constructor
+ * @since 2.1
*/
+ public TimeGraphPresentationProvider() {
+ this(Messages.TmfTimeLegend_TRACE_STATES);
+ }
+
@Override
public String getStateTypeName() {
- return Messages.TmfTimeLegend_TRACE_STATES;
+ return fStateTypeName;
}
/**
public String getStateTypeName(ITimeGraphEntry entry) {
return null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTable()
- */
+
@Override
public StateItem[] getStateTable() {
return null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventTableIndex(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
- */
@Override
public int getStateTableIndex(ITimeEvent event) {
return 0;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawControl(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
+ /**
+ * @since 2.1
+ */
+ @Override
+ public ITmfTimeGraphDrawingHelper getDrawingHelper() {
+ return fDrawingHelper;
+ }
+
+ /**
+ * @since 2.1
*/
+ @Override
+ public void setDrawingHelper(ITmfTimeGraphDrawingHelper helper) {
+ fDrawingHelper = helper;
+ }
+
@Override
public void postDrawControl(Rectangle bounds, GC gc) {
// Override to add own drawing code
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEntry(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
- */
@Override
public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc) {
// Override to add own drawing code
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEvent(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
- */
@Override
public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) {
// Override to add own drawing code
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemHeight(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
- */
@Override
public int getItemHeight(ITimeGraphEntry entry) {
return DEFAULT_ITEM_HEIGHT;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemImage(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
- */
@Override
public Image getItemImage(ITimeGraphEntry entry) {
return null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
- */
@Override
public String getEventName(ITimeEvent event) {
return null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
- */
@Override
public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent, long)
- */
/**
* @since 2.0
*/
return getEventHoverToolTipInfo(event);
}
-}
\ No newline at end of file
+ /**
+ * @since 3.0
+ */
+ @Override
+ public boolean displayTimesInTooltip() {
+ return true;
+ }
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public void addColorListener(ITimeGraphColorListener listener) {
+ if (!fListeners.contains(listener)) {
+ fListeners.add(listener);
+ }
+ }
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public void removeColorListener(ITimeGraphColorListener listener) {
+ fListeners.remove(listener);
+ }
+
+ /**
+ * Notifies listeners of the state table change
+ * @since 3.0
+ */
+ protected void fireColorSettingsChanged() {
+ for (ITimeGraphColorListener listener : fListeners) {
+ listener.colorSettingsChanged(getStateTable());
+ }
+ }
+
+}